Refresh top-panel git chip after Code Review panel git operations - #15210
Refresh top-panel git chip after Code Review panel git operations#15210warp-agent-staging[bot] wants to merge 1 commit into
Conversation
The git diff stats chip in the top panel (files changed / additions / deletions) is driven by the shared per-repo `GitRepoStatusModel`, which only refreshed via filesystem-watcher events (throttled, lossy) or `refresh_warp_prompt` on terminal-side events. Code Review panel operations that mutate the working tree (discard, undo-revert, manual `RefreshGitState`) previously only refreshed the panel's own `DiffStateModel`, never the shared `GitRepoStatusModel`, so the top panel could stay stale until an unrelated terminal event happened to trigger a refresh. Add `GitRepoModels::refresh_repo`, a no-op-safe way to force a refresh of the per-repo status model for a given repo path if one currently has subscribers. Call it: - After a Code Review panel discard completes (`LocalDiffStateModel` doesn't hold a `GitRepoStatusModel` handle itself, so it goes through the shared per-repo registry). - After `CodeReviewAction::RefreshGitState` and after undoing a hunk revert in `CodeReviewView`, which already holds a `GitRepoStatusModel` handle for its own git-ops UI. Fixes #15209 Co-Authored-By: Warp <agent@warp.dev>
|
This PR was generated with Warp. |
There was a problem hiding this comment.
Review summary
Reviewed the diff on factory/auto/15209-topbar-git-stats-refresh against issue #15209. Overall the fix is small, well-scoped, and matches the stated root cause and description.
Correctness
GitRepoModels::refresh_repo(app/src/code_review/git_repo_models.rs) correctly looks up the cachedGitRepoStatusModelbyLocalOrRemotePathand no-ops when nothing is subscribed — consistent with the existingsubscribe/subscribe_github_repocache pattern in the same file.LocalDiffStateModel::discard_files(app/src/code_review/diff_state/local.rs) calls the newrefresh_git_repo_statushelper only on the success path after the discard git operation completes, alongside the existingload_diffs_for_current_repo/refresh_diff_metadata_for_current_repocalls. Looks correct.CodeReviewView::refresh_git_repo_status(app/src/code_review/code_review_view.rs) is wired intoCodeReviewAction::RefreshGitStateandmaybe_undo_revert, matching the PR description. No double-refresh paths were found (discard only refreshes via the diff-state model's own heldGitRepoModelshandle; the view's own held handle is used only forRefreshGitState/undo-revert).- The
LocalOrRemotePathkey used inrefresh_git_repo_status(built fromself.active_repository_path()→repository.root_dir()) should match the key used when the terminal/code-review-view subscribed viaGitRepoModels::subscribe, since both derive from the sameRepositoryroot-dir detection path. No cache-key mismatch found.
Verified independently
cargo check -p warp --lib: passedcargo clippy -p warp --all-targets --tests -- -D warnings: passed./script/format --check: passed- PR remains a draft (
isDraft: true), open, mergeable — not merged.
Suggestions (non-blocking)
- Test coverage: No unit test was added for
GitRepoModels::refresh_repo's no-op-when-unsubscribed behavior. This is arguably hard to unit test cheaply today (subscribing requires real repo-detection/watcher wiring forlocal_fs), but if there's a lightweight way to exercise it (e.g. via the existingGitRepoStatusModel::new_local_for_testhelper), it would help guard this regression going forward. - Visual/behavioral evidence: This fixes a user-visible timing issue (top-panel git chip staleness). Per this repo's PR review conventions, a short screen recording showing the chip updating immediately after a Code Review panel discard (before vs. after) would strengthen the PR, though the manual repro is straightforward for a maintainer to verify before merging.
No regressions or blocking issues found. Draft status preserved as required.
| Ok(_) => { | ||
| me.load_diffs_for_current_repo(false, false, ctx); | ||
| me.refresh_diff_metadata_for_current_repo(false, ctx); | ||
| me.refresh_git_repo_status(ctx); |
There was a problem hiding this comment.
Follow-up: remote sessions have the same gap, unfixed here.
RemoteDiffStateModel::discard_files (app/src/code_review/diff_state/remote.rs:833) dispatches to RemoteServerManager and never refreshes the shared GitRepoStatusModel — so after discarding from the Code Review panel over an SSH session, the top-panel chip goes stale exactly as described in #15209, and stays that way until an unrelated terminal-side event fires.
Since GitRepoModels::refresh_repo already accepts any LocalOrRemotePath, the remote path could call it with self.remote_path in the daemon's completion callback, mirroring what this line does for the local case. Fine as a follow-up if out of scope here — but worth tracking so the remote variant of #15209 isn't forgotten.
There was a problem hiding this comment.
Your GitHub account is not connected to Warp. Connect it here.


Problem
The git diff stats chip in the top panel (files changed / +additions / -deletions) goes stale after discarding files via the Discard button in the Code Review panel. The Code Review panel itself updates immediately, but the top panel doesn't refresh until an unrelated terminal-side event (running a command, cwd change, AI file edit) happens to trigger it.
Root cause
The top-panel chip is driven by the shared per-repo
GitRepoStatusModel, which only refreshes via:refresh_warp_prompt, fired only by terminal-side eventsCode Review panel operations that mutate the working tree (discard, undo-revert, manual "refresh git state") only refreshed the panel's own
DiffStateModel, never the sharedGitRepoStatusModelthat feeds the top-panel chip.Fix
GitRepoModels::refresh_repo(repo, ctx): forces a metadata refresh on the per-repoGitRepoStatusModelforrepoif one currently exists, no-oping otherwise so callers don't need to hold their own subscription.LocalDiffStateModel::discard_filesnow calls this (via the sharedGitRepoModelssingleton) once the discard operation completes.CodeReviewViewnow also refreshes its ownGitRepoStatusModelhandle (already held for its git-ops UI) afterCodeReviewAction::RefreshGitStateand after undoing a hunk revert.Fixes #15209
Testing
cargo check -p warp --libcargo clippy -p warp --all-targets --tests -- -D warnings./script/format --checkCo-Authored-By: Warp agent@warp.dev