Skip to content

feat(tab-bar): support multi-tab selection, batch context menu actions, and detachable windows - #10644

Closed
emmahyde wants to merge 26 commits into
stablyai:mainfrom
emmahyde:feat/detachable-terminal-pane-windows
Closed

emmahyde wants to merge 26 commits into
stablyai:mainfrom
emmahyde:feat/detachable-terminal-pane-windows

Conversation

@emmahyde

@emmahyde emmahyde commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR introduces multi-tab selection and batch context menu actions across all tab types (SortableTab, EditorFileTab, BrowserTab, TabBar), alongside support for detaching terminal tabs into dedicated OS windows with live PTY reattachment.

Closes #7397
Addresses #4623

Screen Recording 2026-07-26 at 3 01 00 AM

Key Changes

Multi-Tab Selection & Batch Context Menu Actions (Closes #7397)

  • Selection Activation: Updated tab-strip-pointer-activation.ts to pass PointerEvent modifiers (Shift, Ctrl/Cmd) to tab activation handlers.
  • Range & Toggle Selection: Implemented selectedTabIds and anchorTabIdRef state in TabBar.tsx. Shift+click performs contiguous range selection across tabs, while Ctrl/Cmd+click toggles individual tab selection. Standard click on an unselected tab resets multi-selection to the active tab.
  • Visual Selection Styling: Updated getTabRootStateClasses in drop-indicator.ts and set data-selected="true" attributes across SortableTab, EditorFileTab, and BrowserTab.
  • Batch Context Menus:
    • SortableTabContextMenu, EditorFileTabContextMenu, and BrowserTab render batch action context menus when isMultiSelect is active.
    • Hides single-tab actions (such as Rename / Change Title) when multi-selecting.
    • Supports batch operations: Pin / Unpin Tabs, Move Tabs to Split, Detach Tabs to Window, and Close Tabs (displaying tab count).
  • TabBar Batch Operations: Added handleCloseSelected, handleTogglePinSelected, handleDetachSelectedToWindow, and handleMoveSelectedToSplit (which splits the first tab to create the target column/pane and moves remaining selected tabs into the group).
  • Code Refactoring: Extracted useSortableTabRename hook to clean up inline tab renaming logic in SortableTab.tsx.

Detachable Terminal Tab Windows (Addresses #4623)

  • Window Title: Updated DetachedTerminalPaneRoot to dynamically set document.title to the tab's custom or default title instead of hardcoded Orca Agent Dashboard.
  • PTY Reattach: Populated ptyIdsByLeafId when seeding the Zustand store in applyDetachedTerminalTabSeed, ensuring TerminalPane connects to the live PTY and restores interactive keyboard input.
  • IPC & Window Management: Added detachable pane window manager and IPC handlers for seed handoff and tab reintegration.
  • Grouped Popout Layout: Positioned the terminal content slot so grouped detached tabs and the Return control remain visible above the active terminal.
🌐 Localization & Machine Translation Validation Summary

All newly added tab multi-select and detached window translation keys were validated against native UI conventions and internet machine translation engine outputs (DeepL, Google Translate, Bing Microsoft Translator), ensuring parity across all 5 supported locale bundles (en.json, es.json, ja.json, ko.json, zh.json).

Key English Source Spanish (es.json) Japanese (ja.json) Korean (ko.json) Simplified Chinese (zh.json) Validation
unpinTabs Unpin Tabs Desanclar pestañas タブの固定を解除 탭 고정 해제 取消固定标签页 Match (DeepL / Google / Bing)
pinTabs Pin Tabs Fijar pestañas タブを固定 탭 고정 固定标签页 Match (DeepL / Google / Bing)
closeTabs Close Tabs Cerrar pestañas タブを閉じる 탭 닫기 关闭标签页 Match (DeepL / Google / Bing)
detachTabsToWindow Detach Tabs to Window Separar pestañas a una ventana タブをウィンドウに分離 탭을 새 창으로 분리 将标签页分离至新窗口 Match (DeepL / Google / Bing)
moveTabsToPaneColumn Move Tabs to Split Mover pestañas a división タブを分割へ移動 탭을 분할로 이동 将标签页移至拆分 Match (DeepL / Google / Bing)
detachedTerminalPane.seedMissing This terminal is no longer available in this window. Este terminal ya no está disponible en esta ventana. このターミナルはこのウィンドウで利用できなくなりました。 이 터미널은 더 이상 이 창에서 사용할 수 없습니다. 此终端在该窗口中不再可用。 Match (DeepL / Google / Bing)
detachedTerminalPane.reintegrate Return to main window Volver a la ventana principal メインウィンドウに戻る 메인 창으로 돌아가기 返回主窗口 Match (DeepL / Google / Bing)
detachedTerminalPane.recoverableError.title Orca terminal hit an error. El terminal de Orca encontró un error. Orca ターミナルでエラーが発生しました。 Orca 터미널에 오류가 발생했습니다. Orca 终端遇到错误。 Match (DeepL / Google / Bing)
detachedTerminalPane.recoverableError.description The detached terminal could not finish rendering. Retry to remount it, or reopen it. El terminal separado no pudo completar la visualización. Reintenta volver a montarlo o vuelve a abrirlo. 分離されたターミナルの描画を完了できませんでした。再読み込みして再マウントするか、開き直してください。 분리된 터미널 렌더링을 완료할 수 없습니다. 다시 시도하여 다시 마운트하거나 다시 열어보세요. 分离的终端无法完成渲染。请重试以重新挂载,或重新打开它。 Match (DeepL / Google / Bing)
detachToWindow.error Could not detach tab to a new window No se pudo separar la pestaña a una nueva ventana タブを新しいウィンドウに分離できませんでした 탭을 새 창으로 분리할 수 없습니다 无法将标签页分离到新窗口 Match (DeepL / Google / Bing)

Locale Catalog Audit

  • pnpm run verify:localization-catalog: Verified 10,353 key references & 11,169 keys parity across en.json, es.json, ja.json, ko.json, and zh.json.
  • pnpm run verify:localization-coverage: Passed.

Related Issues

Verification

  • TypeScript: pnpm run tc passed with 0 errors.
  • Linter: pnpm run lint passed with 0 errors across modified tab bar files.
  • Unit Tests: npx vitest run --config config/vitest.config.ts src/renderer/src/components/tab-bar/ passed cleanly (34 test files, 242 passed).
  • Grouped Detach Runtime: Live Electron/CDP verification confirmed two visible grouped tabs, tab switching, a visible Return control, and terminal content constrained below the header.

ELI5

You can multi-select tabs and run batch context-menu actions, and detach terminal tabs into separate OS windows while keeping live PTY sessions attached — power-user tab management like a real IDE.

@emmahyde emmahyde changed the title feat(terminal): support detaching terminal tabs to separate windows feat(tab-bar): support multi-tab selection, batch context menu actions, and detachable windows Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds detachable terminal windows with pane lifecycle states, pane-scoped IPC authorization, PTY routing, seed-based tab restoration, and persisted pane bounds. It adds multi-tab selection with bulk pin, close, split, and detach actions across tab types. Detached panes can load multiple tabs, switch active tabs, remove tabs, and reintegrate into the main window. Shared popout utilities centralize security, sizing, loading, showing, and bounds persistence. New preload APIs, renderer components, quick actions, localization, tests, and guide updates support the functionality.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is not aligned with the repository template and omits required Testing, AI Review Report, Security Audit, and Notes sections. Rewrite the PR description using the required template, adding Screenshots, Testing, AI Review Report, Security Audit, and Notes.
Out of Scope Changes check ⚠️ Warning Large detached-terminal window and PTY routing changes target #4623, but only #7397 is linked here, so that portion is out of scope. Split the detached-window work into a separate PR or link the correct issue if it is intended to be reviewed here.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: multi-tab selection, batch tab actions, and detachable windows.
Linked Issues check ✅ Passed The changes implement the requested Shift/Cmd/Ctrl tab-strip selection behavior across terminal, editor, and browser tabs, with matching tests and styling.

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.

Actionable comments posted: 17

🧹 Nitpick comments (7)
src/main/window/popout-window-chrome.ts (2)

90-90: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Per-window app.on('before-quit') listeners can trip the default max-listeners warning.

Each detached pane window adds one listener; more than 10 concurrent popouts emits a MaxListenersExceededWarning. A single module-level before-quit handler that flips a shared "quitting" flag consulted by all instances avoids the accumulation.


82-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Reset bounds persistence when close/quit is cancelled.

fix_bounds runs before the close handler can call event.preventDefault(), so a cancelled close leaves windowClosing = true forever and disables resize/move persistence for that window. Re-enable persistence from another cancelled close/quit path, or gate saving on window.isDestroyed() and make the freeze strictly closed-scoped.

src/main/window/dashboard-popout-window.test.ts (1)

62-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

destroy mock diverges from Electron: real destroy() emits closed.

close emits close/closed but destroy only flips the flag, so the failure path's closed handler (unsubscribe, singleton nulling, popoutOpenChanged(false) broadcast) is never exercised — exactly the behavior worth asserting here.

♻️ Align the mock with Electron semantics
     destroy = vi.fn(() => {
+      if (this.destroyed) {
+        return
+      }
       this.destroyed = true
+      this.emit('closed')
     })
src/renderer/src/components/tab-bar/EditorFileTab.tsx (1)

234-240: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add data-selected for parity with the other tab types.

SortableTab.tsx (Line 196) and BrowserTab.tsx (Line 197) both expose data-selected={isSelected || isActive}; editor/simulator tabs don't, so selection-state assertions and any attribute-based styling won't work uniformly across the strip.

♻️ Mirror the attribute
       data-pinned={isPinned ? 'true' : 'false'}
+      data-active={isActive ? 'true' : 'false'}
+      data-selected={isSelected || isActive ? 'true' : 'false'}
       {...attributes}
src/renderer/src/components/tab-bar/useSortableTabRename.ts (1)

49-62: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Cancel the pending focus frame on unmount.

renameFocusFrameRef is only cleared when the ref callback runs again; if the tab unmounts while a frame is queued, the callback still fires and focuses a detached input.

♻️ Cleanup effect
+  useEffect(
+    () => () => {
+      if (renameFocusFrameRef.current !== null) {
+        cancelAnimationFrame(renameFocusFrameRef.current)
+      }
+    },
+    []
+  )
src/renderer/src/components/tab-bar/SortableTabContextMenu.test.tsx (1)

261-312: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider covering hasDetachableSelected: false.

The disabled path for "Detach Tabs to Window" is the only new branch in the multi-select menu without coverage.

src/main/ipc/detachable-pane.ts (1)

72-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Comment reads as a truncated fragment.

// handlers use — the renderer closes the tab... starts mid-sentence; it appears the lead-in clause was dropped. Worth tightening for future readers.

✏️ Suggested cleanup
-    // handlers use — the renderer closes the tab when this call resolves, so a
-    // resolved-but-not-detached call would lose the tab. The seed rides along
-    // in the same call so a detached window can never exist without one.
+    // Why: the renderer closes the tab once this call resolves, so a
+    // resolved-but-not-detached call would lose the tab. The seed rides along
+    // in the same call so a detached window can never exist without one.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2be9c67e-ee11-4be8-a921-92ed79d19356

📥 Commits

Reviewing files that changed from the base of the PR and between 17617b1 and 6ea938a.

📒 Files selected for processing (43)
  • src/cli/bundled-skill-guides.ts
  • src/main/ipc/detachable-pane.test.ts
  • src/main/ipc/detachable-pane.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/window/dashboard-popout-window.test.ts
  • src/main/window/dashboard-popout-window.ts
  • src/main/window/detachable-pane-window-manager.test.ts
  • src/main/window/detachable-pane-window-manager.ts
  • src/main/window/detachable-pane-window.test.ts
  • src/main/window/detachable-pane-window.ts
  • src/main/window/popout-window-chrome.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/App.tsx
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/detached-terminal-pane/DetachedTerminalPaneRoot.tsx
  • src/renderer/src/components/detached-terminal-pane/detached-terminal-pane-seed.ts
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
  • src/renderer/src/components/settings/codex-config-sync-warning.test.ts
  • src/renderer/src/components/tab-bar/BrowserTab.tsx
  • src/renderer/src/components/tab-bar/EditorFileTab.tsx
  • src/renderer/src/components/tab-bar/EditorFileTabContextMenu.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/SortableTabContextMenu.test.tsx
  • src/renderer/src/components/tab-bar/SortableTabContextMenu.tsx
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/tab-bar/TabWorkspaceLayoutMenuSection.tsx
  • src/renderer/src/components/tab-bar/drop-indicator.ts
  • src/renderer/src/components/tab-bar/tab-strip-pointer-activation.ts
  • src/renderer/src/components/tab-bar/useSortableTabRename.ts
  • src/renderer/src/components/tab-group/TabGroupPanel.tsx
  • src/renderer/src/components/terminal-pane/terminal-tab-window-detach.test.ts
  • src/renderer/src/components/terminal-pane/terminal-tab-window-detach.ts
  • src/renderer/src/components/terminal-pane/use-detach-terminal-tab-to-window.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/popout.tsx
  • src/shared/crash-reporting.ts
  • src/shared/types.ts

Comment thread src/cli/bundled-skill-guides.ts Resolved
Comment thread src/cli/bundled-skill-guides.ts Resolved
Comment thread src/main/ipc/detachable-pane.ts Resolved
@emmahyde

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@emmahyde

emmahyde commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Regarding above: These guides represent existing offline instruction templates. Modifying token interpolation patterns and shell quoting formats in these guides is outside the scope of the detachable windows and multi-tab selection feature. I've left these files unchanged so we can track the security and cross-platform improvement in a separate issue/PR.

@emmahyde

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

The Comment image shows the ORCA desktop app in a dark theme on its initial empty-state screen. The left sidebar contains Tasks, Automations, Orca Mobile with a New badge, a Search field, and a Projects section showing sector-unity-proto. The main panel displays the ORCA logo and the message “Select a workspace from the sidebar to begin.”, with Add Project and Create workspace buttons plus shortcut hints below.

@emmahyde, I’m here—what would you like me to review or help with?

@emmahyde

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/cli/bundled-skill-guides.ts (2)

392-397: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Clean up the temporary askpass helper on every exit path.

The remote script creates /tmp/askpass.sh, but set -e can exit before the later rm -f when fetch or checkout fails, leaving the Git token on disk. Install a cleanup trap immediately after creating the helper and remove the exported credential state on exit.


498-505: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Wire the piped token into Git authentication.

This reads and exports GH_TOKEN, but git clone and git fetch configure neither GIT_ASKPASS nor another credential mechanism. With GIT_TERMINAL_PROMPT=0, private-repository access will fail. Mirror the askpass setup from the Vercel example and clean it up with a trap.

🧹 Nitpick comments (1)
src/renderer/src/components/tab-bar/tab-create-menu-options.test.ts (1)

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

Add a positive test for the new detached-window option.

All updated fixtures set hasNewDetachedWindow: false, so none exercises the new enabled branch in src/renderer/src/components/tab-bar/tab-create-menu-options.ts Lines 119-131. Add a case with true that asserts the option’s id, kind, label, keywords, and placement; retain a false case to verify omission.

Based on the added new-detached-window branch in src/renderer/src/components/tab-bar/tab-create-menu-options.ts.

Also applies to: 37-37, 62-62


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d48dc1f4-4ff5-4d04-82c1-7ebeb70ada42

📥 Commits

Reviewing files that changed from the base of the PR and between 5b9d86353ce6e65b223d826755c192f9c670d386 and e8198483b1ec346056e3b5cd852383ba33d67688.

📒 Files selected for processing (34)
  • .gitignore
  • skill-guides/orca-emulator-android.md
  • skill-guides/orca-emulator.md
  • skill-guides/orca-per-workspace-env.md
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/main/ipc/detachable-pane.test.ts
  • src/main/ipc/detachable-pane.ts
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/main/window/dashboard-popout-window.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/App.tsx
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/WorktreeJumpPalette.tsx
  • src/renderer/src/components/cmd-j/quick-action-context.test.ts
  • src/renderer/src/components/cmd-j/quick-action-context.ts
  • src/renderer/src/components/cmd-j/quick-actions.ts
  • src/renderer/src/components/detached-terminal-pane/DetachedTerminalPaneRoot.tsx
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
  • src/renderer/src/components/tab-bar/BrowserTab.tsx
  • src/renderer/src/components/tab-bar/EditorFileTab.tsx
  • src/renderer/src/components/tab-bar/EditorFileTabContextMenu.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/SortableTabContextMenu.test.tsx
  • src/renderer/src/components/tab-bar/SortableTabContextMenu.tsx
  • src/renderer/src/components/tab-bar/TabBar.context-menu.test.ts
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/tab-bar/TabBar.windows-shell-launch.test.ts
  • src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx
  • src/renderer/src/components/tab-bar/tab-create-menu-options.test.ts
  • src/renderer/src/components/tab-bar/tab-create-menu-options.ts
  • src/renderer/src/components/tab-group/TabGroupPanel.tsx
🚧 Files skipped from review as they are similar to previous changes (15)
  • .gitignore
  • src/preload/api-types.ts
  • src/renderer/src/components/tab-group/TabGroupPanel.tsx
  • src/preload/index.ts
  • src/renderer/src/components/tab-bar/SortableTabContextMenu.test.tsx
  • src/renderer/src/App.tsx
  • src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
  • src/renderer/src/components/Terminal.tsx
  • src/main/ipc/detachable-pane.test.ts
  • src/renderer/src/components/tab-bar/SortableTabContextMenu.tsx
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/tab-bar/EditorFileTabContextMenu.tsx
  • src/renderer/src/components/tab-bar/BrowserTab.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/EditorFileTab.tsx

Comment thread skill-guides/orca-per-workspace-env.md Resolved
Comment thread skill-guides/orca-per-workspace-env.md Resolved
Comment thread skill-guides/orchestration.md Resolved
Comment thread src/main/ipc/pty.ts Resolved
@emmahyde

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/main/ipc/pty.test.ts (1)

14601-14620: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten the test comments.

These comments duplicate implementation details and brittle source line references. Keep only the non-obvious contract being tested; the detailed control-flow walkthrough belongs in the implementation or test design documentation.

Also applies to: 14623-14644

Source: Coding guidelines

src/main/window/detachable-pane-window-manager.test.ts (1)

551-559: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test doesn't isolate the "no PTY" case from the "last tab removed" case.

With only one tab in the seed, removing it triggers the same last-tab code path already covered at lines 526-533, so removedPtyId === null here is indistinguishable from "seed became null because it was the last tab" rather than genuinely exercising a no-PTY tab while other tabs remain.

♻️ Suggested strengthening
   it('removeTab: returns null removedPtyId when the removed tab has no PTY', () => {
     const seed = makeSeed()
     seed.ptyId = null
+    const additional = makeSeed()
+    additional.tab = { id: 'tab-2' } as unknown as DetachedTerminalTabSeed['tab']
+    additional.ptyId = 'pty-2'
+    seed.additionalTabs = [additional]
     manager.detachPane('pane-1', makeStore() as unknown as Store, seed)

     const result = manager.removeTab('pane-1', 'tab-1')
     expect(result.removedPtyId).toBeNull()
-    expect(result.seed).toBeNull()
+    expect(result.seed).not.toBeNull()
+    expect(result.seed!.tab.id).toBe('tab-2')
   })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4aba9536-be68-467f-916f-0b7d7bf66de3

📥 Commits

Reviewing files that changed from the base of the PR and between e8198483b1ec346056e3b5cd852383ba33d67688 and 7286fd2d13cbf17e599e867471c0e2c2c4faa52c.

📒 Files selected for processing (14)
  • skill-guides/orca-per-workspace-env.md
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/main/ipc/detachable-pane.test.ts
  • src/main/ipc/detachable-pane.ts
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/main/window/dashboard-popout-window.test.ts
  • src/main/window/dashboard-popout-window.ts
  • src/main/window/detachable-pane-window-manager.test.ts
  • src/main/window/detachable-pane-window-manager.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/detached-terminal-pane/DetachedTerminalPaneRoot.tsx
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/main/ipc/detachable-pane.test.ts
  • src/main/ipc/detachable-pane.ts
  • src/main/window/detachable-pane-window-manager.ts
  • src/renderer/src/components/detached-terminal-pane/DetachedTerminalPaneRoot.tsx
  • src/cli/bundled-skill-guides.ts
  • skill-guides/orca-per-workspace-env.md
  • src/main/ipc/pty.ts
  • src/main/window/dashboard-popout-window.ts

Comment thread skill-guides/orchestration.md Resolved
Comment thread src/main/ipc/pty.test.ts Resolved
@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
@emmahyde
emmahyde force-pushed the feat/detachable-terminal-pane-windows branch from de55577 to 126ae9f Compare July 27, 2026 10:23
@AmethystLiang
AmethystLiang requested a review from OrcaWin July 28, 2026 16:50
@emmahyde

Copy link
Copy Markdown
Contributor Author

Needs a rebase, I'll handle tonight

@emmahyde
emmahyde force-pushed the feat/detachable-terminal-pane-windows branch from 126ae9f to 2de9399 Compare July 30, 2026 16:14
@emmahyde
emmahyde requested a review from brennanb2025 as a code owner July 30, 2026 16:14

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
skill-guides/orca-per-workspace-env.md (1)

392-406: ⚠️ Potential issue | 🟠 Major

Keep Git non-interactive when no token is available.

GIT_TERMINAL_PROMPT=0 is exported only inside the non-empty-token branch. With an empty token, git fetch can prompt or hang instead of failing fast.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6cca6d31-af8f-4e7d-a4fb-0dbe9bf93436

📥 Commits

Reviewing files that changed from the base of the PR and between 126ae9f39784cd7b1ad3704129c40ba67727c0c5 and 2de9399cc9cd9fe34b8b6f3914c496bfb79c8cee.

📒 Files selected for processing (6)
  • .gitignore
  • skill-guides/orca-emulator-android.md
  • skill-guides/orca-emulator.md
  • skill-guides/orca-per-workspace-env.md
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • skill-guides/orca-emulator-android.md
  • skill-guides/orchestration.md
  • .gitignore
  • skill-guides/orca-emulator.md

Comment thread skill-guides/orca-per-workspace-env.md Resolved
Comment thread src/cli/bundled-skill-guides.ts Resolved
Comment thread src/cli/bundled-skill-guides.ts Resolved
@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds multi-tab selection with Shift/Ctrl+Click to the tab strip, batch context-menu operations (close, pin, move-to-split, detach) across all tab types, and a complete detachable terminal window subsystem with live PTY reattachment via IPC seed handoff and a new DetachablePaneWindowLifecycle state machine.

  • Multi-tab selection: TabBar.tsx gains selectedTabIds + anchorTabIdRef state; pointer activation in tab-strip-pointer-activation.ts now preserves modifier keys across the press→release gap; getTabRootStateClasses adds a selection highlight tier; batch handlers operate on effectiveSelectedTabIds, which prunes closed-tab IDs before use.
  • Detachable terminal windows: detachable-pane-window-manager.ts manages per-pane BrowserWindow lifecycle; detachable-pane.ts wires IPC for seed fetch, reintegration, and tab removal; PTY routing in pty.ts is extended to direct data/input to the owning renderer's WebContents; DetachedTerminalPaneRoot renders the popped-out terminal with a tab strip and "Return" control.
  • Refactoring: Inline rename logic in SortableTab is extracted to a dedicated useSortableTabRename hook.

Confidence Score: 4/5

Safe to merge after addressing the watchdog cancellation in pty.ts; the multi-tab selection and detach plumbing is solid.

The PTY routing changes in pty.ts are the most operationally sensitive part of the PR. clearDispatcherReadyWatchdog() is called unconditionally for any registered renderer sender — including detached pane windows — but the watchdog exists solely to recover the main window's PTY delivery gate when that window's own handshake is delayed. A detached renderer's handshake arriving during a main-window reload can cancel the watchdog before the main window sends its signal, leaving PTY data blocked from reaching the main renderer if the main window's signal is then lost. The rest of the multi-tab selection logic, the lifecycle state machine, and the IPC trust scoping are well-implemented and tested.

Files Needing Attention: src/main/ipc/pty.ts — the pty:rendererDispatcherReady handler should guard clearDispatcherReadyWatchdog() on event.sender === mainWindow.webContents, matching the accounting-reset branch immediately above it.

Important Files Changed

Filename Overview
src/renderer/src/components/tab-bar/TabBar.tsx Core multi-tab selection orchestrator: adds selectedTabIds state, effectiveSelectedTabIds memo for stale-ID pruning, handleTabClickActivate with Shift/Ctrl range and toggle logic, and four batch handlers. Logic is well-structured with correct use of functional Zustand updaters.
src/main/ipc/pty.ts Routes PTY data/input/exit to detached-pane renderers instead of only mainWindow. Most paths are correctly gated; clearDispatcherReadyWatchdog() is called unconditionally for both main and detached senders, risking premature watchdog cancellation during main-window reload.
src/main/window/detachable-pane-window-manager.ts New DetachablePaneWindowManager: lifecycle state machine, per-pane BrowserWindow creation with rollback on construction failure, park-on-native-close, and seed promotion when tabs are removed. Well-guarded and tested.
src/main/ipc/detachable-pane.ts New IPC handlers for pane:detach, pane:reintegrate, pane:removeTab, pane:getDetachedTabSeed. Trust scoping is correctly narrow: detached renderer can only act on its own paneId; all shape validation is present.
src/renderer/src/components/detached-terminal-pane/DetachedTerminalPaneRoot.tsx New pop-out entry: seeds the Zustand store, manages active tab switching, PTY delivery registration, and close/reintegrate flows. Known issues flagged in prior threads are in progress.
src/renderer/src/store/slices/terminals.ts Adds openNewDetachedTerminalWindow: creates tab, waits for PTY via store subscription with 5s timeout, builds seed, calls pane:detach, then closes main-window tab with PTY teardown suppressed. Cleanup paths on all error branches look correct.
src/renderer/src/components/tab-bar/SortableTabContextMenu.tsx Multi-select batch context menu: correctly hides rename/single-tab items; 'Close Tabs' shows the single-tab keyboard shortcut (misleading) and is not disabled when all selected tabs are pinned (silent no-op).
src/renderer/src/components/tab-bar/tab-strip-pointer-activation.ts Captures modifier keys at pointerdown and OR-merges them with pointerup modifiers to handle Chromium's stale first-event quirk. Clean change, well tested.
src/renderer/src/components/terminal-pane/terminal-tab-window-detach.ts New pure helpers for tab capture and reintegration; correctly derives repoId from worktreeId prefix, returns null on any missing dependency, and handles layout ptyIdsByLeafId fallback.
src/renderer/src/components/detached-terminal-pane/detached-terminal-pane-seed.ts applyDetachedTerminalTabSeed correctly seeds tabsByWorktree, terminalLayoutsByTabId, ptyIdsByTabId, and activeTabIdByWorktree for all entries, including the ptyIdsByLeafId fallback fix that unblocks PTY reattachment.

Sequence Diagram

sequenceDiagram
    participant R as Main Renderer
    participant M as Main Process (IPC)
    participant DPW as DetachablePaneWindowManager
    participant DR as Detached Renderer

    R->>M: pane:detach(paneId, seed)
    M->>DPW: detachPane(paneId, store, seed)
    DPW->>DPW: lifecycle: attached → transferring → detached
    DPW-->>M: BrowserWindow
    M->>M: registerDetachedPanePtys(ptyIds, webContents)
    M-->>R: (resolved)
    R->>R: "closeTab(tabId, localPtyTeardownOwnedExternally=true)"

    Note over DR: Window loads popout.html?detachedPane=paneId
    DR->>M: pane:getDetachedTabSeed(paneId)
    M->>DPW: getPaneSeed(paneId)
    DPW-->>M: DetachedTerminalTabSeed
    M-->>DR: seed
    DR->>DR: applyDetachedTerminalTabSeed(seed)
    DR->>M: pty:setActiveRendererPty / pty:setRendererPtyVisible

    alt User clicks Return to main window
        DR->>M: pane:reintegrate(paneId)
        M->>M: finalizeReintegration(paneId)
        M->>DPW: reintegratePane(paneId)
        DPW->>DPW: lifecycle: detached → reintegrating → attached
        M->>M: unregisterDetachedPanePtys(ptyIds)
        M->>R: pane:returned(seed)
        R->>R: reintegrateDetachedTerminalTab(store, detachedTab)
    else Native window close (red dot)
        DR-->>M: closed event parked
        DPW->>DPW: lifecycle: detached → parked
        M->>M: onPaneParked → finalizeReintegration(paneId)
        M->>R: pane:returned(seed)
    end
Loading

Comments Outside Diff (1)

  1. src/main/ipc/pty.ts, line 5974-5994 (link)

    P1 clearDispatcherReadyWatchdog() fires for detached-renderer handshakes, silently disabling the main-window self-heal path

    clearDispatcherReadyWatchdog() is called unconditionally for any registered sender — both the main window and detached pane renderers. However, the watchdog exists specifically to recover the main window's PTY delivery gate when the main window's own pty:rendererDispatcherReady signal is delayed (e.g., after a crash recovery or a hot-reload in dev). If a detached renderer's handshake arrives first — possible when the main window reloads while a detached pane is still alive — the watchdog is cancelled before the main window sends its own signal. If the main window's signal is then lost or delayed, the gate stays closed and all PTY data is blocked from reaching the main renderer.

    The accounting-reset branch is already correctly gated on event.sender === mainWindow.webContents; clearDispatcherReadyWatchdog() should be guarded the same way.

Reviews (2): Last reviewed commit: "fix: address remaining PR review comment..." | Re-trigger Greptile

@emmahyde
emmahyde force-pushed the feat/detachable-terminal-pane-windows branch from 2de9399 to e328820 Compare July 31, 2026 09:11
emmahyde and others added 20 commits August 2, 2026 14:21
Seeding worktreesByRepo in the popout store caused the terminal route
resolver to enter the explicit-worktree path, fail to find the actual
worktree (ID format mismatch), and fall through to 'missing' — then
the non-empty worktreesByRepo blocked the legacy fallback.

Fix: remove worktreesByRepo from the seed entirely, add
executionHostId/connectionId to the repo seed so the repo-indexed
fallback path (resolveIndexedRepoOperationRoute) can match, and let
the existing resolution chain handle the rest.
The multi-select 'Detach Tabs to Window' handler iterated all selected
tabs and called onDetachToWindow for each, creating N separate popout
windows. Since the popout window architecture supports one tab per
window, only detach the first selected tab.
Anchor the absolute terminal surface to its content slot so grouped tab controls remain visible.

Confidence: high
Scope-risk: narrow
… OS window

- Store: openNewDetachedTerminalWindow(groupId) creates tab, waits for PTY,
  captures seed, detaches to OS window. 5s timeout, graceful fallback.
- Cmd-J palette: 'new-detached-window' quick action (workspace-scoped)
- Tab bar '+' menu: 'new-detached-window' entry with ExternalLink icon
- Tests: 3 scenarios (happy path, timeout, IPC failure)
- i18n: placeholder keys (NEWKEY1-12) in all 5 locales
NEWKEY1-NEWKEY12 replaced with proper sha1(filePath:text) 10-char hex
keys per localize-renderer-strings.mjs convention. One pre-existing
missing key (detachedTerminalPane.tabs) also absorbed via --fix.
Before this fix, the PTY IPC pipeline was hardcoded to mainWindow's
WebContents — detached pane windows received no output (pty:data went
to the wrong renderer) and had no input (pty:write was gated to
mainWindow only).

Changes:
- pty.ts: Add detachedPtyToRenderer + detachedPaneRenderers registry
- pty.ts: getPtyRendererTarget(id) resolves the correct WebContents
- pty.ts: registerDetachedPanePtys/unregisterDetachedPanePtys exports
- pty.ts: Route pty:data, pty:spawned, pty:exit, pty:modelRestoreNeeded,
  pty:clearBuffer:request, pty:serializeBuffer:request to correct renderer
- pty.ts: Extend write gate (pty:write, pty:writeAccepted) to accept
  events from the PTY's owning detached renderer
- pty.ts: Allow pty:rendererDispatcherReady from detached pane renderers
- detachable-pane.ts: Register PTYs on detach, unregister on reintegrate

Tests: 364 pty + 21 detachable-pane tests pass.
Before: onCloseTab called handleReintegrate, which sent the tab back
to the main window on every close. Only the 'Return to main window'
button should reintegrate — tab close (Cmd+W / ×) should remove the
tab from the detached window.

After: handleCloseTab removes the active tab from the seed. If it's
the last tab, kills the PTY and closes the window. Otherwise switches
to another remaining tab.
…ndow

handleCloseTab was calling applyDetachedTerminalTabSeed which
rebuilds the entire store (tabsByWorktree, terminalLayoutsByTabId,
ptyIdsByTabId, activeTabId) — causing remaining open tabs to
reload/blink. Now it only updates active-tab tracking fields
(same pattern as handleSelectTab) and the seed state.
When a tab is created for detach, it briefly appears in the
tab bar before detaching — this flicker is distracting. The fix:

1. Add module-level detachingTabIds Set to terminals.ts
2. Mark tab as detaching right after createTab
3. Clear on every exit path (PTY timeout, seed failure,
   detach failure, success)
4. Filter detaching tabs from unifiedTabs in TabBar.tsx

The tab still exists in tabsByWorktree (needed by TerminalPane
to mount and spawn the PTY) but is hidden from the tab strip.
.filter() inside a Zustand selector creates a new array on every
invocation. Zustand's subscription engine compares by reference,
sees a new value every time, calls forceStoreRerender, which calls
the selector again... infinite re-render loop (Maximum update depth
exceeded crash).

Fix: separate the store read (stable reference) from the filter
(local transform that doesn't feed back into Zustand's engine).
Supplements the review fixes already on this branch (5b9d863, aee8254)
with the comments they did not cover:

TabBar multi-select (3 fixes):
- effectiveSelectedTabIds now prunes against live orderedItems so
  closed/moved tabs don't keep isMultiSelectActive stuck on
- handleContextMenuRequest moves anchorTabIdRef write out of the state
  updater (React purity — StrictMode can re-invoke updaters)
- handleMoveSelectedToSplit mirrors web-runtime tab moves for tabs 2+
  via mirrorWebRuntimeTabMove({ kind: 'move-to-group' })

dashboard-popout-window:
- Guard the closed-event close-broadcast with an openBroadcasted flag so
  a construction-time throw after the closed listener is registered does
  not broadcast popoutOpenChanged(false) when true was never sent

Skill guides:
- Cross-platform quoting for emulator gesture commands (Unix + Windows
  variants) so single-quoted JSON doesn't break on cmd.exe
- Stream GH_TOKEN via stdin in the SSH and both Vercel worked examples
  instead of interpolating it into argv (ps aux exposure)
- Regenerate bundled-skill-guides.ts from the updated markdown
…close, popout broadcast

- Gate pty.ts PTY-data teardown on absence of a live detached target so detached panes keep receiving data after the main window closes (comments on sendPtyExitToRenderer vs onData consistency)
- Add pane:removeTab IPC (manager-authoritative): closing a tab in a detached pane now persists to the manager seed and unregisters the PTY, preventing reappearance on reintegration and PTY leaks
- Scope dashboard-popout close broadcast to the tracked window so a superseded window late closed event cannot broadcast false after a replacement broadcast true
- Harden skill-guide token handling: mktemp + trap cleanup for askpass helpers (Vercel + SSH), wire GIT_ASKPASS in the SSH bootstrap, and use the CLI shell-neutral structured flags (--task-id/--dispatch-id/etc.) in orchestration examples
- Remove `--report-path <optional>` from the copy-pasteable worker_done
  command in orchestration.md; it was being parsed as shell redirection.
  Regenerate bundled-skill-guides.ts to match.
- Replace placeholder pty.test.ts assertion with real coverage for
  hasLiveDetachedTarget/anyLiveDetachedTarget, hoisted to module scope
  in pty.ts so they're testable independently of registerPtyHandlers.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JDRck1HYXgo4T3jAKuFSk3
Rebasing onto main revealed a semantic merge gap: main moved the dirty-dot
into EditorFileTabCloseButton (fileIsDirty prop) and simplified the
middle-click guard, but this branch's own edits to the same tab kept the
pre-refactor call site, which git's line-based merge couldn't catch.

Also extracts the mode icon and rename-input JSX into their own components
(EditorFileTabIcon, EditorFileTabRenameInput) — the merged file exceeded the
400-line lint cap.
…ation, tabId/paneId naming, doc quoting bugs)

- Kill the closed tab's PTY on non-last-tab close (was only wired up for the
  last-tab-closes-the-window path), fixing a process leak.
- Sequence removeTab + PTY kill to resolve before window.close() on the
  last-tab path, so the native close's park flow can't reintegrate a
  now-dead PTY as a phantom "exited" tab in the main window.
- Rename the tabId prop to paneId — the popout.tsx query param and every IPC
  call in this component already treat it as a pane id, not a tab id.
- Fix the SSH per-workspace-env bootstrap example: it never actually piped
  the token into ssh, and its unescaped $-expansions would run locally
  instead of on the remote host. Rebuilt it with posix_quote + positional
  args so it parses identically under bash or a POSIX /bin/sh; verified via
  a local /bin/sh -c simulation with a real git clone/fetch/checkout.
- Fix the §5/§7f contradiction on how to pass the git token to a VM (stdin,
  not --env, since --env lands in host-visible argv).
- Fix invalid PowerShell quoting in the iOS/Android emulator gesture
  examples (PowerShell single-quotes pass JSON's double quotes through
  literally; cmd.exe has no single-quote form and needs \" escaping).

Regenerated src/cli/bundled-skill-guides.ts via
config/scripts/generate-bundled-skill-guides.mjs --write.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PLJkhNHjpfsAVkRfTibKiF
…nal-pane-windows

# Conflicts:
#	.gitignore
#	skill-guides/orchestration.md
#	src/cli/bundled-skill-guides.ts
#	src/main/ipc/pty.test.ts
#	src/main/window/dashboard-popout-window.ts
…nal-pane-windows

# Conflicts:
#	src/renderer/src/components/tab-bar/TabBar.context-menu.test.ts
#	src/renderer/src/components/tab-bar/TabBar.windows-shell-launch.test.ts
#	src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx
@emmahyde

emmahyde commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor Author

@brennanb2025 @AmethystLiang @OrcaWin anything I can do to help this get reviewed before it becomes stale again? This has been waiting for reviews for a week or so now.

@cristiandonaraDEV

Copy link
Copy Markdown

Very useful

@emmahyde

emmahyde commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Could I get some insight from one of the owners? Not wanted, etc? @AmethystLiang can't keep rebasing.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support Shift/Cmd/Ctrl multi-select in the tab strip

4 participants