opencove
opencove copied to clipboard
fix: 修复 DOM 终端缩放后宽度恢复
Change Scope
- [ ] Small Change: Fast feedback, localized UI/logic, low-risk.
- [x] 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;1Ras 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.tspnpm checkpnpm test:e2e tests/e2e/recovery.agent-terminal-replies.spec.ts --project electron --reporter=linepnpm test:e2e tests/e2e/workspace-canvas.terminal-dom-right-edge.spec.ts --project electron --reporter=linepnpm line-check:stagedpnpm pre-commitpassed. Full E2E reported 9 first-run flaky timeouts, all passed on retry.
Delivery & Compliance Checklist
- [x]
pnpm pre-commitpassed. - [ ] I have signed the CLA if required (see
CLA.md). - [x] I have included tests to lock down the behavior.
- [x] I have adhered to
DEVELOPMENT.mdarchitectural boundaries. - [ ] I have attached a screenshot or screen recording (if this touches the UI).
- [x] 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.