Skip to content

POC- feat(desktop): add minimal pane popout window - #1959

Closed
Kitenite wants to merge 12 commits into
mainfrom
kitenite/please-add-a-new-window-type-o
Closed

Kitenite wants to merge 12 commits into
mainfrom
kitenite/please-add-a-new-window-type-o

Conversation

@Kitenite

@Kitenite Kitenite commented Mar 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add a dedicated Electron pane window type and open/focus flow via window.openPane
  • add a stripped route #/pane/$paneId that renders only the pane content (terminal), not the workspace shell
  • add an "Open in window" action in terminal pane toolbar
  • isolate pane-window router history from shared persisted app history
  • fix window creation to forward hash/query into route registration so pane windows boot to the stripped route reliably

Why

Pane popout windows were opening into the full app shell due to shared history + dropped route hash. This change makes pane popouts minimal and route-stable.

Validation

  • bun run --cwd apps/desktop typecheck
  • bun test apps/desktop/src/renderer/lib/persistent-hash-history/persistent-hash-history.test.ts
  • bunx biome check on touched files

Summary by cubic

Adds a minimal pop-out window for terminal panes with its own route and isolated (non-persistent) history. Reuses/focuses existing pane windows, prevents full app state writes, and keeps terminals attached when another pane window or pane client is active.

  • New Features

    • Electron "pane" window with /pane/$paneId route that renders only the terminal and sets titles from pane/workspace names.
    • "Open in window" toolbar action that reuses/focuses an existing pane window.
  • Bug Fixes

    • Normalize and forward route hashes so pane windows boot to the right route in dev and prod; isolate pane-window history from persisted app history.
    • Prevent pane windows from persisting tabs UI state via tRPC (mirror-only).
    • Centralize IPC handler attach/detach, attach pane windows to the singleton, and clean up pane presence on webContents destroy.
    • Guard terminal detach when another live pane window or mounted client exists (excludes the caller).

Written for commit b40c6e8. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • "Open in window" button to pop a terminal pane into a separate window; pane windows reuse existing instances and update titles with workspace name.
  • Behavior Changes

    • Pane popouts use isolated navigation (do not persist main app state or full tab snapshots).
    • Terminal attachment now avoids detaching if a live pane window remains open.
  • Tests

    • Added test for isolated history behavior in pane hashes.

@coderabbitai

coderabbitai Bot commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

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

Adds detachable "pane" windows end-to-end: new TRPC endpoints and UI action to open panes, a pane window factory with reuse/caching, hash-aware window creation and routing, history/persistence guards for pane popouts, and centralized IPC handler wiring.

Changes

Cohort / File(s) Summary
Window creation & types
apps/desktop/src/lib/electron-app/factories/windows/create.ts, apps/desktop/src/shared/types/electron.ts
createWindow signature now accepts and forwards hash and query; WindowProps gains optional hash.
Pane factory & main window
apps/desktop/src/main/windows/pane.ts, apps/desktop/src/main/windows/main.ts
New pane window factory with caching/reuse (openPaneWindow, hasLivePaneWindow); main window IPC wiring migrated to centralized ipc-handler accessors and attach/detach helpers.
IPC handler API
apps/desktop/src/main/lib/ipc-handler/index.ts
Introduces WindowIpcHandler interface, singleton accessor functions (getIpcHandler/setIpcHandler) and adapter helpers (attachWindowToIpcHandler/detachWindowFromIpcHandler).
TRPC & Renderer UI
apps/desktop/src/lib/trpc/routers/window.ts, apps/desktop/src/renderer/screens/.../TabPane.tsx, apps/desktop/src/renderer/screens/.../TabView/index.tsx
Adds openPane and hasLivePaneWindow procedures; TabPane adds "Open in window" action and accepts workspaceName prop passed through TabView.
Routing & window loader
apps/desktop/src/lib/window-loader.ts, apps/desktop/src/renderer/routes/pane/$paneId/page.tsx
WindowId adds pane; registerRoute accepts optional hash; new /pane/$paneId/ route page renders terminal or explanatory states.
History & persistence guards
apps/desktop/src/renderer/lib/persistent-hash-history/persistent-hash-history.ts, apps/desktop/src/renderer/lib/persistent-hash-history/persistent-hash-history.test.ts, apps/desktop/src/renderer/lib/trpc-storage.ts
Initial hash extraction and normalization added; history persistence disabled for pane routes (no localStorage writes); test added; trpc storage adapter skips persisting for pane popouts.
Misc / Manifest
package.json
Minor manifest edits.

Sequence Diagram(s)

sequenceDiagram
    participant User as User / UI
    participant TabPane as TabPane
    participant TRPC as electronTrpc.window
    participant Factory as openPaneWindow
    participant WinLoader as createWindow / Window Loader
    participant Renderer as Renderer Route
    participant IPC as IPC Handler

    User->>TabPane: Click "Open in window"
    TabPane->>TRPC: openPane({ paneId, paneName, workspaceName })
    TRPC->>Factory: openPaneWindow({ paneId, paneName, workspaceName })
    
    alt reuse existing window
        Factory->>IPC: attachWindowToIpcHandler(existingWindow)
        Factory->>Factory: restore / show / focus existingWindow
        Factory-->>TRPC: { reused: true }
    else create new window
        Factory->>WinLoader: createWindow({ id, hash: '/pane/{paneId}', ... })
        WinLoader->>Renderer: load URL with hash "#/pane/{paneId}"
        Renderer->>Renderer: render /pane/$paneId page (Terminal or message)
        Factory->>IPC: attachWindowToIpcHandler(newWindow)
        Factory-->>TRPC: { reused: false }
    end

    TRPC-->>TabPane: { success: true, reused }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through hashes, opened panes with cheer,
Windows reused or born anew, focused and near.
Histories keep hush for popouts on the run,
IPC ties the windows till the work is done,
A rabbit applauds each pane set free!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.26% 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 PR title 'POC- feat(desktop): add minimal pane popout window' directly describes the main change: adding a minimal pane popout window feature to the desktop app. The title is clear, concise, and accurately summarizes the primary objective of the changeset.
Description check ✅ Passed The pull request description includes a summary, rationale, validation steps, and auto-generated cubic summary with detailed feature/bug fix breakdown.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/please-add-a-new-window-type-o

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 and usage tips.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/main/windows/pane.ts">

<violation number="1" location="apps/desktop/src/main/windows/pane.ts:54">
P2: Missing `did-fail-load` handler: if the pane renderer fails to load, the window remains invisible forever (created with `show: false`). The main window handles this case by showing itself on load failure. Consider adding a parallel handler here so the user can at least see and close a failed pane window.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread apps/desktop/src/main/windows/pane.ts Resolved

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx`:
- Around line 125-132: The icon-only button that calls handleOpenPaneWindow (and
uses openPaneWindowMutation and the TbExternalLink icon) lacks an accessible
name; add an explicit accessible label such as aria-label="Open pane in new
window" (or a localized string) to the button and/or include a visually-hidden
text node for screen-readers; do not rely solely on the icon or title attribute
so assistive tech can identify the action reliably.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b0aac4 and a243bd4.

📒 Files selected for processing (9)
  • apps/desktop/src/lib/electron-app/factories/windows/create.ts
  • apps/desktop/src/lib/trpc/routers/window.ts
  • apps/desktop/src/lib/window-loader.ts
  • apps/desktop/src/main/windows/pane.ts
  • apps/desktop/src/renderer/lib/persistent-hash-history/persistent-hash-history.test.ts
  • apps/desktop/src/renderer/lib/persistent-hash-history/persistent-hash-history.ts
  • apps/desktop/src/renderer/routes/pane/$paneId/page.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx
  • apps/desktop/src/shared/types/electron.ts

@Kitenite

Kitenite commented Mar 2, 2026

Copy link
Copy Markdown
Member Author

Addressed both review findings in bf188b8:

  1. Stale tabs snapshot overwrite risk (High)
  • Pane windows now run tabs store in mirror-only mode: skips when route is .
  • This prevents pane-window writes from persisting full tabs snapshots back to main.
  1. IPC cleanup hooks missing on pane windows (Medium)
  • Added shared IPC handler registry and now attach pane windows via when created.
  • Pane windows now get per-window subscription cleanup hooks ( / ) like main.

Also verified:

  • Checked 2121 files in 459ms. No fixes applied. on touched files

@Kitenite

Kitenite commented Mar 2, 2026

Copy link
Copy Markdown
Member Author

Addressed both review findings in commit bf188b870.

  1. High: stale tabs snapshot overwrite risk
  • Pane windows now run tabs store in mirror-only mode: trpcTabsStorage skips uiState.tabs.set when route hash is #/pane/....
  • This prevents pane-window writes from persisting full tabs snapshots back to main.
  1. Medium: missing IPC window attachment / cleanup
  • Added a shared IPC handler registry and now attach pane windows with attachWindowToIpcHandler(window) on creation.
  • Pane windows now get trpc-electron window lifecycle cleanup hooks (did-start-navigation and destroyed) via attachWindow.

Validation:

  • bun run --cwd apps/desktop typecheck
  • bunx biome check on touched files

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/main/windows/pane.ts">

<violation number="1" location="apps/desktop/src/main/windows/pane.ts:52">
P1: Missing `detachWindowFromIpcHandler` call on window close. The main window (`main.ts:282`) detaches from the IPC handler when closed, but pane windows don't. This leaves a stale reference in the IPC handler after the pane window is destroyed, which may cause errors when the handler tries to communicate with it.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

},
hash: `/pane/${encodeURIComponent(paneId)}`,
});
attachWindowToIpcHandler(window);

@cubic-dev-ai cubic-dev-ai Bot Mar 2, 2026 •

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.

P1: Missing detachWindowFromIpcHandler call on window close. The main window (main.ts:282) detaches from the IPC handler when closed, but pane windows don't. This leaves a stale reference in the IPC handler after the pane window is destroyed, which may cause errors when the handler tries to communicate with it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/main/windows/pane.ts, line 52:

<comment>Missing `detachWindowFromIpcHandler` call on window close. The main window (`main.ts:282`) detaches from the IPC handler when closed, but pane windows don't. This leaves a stale reference in the IPC handler after the pane window is destroyed, which may cause errors when the handler tries to communicate with it.</comment>

<file context>
@@ -48,6 +49,7 @@ export function openPaneWindow({
 		},
 		hash: `/pane/${encodeURIComponent(paneId)}`,
 	});
+	attachWindowToIpcHandler(window);
 
 	paneWindows.set(paneId, window);
</file context>
Fix with Cubic

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/desktop/src/main/windows/pane.ts`:
- Around line 52-64: The window is attached to IPC via
attachWindowToIpcHandler(window) but never detached, causing stale IPC
registrations; add cleanup in the window "closed" handler to remove IPC handlers
for this pane—either call a corresponding detach function (e.g.
detachWindowFromIpcHandler(window) or implement one alongside
attachWindowToIpcHandler) before deleting the pane from paneWindows, and also
remove any remaining listeners on window.webContents (like the "did-finish-load"
listener) to fully release resources for paneId/window.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a243bd4 and bf188b8.

📒 Files selected for processing (4)
  • apps/desktop/src/main/lib/ipc-handler/index.ts
  • apps/desktop/src/main/windows/main.ts
  • apps/desktop/src/main/windows/pane.ts
  • apps/desktop/src/renderer/lib/trpc-storage.ts

Comment thread apps/desktop/src/main/windows/pane.ts Resolved

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalLifecycle.ts`:
- Around line 682-693: The async detach can race with a remount and detach a
newly mounted session; to fix, capture the timeout handle (detachTimeout) and
after awaiting shouldKeepAttachedForSingleClient(paneId) verify that
pendingDetaches.get(paneId) === detachTimeout before calling detachRef.current({
paneId }); also only delete pendingDetaches and coldRestoreState for this pane
when that same handle matches, ensuring stale async work cannot affect a
remounted pane; adjust the closure in useTerminalLifecycle where detachTimeout,
pendingDetaches, coldRestoreState, shouldKeepAttachedForSingleClient, and
detachRef.current are used to perform this guard.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf188b8 and df86e7e.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalLifecycle.ts

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalLifecycle.ts">

<violation number="1" location="apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalLifecycle.ts:683">
P1: Race condition: the async IIFE inside `setTimeout` is not cancellable on remount. If the 50ms timer fires before a quick remount occurs, `clearTimeout` is a no-op and the in-flight async query will eventually detach (and delete `coldRestoreState`) even though the terminal has already re-attached. Guard the async body by checking that `pendingDetaches.get(paneId) === detachTimeout` before proceeding.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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

♻️ Duplicate comments (1)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx (1)

128-135: ⚠️ Potential issue | 🟠 Major

Add an accessible name to the icon-only “open in window” button.

On Line 128, the icon-only <button> has no programmatic label, so assistive tech cannot reliably announce its action.

Suggested fix
 									<button
 										type="button"
+										aria-label="Open in window"
+										title="Open in window"
 										onClick={handleOpenPaneWindow}
 										disabled={openPaneWindowMutation.isPending}
 										className="rounded p-0.5 text-muted-foreground/60 transition-colors hover:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-40"
 									>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx`
around lines 128 - 135, The icon-only button that triggers handleOpenPaneWindow
(using openPaneWindowMutation and rendering TbExternalLink) lacks a programmatic
label; add an accessible name by supplying an appropriate aria-label (e.g.,
aria-label="Open pane in new window") or include visually-hidden text inside the
button to describe its action so screen readers can announce it, and ensure the
label updates if behavior or state changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx`:
- Around line 128-135: The icon-only button that triggers handleOpenPaneWindow
(using openPaneWindowMutation and rendering TbExternalLink) lacks a programmatic
label; add an accessible name by supplying an appropriate aria-label (e.g.,
aria-label="Open pane in new window") or include visually-hidden text inside the
button to describe its action so screen readers can announce it, and ensure the
label updates if behavior or state changes.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df86e7e and 3e25bc7.

📒 Files selected for processing (4)
  • apps/desktop/src/lib/trpc/routers/window.ts
  • apps/desktop/src/main/windows/pane.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/src/lib/trpc/routers/window.ts

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx">

<violation number="1" location="apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx:131">
P2: The `title` attribute will produce a native browser tooltip on top of the existing Radix `<TooltipContent>` tooltip, causing a double-tooltip UX glitch. No other `TooltipTrigger` in the codebase uses `title`. Remove it — the `aria-label` already provides the accessible name, and `<TooltipContent>` handles the visual tooltip.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

<button
type="button"
aria-label="Open pane in new window"
title="Open in window"

@cubic-dev-ai cubic-dev-ai Bot Mar 3, 2026 •

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.

P2: The title attribute will produce a native browser tooltip on top of the existing Radix <TooltipContent> tooltip, causing a double-tooltip UX glitch. No other TooltipTrigger in the codebase uses title. Remove it — the aria-label already provides the accessible name, and <TooltipContent> handles the visual tooltip.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx, line 131:

<comment>The `title` attribute will produce a native browser tooltip on top of the existing Radix `<TooltipContent>` tooltip, causing a double-tooltip UX glitch. No other `TooltipTrigger` in the codebase uses `title`. Remove it — the `aria-label` already provides the accessible name, and `<TooltipContent>` handles the visual tooltip.</comment>

<file context>
@@ -127,6 +127,8 @@ export function TabPane({
 									<button
 										type="button"
+										aria-label="Open pane in new window"
+										title="Open in window"
 										onClick={handleOpenPaneWindow}
 										disabled={openPaneWindowMutation.isPending}
</file context>
Fix with Cubic

@Kitenite Kitenite changed the title feat(desktop): add minimal pane popout window POC- feat(desktop): add minimal pane popout window Mar 3, 2026
@Kitenite
Kitenite marked this pull request as draft March 3, 2026 01:19
@Kitenite

Kitenite commented May 6, 2026

Copy link
Copy Markdown
Member Author

Closing as stale: created in Jan-Mar with no recent activity. If still relevant, re-open or re-create from a fresh branch. Bulk audit 2026-05-06.

@Kitenite Kitenite closed this May 6, 2026
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