Skip to content

feat: reload by itself when the working tree or refs change - #10

Merged
Lars- merged 4 commits into
mainfrom
feat/live-refresh
Oct 31, 2026
Merged

Lars- merged 4 commits into
mainfrom
feat/live-refresh

Conversation

@Lars-

@Lars- Lars- commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

What this changes

GitCraft now notices changes made outside it and reloads by itself: a file saved in an editor, git add, a commit, a new branch or a checkout in a terminal show up within a moment, without clicking Refresh or switching windows.

  • gitcraft-core gets Repo::watch (watch.rs), built on notify (CC0-1.0) for the native file events on every platform. It watches the working tree and the git directory and only reports what GitCraft shows: files git does not ignore (gitoxide's own ignore rules, read again when a .gitignore or info/exclude changes), refs, HEAD and the index. Objects, logs, lock files and plain reads do not count, so a build in target/ or node_modules/ does not wake the app.
  • git status now runs with --no-optional-locks. Without it, the reload after a change could rewrite the index, which wakes the watcher again and briefly holds index.lock, making the user's own git in a terminal fail.
  • Only the tab on screen reloads; a tab out of sight reloads when it is shown, as before. Between two automatic reloads there is at least as much time as the last one took (and 100 ms), so a long checkout or a script that keeps writing never keeps the window busy.
  • Setting up the watch takes about 25 µs per folder (88 ms for 3,300 folders here), so it happens in the first background load, not in the window. If it fails (for example at the inotify limit), the error bar says so and refreshing on focus still works.

How it is tested

  • changes_made_outside_are_noticed (core): an edited file, staging, a new branch and a checkout from the command line are each reported.

  • ignored_files_and_reading_are_not_noticed (core): writing in an ignored folder, reading the history, the status, the stashes and a diff report nothing; after .gitignore changes, the same folder is reported. Checked that the test fails without --no-optional-locks, without skipping read events and without the ignore rules.

  • On macOS, FSEvents can still report changes made just before watching began (seen in CI with printed events: reads themselves report nothing there either). The core tests let those early reports pass first; in the app they cost at most one extra reload when a tab opens.

  • changes_made_outside_show_up_by_themselves (app): an edit and a commit made outside show up in the window on their own; the test fails when the watcher is off.

  • Tried on the desktop with the release build: a new file and a branch made from a terminal appeared within a second, removing them again restored the view. Idle CPU stays at zero; 1,500 writes to an ignored folder cost about 50 ms of CPU in total.

  • cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass

  • It adds as little code as the change needs, and removes what it makes unnecessary

  • Nothing in it comes from GitKraken or another closed-source client (see CONTRIBUTING.md)

@Lars-
Lars- merged commit bbb30c7 into main Oct 31, 2026
14 checks passed
@Lars-
Lars- deleted the feat/live-refresh branch October 31, 2026 10:34
@Lars- Lars- mentioned this pull request Oct 31, 2026
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