fix(dashboard): rescan periodically so a long-lived dashboard stays live - #161
Open
DiegoDAF wants to merge 2 commits into
Open
fix(dashboard): rescan periodically so a long-lived dashboard stays live#161DiegoDAF wants to merge 2 commits into
DiegoDAF wants to merge 2 commits into
Conversation
/api/data only reads the DB and the browser polls it every 30s, but nothing rescanned transcripts after the startup scan — so a dashboard left open served a frozen snapshot while the footer advertised "Auto-refresh in 30s". cmd_dashboard's background thread now keeps rescanning on the same cadence. Rescans are incremental (processed_files skips unchanged mtimes), so a steady-state pass over a ~700-file backlog touches only the live sessions (~0.1s), and runs with verbose=False to keep the terminal quiet. Adds --auto-refresh SECONDS (and the AUTO_REFRESH env var) to tune the interval, plus --no-auto-refresh / --auto-refresh 0 to restore the scan-once-at-startup behaviour.
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.
The bug
A dashboard left open serves a frozen snapshot. The browser polls
/api/dataevery 30s and the footer advertises "Auto-refresh in 30s" — but/api/dataonly reads the DB, and nothing rescans transcripts after the single startup scan. The numbers stop moving the moment that scan finishes.Hit this in normal use: a dashboard started at 10:48 was still serving 10:48's data 27 hours later. Yesterday showed only a partial total (the turns written before the scan ran), today was missing entirely, and the footer kept cheerfully promising a refresh every 30 seconds.
The fix
cmd_dashboard's background thread now keeps rescanning on the same 30s cadence, so the poll the client already performs actually lands on fresh data.Rescans are incremental, so this is close to free —
processed_filesskips any transcript whose mtime is unchanged. Measured on a ~700-file backlog, a steady-state pass touches only the handful of live sessions:They run with
verbose=Falseso the terminal stays quiet (the startup scan already reported the backlog), and a failing tick is caught and logged rather than killing the loop.New flags
--auto-refresh SECONDSAUTO_REFRESHenv var)--no-auto-refresh/--auto-refresh 0Default is on at 30s. Since the UI already promises auto-refresh, this is framed as fixing a broken promise rather than adding an opt-in feature — but it's a one-line change to flip the default if you'd rather it be opt-in.
Verification
--no-auto-refresh) plus the loop itself: that it rescans after startup, that ticks are quiet, and that0disables it. Full suite: 159 passing./api/datareflected it one tick later with no restart (111 → 333 output tokens).Notes
## v1.5.6 — TBD, withscanner.VERSIONandvscode-extension/package.jsonbumped in lockstep sotests/test_version.pypasses. It's in its own commit — drop it if you'd rather choose the number at release time.DEV, per AGENTS.md.