Skip to content

feat: live colored compile log streaming in browser loading page (spinner only, no progress bar) #153

Closed

Description

@zackees

Context

With #151/#152 the instant-launch viewer now correctly loads the embedded HTTP server's loading page (LOADING_PAGE in crates/fastled-cli/src/server.rs) while a build is running. But the in-browser compile experience is still poor:

  1. No determinate progress is possible. The build pipeline (meson + emcc) has no known step count, so any progress-bar style indicator is fake. The page must use an indeterminate spinner only.
  2. Build tool output is not streamed live. The SSE plumbing exists (/build-stream, emit_build_log in crates/fastled-cli/src/compile_stream.rs already tags each line with "stream":"stdout"|"stderr"), but:
    • Build subprocesses are launched with Command::status() (run_status in crates/fastled-cli/src/wasm_build.rs:204), so their stdout/stderr go straight to the terminal and are never captured line-by-line.
    • emit_build_result_logs only emits result.output after build::run_build returns — the browser log panel gets one burst at the end of the build instead of a live tail.
  3. No log coloring. The loading page's appendLog() (server.rs:103) ignores the stream field entirely and renders every line in flat gray. Warnings and errors are indistinguishable from noise.
  4. Fatal compile/link errors leave the browser with nothing displayable. When the build step fails fatally (compiler error or wasm-ld link error), no index.html/artifacts are produced, so there is nothing the server can serve except the loading page. The page must own this terminal-failure state end-to-end: today the error styling exists (setError), but the guarantees around it are unspecified — the page must never reload into a 404/blank view, must keep the full error log readable, and must recover automatically when a file change triggers a successful rebuild.

Proposal

Enhance the loading page and the compile streaming path:

  1. Indeterminate spinner only. Keep/confirm the spinner as the sole activity indicator with the elapsed-time counter. Remove any progress-bar-style UI (none should be added in future work either — step counts are unknowable).
  2. Live stdout/stderr streaming. Change the build subprocess invocations (meson configure/compile, emcc-driven steps in wasm_build.rs) to spawn with piped stdout/stderr, read both pipes line-by-line on background threads, and forward each line through the existing emit_build_log(tx, line, stream) so the terminal and the SSE channel see output in real time, not post-hoc.
  3. Colored log lines in the browser. In LOADING_PAGE's JS, use the already-present d.stream field plus line-content classification to render:
    • lines containing warning: (emcc/clang style) → yellow (#ffd54f or similar)
    • lines containing error: / fatal error: / lines arriving on stderr that match error patterns → red (#ef5350)
    • everything else → current gray
    • Switch #log from a single text node to per-line <div> elements (escaped text, no innerHTML injection) so lines can be styled individually; keep auto-scroll-to-bottom behavior, but stop auto-scrolling if the user has scrolled up.
  4. Keep terminal behavior unchanged — emit_build_log already mirrors to stdout/stderr.
  5. Fatal-error handling when no artifacts exist. When the build fails with a fatal compiler or link error and index.html was never produced:
    • The loading page stays up in an explicit error state: spinner stops (red), header reads Compilation failed, elapsed timer freezes, and the full streamed log (with errors in red) remains scrollable. Auto-scroll jumps to the first error line rather than the bottom.
    • The page must not location.reload() on error — reloading would re-serve the loading page and wipe the log. The success → reload transition only fires when index.html actually exists on disk (server should verify before emitting success).
    • The SSE connection stays open after an error so the page hears the next compiling event: when the file watcher triggers a rebuild, the page resets to the building state, and on eventual success reloads into the sketch — full fail → edit → rebuild → success cycle without restarting the CLI or the viewer.
    • build-status.json is written with {"status":"error", ...} so the polling fallback reaches the same error state as SSE clients.
    • Stale-artifact case: if a previous successful build left index.html on disk and a later rebuild fails, the browser is showing the (now stale) sketch and cannot see the loading page. At minimum the failure must be visible in the terminal and build-status.json; an in-sketch error overlay is out of scope here (see Decisions).

Acceptance criteria

  • Loading page shows an indeterminate spinner + elapsed time; no progress bar exists anywhere in the compile-monitoring UI.
  • During a forced full recompile (delete fastled_js/ and .build/ first), compiler output lines appear in the browser log panel while the build is running (verifiable: lines appear before Build finished / before the page reloads), not as a single burst at completion.
  • Lines classified as warnings render in yellow; lines classified as errors render in red; this is verifiable by inducing a sketch with a warning and a sketch with a compile error.
  • Log rendering escapes content (no HTML injection from compiler output).
  • Terminal output remains unchanged (still mirrored line-by-line).
  • Fatal-error e2e (cold start, forced full recompile, sketch with a guaranteed compile error): viewer shows the error state — red stopped spinner, Compilation failed, full log with red error lines — and stays there indefinitely; no blank page, no 404, no reload loop.
  • Same scenario with a link error (e.g., undefined symbol) reaches the identical error state.
  • After the error, editing the sketch to fix it triggers a rebuild: the page returns to the compiling state and, on success, auto-reloads into the working sketch — all in the same CLI/viewer session.
  • success is only emitted/reloaded when index.html exists on disk; an error status never triggers a reload.
  • build-status.json reflects error status so non-SSE polling clients see the failure.
  • soldr cargo test --workspace passes; new unit tests cover line classification, the piped-output line forwarding, and the error-state status transitions (error → compiling → success).

Decisions

  • No progress bar removal needed in code: current LOADING_PAGE on main already uses a spinner with no <progress> element — this issue locks that in and focuses on the real gaps (live streaming + coloring). If the user saw a progress bar it was from an older binary.
  • Classification heuristic: substring match on warning: / error: (clang/emcc diagnostic format) plus the SSE stream field; simple and covers the dominant toolchain.
  • Streaming mechanism: reuse the existing broadcast SSE channel and emit_build_log; the change is in subprocess capture (run_status → spawn + piped readers), not in transport.
  • Priority: P2 — UX polish on a now-working feature (fix: point Tauri viewer at HTTP server URL instead of fastled:// protocol #152), not a regression.
  • Stale-artifact rebuild failure: an error overlay injected into the already-loaded sketch page is deliberately out of scope — it requires touching the generated frontend. This issue only guarantees error visibility on the loading page (no-artifact case) plus terminal + build-status.json; an in-sketch overlay can be a follow-up.
  • Scroll-to-first-error on failure: chosen over scroll-to-bottom because emcc error output is often followed by long noise; first diagnostic is what the user needs.

Related issues

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions