Add --watch and --fetch flags for auto-refreshing the view#159
Open
jpeletier wants to merge 4 commits into
Open
Add --watch and --fetch flags for auto-refreshing the view#159jpeletier wants to merge 4 commits into
jpeletier wants to merge 4 commits into
Conversation
Spawns a worker thread that emits AppEvent::AutoRefresh every N seconds (default 30, minimum 5). The handler skips ticks while the user is typing in the status line, then dispatches to the active view's existing refresh() method, reusing the manual-refresh path end-to-end so cursor and scroll state are preserved.
Implies --watch (defaults to 30s when not set). Runs `git fetch --all --quiet` on the watch worker thread before sending each AutoRefresh, so commits and refs pushed to remotes show up automatically. Errors (offline, auth failures) are swallowed so the refresh tick still fires.
Update the help block in README.md and add dedicated sections to the command-line options page in the mdBook docs.
The watch worker thread inherits the TUI's terminal, which is in raw mode under the alternate screen — so any prompt git's child wants to show (credential prompts, host-key confirmations) blocks indefinitely because the user can't see or answer it. Stderr is also swallowed, so the hang is invisible. Force the fetch fully non-interactive: set GIT_TERMINAL_PROMPT=0 to disable git's own prompts and close stdin on the child so anything that falls back to reading stdin fails fast instead of waiting.
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.
I added these flags because I like to have
serierunning on the side so I don't miss any updates to the repo while I am working on something else.Summary
--watch [<SECONDS>](default 30s when bare, minimum 5s) that periodically re-runs the existing refresh path so external git activity shows up automatically. Cursor and scroll state are preserved across refreshes via the existingRefreshViewContext.--fetchflag that implies--watch(defaulting to 30s) and runsgit fetch --all --quieton the watch worker thread before each tick. Fetch errors (offline, auth) are silently ignored so the refresh still fires. The fetch is forced fully non-interactive (GIT_TERMINAL_PROMPT=0, stdin closed) so it can't hang on a prompt the TUI hides.AppEvent::AutoRefreshis handled inapp.rs's main loop by calling the active view's existingrefresh()method, which emits the sameAppEvent::Refresh(context)that pressingrproduces today. The watch worker thread stops/starts alongside the key-poll thread on suspend/resume, sosuspend-type user commands (e.g.vim) cleanly pause the timer.README.md--helpblock anddocs/src/getting-started/command-line-options.mdupdated.Test plan
cargo build,cargo clippy --all-targets -- -D warnings,cargo fmt --checkall cleancargo test— 45 unit + 19 integration tests pass--helpshows both new flagsserie --watch 5+ external commit in another terminal → new commit appears within ~5s, cursor preservedserie --watch 5 --fetchagainst an SSH remote → pulls down upstream commits without manualgit fetch/-search prompt while AutoRefresh ticks → input not torn down (skipped viaStatusLine::Inputguard)suspend-type user command (e.g. vim) → timer paused during suspend, resumes on return