Skip to content

fix(terminal): keep resizing after initial connection failure - #285

Merged
shihuili1218 merged 1 commit into
mainfrom
fix/terminal-resize-after-connect-failure
Sep 24, 2026
Merged

shihuili1218 merged 1 commit into
mainfrom
fix/terminal-resize-after-connect-failure

Conversation

@shihuili1218

Copy link
Copy Markdown
Collaborator

Terminal panes can stop resizing after an initial connection fails or is cancelled. The resize observer was registered only after the first successful connection; an early return skipped registration, and reconnecting never installed it.

Register the observer immediately after opening and fitting xterm, before asynchronous setup. Keep the existing zero-size guard and observer cleanup on pane destruction.

Desktop GUI, mobile GUI, and the shared Headless/JetBrains frontend use this fix. CLI: not applicable (terminal-pane UI only).

Validation:

  • npm test: 780 tests passed.
  • npm run build: passed.
  • cargo fmt --manifest-path src-tauri/Cargo.toml --check: passed.
  • cargo test --locked --offline --manifest-path src-tauri/Cargo.toml: 744 tests passed; one documentation test ignored.
  • git diff --check: passed.

The pre-fix failure was reproduced: the pane width changed from 862 to 931 while xterm stayed at 978, and the heap snapshot confirmed the active pane had no ResizeObserver. Post-fix GUI acceptance is still pending: resize during an initial connection failure, retry and disconnect, hide/show the tab, and close the pane. Existing automated tests do not directly exercise this component lifecycle.

@shihuili1218
shihuili1218 marked this pull request as ready for review September 24, 2026 05:50
Copilot AI lite review requested due to automatic review settings September 24, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Add lifecycle test coverage or complete the stated GUI acceptance before merging.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes terminal pane resizing after an initial connection failure or cancellation.

Changes:

  • Registers ResizeObserver before asynchronous connection setup.
  • Preserves zero-size protection and cleanup on pane destruction.
File Summary
src/​lib/​components/​TerminalPane.svelte Ensures resize handling persists throughout the pane lifecycle.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1621 to +1625
resizeObs = new ResizeObserver((entries) => {
// Skip fitting when the container is hidden (display:none
// collapses dimensions to zero) — fitting at 0×0 corrupts
// xterm's column count and causes the narrow-tab bug.
const { width, height } = entries[0].contentRect;
@shihuili1218
shihuili1218 merged commit 49a126f into main Sep 24, 2026
2 checks passed
@shihuili1218
shihuili1218 deleted the fix/terminal-resize-after-connect-failure branch September 24, 2026 06:40
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