Repository navigation
feat(web): live scan progress via the existing /api/scan/events SSE endpoint (#152) - #234
Merged
Merged
Conversation
The installed sse-starlette str()-ifies dict payload data — the wire carried Python repr (single quotes, capitalized booleans) that no browser EventSource client can JSON.parse. This wire-format defect is why the endpoint was dead surface in #143. Pre-serialize with json.dumps(); regression test drives a real uvicorn server (ASGITransport buffers infinite SSE bodies, so in-process reads hang).
pyright: files_to_process holds the worker's (Path, str, str) input tuples from _scan_and_filter, not the generic result T — the original untyped list() inferred this; the counting loop's explicit list[T] annotation broke it. Caught by CI's pyright gate (the local Task 6 gates ran ruff/pylint/pytest but not pyright).
2 tasks done
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.
Closes #152.
What does this PR do?
While a scan runs,
ScanStatusStripnow shows a live file count —Scanning <dir> — 45 461 files — 42s— fed by the previously dead/api/scan/eventsSSE endpoint (#143's dead-surface finding), updating at the 1s tick. The strip also appears during the initial-load scan (startup), which previously had no progress feedback and is typically the longest scan of a session on a network share. Count segment renders only while the server reportsin_progress— cache-only spinner runs (sort reloads) keep the elapsed-only display, never stale numbers.The issue as filed assumed a web-only change; that premise was false (
cached_resultsonly lands after the whole scan), so the scope is core + server + web per the approved design:docs/superpowers/specs/2026-11-23-scan-progress-design.mddocs/superpowers/plans/2026-11-23-scan-progress.mdChange summary
scan_and_process_dynamicgains optionalon_progress: Callable[[int], None] | None, invoked at the_scan_and_filterconsumption point with the running count of filter-passing candidates (monotonic, converges to the result count; existing callers unaffected).ServerState.scan_progress_count(reset at the top ofexecute_scan, before theexists()early return; writes generation-guarded); SSEstatuspayload gainsprogress.useScanProgress(active)hook (oneEventSourceopen whilescanning || initialScanActive, silent elapsed-only fallback on stream errors, inert withoutEventSource); count segment inScanStatusStripgated on SSEin_progress; ActionBar strip gate extended to the startup scan.Notable bug found in live verification
The SSE endpoint was unusable by any browser client all along: the installed sse-starlette
str()-ifies dict payloads, so the wire carried Python repr ({'in_progress': True, ...}) thatJSON.parserejects. Fixed by pre-serializing withjson.dumps(), pinned by a wire-format regression test that drives a real uvicorn server (ASGITransport buffers infinite SSE bodies, so in-process reads hang — the reason the original plan's wire test was ruled out). Live-verified in a real browser over a 240k-file scan:0 files → 45 461 → 134 910 → 240 000ticking at the SSE cadence, converging to the server's final count.Type of change
Pre-commit checklist
ruff formatappliedruff check --fixpassesAGENTS.md/tests/AGENTS.mdunchanged (no module tree / public-import changes)Testing
uv run pytest --cov=src/profiles --cov-fail-under=85→ 1650 passed, 1 skipped, coverage 88.98%; pylint 9.89/10; ruff clean.npm test→ 40 files / 499 passed;tsc -bclean; dist rebuilt and committed.--server-only+ synthetic 240k-file tree): strip visible instantly on click and during startup; count ticks0 → 45 461 → 134 910 → 240 000at the 1s SSE cadence and converges to the server total; strip unmounts on completion; count segment hidden pre-fix wire (regression confirmed) and present post-fix.Screenshots
Live progress mid-scan (bottom-left, 240k-file scan at the 6s mark):
(Screenshot verified in-session via browser automation; the strip replaces the elapsed-only spinner and the count ticks once per second.)
Multi-window note (accepted limitation)
The progress counter is server-global — two windows scanning simultaneously would see each other's numbers. This inherits the existing single-active-scan state model (shared
scan_generation/cached_results/active_directory); documented in the spec. If multi-client use ever becomes real, the fix is a broader scan-session design, not a progress-only id.