Repository navigation
Closed
Description
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:
- 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.
- Build tool output is not streamed live. The SSE plumbing exists (
/build-stream,emit_build_logincrates/fastled-cli/src/compile_stream.rsalready tags each line with"stream":"stdout"|"stderr"), but:- Build subprocesses are launched with
Command::status()(run_statusincrates/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_logsonly emitsresult.outputafterbuild::run_buildreturns — the browser log panel gets one burst at the end of the build instead of a live tail.
- Build subprocesses are launched with
- No log coloring. The loading page's
appendLog()(server.rs:103) ignores thestreamfield entirely and renders every line in flat gray. Warnings and errors are indistinguishable from noise. - 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:
- 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).
- 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 existingemit_build_log(tx, line, stream)so the terminal and the SSE channel see output in real time, not post-hoc. - Colored log lines in the browser. In
LOADING_PAGE's JS, use the already-presentd.streamfield plus line-content classification to render:- lines containing
warning:(emcc/clang style) → yellow (#ffd54for similar) - lines containing
error:/fatal error:/ lines arriving onstderrthat match error patterns → red (#ef5350) - everything else → current gray
- Switch
#logfrom 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.
- lines containing
- Keep terminal behavior unchanged —
emit_build_logalready mirrors to stdout/stderr. - Fatal-error handling when no artifacts exist. When the build fails with a fatal compiler or link error and
index.htmlwas 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. Thesuccess → reloadtransition only fires whenindex.htmlactually exists on disk (server should verify before emittingsuccess). - The SSE connection stays open after an error so the page hears the next
compilingevent: 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.jsonis 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.htmlon 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 andbuild-status.json; an in-sketch error overlay is out of scope here (see Decisions).
- The loading page stays up in an explicit error state: spinner stops (red), header reads
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 beforeBuild 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.
-
successis only emitted/reloaded whenindex.htmlexists on disk; anerrorstatus never triggers a reload. -
build-status.jsonreflectserrorstatus so non-SSE polling clients see the failure. -
soldr cargo test --workspacepasses; 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_PAGEonmainalready 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 SSEstreamfield; 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
- feat: instant launch — open web view immediately, stream compile, switch to sketch when ready #148 / feat: instant launch — explicit failure UX in the loading page #149 — instant-launch loading page (closed)
- fix: instant launch broken — Tauri viewer loads fastled:// directory protocol, never the HTTP server, shows 'Not Found' forever #151 / fix: point Tauri viewer at HTTP server URL instead of fastled:// protocol #152 — viewer pointed at HTTP server so this page is actually visible (closed)
- feat: stream compilation output to browser in real time #49, feat: stream live compilation output to Tauri viewer #43 — earlier "stream compile output to browser" work (closed); live line-by-line capture was never wired into the native Rust build path
Metadata
Metadata
Assignees
Labels
No labels
Activity