Skip to content

fix(web): jump to the requested line when it arrives in a large file - #45441

Merged
juliusmarminge merged 4 commits into
pingdotgg:mainfrom
only21mil:fix/web-large-file-preview-jump-past-first-chunk
Nov 29, 2026
Merged

juliusmarminge merged 4 commits into
pingdotgg:mainfrom
only21mil:fix/web-large-file-preview-jump-past-first-chunk

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

Jumping to a line past the first 1 MB of a large text file (1–64 MB) via Project Content Search or a file:line link scrolls to the end of the 1 MB preview and stays there after the full file loads. FullTextPreview renders the partial preview while useFileLineReveal clamps the target and marks the request handled early.

Change

  • In apps/web/src/components/files/LargeFilePreview.tsx, pass file.done to the reveal hook via onPostRender?.(file.done), so scroll persistence and request cancellation stay active during download.
  • In apps/web/src/components/files/FilePreviewPanel.tsx, replace clampFileLine with resolveRevealLine(contents, line, complete) and pass complete through fileLineReveal("codeView", complete): targets past an incomplete preview resolve to null (ignoring trailing \n/\r\n/\r), clear stale highlights, cancel superseded reveals, and defer without marking handledRequestId until the target line arrives or complete is true.
  • Add one browser test in apps/web/src/components/files/FilePreviewPanel.browser.test.tsx covering download scroll persistence, in-preview reveal, request replacement, and deferred reveal.

Scope

Small bug fix for wrong scroll target on 1–64 MB source previews (no issue). Covers web and Electron desktop; mobile has no large-file line reveal.

Verification

  1. Add README.md (# Demo) and a 9.6 MB big9.log (150,000 64-byte lines, NEEDLE_LINE_140000 on line 140,000).
  2. Open README.md (Ctrl+Shift+F → Demo → Enter) to start the diff worker pool.
  3. Open big9.log:140000 (NEEDLE_LINE_140000): d962b44fd353 stays at lines 16,380–16,391; 7db02642f46c centers line 140,000.

Setup. Ubuntu 26.04 (Linux x86_64), light theme, 1280x800, same big9.log fixture with isolated state per commit (Browser panel; hostname "Test machine").

Before (d962b44fd353) After (7db02642f46c)
Viewport stuck at lines 16380 to 16391 after full download of big9.log
Viewport stuck at lines 16380 to 16391 after full download of big9.log
Viewport centered and highlighted on line 140000 NEEDLE_LINE_140000 in big9.log
Viewport centered and highlighted on line 140000 NEEDLE_LINE_140000 in big9.log

Not shown. Electron shell, macOS/Windows (shared web preview), mobile (no large-file line reveal), and repo-wide CI (vp run check:changed and apps/web/src/components/files passed).

Automated test and check output (verified by AI agent)
  • Base d962b44fd353 fail-first (5/5):
FAIL  |@t3tools/web (browser) (chromium)| src/components/files/FilePreviewPanel.browser.test.tsx > source file scroll > defers large-file line reveals past the preview without blocking in-preview reveals or scroll persistence
AssertionError: expected <div data-line-type="context" …(3)>…(1)</div> to be null
 ❯ src/components/files/FilePreviewPanel.browser.test.tsx:648:9
  • Head 6acf3525df51 (test-only on 7db02642f46c; byte-identical prod files): single test 1 passed | 56 skipped (57) (235ms); apps/web/src/components/files 41/41 files, 561/561 tests (64.76s).
  • vp run check:changed d962b44fd353: pass (format, lint, knip, typecheck, test 163/163, react compiler).
  • Live jumps (7db02642f46c, where after.png was captured; byte-identical prod files to 6acf3525df51): event=050000 → lines 49,994–50,006; event=000050 → lines 44–56.
  • git merge-tree --write-tree d962b44fd353 6acf3525df51: exit 0 (66094ccc4291d9756765d95691a7e630e59dc8e1).

Generated with Gemini 4 Neon in T3 Code Nightly

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 29, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 6acf352

Macroscope's review found this PR approvable — Large-file previews now wait for the requested line to arrive before scrolling to it, while retaining end-of-file clamping after loading finishes. The change is limited to preview navigation and does not alter file contents or product defaults.

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

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Large-file previews now pass file completion state to line reveal handling. Requests for lines beyond the loaded content remain unresolved until more content arrives or loading completes. A browser test checks reveals before and after the full-file response.

Changes: Deferred line reveals

Layer / File(s) Summary
Completion-aware line reveal
apps/web/src/components/files/LargeFilePreview.tsx, apps/web/src/components/files/FilePreviewPanel.tsx, apps/web/src/components/files/FilePreviewPanel.browser.test.tsx
LargeFilePreview passes file completion state to the post-render handler. Reveal logic waits when incomplete content does not contain the requested line. The browser test checks a reveal in loaded content, clears the previous reveal when the requested line changes, and checks the new reveal after the full-file response.

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

Change: Bug fix

Suggested reviewers: brandon-julio-t, juliusmarminge

Merge Risk: Minimal · up to 68e1b

This change makes jumps to lines beyond a large file's initial preview wait for the line to load instead of stopping early. No concrete merge-blocking risk was identified. Electron and desktop-OS behavior were not shown by the author.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: jumping to a requested line in a large file once the content arrives. It follows the conventional commit format. The PR objectives describe the same fix, so the title …
Description check Passed The description follows the template sections (Problem, Change, Scope, Verification). The Problem and Change sections clearly explain the bug and the fix. Scope names a small bug fix and says why no i…
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: jumping to a requested line in a large file once the content arrives. It follows the conventional commit format. The PR objectives describe the same fix, so the title matches the changeset.

Full details: Description check

Explanation

The description follows the template sections (Problem, Change, Scope, Verification). The Problem and Change sections clearly explain the bug and the fix. Scope names a small bug fix and says why no issue is linked. Verification gives concrete before/after evidence, a fail-first test result, and the checks run. The description also covers the UI screenshots the template asks for. It does not include the template's HTML comment prompts, which is expected. Two gaps remain: the Scope section does not link an issue, and the Verification section gives a commit hash for a 'd962b44fd353' base that points to a different repository owner than the PR. Both are minor and do not block the check.

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 6acf352 and 68e1b44.

Files selected for processing: 2

  • apps/web/src/components/files/FilePreviewPanel.browser.test.tsx
  • apps/web/src/components/files/FilePreviewPanel.tsx

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 29, 2026
juliusmarminge and others added 2 commits November 29, 2026 10:27
Drop the scroll-restoration steps the change does not touch, and give
resolveRevealLine one null path and a comment for the trailing-line-break rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Nov 29, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Environment: Chromium web client, 1280×800, light theme, fresh isolated state on each commit.

On each commit, seed a fresh demo project with README.md containing Demo and a 9,600,000-byte big9.log (150,000 lines, NEEDLE_LINE_140000 on line 140,000), and a replay thread. Open the thread, use Ctrl+Shift+F to search Demo and open README.md to initialize the diff workers. Maximize the file panel, disable word wrap, and hide the file explorer for legible captures. Deliver the real big9.log HTTP response body at 500 KiB/s using a browser fetch stream wrapper, search NEEDLE_LINE_140000, and press Enter. Capture during download, await response EOF, then check the requested row is centered and has the file-link highlight; capture the final viewport. Repeat the identical scenario on base and head.

Scenario: A search result beyond the preview is centered when its file arrives

Proven: the scenario fails on base 54a42b22f4 and passes on head 68e1b44211.

Base 54a42b22f4 Head 68e1b44211
Result ❌ failed
ASSERTION_FAILED: expect.poll(...).toBe(...) timed out after 15000 ms
last: expected false to be true
✅ passed
requested line during download Base 54a42b22f4: requested line during download Head 68e1b44211: requested line during download
requested line after download Base 54a42b22f4: requested line after download Head 68e1b44211: requested line after download
failure Base 54a42b22f4: failure
Recording Before recording After recording

Scenario and synthetic seed.

Observed: base remains at rows 16,351–16,385 after EOF; head centers and highlights NEEDLE_LINE_140000 at line 140,000.

Not shown:

  • The direct big9.log:140000 link variant was not exercised; this proof uses the reported Project Content Search entry path.

@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 Nov 29, 2026
@juliusmarminge
juliusmarminge merged commit 29ce132 into pingdotgg:main Nov 29, 2026
56 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants