Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): retain wrapped row heights during edits #10018

Mergedjuliusmarmingemerged 12 commits intomain fromrefs/pull/10018/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Adding a line near EOF in a large wrapped file discards measured heights for unchanged rows. The file shrinks to single-row estimates and the viewport jumps away from the caret.

Retain measurements before the first changed line. Invalidate changed/shifted rows, use the existing full reset across line-number digit boundaries, and clear old-width measurements during height reconciliation. The existing ResizeManager schedules that work; this adds no observer or synchronous geometry read to the edit callback. Other explicit layout, metric and annotation resets remain intact.

Related to #7907; keep it open for the remaining caret behavior. The highlight and grammar errors were repaired separately in #9902 and #9947.

Verification

  • 55 focused tests pass, including real Editor/VirtualizedFile/ResizeManager behavior with controlled measurements and render-queue drains. The final width regressions fail nine assertions before the repair and pass afterward.
  • Seven additional full-reset controls, Enter/undo/redo history receipts, targeted lint and web typecheck pass. FilePreviewPanel retains one unrelated pre-existing effect-dependency lint warning.
  • Linux Chromium 152, identical synthetic 8,255-line files, 283px editor, 13px font: cold Enter moves scrollTop 177428 → 16088 before, versus 177428 → 177440 after with the new EOF caret visible. Both insert line 8,256; later native edit/reopen controls also verify disk persistence. Ordinary Undo passes.
  • Native explorer resize 283px ↔ 539px and line-count changes 9,999 ↔ 10,000 discard obsolete prefix measurements in both directions. Normal Settings → Appearance destroys the old editor/cache; changing code font to 14px creates a fresh instance, then restoring 13px works.

The baseline was recorded on main with the merged highlight/grammar repairs. Subsequent main changes through f87ecf0c leave this TSX editing path unchanged. The after capture uses 6df6b169. Both clips preserve native speed, with Enter near seven seconds.

Before

Before: Enter jumps from EOF to the region around line 476

Before recording, 12 seconds

After

After: Enter keeps the new line 8256 and caret visible

After recording, 12 seconds

Limits

This does not fix the existing Redo, resize or digit-boundary caret-scroll policy. Resize invalidation completes after observer delivery and the render drain, not synchronously before an earlier edit. Late in-place settings hydration remains unproven. The original CachyOS/Electron build was not exercised; web and desktop share this editor. Mobile and advanced CodeView editing have no changed T3 caller.

Prepared by GPT 6 Astra via Codex in T3 Code.

Note

Fix wrapped row height retention during edits in VirtualizedFile layout

  • Adds a deterministic test DOM geometry model, resize observer double, and render-frame drain utility so wrapped-layout behavior can be tested without a real browser layout engine
  • Covers insertion, deletion, multi-selection edits, undo/redo, annotation changes, metric changes, and width transitions against large wrapped and unwrapped files
  • Verifies that unchanged prefix measurements survive edits while changed, shifted, or width-affected rows are invalidated and recomputed
  • Tests gutter digit-width boundary crossings (4→5 and 5→4 digits) to confirm prefix measurements are cleared when line-number width changes but preserved when it does not
  • All changes are in fileEditorVirtualization.test.ts
Macroscope summarized 6df6b16.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.6 KiB13.6 KiB−14 B (−0.1%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB+3 B (+0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.6 KiB6.6 KiB−17 B (−0.3%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.1 KiB57.1 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages10100 (0.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.6 KiB−17 B (−0.1%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB+1 B (+0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB−18 B (−0.3%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.8 KiB57.8 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages990 (0.0%)21✅

      Baseline: 4e59b06 · PR result: 6df6b16 · 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: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

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

    3. Approvability

      Verdict: Approved at 6df6b16

      Macroscope's review found this PR approvable — This is a focused fix to row-height caching and resize reconciliation in the existing wrapped file editor, with no product-default, schema, security, or deployment changes. The production logic is narrowly scoped and backed by extensive regression coverage for edits, undo/redo, resizing, gutter-width boundaries, and cleanup.

      Notes:

      • No code objects were reviewed. Approvability was decided on eligibility alone.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge merged this6270a6f

    5. juliusmarminge closed this

Sign in to join this conversation.