fix(web): expanding hidden diff context works after a diff refresh#33629
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:
| 1 | hydrate 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
Added 1 commit
- fix(web): expanding hidden diff context works after a diff refresh910d112
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.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
ℹ️ No successful
mainbaseline artifact is available yet. This run establishes the initial measurement.
| Provider | Metric | Main baseline | This PR | Impact | PR ceiling | |
|---|---|---|---|---|---|---|
| Codex | Total thread wire | — | 5.0 KiB | — | 6.8 KiB | ✅ |
| Codex | Thread snapshot wire | — | 3.8 KiB | — | 4.9 KiB | ✅ |
| Codex | Live turn WebSocket wire | — | 1.2 KiB | — | 2.0 KiB | ✅ |
| Codex | Live turn WebSocket decoded | — | 21.5 KiB | — | 24.4 KiB | ✅ |
| Codex | Live turn messages | — | 1 | — | 8 | ✅ |
| Claude | Total thread wire | — | 5.0 KiB | — | 6.8 KiB | ✅ |
| Claude | Thread snapshot wire | — | 3.8 KiB | — | 4.9 KiB | ✅ |
| Claude | Live turn WebSocket wire | — | 1.2 KiB | — | 2.0 KiB | ✅ |
| Claude | Live turn WebSocket decoded | — | 21.9 KiB | — | 24.4 KiB | ✅ |
| Claude | Live 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.
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.tsThe 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
- pingdotgg/t3code#33627 — Changes diff hydration matching for equal targets and the same refresh path.
- pingdotgg/t3code#28917 — Covers context expansion after an equivalent partial diff is refreshed.
- pingdotgg/t3code#27131 — Shares the selection-clearing behavior included in this patch.
Suggested labels:
bugfix,size:SSuggested 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 name Status Explanation Title check Passed The title clearly and concisely describes the main change: hidden diff context now expands after a diff refresh. Description check Passed 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 d… 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: 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
-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: t3code/pierre-diffs-expand-context
- File: .coderabbit.config.ts
- Commit: 910d112
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
72c52149-2835-4451-b066-ce754fc9e3b5
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.tspatches/@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.
External image Recent review info
-
External image Run configuration
-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: t3code/pierre-diffs-expand-context
- File: .coderabbit.config.ts
- Commit: 910d112
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
72c52149-2835-4451-b066-ce754fc9e3b5
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.yamlis excluded by!**/pnpm-lock.yaml
External image Files selected for processing: 2
-
apps/web/src/components/diffs/codeViewContextExpansion.browser.test.tspatches/@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.
-