Skip to content

cleanup(terminal): dedupe pane teardown, reuse platform check, harden shadow-cursor tracking - #7320

Merged
nwparker merged 1 commit into
mainfrom
nwparker/cleanup-terminal
Jul 4, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/cleanup-terminal

Conversation

@nwparker

@nwparker nwparker commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

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).

Fix Kind Origin PR
Extract shared teardownManagedPane so closeManagedPane/detachManagedPaneForExternalMove can't drift elegance #7215
Reuse the existing isMacPlatform() instead of a second inline navigator.userAgent copy clean terminal URL modifier-click restore
Gate shadow-cursor CSI moves on empty params so modified cursor keys reset tracking instead of desyncing bug (robustness) #6954
Move the getAuthoritativePaneAgent JSDoc back onto the function it documents (~215 lines away) comment #6954

The one behavior change

consumeShellCommandCsiSequence treated any ESC[…D / ESC[…C as 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 for pane-split-close, pty-connection, terminal-link-handlers — all green.

🤖 Generated with Claude Code

Made with Orca 🐋

… 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.
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This 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()
Loading

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:
A rabbit typed a command with care,
The cursor hopped with params rare,
Now macOS taps its own true key,
And panes tear down more tidily,
Hop, refactor, ship with glee!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description misses required template sections for screenshots, testing, AI review, security audit, and notes. Add the missing sections and complete the testing checklist, AI review report, security audit, screenshots, and notes.
Linked Issues check ⚠️ Warning The PR only changes terminal cleanup code and does not implement the repo filter dropdown 'Add repo' option in #39. Add the dropdown item at the bottom with a divider, wire it to addRepo(), and verify folder-picker behavior and normal filter selection.
Out of Scope Changes check ⚠️ Warning All code changes are terminal cleanup work and are unrelated to the linked #39 repo filter dropdown feature. Move these terminal cleanup changes to a separate PR or retarget the PR to the linked dropdown feature.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the terminal cleanup changes in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/pty-connection.ts (1)

1800-1803: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider 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 shared isMacPlatform() 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

📥 Commits

Reviewing files that changed from the base of the PR and between 22d5989 and e8f966c.

📒 Files selected for processing (3)
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/terminal-link-activation.ts
  • src/renderer/src/lib/pane-manager/pane-split-close.ts

@nwparker
nwparker merged commit 529c06f into main Jul 4, 2026
5 of 7 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… 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.
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.

1 participant