Skip to content

fix(server): refresh divergence after a merged branch ref changes - #31342

Merged
Yash-Singh1 merged 1 commit into
mainfrom
t3/sync-ref-after-merge
Nov 5, 2026
Merged

Yash-Singh1 merged 1 commit into
mainfrom
t3/sync-ref-after-merge

Conversation

@Yash-Singh1

Copy link
Copy Markdown
Collaborator

Problem

After an agent turn merged a branch, the thread could still show stale ahead and behind counts. The turn completion refresh could be skipped when background activity policy paused work.

Change

Always refresh cached remote status at turn completion, without fetching from the remote. This updates divergence after the branch ref changes even when periodic background polling is paused.

Scope and approval

This is a focused fix for stale Git divergence after a merge. The regression test reproduced the stale counts, and the server already has a turn completion refresh for this status.

Verification

The regression test verifies that counts update from 3 ahead and 5 behind to 7 ahead and 0 behind while background work is disabled. All 27 focused tests passed. vp run check:changed passed its format, lint, knip, GraphQL, affected package typecheck, and test checks.

Codex with the Codex harness

- Keep turn-end VCS refreshes updating divergence while background polling is paused
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 5, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at db358c6

Macroscope's review found this PR approvable — Turn completion now refreshes PR status and divergence even when background polling is paused. Existing branch guards and locking remain, without enabling upstream fetching or automatic pulls.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Baseline: 67eebac · PR result: db358c6 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

refreshPullRequestStatus now reads remote status after its cache guard, regardless of whether background VCS status work is enabled. Tests check the refreshed status and recovery behavior while background work remains disabled.

Changes: Pull request status refresh

Layer / File(s) Summary
Refresh status and verify results
apps/server/src/vcs/VcsStatusBroadcaster.ts, apps/server/src/vcs/VcsStatusBroadcaster.test.ts
refreshPullRequestStatus no longer checks background-work policy before reading remote status. Tests verify the returned and merged status, the upstream-refresh option, and recovery with background work disabled.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#18842: Adds tests for gating PR refresh after snapshot eviction. This change removes the background-work gate from the same refresh path.

Suggested labels: bugfix, size:M

Suggested reviewers: justyannicc, macroscopeapp, utkarshusername

Merge Risk: Minimal · up to db358

This fixes stale ahead/behind counts after an agent turn merges a branch while background polling is paused. The refresh may wait on a forge lookup when the branch has no PR, but this only delays the status update briefly. No merge-blocking risk remains.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description follows the template's main sections. Problem gives the stale ahead/behind symptom and the cause. Change explains that cached remote status now always refreshes at turn completion with… Add a link to the triaged bug issue or the discussion with explicit maintainer approval, including the approval comment. If there is no prior issue, explain why this small, obvious bug fix qualifies without one. Optionally state anything no…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: refreshing divergence (ahead/behind counts) after a merged branch ref changes. The changeset removes the background-work gate in refreshPullRequestStatus so the cached…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: refreshing divergence (ahead/behind counts) after a merged branch ref changes. The changeset removes the background-work gate in refreshPullRequestStatus so the cached remote status always refreshes, and the test checks that counts update from 3 ahead/5 behind to 7 ahead/0 behind. The title follows the conventional commit format and is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the template's main sections. Problem gives the stale ahead/behind symptom and the cause. Change explains that cached remote status now always refreshes at turn completion without fetching. Scope and approval links no issue or maintainer approval and only describes the fix as focused. Verification reports the regression test's observed counts and the 27 passing focused tests, plus the check:changed run. The author did not link a triaged issue or maintainer approval, which the template asks for, so the Scope and approval section is incomplete. The verification section also does not state anything that could not be checked, and it does not cite the exact commands for the focused tests.

Resolution

Add a link to the triaged bug issue or the discussion with explicit maintainer approval, including the approval comment. If there is no prior issue, explain why this small, obvious bug fix qualifies without one. Optionally state anything not checked and name the focused test commands.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 67eebac and db358c6.

Files selected for processing: 2

  • apps/server/src/vcs/VcsStatusBroadcaster.test.ts
  • apps/server/src/vcs/VcsStatusBroadcaster.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@Yash-Singh1
Yash-Singh1 merged commit 01a8db0 into main Nov 5, 2026
31 checks passed
@Yash-Singh1
Yash-Singh1 deleted the t3/sync-ref-after-merge branch November 5, 2026 08:35
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Nov 5, 2026
**v0.1.8-nightly.20261105.4218** · 9 changes from 3 contributors

- **Thread history.** Long threads retain their visible history when you open or reconnect to them.

### Plus 4 more bug fixes.

<details>
<summary>Full changelog</summary>

## What's Changed
* revert(web): working threads stay in the Working shelf when their environment disconnects by @juliusmarminge in pingdotgg/t3code#31269
* refactor: Effect code reads env through HostProcess.Environment by @juliusmarminge in pingdotgg/t3code#31218
* refactor: Effect.try calls map failures to typed errors by @juliusmarminge in pingdotgg/t3code#31217
* fix(web): sidebar project filter rows line up and stay still on hover by @shivamhwp in pingdotgg/t3code#29639
* refactor: errors are Schema.TaggedError, not Data.TaggedError or native Error by @juliusmarminge in pingdotgg/t3code#31216
* fix(server): a stopped run no longer shrinks thread history to one row by @shivamhwp in pingdotgg/t3code#31266
* fix(server): refresh divergence after a merged branch ref changes by @Yash-Singh1 in pingdotgg/t3code#31342
* fix(mobile): one aligned notice for ChatGPT sharing limits by @shivamhwp in pingdotgg/t3code#31277
* fix(mobile): composer keeps the keyboard when a queued edit ends by @shivamhwp in pingdotgg/t3code#31317


**Full Changelog**: pingdotgg/t3code@v0.1.8-nightly.20261105.4205...v0.1.8-nightly.20261105.4218

</details>


Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.8-nightly.20261105.4218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant