Skip to content

Add --watch option to auto-refresh the graph on repository changes - #200

Open
cavaldos wants to merge 1 commit into
lusingander:masterfrom
cavaldos:feature/watch-auto-refresh
Open

cavaldos wants to merge 1 commit into
lusingander:masterfrom
cavaldos:feature/watch-auto-refresh

Conversation

@cavaldos

@cavaldos cavaldos commented Nov 8, 2026

Copy link
Copy Markdown

Closes #199

Summary

Adds an opt-in --watch (-w) flag and core.option.watch config option. When enabled, Serie refreshes the graph automatically when the repository changes (branch switch, commit, rebase, fetch, ...), keeping the current selection and view as the manual refresh does. Default behavior is unchanged.

How it works

  • A background thread (src/watch.rs) polls mtime/size of HEAD, packed-refs and everything under refs/, for both the git dir and the common git dir (so linked worktrees work).
  • Changes are debounced: it waits until files have been quiet for 500 ms, then sends the new AppEvent::RepositoryChanged.
  • The app handles that event by calling the current view's existing refresh(), reusing the manual refresh path.
  • Polling avoids adding a new dependency.

Limitations

  • A change arriving while the help view is open is applied only on the next repository change (that view has no refresh).

Testing

  • cargo fmt --check, cargo clippy --all-targets, cargo test pass.
  • Manually tested with --watch.
  • No automated test for the watcher thread itself.

Docs updated (command-line options and config file format).

Serie loaded the repository only once at startup, so switching branches,
committing, rebasing or fetching in another terminal left the graph stale
until the user pressed the refresh key or relaunched.

Add an opt-in `--watch` (`-w`) flag and `core.option.watch` config option.
When enabled, a background thread polls the modification time and size of
`HEAD`, `packed-refs` and everything under `refs/` (for both the git dir
and the common git dir, so linked worktrees are covered). Once a change
is detected it waits until the files have been quiet for 500 ms, then
sends a new `AppEvent::RepositoryChanged`.

The app handles that event by calling the current view's existing
`refresh()`, so it reuses the manual refresh path and keeps the current
selection and view where possible. Polling avoids adding a new
dependency. Default behavior is unchanged.

Known limitation: a change that arrives while the help view is open is
not applied until the next repository change, since that view has no
refresh.

Closes lusingander#199

This branch has not been deployed

No deployments
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.

Feature request: auto-refresh the commit graph when the repository changes (branch switch, new commits)

1 participant