-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi-line status prompt ticker (#3577)
fixes #3546 This PR introduces a new `MultilinePromptLogger` that allows the status of multiple in-progress threads to be reported and viewed during a Mill evaluation: https://github.com/user-attachments/assets/32d2a7e4-6db9-4dcc-81ed-a775e307d1c2 `MultilinePromptLogger` is basically a minimal translation of the current `ticker` API to work with a multi-line prompt. There's probably a lot of other interesting improvements we can make now that we are multi-line, but this is a decent start that lets people know what their parallel build is doing. The UI works correctly both during scrolling and not-scrolling, and uses the same minimal ANSI codes that the existing ticker uses, so hopefully we won't hit any more edge cases that we aren't already hitting today From an implementation perspective, `MultilinePromptLogger` is mostly a drop in replacement for the old `PrintLogger`. User-facing notes: 1. It prints multiple `ticker` lines at vertically at the bottom of the terminal, and has the logs printed above 2. It requires that you use `.endTicker()` after every `.ticker("...")` call, so we can know where we should clear the ticker status (previously they always just got overriden by the next `.ticker` call) 3. We need to introduce a `withPaused{...}` block so that when you're running REPLs and stuff the prompt is not shown 4. We only can support logs which end with newlines. This means things like interactive progress bars and other ANSI magic won't work in the scrollback. This is a limitation of the current implementation that is hard to fix without going for more advanced techniques, but should be enough for the vast majority of logs and is a similar limitation as a lot of other tools. 5. Console dimensions are propagated from the mill client to the mill server via a `terminfo` file specific to each server. This is used to size the prompt so it takes up the whole width and about 1/3 of the height. This happens every 100ms, so there may be some delay, but at least it means the prompt will right-size itself on next render. The regular cadence also means it shouldn't be a performance bottleneck 6. For non-interactive runs which lack a terminal, prompt WxH defaults to 120x50, and we tweak the rendering: we no longer render blank lines to preserve prompt height stability, we render less frequently and only if the statuses change, and we add a footer so the bottom of the prompt is clearly marked. 7. `--ticker` now defaults to `true` even for non-interactive runs, since the periodic display of prompt (I set to 60s intervals, if prompt changes) is useful e.g. for debugging stuck background jobs or CI runs. Implementation Notes 1. The logger needs to extend `AutoCloseable`, since it uses a background thread to keep the prompt UI up to date. This renders every 100ms (arbitrary) to try and balance between prompt readability and latency. We have additional delays built in to hiding a status line and then finally removing it, to try and preserve the height so it doesn't bounce up and down too much as the set of running tasks changes 2. We re-use the `ProxyStream` classes to combine the stderr/stdout before re-splitting them. This allows us to perform some buffering, while simultaneously maintaining ordering of writes to each stream, while also allowing us to detect quiescence so we can only bother writing out a prompt when everything else is done and it won't get immediately over-written. `ProxyStream.Pumper` needed some tweaks to add hooks and remove client-specific assumptions 3. I experimented with having the ticker logic live in the Mill client rather than server, which would make more sense, but we need the server to have the ability to enable/disable the ticker logic to run `console` and similar interactive tasks, and so it has to live in the server The old ticker remains available at `--disable-prompt`. Further improvements can come after 0.12.0.
- Loading branch information
Showing
47 changed files
with
2,627 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package mill.main.client; | ||
import java.io.IOException; | ||
import java.nio.file.*; | ||
|
||
/** | ||
* Used to add `println`s in scenarios where you can't figure out where on earth | ||
* your stdout/stderr/logs are going and so we just dump them in a file in your | ||
* home folder so you can find them | ||
*/ | ||
public class DebugLog{ | ||
synchronized public static void println(String s){ | ||
Path path = Paths.get(System.getProperty("user.home"), "mill-debug-log.txt"); | ||
try { | ||
if (!Files.exists(path)) Files.createFile(path); | ||
Files.writeString(path, s + "\n", StandardOpenOption.APPEND); | ||
}catch (IOException e){ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.