Repository navigation
cleanup(terminal): dedupe pane teardown, reuse platform check, harden shadow-cursor tracking - #7320
Conversation
… shadow-cursor tracking Quality pass on terminal PRs merged 2026-07-03: - pane-split-close: extract a shared `teardownManagedPane` so `closeManagedPane` and `detachManagedPaneForExternalMove` can't drift apart on future edits (#7215). - terminal-link-activation: reuse the existing `isMacPlatform()` instead of a second inline `navigator.userAgent` copy, keeping one source of truth for Mac detection. - pty-connection: gate the shadow-cursor moves on empty CSI params so parameterized/ modified cursor keys (e.g. Ctrl+Left word-jump, `ESC[1;5D`) reset command tracking instead of silently desyncing the buffer used to infer a typed agent name; relocate the `getAuthoritativePaneAgent` JSDoc to the function it documents (#6954). No behavior change except the cursor-tracking hardening; all touched unit suites pass.
📝 WalkthroughWalkthroughThis PR modifies three unrelated areas. In pty-connection.ts, CSI cursor-sequence handling during typed-command sampling now only emulates shadow cursor movement for unparameterized left/right moves, falling back to resetting tracking for parameterized sequences; documentation comments about authoritative pane agent resolution were relocated and reworded. In terminal-link-activation.ts, macOS detection now uses isMacPlatform() instead of user-agent string matching. In pane-split-close.ts, a new internal helper teardownManagedPane(args, reason) centralizes pane-removal logic previously duplicated between closeManagedPane and detachManagedPaneForExternalMove, which now delegate to it with 'close' or 'detach' reasons respectively. Sequence Diagram(s)sequenceDiagram
participant closeManagedPane
participant detachManagedPaneForExternalMove
participant teardownManagedPane
closeManagedPane->>teardownManagedPane: teardownManagedPane(args, 'close')
detachManagedPaneForExternalMove->>teardownManagedPane: teardownManagedPane(args, 'detach')
teardownManagedPane->>teardownManagedPane: release identity, remove container, activate replacement pane
teardownManagedPane->>teardownManagedPane: reapply opacity, safeFit, update drag state
teardownManagedPane->>teardownManagedPane: onPaneClosed(reason), onLayoutChanged()
Estimated code review effort: 3 (out of 5) — Medium Related issues: None found. Related PRs: None found. Suggested labels: refactor, bug-fix, terminal, pane-manager Suggested reviewers: None specified. Poem: 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/pty-connection.ts (1)
1800-1803: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider reusing
isMacPlatform()here too.This unchanged line still checks
navigator.userAgent.includes('Mac')directly, while the sibling PR in this stack (terminal-link-activation.ts) replaces the same pattern with the sharedisMacPlatform()helper. Since this file is already being touched in this cohort, consolidating here would avoid a second source of truth for Mac detection.♻️ Proposed fix
+import { isMacPlatform } from './terminal-link-open-hints' ... - if (!navigator.userAgent.includes('Mac') && pane.terminal.hasSelection()) { + if (!isMacPlatform() && pane.terminal.hasSelection()) {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4062b172-cacb-42be-b6f3-2add3cdc69e4
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/terminal-link-activation.tssrc/renderer/src/lib/pane-manager/pane-split-close.ts
… shadow-cursor tracking (stablyai#7320) Quality pass on terminal PRs merged 2026-07-03: - pane-split-close: extract a shared `teardownManagedPane` so `closeManagedPane` and `detachManagedPaneForExternalMove` can't drift apart on future edits (stablyai#7215). - terminal-link-activation: reuse the existing `isMacPlatform()` instead of a second inline `navigator.userAgent` copy, keeping one source of truth for Mac detection. - pty-connection: gate the shadow-cursor moves on empty CSI params so parameterized/ modified cursor keys (e.g. Ctrl+Left word-jump, `ESC[1;5D`) reset command tracking instead of silently desyncing the buffer used to infer a typed agent name; relocate the `getAuthoritativePaneAgent` JSDoc to the function it documents (stablyai#6954). No behavior change except the cursor-tracking hardening; all touched unit suites pass.
Cleanup pass — terminal (1 of 3)
Code-quality follow-ups on terminal PRs merged 2026-07-03. Surfaced by an automated multi-agent review of the day's merges; every finding was adversarially verified before fixing. Priority order: elegant → performant → clean → functional (plus real bugs).
teardownManagedPanesocloseManagedPane/detachManagedPaneForExternalMovecan't driftisMacPlatform()instead of a second inlinenavigator.userAgentcopygetAuthoritativePaneAgentJSDoc back onto the function it documents (~215 lines away)The one behavior change
consumeShellCommandCsiSequencetreated anyESC[…D/ESC[…Cas a ±1 shadow-cursor move, ignoring the CSI params. A modified cursor key such as Ctrl+Left (ESC[1;5D, word-jump in readline/zsh) moves the real cursor by a whole word, so the shadow line desynced and a subsequent edit landed at the wrong offset — garbling the command line sampled to infer a manually typed agent name (omp). Parameterized sequences now fall through to the existing reset path (a safe miss), consistent with how app-mode arrow keys already reset tracking.Verification
pnpm run typecheck·oxlint·oxfmt· unit suites forpane-split-close,pty-connection,terminal-link-handlers— all green.🤖 Generated with Claude Code
Made with Orca 🐋