Repository navigation
fix(scan): rerun a scan that was requested while one was running - #20
Merged
Merged
Conversation
scanAll() returned { skippedConcurrent: true } and forgot the request.
When a watch event's debounced scan landed during a running scan, and
that scan had already passed the changed file, the change waited for
the 60 s interval scan. The dashboard and menubar lagged by up to a
minute after the last write of a burst.
Now a mid-scan request sets a flag, and the scan that finishes
schedules one debounced follow-up. Going through the debounce keeps
continuous writes from turning into back-to-back scans. stop() cancels
the follow-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Reviewed and verified in a clean worktree — LGTM.
Same note as on #19: the two PRs conflict in |
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.
Problem
scanAll()returns{ skippedConcurrent: true }when a scan is already running, and the request is then lost. The watcher's debounced scan can fire while the previous scan is still in progress; at 5000 Codex files, an idle scan takes ~0.5–1 s. If the running scan has already passed the file that just changed, that change is only picked up by the 60 s interval scan. This typically happens at the end of a burst of agent activity: the last write lands mid-scan and nothing follows it. The dashboard and the menubar then show stale numbers for up to a minute.Fix
_rescan. When the running scan finishes, it schedules one follow-up scan through the normal debounce (_scheduleScan). Going through the debounce keeps continuous writes at the current scan rate instead of turning them into back-to-back scans.stop()sets_stopped, so a scan that finishes after shutdown does not schedule anything.startWatching()clears the flag.scanAll()keeps the same return values. CLI callers (scan,today,doctor) never call it concurrently, so they are unaffected.Tests
test/scan-rerun.mjs:scanAll()again, which is skipped. It then waits for a follow-up scan, at most 5 s; in practice ~0.8 s, the debounce time. Finally it asserts that every rollout was ingested. This case fails onmainwith "no follow-up scan within 5 s".stop()during a scan cancels the follow-up.Full
npm testis green. This PR is independent of #16–#19; the only overlap is the one-line registration intest/run.mjs.🤖 Generated with Claude Code