Skip to content

Add --watch and --fetch flags for auto-refreshing the view#159

Open
jpeletier wants to merge 4 commits into
lusingander:masterfrom
jpeletier:watch
Open

Add --watch and --fetch flags for auto-refreshing the view#159
jpeletier wants to merge 4 commits into
lusingander:masterfrom
jpeletier:watch

Conversation

@jpeletier
Copy link
Copy Markdown

@jpeletier jpeletier commented May 17, 2026

I added these flags because I like to have serie running on the side so I don't miss any updates to the repo while I am working on something else.

Summary

  • Add --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 existing RefreshViewContext.
  • Add --fetch flag that implies --watch (defaulting to 30s) and runs git fetch --all --quiet on 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.
  • Reuses the existing manual-refresh machinery end-to-end: a new AppEvent::AutoRefresh is handled in app.rs's main loop by calling the active view's existing refresh() method, which emits the same AppEvent::Refresh(context) that pressing r produces today. The watch worker thread stops/starts alongside the key-poll thread on suspend/resume, so suspend-type user commands (e.g. vim) cleanly pause the timer.
  • Docs: README.md --help block and docs/src/getting-started/command-line-options.md updated.

Test plan

  • cargo build, cargo clippy --all-targets -- -D warnings, cargo fmt --check all clean
  • cargo test — 45 unit + 19 integration tests pass
  • --help shows both new flags
  • Manual TUI test: serie --watch 5 + external commit in another terminal → new commit appears within ~5s, cursor preserved
  • Manual TUI test: serie --watch 5 --fetch against an SSH remote → pulls down upstream commits without manual git fetch
  • Manual TUI test: typing in /-search prompt while AutoRefresh ticks → input not torn down (skipped via StatusLine::Input guard)
  • Manual TUI test: suspend-type user command (e.g. vim) → timer paused during suspend, resumes on return

jpeletier added 4 commits May 17, 2026 01:24
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.
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