feat(watch): live-refresh on external .git changes + fetch-on-focus#7
Merged
Conversation
Add a filesystem watcher so the graph/branches update the instant git state changes underneath the app - a commit/checkout/stash/rebase from a terminal or another tool - without a manual refresh. Watches the repo's git dir(s) (worktree gitdir + shared commondir) via notify-debouncer-mini, collapsing each op's write burst into one debounced `repo-changed` event; handles live in Tauri state, started on repo load and dropped on tab close. Purely local: no network, so nothing to rate-limit. Also make regaining window focus pull remote state (prune included) when auto-fetch is enabled, throttled to the configured interval via a single self-gating backgroundFetch() shared with the interval timer. Hardening: the watcher listener skips our own writes' debounced echo (in-flight via busyRef, just-settled via lastOpAt) so a fast local op can't refresh twice, and the load path re-checks liveness after its initial refresh so closing a tab mid-load cannot leak a watcher.
|
🎉 This PR is included in version 0.29.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
What
Makes GitChef react to changes automatically, closing the gap the user hit: deleted-upstream branches lingering until a manual Fetch.
1. Filesystem watcher (
src-tauri/src/watch.rs) - instant local reactivitynotify-debouncer-mini, 400ms debounce collapsing an op's write burst into onerepo-changedevent.refresh({stats:false})on the event - zero network, nothing to rate-limit.2. Fetch-on-focus - the missing half of remote reactivity
backgroundFetch()shared with the interval timer.Already existed (not rebuilt)
Periodic auto-fetch (Off/1/5/15min, Settings, default Off), auto-prune on pull +
fetch --all --prune, focus/visibility local refresh.Review + hardening
Code-review agent + ponytail pass run on the diff. Fixes applied:
await- re-check liveness beforewatchRepo.backgroundFetchso interval + focus share one clock (no double-fetch).lastOpAt), not just whilebusyRefis set.Verify
.gitwrite + idempotency): passNote
Auto-fetch still defaults to Off. The watcher (local reactivity) is always on; remote pruning stays manual/auto-fetch-gated unless we flip that default - open question for a follow-up.
https://claude.ai/code/session_01RVF5LSdTyciWKY1k5sedU8