Repository navigation
refactor: one debounced watcher for config and scan; core counts the menubar's live numbers - #168
Merged
Merged
Conversation
…menubar's live numbers tw-watch: watch a set of directories without recursing, keep create/modify/ remove events whose path passes a filter, debounce a burst into one signal and drop signals while one is pending. tw-config's config-file watch and tw-scan's client-surface watch now differ only in which directories and which paths count; notify is a dependency of tw-watch alone. GET /live: the running requests (the same set as /in-flight, as small views sorted by start) and the generation rate over the last minute (output tokens over time after the first byte, weighted by tokens; null when nothing finished). The event bus already tracked what is in flight; it now also keeps first-byte times and recent finishes, so the desktop's menubar can stop counting requests itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Two cleanups.
One debounced watcher (
tw-watch, new, layer two)tw-config/src/watch.rsandtw-scan/src/watch.rswere the same code twice: watch directories without recursing, keep create/modify/remove events, debounce,try_sendinto an mpsc. They now call one function:Each caller only says which directories and which paths count (tw-config: the config file's name in its directory, 200 ms; tw-scan: interesting extensions that are not ours, 300 ms). The channel holds at most one pending signal.
Watch/WatchErrorare re-exported from both modules, so callers are unchanged.notifyis now a dependency of tw-watch alone. Layer one is untouched (tw-watch is layer two;layer_onetest still green).Core counts the menubar's live numbers (
GET /live)The desktop's
src-tauri/src/tally.rslistened to the event stream to count running requests and compute the generation rate, and had to reconcile with/in-flightafter joining late or dropping events. The event bus already tracks what is in flight; it now also keeps first-byte times and the last minute of finished requests.ep::Live: GET "/live", () => LiveViewLiveView { running: Vec<RunningView>, tokens_per_sec: Option<u32> }RunningView { id, client, client_hint: Option<String>, model, provider, at_ms }, sorted by start (same set as/in-flight)nullwhen none.Lite follow-up: call
/livewherever the menubar collects (refresh_live, and the quit confirmation's count) and deletetally.rs,resync_tallyand the tally feeding in the event bridge.🤖 Generated with Claude Code