Skip to content

Refresh top-panel git chip after Code Review panel git operations - #15210

Draft
warp-agent-staging[bot] wants to merge 1 commit into
masterfrom
factory/auto/15209-topbar-git-stats-refresh
Draft

Refresh top-panel git chip after Code Review panel git operations#15210
warp-agent-staging[bot] wants to merge 1 commit into
masterfrom
factory/auto/15209-topbar-git-stats-refresh

Conversation

@warp-agent-staging

Copy link
Copy Markdown
Contributor

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:

  • model creation
  • the filesystem-watcher chain (throttled to once per 5s, and suppressed during index-lock)
  • refresh_warp_prompt, fired only by terminal-side events

Code Review panel operations that mutate the working tree (discard, undo-revert, manual "refresh git state") only refreshed the panel's own DiffStateModel, never the shared GitRepoStatusModel that feeds the top-panel chip.

Fix

  • Added GitRepoModels::refresh_repo(repo, ctx): forces a metadata refresh on the per-repo GitRepoStatusModel for repo if one currently exists, no-oping otherwise so callers don't need to hold their own subscription.
  • LocalDiffStateModel::discard_files now calls this (via the shared GitRepoModels singleton) once the discard operation completes.
  • CodeReviewView now also refreshes its own GitRepoStatusModel handle (already held for its git-ops UI) after CodeReviewAction::RefreshGitState and after undoing a hunk revert.

Fixes #15209

Testing

  • cargo check -p warp --lib
  • cargo clippy -p warp --all-targets --tests -- -D warnings
  • ./script/format --check

Co-Authored-By: Warp agent@warp.dev

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>
@cla-bot cla-bot Bot added the cla-signed label Aug 16, 2026
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

View run View conversation

@warp-agent-staging warp-agent-staging Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 cached GitRepoStatusModel by LocalOrRemotePath and no-ops when nothing is subscribed — consistent with the existing subscribe/subscribe_github_repo cache pattern in the same file.
  • LocalDiffStateModel::discard_files (app/src/code_review/diff_state/local.rs) calls the new refresh_git_repo_status helper only on the success path after the discard git operation completes, alongside the existing load_diffs_for_current_repo / refresh_diff_metadata_for_current_repo calls. Looks correct.
  • CodeReviewView::refresh_git_repo_status (app/src/code_review/code_review_view.rs) is wired into CodeReviewAction::RefreshGitState and maybe_undo_revert, matching the PR description. No double-refresh paths were found (discard only refreshes via the diff-state model's own held GitRepoModels handle; the view's own held handle is used only for RefreshGitState/undo-revert).
  • The LocalOrRemotePath key used in refresh_git_repo_status (built from self.active_repository_path()repository.root_dir()) should match the key used when the terminal/code-review-view subscribed via GitRepoModels::subscribe, since both derive from the same Repository root-dir detection path. No cache-key mismatch found.

Verified independently

  • cargo check -p warp --lib: passed
  • cargo 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)

  1. 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 for local_fs), but if there's a lightweight way to exercise it (e.g. via the existing GitRepoStatusModel::new_local_for_test helper), it would help guard this regression going forward.
  2. 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aqeelat aqeelat Aug 17, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your GitHub account is not connected to Warp. Connect it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Top panel git stats (files changed / additions / deletions) stay stale after using Code Review panel's Discard button

1 participant