fix(web): expanding hidden diff context works after a diff refresh#33629

merged1
t3code/pierre-diffs-1.7
t3code/pierre-diffs-expand-context
opened11d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 11d ago

Stacked on #33627.

Problem

In the Diff panel, the "N unmodified lines" expand control could do nothing. Each click fetched the file contents successfully, but no lines appeared, and the file stayed that way.

It happens after the panel re-fetches a diff that has not changed (it does that on show and on window focus) and the file's item then changes version, for example because you unfold it or add a comment. The refresh re-parses the patch into new objects with the same cacheKey. Pierre keeps rendering the object it already holds, but applied loaded file contents only if the item's object was that exact one. They no longer are, so the contents were discarded.

The Pierre code involved is the same in 1.6.1, so this is not from the upgrade. I did not run main to confirm it there.

Fix

One line in our @pierre/diffs patch: match pending file contents to the item by cacheKey instead of object identity. That is the rule Pierre already uses to decide an incoming diff is unchanged.

Evidence

codeViewContextExpansion.browser.test.ts re-supplies an unchanged partial diff as a new object and then expands. It failed before the patch line (expected [ 'line 1', 'changed 1', …(8) ] to include 'line 30') and passes with it. The same test without the re-supplied diff passed before the fix, so the failure was this case and not the harness.

In a dev instance (headless Chromium, replay provider): open the Diff panel, press Refresh, unfold src/alpha.ts, click expand. A trace on the patched line shows the mismatch that used to drop the contents, now applied:

1hydrate src/alpha.ts: sameObject=false itemIsInput=false appliedPartial=false key=…:compact-partial:hydrated

The file goes from 15 to 52 rendered lines and stays expanded through another Refresh.

After: src/alpha.ts with its hidden lines expanded after a diff refresh

vp run check:changed passes.

Claude Fable 5.2 in Claude Code, via T3 Code.

🤖 Generated with Claude Code

Fixes pingdotgg/t3code#27171

Checks

26 successful · 10 skipped
All checks passed
910d112

Added 1 commit

  • fix(web): expanding hidden diff context works after a diff refresh910d112
Synced from GitHub

Approvability

Verdict: Approved at 910d112

Macroscope's review found this PR approvable — Hidden diff context can expand after a refresh recreates an otherwise unchanged diff object. The change is limited to viewer state, with reported browser regression coverage and no persistent-data or permission changes.

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

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire—5.0 KiB—6.8 KiB✅
CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
CodexLive turn WebSocket decoded—21.5 KiB—24.4 KiB✅
CodexLive turn messages—1—8✅
ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
ClaudeLive turn WebSocket decoded—21.9 KiB—24.4 KiB✅
ClaudeLive turn messages—1—8✅

Baseline: unavailable · PR result: 910d112 · 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.

Synced from GitHub

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Pierre diff patch updates search-match revealing, collapsed diff rendering, hydration matching, selection clearing, file-header counts, and package exports. A browser test covers expanding hidden context after a refreshed partial diff.

Changes: Diff rendering and context expansion

Layer / File(s)Summary
Diff patch updates and refresh regression test
patches/@pierre__diffs@1.7.0-beta.3.patch, apps/web/src/components/diffs/codeViewContextExpansion.browser.test.ts
The patch adds search-match reveal handling, updates collapsed diff rendering and hydration matching, adjusts selection clearing and file-header counts, and adds package exports. The browser test checks that expanding hidden context shows the previously hidden line after the diff is supplied again as a newly parsed object.

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

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#27171 — The issue concerns hidden-line expansion, which this change tests after a diff refresh.

Possibly related PRs

Suggested labels: bugfix, size:S

Suggested reviewers: t3dotgg

Merge Risk: External image Minimal · up to 910d1

The diff-context expansion fix is mergeable after normal checks; no concrete blocking risk remains.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the main change: hidden diff context now expands after a diff refresh.
Description checkPassedThe description explains the problem, the cacheKey-based fix, and focused test and manual verification results. It also links the issue. The required “Scope and approval” heading is missing, but the d…
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, the cacheKey-based fix, and focused test and manual verification results. It also links the issue. The required “Scope and approval” heading is missing, but the description is otherwise mostly complete.

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
External image Recent review info

External image Run configuration

External image Commits

Reviewing files that changed from the base of the PR and between 605508f78057836da4803ebd87004919b6e1b794 and 910d112a524898683210481483abbda707534a08.

External image Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
External image Files selected for processing: 2

  • apps/web/src/components/diffs/codeViewContextExpansion.browser.test.ts
  • patches/@pierre__diffs@1.7.0-beta.3.patch

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