Skip to content

fix: 修复 DOM 终端缩放后宽度恢复#280

Open
wosuxiongmao wants to merge 2 commits into
DeadWaveWave:mainfrom
wosuxiongmao:fix/terminal-dom-resize-width
Open

fix: 修复 DOM 终端缩放后宽度恢复#280
wosuxiongmao wants to merge 2 commits into
DeadWaveWave:mainfrom
wosuxiongmao:fix/terminal-dom-resize-width

Conversation

@wosuxiongmao

@wosuxiongmao wosuxiongmao commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Change Scope

  • Small Change: Fast feedback, localized UI/logic, low-risk.
  • Large Change: Runtime-risk terminal renderer geometry/recovery behavior.

What Does This PR Do?

Fixes DOM terminal width recovery after resize/zoom while keeping PTY geometry ownership separate from renderer-local visual refresh.

  • Keeps the DOM renderer measured-geometry calibration that prevents right-edge text overflow.
  • Refreshes DOM renderer visual footprint after output/zoom without committing PTY geometry from renderer-only paths.
  • Guards viewport zoom refresh so the initial mount does not force a local terminal fit/resize; real viewport zoom changes still force a renderer refresh.
  • Makes the DOM right-edge E2E deterministic for the DOM renderer and robust against row selection/metric timing.
  • Updates the delayed xterm reply recovery E2E to assert against the xterm transcript reader instead of DOM text, so it remains valid under canvas/WebGL rendering.

Large Change Spec

1. Reference / Practice

Terminal geometry has two separate owners: PTY size is durable/runtime state, while renderer dimensions are visual state. The fix keeps those paths separate: visual refresh may repaint or sync DOM renderer dimensions, but PTY resize remains owned by explicit geometry commit paths.

2. Business Logic & Acceptance Criteria

  • DOM terminal output stays away from the right clipping edge across canvas zoom.
  • Initial terminal mount does not perform a forced local fit that can diverge from canonical PTY geometry.
  • Actual viewport zoom changes still refresh terminal visuals.
  • Restored agent terminals do not show delayed DSR replies like ^[[1;1R as visible output.

3. State Owners, Invariants, Risks

  • PTY geometry is owned by terminal geometry commit/sync paths.
  • Renderer-local refresh may call xterm refresh/DOM sync, but must not become the durable PTY authority.
  • Viewport zoom state is owned by the canvas/effective DPR path; the terminal hook only reacts to real zoom changes.
  • Main risk is regressions in terminal restore, zoom, DOM renderer clipping, and transcript-based E2E assertions.

4. Verification

  • pnpm test -- --run tests/unit/contexts/terminalNode.appearance-sync.spec.tsx tests/unit/terminalNode/terminalGeometrySync.spec.ts tests/unit/terminalNode/terminalDomRendererGeometrySync.spec.ts tests/unit/terminalNode/terminalGeometrySync.domVisual.spec.ts tests/unit/terminalNode/terminalGeometrySync.initialGeometry.spec.ts tests/unit/terminalNode/terminalGeometrySync.domFit.spec.ts
  • pnpm check
  • pnpm test:e2e tests/e2e/recovery.agent-terminal-replies.spec.ts --project electron --reporter=line
  • pnpm test:e2e tests/e2e/workspace-canvas.terminal-dom-right-edge.spec.ts --project electron --reporter=line
  • pnpm line-check:staged
  • pnpm pre-commit passed. Full E2E reported 9 first-run flaky timeouts, all passed on retry.

Delivery & Compliance Checklist

  • pnpm pre-commit passed.
  • I have signed the CLA if required (see CLA.md).
  • I have included tests to lock down the behavior.
  • I have adhered to DEVELOPMENT.md architectural boundaries.
  • I have attached a screenshot or screen recording (if this touches the UI).
  • I have updated documentation/PR notes where behavior or verification changed.

Screenshots / Visual Evidence

No screenshot attached. Covered by automated E2E: workspace-canvas.terminal-dom-right-edge.spec.ts and recovery.agent-terminal-replies.spec.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants