I don't think this is fully ready but its mostly usable as a POC.
Basically the jitteriness comes from two causes:
Unlimited height. If we have 1000 packages, for example, and 50 line terminal then we are still trying to write all 1000 packages. This makes it hard for the terminal emulator to keep up
Fast writes. We write every time an event comes in, which can be very very often. Like 1000s per second. Again, we cannot keep up.
This PR fixes this by only including the last <height> lines (determined from inspecting the terminal) and writing updates on a 100ms timer instead of fixed.
Some things I think would make this better/acceptable to merge:
The implementation is racy, easy to fix though.
We could optimize writes to not write if there are no changes.
We could optimize to write faster than every 100ms a few times with backoff to 100ms - probably overkill
We can not bother writing >height lines, since we just throw it away anyways
We could move to a pull based model, where every 100ms we compute what to write.
Prioritize what we write. The last N is not ideal -- we could have [1 running test, 100 skipped tests, 1 running test]. The 2 running test lines are most important. As long as NumCPUs < terminal height, this would always ensure we can see all running tests.
For https://github.com/gotestyourself/gotestsum/issues/352
I don't think this is fully ready but its mostly usable as a POC.
Basically the jitteriness comes from two causes:
This PR fixes this by only including the last
<height>
lines (determined from inspecting the terminal) and writing updates on a 100ms timer instead of fixed.This is inspired by https://github.com/docker/compose/blob/80856eacafcf96d6f27e74c07e42386fe662f8ef/pkg/progress/tty.go#L50 which has, IMO, a pretty nice progress UI. Note they don't do the height part.
Some things I think would make this better/acceptable to merge:
Opening for early feedback