Dashboard: ANSI color in live logs + fix run-detail loading flash#169
Open
kevinlu1248 wants to merge 1 commit into
Open
Dashboard: ANSI color in live logs + fix run-detail loading flash#169kevinlu1248 wants to merge 1 commit into
kevinlu1248 wants to merge 1 commit into
Conversation
Live training logs from Modal/Ray/Megatron carry raw ANSI SGR codes. The backend streams lines verbatim, so the dashboard rendered them as escaped plain text (e.g. "[32mINFO[0m"). Add a small ANSI parser (16-color, bright, 256-color, truecolor, bold/dim/italic/underline/inverse) that converts each line into styled segments at ingestion, and render those segments as spans. Non-SGR sequences and stray control chars are dropped. Also fix two log-stream issues on the run detail page: - "Loading run …" flash: `run` was derived live from the parent's allRuns, which is replaced wholesale every 5s. A poll missing this run flipped it to null, flashing the loading state and tearing down the live stream. Latch the last resolved run; only drop to null when runId itself changes. - Wrap EventSource construction in try/catch so a constructor throw surfaces as an error state instead of killing the effect. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes to the training-gym dashboard's live log streaming on the run detail page.
1. ANSI color rendering in live logs
Modal/Ray/Megatron logs carry raw ANSI SGR codes, and the backend streams lines verbatim — so the dashboard rendered them as escaped plain text (e.g.
[32mINFO[0m).dashboards/frontend/src/lib/ansi.jsparses a line into[{text, style}]segments. Supports 16-color fg/bg, bright variants, 256-color (38;5;n), truecolor (38;2;r;g;b), and bold/dim/italic/underline/inverse. Non-SGR sequences (cursor moves, screen clears) and stray control chars are dropped.<span>s.2. "Loading run …" flash
runwas derived live from the parent'sallRuns, which is replaced wholesale every 5s by the auto-refresh. A single poll missing this run flippedruntonull— flashing the loading state and tearing down the live log stream. Now the last resolved run is latched; it only drops tonullwhenrunIditself changes to one not yet loaded.3. Stream crash hardening
Wrapped
new EventSource(url)in try/catch so a constructor throw surfaces as an error state instead of killing the effect/component. The latch above also stops the unmount/remount thrash that reset the stream mid-flight.Testing
npm run buildpasses (only pre-existing unused-CSS warnings, unrelated).🤖 Generated with Claude Code