Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

test(browser): the canvas and modal webviews for one node share one partition

Claude Codea7c8112d7e08
diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsx
index 75c86b4d9..847ece7a2 100644
--- a/src/renderer/components/kanban/CardModal.tsx
+++ b/src/renderer/components/kanban/CardModal.tsx
@@ -270,6 +270,7 @@ export function CardModal({ session, columnTitle, board, onChangeBoard, onClose,
key={session.id}
nodeId={session.id}
url={session.url ?? ''}
+ partition={session.partition}
onUrlChange={(u) => onBrowserNav({ url: u })}
onTitleChange={(t) => onBrowserNav({ title: t })}
/>
diff --git a/src/renderer/components/kanban/KanbanView.tsx b/src/renderer/components/kanban/KanbanView.tsx
index c26f1ba30..448c1b172 100644
--- a/src/renderer/components/kanban/KanbanView.tsx
+++ b/src/renderer/components/kanban/KanbanView.tsx
@@ -43,6 +43,9 @@ export interface KanbanSession {
textUpdatedBy?: string
/** Browser node URL (kind 'browser' only) — shown on the card, opened in the modal webview. */
url?: string
+ /** Browser node session partition (kind 'browser' only) — threaded to the modal webview so it
+ * shares the canvas node's jar (`browser-partition-parity.test.tsx`). Absent = default session. */
+ partition?: string
/** The subset of the node's `data` the card modal's co-attach terminal needs to spawn/join the
* same session (kind 'terminal' only; sticky passes `{}`). */
spawn: ModalSpawn
diff --git a/src/renderer/nodes/browser-partition-parity.test.tsx b/src/renderer/nodes/browser-partition-parity.test.tsx
new file mode 100644
index 000000000..f1d0022bb
--- /dev/null
+++ b/src/renderer/nodes/browser-partition-parity.test.tsx
@@ -0,0 +1,113 @@
+// @vitest-environment jsdom
+//
+// One node, two mounts: the canvas BrowserNode and the kanban CardModal both render the SHARED
+// BrowserSurface. This pins that they hand it the SAME `partition`, so the two mounts share one
+// session jar. A mismatch is not cosmetic — it is the modal being a different, logged-out browser,
+// which a user reads as "my login vanished".
+//
+// The shared leaf BrowserSurface is replaced by a spy that renders a real <webview partition>, so
+// the assertion is against the actual attribute each wrapper's real data->prop plumbing produces
+// (the bug surface lives in the wrappers, never in the identical leaf).
+import { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { ReactFlowProvider, type NodeProps } from '@xyflow/react'
+import type { CanvasNode } from '../state/workspace'
+import type { KanbanSession } from '../components/kanban/KanbanView'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+// The shared surface both mounts use: render the partition straight onto a real <webview> so the
+// test reads the same attribute a real guest would attach on.
+vi.mock('./BrowserSurface', () => ({
+ BrowserSurface: ({ partition }: { partition?: string }) => (
+ // eslint-disable-next-line react/no-unknown-property
+ <webview partition={partition || undefined} data-testid="surface" />
+ )
+}))
+// CardModal's non-browser children are irrelevant to partition parity — stub them so the modal
+// renders without their store/context burden.
+vi.mock('../session/session', () => ({ useSession: () => ({ api: { pty: { generateName: vi.fn() } } }) }))
+vi.mock('../components/kanban/BoardLogPanel', () => ({ BoardLogPanel: () => null }))
+vi.mock('../components/kanban/CardMetaBar', () => ({ CardMetaBar: () => null }))
+vi.mock('../components/kanban/ModalTerminal', () => ({ ModalTerminal: () => null }))
+vi.mock('../components/ContextMeter', () => ({ ContextMeter: () => null }))
+
+import BrowserNode from './BrowserNode'
+import { CardModal } from '../components/kanban/CardModal'
+
+function partitionFromCanvas(nodePartition: string | undefined): string | null {
+ const host = document.createElement('div')
+ document.body.append(host)
+ const root = createRoot(host)
+ const data = { title: 'B', color: '#0a84ff', group: null, url: 'https://x.test/', partition: nodePartition }
+ act(() =>
+ root.render(
+ <ReactFlowProvider>
+ <BrowserNode {...({ id: 'browser-1', data, selected: false } as unknown as NodeProps<CanvasNode>)} />
+ </ReactFlowProvider>
+ )
+ )
+ const wv = host.querySelector('webview')!
+ const p = wv.getAttribute('partition')
+ act(() => root.unmount())
+ host.remove()
+ return p
+}
+
+function partitionFromModal(sessionPartition: string | undefined): string | null {
+ const host = document.createElement('div')
+ document.body.append(host)
+ const root = createRoot(host)
+ const session: KanbanSession = {
+ id: 'browser-1',
+ title: 'B',
+ color: '#0a84ff',
+ kind: 'browser',
+ url: 'https://x.test/',
+ partition: sessionPartition,
+ spawn: {}
+ }
+ act(() =>
+ root.render(
+ <CardModal
+ session={session}
+ columnTitle={null}
+ board={{ columns: [], assignments: {} } as never}
+ onChangeBoard={vi.fn()}
+ onClose={vi.fn()}
+ onOpenCanvas={vi.fn()}
+ onRename={vi.fn()}
+ onEditSticky={vi.fn()}
+ onBrowserNav={vi.fn()}
+ />
+ )
+ )
+ const wv = document.body.querySelector('webview')!
+ const p = wv.getAttribute('partition')
+ act(() => root.unmount())
+ host.remove()
+ return p
+}
+
+afterEach(() => {
+ document.body.innerHTML = ''
+})
+
+describe('canvas + modal webviews for one node share one partition', () => {
+ it('an agent-opened node: both mounts carry the identical named partition', () => {
+ const part = 'persist:nt-agent-browser-p1'
+ const canvas = partitionFromCanvas(part)
+ const modal = partitionFromModal(part)
+ expect(canvas).toBe(part)
+ expect(modal).toBe(part)
+ expect(canvas).toBe(modal)
+ })
+
+ it('a user-opened node: BOTH mounts omit the attribute (default session, not two jars)', () => {
+ // The undefined case is the one a naive fix breaks: passing '' on one side and nothing on the
+ // other makes the modal a fresh default-session browser while the canvas node is on its own.
+ expect(partitionFromCanvas(undefined)).toBe(null)
+ expect(partitionFromModal(undefined)).toBe(null)
+ })
+})