Skip to content

Fix stale git diff chip and code review button#11242

Merged
johnturcoo merged 2 commits into
masterfrom
johnturco/remote-1699-git-diff-chip-not-updating-until-terminal-command-is-run
May 19, 2026
Merged

Fix stale git diff chip and code review button#11242
johnturcoo merged 2 commits into
masterfrom
johnturco/remote-1699-git-diff-chip-not-updating-until-terminal-command-is-run

Conversation

@johnturcoo
Copy link
Copy Markdown
Contributor

@johnturcoo johnturcoo commented May 18, 2026

Description

Resolves #11016

The GitDiffStats prompt chip and code review button could show stale state when entering or leaving a git repository.

Problem 1 — Flicker on entering a repo: The chip has two value sources: a shell fallback (git diff --shortstat HEAD, tracked changes only) and a repo-status watcher that also counts untracked files. On cd into a repo there is a race that can cause untracked files to not appear in the diff chip.

Problem 2 — Stale state on leaving a repo: When cd'ing out of a repository, the chip's last value and the code review button's diff annotation are not immediately cleared.

This PR resolves both of these issues

Changes

  • fetch_chip_value_once(): If the repo-status watcher attached while a GitDiffStats shell-fallback command was in flight, discard the fallback's result so it can't overwrite the watcher's accurate value.
  • set_git_repo_status(): On repo detach, immediately abort in-flight handlers and clear the cached GitDiffStats value, then signal a re-render.
  • clear_git_repo_status() : On repo exit, refresh the pane header and emit TerminalViewStateChanged so the code review button drops its diff annotation immediately.

Linked Issue

https://linear.app/warpdotdev/issue/REMOTE-1699/git-diff-chip-not-updating-until-terminal-command-is-run

Testing

  • I have manually tested my changes locally with ./script/run

Screenshots / Videos

Demo of issue (Note that the code review button also shows stale diffs upon leaving a directory)
Demo of fix (Untracked file changes now appear right away in the diff chip. Diff chip and code review button are both cleared upon exiting a repo)

Changelog Entries for Stable

CHANGELOG-BUG-FIX: Fixed the git diff prompt chip flickering on entering a repository, and stale git diff state on the prompt chip and code review button when leaving a repository.

@cla-bot cla-bot Bot added the cla-signed label May 18, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 18, 2026

@johnturcoo

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

Reviewed PR #11242, which prevents the GitDiffStats shell fallback from overwriting watcher-driven values after the git status watcher attaches, and clears repo-derived prompt/header state when leaving a repository.

Concerns

  • No blocking correctness, spec-alignment, or security concerns found in the annotated diff. The PR description includes user-visible demo evidence for the behavior change.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@vkodithala vkodithala self-requested a review May 19, 2026 12:43
Comment on lines +776 to +785
// GitDiffStats has two value sources that can race when entering a repo:
// this shell fallback (`git diff --shortstat HEAD`, tracked changes only)
// and a repo-status watcher that also counts untracked files. If the
// watcher attached while this fallback was in flight, drop the fallback's
// result
if matches!(chip_kind, ContextChipKind::GitDiffStats)
&& me.is_updated_externally(&chip_kind)
{
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

Copy link
Copy Markdown
Contributor

@vkodithala vkodithala left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for attaching a demo! Left a small note, non-blocking.

Comment thread app/src/terminal/view.rs Outdated
Comment on lines +4816 to +4819
// Redraw on repo exit so the code review button drops its diff annotation immediately.
self.refresh_pane_header(ctx);
ctx.emit(Event::TerminalViewStateChanged);
ctx.notify();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense to me that we emit a TerminalViewStateChanged (since this updates the diff chip on the workspace header) and re-render the active terminal view - but a little confused at why we're refreshing the pane header? Is there any dependency between the pane header <> repo status?

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.

Thanks for the call out!

No need to refresh the pane header here, and also re-rendering the active terminal view is also redundant (set_git_repo_status already re-renders). Updated!

@johnturcoo johnturcoo enabled auto-merge (squash) May 19, 2026 16:07
@johnturcoo johnturcoo merged commit 2fe9d43 into master May 19, 2026
25 checks passed
@johnturcoo johnturcoo deleted the johnturco/remote-1699-git-diff-chip-not-updating-until-terminal-command-is-run branch May 19, 2026 16:23
lawsmd pushed a commit to lawsmd/cortex that referenced this pull request May 22, 2026
## Description

Resolves warpdotdev#11016 

The `GitDiffStats` prompt chip and code review button could show stale
state when entering or leaving a git repository.

Problem 1 — Flicker on entering a repo: The chip has two value sources:
a shell fallback (git diff --shortstat HEAD, tracked changes only) and a
repo-status watcher that also counts untracked files. On cd into a repo
there is a race that can cause untracked files to not appear in the diff
chip.

Problem 2 — Stale state on leaving a repo: When cd'ing out of a
repository, the chip's last value and the code review button's diff
annotation are not immediately cleared.

This PR resolves both of these issues

## Changes
- `fetch_chip_value_once()`: If the repo-status watcher attached while a
GitDiffStats shell-fallback command was in flight, discard the
fallback's result so it can't overwrite the watcher's accurate value.
- `set_git_repo_status()`: On repo detach, immediately abort in-flight
handlers and clear the cached GitDiffStats value, then signal a
re-render.
- `clear_git_repo_status()` : On repo exit, refresh the pane header and
emit TerminalViewStateChanged so the code review button drops its diff
annotation immediately.


## Linked Issue


https://linear.app/warpdotdev/issue/REMOTE-1699/git-diff-chip-not-updating-until-terminal-command-is-run

## Testing

- [x] I have manually tested my changes locally with `./script/run`

### Screenshots / Videos

[Demo of
issue](https://www.loom.com/share/42e8748176f04510a530727cb7fe7f61)
(Note that the code review button also shows stale diffs upon leaving a
directory)
[Demo of fix
](https://www.loom.com/share/c1b06e3c8804498ab3d958570f6d0c71)
(Untracked file changes now appear right away in the diff chip. Diff
chip and code review button are both cleared upon exiting a repo)



## Changelog Entries for Stable

CHANGELOG-BUG-FIX: Fixed the git diff prompt chip flickering on entering
a repository, and stale git diff state on the prompt chip and code
review button when leaving a repository.
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.

Stale git diff chip when navigating in/out of repo directory

2 participants