Skip to content

APP-4263 Fix git ops flicker bug #9452

Merged
MaggieShan merged 6 commits intomasterfrom
edward/app-4263-fix-flicker-tristate
May 5, 2026
Merged

APP-4263 Fix git ops flicker bug #9452
MaggieShan merged 6 commits intomasterfrom
edward/app-4263-fix-flicker-tristate

Conversation

@exzshao
Copy link
Copy Markdown
Contributor

@exzshao exzshao commented Apr 29, 2026

Description

Fixes APP-4263: the code review git operations header briefly showed incorrect PR-related actions while PR info for the current branch was still being refreshed.

load_metadata_for_repo returns pr_info: None because PR info is fetched separately via refresh_pr_info (gh pr view). That made the UI treat unknown PR state as "no PR" while the async lookup was in flight, which could briefly show Create PR. With the handle-only version, switching between two branches that both have PRs could also briefly fall back from PR #N to disabled Commit before resolving to PR #M.

Fix

In app/src/code_review/diff_state.rs:

  1. Track an in-flight PR lookup with refreshing_pr_info_handle: Option<SpawnedFutureHandle> instead of storing PR staleness in metadata.
  2. Abort any previous PR lookup before starting a new one.
  3. Carry forward cached pr_info through metadata refreshes so the header does not clear to disabled Commit while the next branch's PR lookup is pending.

In app/src/code_review/code_review_view.rs:

  1. Gate Create PR on !is_pr_info_refreshing() so an unknown/pending PR lookup is not treated as "no PR".
  2. If cached PR info is being carried while a new lookup is pending, keep the previous PR #N label visible but disable the button/menu item with a "Refreshing PR info" tooltip so it cannot open a stale PR.
  3. Once the lookup resolves, update the header to the new branch's PR #M, Create PR, or disabled Commit state as appropriate.

Testing

Not run in this update per request.

Expected/manual behavior:

  • Main/master → feature branch: no Create PR flicker while gh pr view is pending.
  • Branch with PR → branch with PR: no disabled Commit interstitial; previous PR label remains disabled until the new PR info resolves.
  • Branch with PR → branch without PR: previous PR label remains disabled briefly, then transitions to Create PR if the branch is eligible.
  • Dropdown Create PR and commit-dialog create-PR intent remain unavailable while PR info is refreshing.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

UPDATED LOOM: https://www.loom.com/share/4c94527c09914af9b295e49b4719159a

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

oz-for-oss Bot commented Apr 29, 2026

@exzshao

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

I completed the review and posted feedback on this pull request.

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

You can view the conversation on Warp.

I completed the review and posted feedback on 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

@exzshao exzshao changed the title Add FAQ, serde_json, and event sequence to AI conversation APP-4263 Fix git ops flicker bug Apr 29, 2026
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

This PR changes DiffStateModel metadata refresh handling so cached PR information is always preserved after loading fresh metadata.

Concerns

  • Cached PR information is now preserved even when the current branch changes, which can show or open the previous branch's PR before the asynchronous refresh completes or if it returns no PR.
  • Security pass: no security-specific issues were found in the provided diff.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

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

Powered by Oz

Comment thread app/src/code_review/diff_state.rs
@exzshao exzshao requested a review from MaggieShan April 29, 2026 20:41
Copy link
Copy Markdown
Contributor

@MaggieShan MaggieShan left a comment

Choose a reason for hiding this comment

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

One main comment

Comment thread app/src/code_review/diff_state.rs Outdated
@exzshao exzshao requested a review from MaggieShan April 30, 2026 14:12
Comment thread app/src/code_review/diff_state.rs
Comment thread app/src/code_review/code_review_view.rs Outdated
Comment thread app/src/code_review/code_review_view.rs Outdated
@exzshao exzshao requested a review from MaggieShan April 30, 2026 19:48
oz-for-oss[bot]
oz-for-oss Bot previously requested changes Apr 30, 2026
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

This PR tracks PR-info refreshes to avoid git-operations header flicker while gh pr view is pending and disables stale PR actions during refresh.

Concerns

  • PR lookup completion is not tied to the lookup, branch, or repository that spawned it, so a result that already crossed from the background task before abort() can clear the current refresh handle and apply stale PR info.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

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

Powered by Oz

Comment thread app/src/code_review/diff_state.rs
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 5, 2026

@MaggieShan

I'm re-reviewing this pull request in response to a review request.

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

@MaggieShan
Copy link
Copy Markdown
Contributor

/oz-review re-review this

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 5, 2026

@MaggieShan

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @kevinchevalier.

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

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 5, 2026
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

This PR adds explicit in-flight PR lookup tracking and gates Create PR / stale PR actions while the lookup is refreshing.

Concerns

  • PR lookup completions are not tied to the lookup generation or branch that spawned them, so a stale completed lookup can still clear the current refresh state and write old PR info.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

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

Powered by Oz

.unwrap_or(None)
},
|me, pr_info, ctx| {
me.refreshing_pr_info_handle = None;
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.

⚠️ [IMPORTANT] This completion may belong to an older lookup that finished before abort() took effect; clearing refreshing_pr_info_handle and then writing pr_info can mark a newer lookup as done and publish stale PR info. Track a refresh generation/current branch and ignore completions that are no longer current.

@oz-for-oss oz-for-oss Bot dismissed stale reviews from themself May 5, 2026 22:51

Oz no longer requests changes for this pull request after the latest automated review.

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

This PR preserves and guards PR metadata while asynchronous gh pr view lookups are in flight, preventing the git operations header from briefly exposing stale Create PR or disabled Commit states during branch transitions.

Concerns

  • The dropdown PR action is disabled while PR info refreshes, but it does not surface the same explanatory tooltip as the primary button.

Found: 0 critical, 0 important, 1 suggestions

Verdict

Approve with nits

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

Powered by Oz

MenuItemFields::new(format!("PR #{}", pr_info.number))
.with_icon(Icon::Github)
.with_on_select_action(CodeReviewAction::ViewPr(pr_info.url))
.with_disabled(is_pr_info_refreshing)
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.

💡 [SUGGESTION] Add the same Refreshing PR info tooltip to the disabled dropdown item; the Create PR branch below needs the same explanation when refresh disables it.

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.

No need at the moment

@oz-for-oss oz-for-oss Bot requested a review from kevinchevalier May 5, 2026 22:51
@MaggieShan MaggieShan removed the request for review from kevinchevalier May 5, 2026 22:52
@MaggieShan MaggieShan merged commit e6df31b into master May 5, 2026
28 checks passed
@MaggieShan MaggieShan deleted the edward/app-4263-fix-flicker-tristate branch May 5, 2026 22:53
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.

2 participants