Skip to content

fix(web): a pull request line link opens its line after a failed file load - #47643

Merged
juliusmarminge merged 13 commits into
pingdotgg:mainfrom
StiensWout:wf/find-7888f1ff26e119cc0d0e59b9
Dec 2, 2026
Merged

juliusmarminge merged 13 commits into
pingdotgg:mainfrom
StiensWout:wf/find-7888f1ff26e119cc0d0e59b9

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Opening a pull request link to an unchanged line makes the Code tab load the file's full contents before it scrolls to the line. If the connection dropped during that load, the read failed and the viewer kept the failure, so the tab only showed the changed sections and the linked line stayed hidden. The pull request file contents read now uses the same lost-connection resend that message dispatch uses: it records the session before sending, resends only when the failure is a lost transport, waits for the replacement session (including one that arrived before the failure was handled), and gives up when the environment stops reconnecting.

Related: #46406, #31166, #39881, #39979, #46711

Reproduction on main

Commit dff224df1d (main). The Code tab shows the file's changed sections. The linked unchanged line stays hidden. Expected: Once the connection returns, the Code tab finishes opening the line named in the link.

  1. Open a pull request diff link to an unchanged line between two changed sections.
  2. Interrupt the environment connection while the app loads the file contents.
  3. Allow the environment to reconnect.
  4. Inspect where the Code tab lands.

The cause is at apps/web/src/components/diffs/useCodeViewFileReveal.ts:109. Ran pnpm scenarios:prove scripts/scenarios/pull-request-line-link-finishes-after-reconnect.e2e.ts --target web with the repro scenario added: it failed in 2 of 2 runs on a clean boat.dev VM, with expect.poll(...).toBe(...) timed out after 15000 ms in the output.

Evidence

Environment: The web app in Chromium on Linux x64, a fresh checkout on a boat.dev VM reset before each run.

Proven: the repro fails at the test commit c6be13d630 and passes on the head 10d39092a6, both on main 57fbce7570.

Before After
Commit c6be13d630 10d39092a6
Result ASSERTION_FAILED: expect.poll(...).toBe(...) timed out after 15000 ms passed
linked line after reconnect Before: linked line after reconnect Before: linked line after reconnect (changed region)
The Code tab shows the file's changed sections. The linked unchanged line stays hidden.
After: linked line after reconnect After: linked line after reconnect (changed region)
Once the connection returns, the Code tab finishes opening the line named in the link.
failure Before: failure
Recording Before: recording After: recording

Tests

  • c6be13d630 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed 57fbce757003664b11548a7fa794741d3384a602 passed on head.

Not in this change

  • The working-tree diff panel's file contents read still fails for good when the connection drops; it only reveals whole files, so links are not affected.
  • A read still waiting for a replacement session keeps running after the Code tab closes, until the environment reconnects, goes idle or is blocked, as message dispatch does.
  • Other pull request reads sent as commands still fail on a dropped connection without resending.
  • The scenario's linked line may already be visible at the file's first scroll position on a tall viewport, so it does not by itself prove the viewer scrolled to the line.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol and Claude Opus 5.5

StiensWout and others added 11 commits December 2, 2026 18:03
…eturns

The reveal-side retry raced the reconnect and re-asked in a loop while offline, so it is replaced: the
pull request file loader now waits for the environment to reconnect and reads again once.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…d connection

The read waits for the replacement session the same way message dispatch does, and gives up
when the environment stops reconnecting, instead of judging the connection in the web client.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Dec 2, 2026
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Diff-file reads now use the existing retry behavior after socket loss. A unit test checks retry after session replacement. An end-to-end scenario checks that a pull-request line link remains visible after reconnection.

Changes: Pull request diff reconnect

Layer / File(s) Summary
Retry diff-file reads after socket loss
packages/client-runtime/src/operations/commands.ts, packages/client-runtime/src/state/pullRequests.ts, packages/client-runtime/src/state/pullRequests.test.ts
diffFileContents now uses the exported resendAfterSocketLoss helper. A unit test checks that a socket-closed error after session replacement returns the replacement attempt’s result and calls the client twice.
Verify line visibility after reconnection
scripts/scenarios/pull-request-line-link-finishes-after-reconnect.e2e.ts
The scenario interrupts the first diff request, waits for reconnection and patch reload, then verifies that “Note 30” is visible in the diff viewport.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant DiffFileContents
  participant Client
  participant SupervisorSession
  DiffFileContents->>Client: Send diff-file request
  Client->>SupervisorSession: Request fails after socket loss
  SupervisorSession->>Client: Make replacement session available
  DiffFileContents->>Client: Retry diff-file request
Loading

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 1d049

Pull request diff file reads now resend after a lost connection, so a linked line can open after a failed load. No merge-blocking risk was found; the change is small and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: a pull request line link now opens its line after a failed file load. The raw summary shows diffFileContents now wraps its request with resendAfterSocketLoss, which res…
Description check Passed The description covers the problem, the change, the scope, and the verification, and it follows the template headings. It links related issues and gives a before/after reproduction with commit referen…
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 change: a pull request line link now opens its line after a failed file load. The raw summary shows diffFileContents now wraps its request with resendAfterSocketLoss, which resends after a lost connection. The title covers the main fix, but it names the symptom and not the mechanism. It also uses the fix(web): conventional commit form the template asks for.

Full details: Description check

Explanation

The description covers the problem, the change, the scope, and the verification, and it follows the template headings. It links related issues and gives a before/after reproduction with commit references and screenshots, plus recordings. It also lists what the change does not address. The description is detailed, and the Scope section does not link a specific issue that shows the bug. It cites related numbers (#46406, #31166, etc.) without saying how each relates. The verification relies on a scenario run and one check command, which the template allows.

Finishing Touches

Generate unit tests (beta)

  • 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 0de94d5 and 1d04945.

Files selected for processing: 1

  • packages/client-runtime/src/state/pullRequests.test.ts

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

}),
);

it.effect.each(["lost", "refused"] as const)(

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.

The refused case repeats the shared retry helper's non-transport failure test and also passes without the new retry wiring. Could you remove this case and keep only the lost-connection race?

Posted via Macroscope — Test Signal

@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 1d04945

Macroscope's review found this PR approvable — Pull-request file-content reads now reuse bounded socket-loss recovery so interrupted loads can recover for line links. Existing routing and request deduplication remain unchanged, with no new writes or product defaults.

Notes:

  • All code in this push has already been reviewed. Approvability was decided on eligibility alone.

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 2, 2026
juliusmarminge and others added 2 commits December 2, 2026 19:11
The refused case passes without the new resend wiring and repeats the
shared helper's own coverage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Environment: Linux web client, Chromium, 1280 × 800, dark theme, fresh isolated state on each commit, real GitHub data.

On each commit, seed a fresh project with the real GitHub repository remote. Open the real PR #47643 Code tab at packages/client-runtime/src/state/pullRequests.ts line 700 using selectedUrl and GitHub's SHA-256 path anchor. Confirm the uninterrupted control reveals line 700. Reload at /, patch WebSocket.prototype.send to close the first pullRequests.diffFileContents socket without sending its request, then navigate in-app to the same link with history.pushState and popstate. Wait 40 seconds, confirm a new open socket sent commands, capture the viewer, and check line 700 is rendered within the diff surface and viewport.

Scenario: A real GitHub PR line link reveals line 700 after a lost full-file read

Proven: the scenario fails on base 9b419ae7f4 and passes on head 1d04945e14.

Base 9b419ae7f4 Head 1d04945e14
Result ❌ failed
ASSERTION_FAILED: expect.poll(...).toBe(...) timed out after 15000 ms
last: expected false to be true
✅ passed
control no interruption Base 9b419ae7f4: control no interruption Head 1d04945e14: control no interruption
linked line after reconnect Base 9b419ae7f4: linked line after reconnect Head 1d04945e14: linked line after reconnect
failure Base 9b419ae7f4: failure
Recording Before After
Same scripted interaction Base recording Head recording

Scenario driver

Observed: base retains changed hunks with 1,328 unmodified lines collapsed after reconnect; head reveals and highlights line 700 at approximately 514 px in the 800 px viewport.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 2, 2026
@juliusmarminge
juliusmarminge merged commit 93f2c51 into pingdotgg:main Dec 2, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 2, 2026
@StiensWout
StiensWout deleted the wf/find-7888f1ff26e119cc0d0e59b9 branch December 3, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants