Skip to content

fix(dashboard): rescan periodically so a long-lived dashboard stays live - #161

Open
DiegoDAF wants to merge 2 commits into
phuryn:DEVfrom
DiegoDAF:feat/auto-refresh-rescan
Open

fix(dashboard): rescan periodically so a long-lived dashboard stays live#161
DiegoDAF wants to merge 2 commits into
phuryn:DEVfrom
DiegoDAF:feat/auto-refresh-rescan

Conversation

@DiegoDAF

Copy link
Copy Markdown

The bug

A dashboard left open serves a frozen snapshot. The browser polls /api/data every 30s and the footer advertises "Auto-refresh in 30s" — but /api/data only 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_files skips any transcript whose mtime is unchanged. Measured on a ~700-file backlog, a steady-state pass touches only the handful of live sessions:

New files: 1   Updated files: 3   Skipped files: 198
real    0m0.106s

They run with verbose=False so 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

Flag Effect
--auto-refresh SECONDS Change the interval (also via the AUTO_REFRESH env var)
--no-auto-refresh / --auto-refresh 0 Scan once at startup — the previous behaviour

Default 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

  • 12 new unit tests — the flag-parsing matrix (bare flag, flag-followed-by-flag, negative, non-numeric, precedence of --no-auto-refresh) plus the loop itself: that it rescans after startup, that ticks are quiet, and that 0 disables it. Full suite: 159 passing.
  • End-to-end, isolated DB + transcripts dir: appended a turn to a JSONL while the server was running; /api/data reflected it one tick later with no restart (111 → 333 output tokens).

Notes

  • The CHANGELOG heading is ## v1.5.6 — TBD, with scanner.VERSION and vscode-extension/package.json bumped in lockstep so tests/test_version.py passes. It's in its own commit — drop it if you'd rather choose the number at release time.
  • Targets DEV, per AGENTS.md.

DiegoDAF added 2 commits July 23, 2026 10:14
/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant