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.

fix(kanban): the card modal's comments use the card's project, not the active one

review49b86f482b6f
diff --git a/CLAUDE.md b/CLAUDE.md
index 9443659d0..e59a6b60c 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -581,10 +581,14 @@ project's nodes only.** The contract:
session. Both kanban boards render under App's LOCAL provider, so each mounts its card modal
through `ProjectSessionScope` (`session/owning-project.ts`: `sessionForProject(<card's project>)`,
keyed by session id, plus `OwningProjectContext`). Before it, opening a team tab's terminal card
- created the host's node id on this desktop every time. Everything under the modal that asks
- `useSession()` — terminal, ⌘M chat, file links — now talks to the core the node runs on. The
- session is resolved at render, so a reconnect while a modal is open takes effect at the board's
- next render.
+ created the host's node id on this desktop every time. Nothing under the modal reads or writes
+ this machine's core for the host's node any more: the terminal runs under the card project's
+ session, the comments panel and the card metadata key the board log on the card's project
+ (`useOwningProjectId() ?? activeProjectId` — on the Omni board a lane is not the active project,
+ and pairing the lane's api with the active id blanked its comments and saved new ones nowhere), a
+ relay card's file links are switched off (`cardFileLinkRoute`) and its ⌘M chat is refused
+ (`stub.chat`, `E_UNSUPPORTED`). The session is resolved at render, so a reconnect while a modal is
+ open takes effect at the board's next render.
(3) TerminalNode and ModalTerminal ask `spawnBelongsElsewhere(project, session.source)` (the
project from `OwningProjectContext`) before any SSH resolve or create: a remote project under a
non-relay session starts nothing and writes a gray "belongs to a remote project that is not
@@ -9892,8 +9896,7 @@ under one `$HOME`, with different bytes; the last writer wins.
`context:update` metadata (deploy one core per team); a viewer's socket backlog over 1 MB still
pauses the shared pty through Stage 2 backpressure; the canvas authority's own limits (a project's
non-content fields stay last writer wins between tabs, the share-time window, oversized nodes, board
-edits to another core, load-time repairs that are never cast, the card modal's comments on a relay
-tab) are under "Known limits" in the doc.
+edits to another core, load-time repairs that are never cast) are under "Known limits" in the doc.
**Surfaces:** Desktop is full (joiner, plus approval and invite code in an owner's hosted tab, plus
Share with team from any desktop OS onto a Linux host). Server Edition is the host (the `team` CLI,
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 41121b017..3af65a498 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -661,9 +661,15 @@ anything else. Board-level fields survive every transform — `pullLinks` is one
- A surface that mounts a terminal outside the canvas (the kanban card modal — both boards live
under App's LOCAL provider) runs under `sessionForProject(<its project>)` and provides
`OwningProjectContext`: wrap it in `ProjectSessionScope` (`session/owning-project.ts`). A new
- terminal-creating path also asks `spawnBelongsElsewhere` before its first create.
+ terminal-creating path also asks `spawnBelongsElsewhere` before its first create. A component
+ under it that keys data by project (the board log, card metadata, pull requests) reads
+ `useOwningProjectId() ?? activeProjectId`, never `activeProjectId` alone: on the Omni board the
+ card's project is not the active one, and its `useSession()` api answers for the card's project.
- Core `join` refuses (`held-elsewhere`) a `requireRemote` create onto a held session that is
- local or on another host. Never join by node id alone.
+ local or on another host, but a create that names no `sshRemote` still attaches to a held
+ REMOTE session, so core alone does not stop a caller that names only a node id. A new caller
+ that creates a remote node passes `requireRemote` plus the `sshRemote` it has, and treats
+ `held-elsewhere` as a refusal that is NOT a lost connection (no reconnect, no drop report).
Do not "fix" this by re-stamping `sshRemoteTmux` onto those nodes: the host would then refuse its
own sessions. CLAUDE.md, "Projects (tabs)".
diff --git a/docs/hosted-team-relay.md b/docs/hosted-team-relay.md
index 3b05de899..faf7e7351 100644
--- a/docs/hosted-team-relay.md
+++ b/docs/hosted-team-relay.md
@@ -798,9 +798,6 @@ it is a new way to use it.
client's baseline and is never cast, so on a governed project it never reaches disk: every load
derives it again. The repairs are deterministic, so this costs nothing visible, but a repair that
must persist on a shared project has to be cast.
-- **The card modal's comments on a relay tab** (`BoardLogPanel`) still read and write the local core's
- board log, not the host's, because the modal renders outside the tab's session. This predates the
- authority; it is a follow-up.
## Status and troubleshooting
diff --git a/src/renderer/components/kanban/BoardLogPanel.tsx b/src/renderer/components/kanban/BoardLogPanel.tsx
index aac8b4959..1a30c8270 100644
--- a/src/renderer/components/kanban/BoardLogPanel.tsx
+++ b/src/renderer/components/kanban/BoardLogPanel.tsx
@@ -9,6 +9,7 @@ import {
} from '@shared/board-comment'
import { formatTimeAgo } from '../../lib/usageFormat'
import { useSession } from '../../session/session'
+import { useOwningProjectId } from '../../session/owning-project'
import { useProjects } from '../../state/projects'
import { useBoardLog } from '../../state/boardLog'
import { useBoardCommentDelivery } from '../../state/boardCommentDelivery'
@@ -135,9 +136,13 @@ function formatStamp(ts: number): string {
}
/** Right panel of the card modal (all card kinds): a composer on top and the card's own
- * comments + activity feed newest-first. Reads/writes the board log for the ACTIVE project via
- * its session api — resolved here (not threaded from Canvas). Subscribes on mount, so a teammate's
- * comment or a board change lands live; unsubscribes on unmount / card swap.
+ * comments + activity feed newest-first. Reads/writes the board log of the project that OWNS the
+ * card (`OwningProjectContext`: the card's project under the card modal's `ProjectSessionScope`,
+ * the store-held project on the canvas), falling back to the active project, through the session
+ * api resolved for that same project. Keying it on the active project paired an Omni lane's api
+ * with another project's id: the lane's comments read blank and a comment typed there was saved
+ * nowhere. Subscribes on mount, so a teammate's comment or a board change lands live;
+ * unsubscribes on unmount / card swap.
*
* A comment that @mentions a session (the composer's @ picker) is also delivered to that agent —
* ONLY from this composer's send, with the text just typed, and only in the desktop app's own
@@ -145,7 +150,9 @@ function formatStamp(ts: number): string {
* instance, a relay peer, a team-presence guest) renders its mentions and types nowhere. */
export function BoardLogPanel({ card, title, readOnly, emptyText, mentionables }: BoardLogPanelProps) {
const { api, source } = useSession()
- const projectId = useProjects((s) => s.activeProjectId)
+ const owningProjectId = useOwningProjectId()
+ const activeProjectId = useProjects((s) => s.activeProjectId)
+ const projectId = owningProjectId ?? activeProjectId
const entries = useBoardLog((s) => s.entriesFor(projectId))
const unsupported = useBoardLog((s) => !!s.unsupportedByProject[projectId])
const error = useBoardLog((s) => !!s.errorByProject[projectId])
diff --git a/src/renderer/components/kanban/CardMetaBar.tsx b/src/renderer/components/kanban/CardMetaBar.tsx
index 02e81fe2b..72bcb3366 100644
--- a/src/renderer/components/kanban/CardMetaBar.tsx
+++ b/src/renderer/components/kanban/CardMetaBar.tsx
@@ -8,6 +8,7 @@ import { useShallow } from 'zustand/react/shallow'
import { loadIdentity, selectFaces, usePresence } from '../../state/presence'
import { useBoardLog } from '../../state/boardLog'
import { useProjects } from '../../state/projects'
+import { useOwningProjectId } from '../../session/owning-project'
const initialOf = (name: string): string => (name.trim()[0] ?? '?').toUpperCase()
@@ -39,7 +40,11 @@ export function CardMetaBar({ nodeId, board, onChange }: CardMetaBarProps) {
const [labelsOpen, setLabelsOpen] = useState(false)
const meta = cardMeta(board, nodeId)
const labels = labelsForCard(board, nodeId)
- const projectId = useProjects((s) => s.activeProjectId)
+ // The card's own project (the modal's ProjectSessionScope), else the active one — the same id
+ // BoardLogPanel keys the log on, so the member pool reads the log the panel shows.
+ const owningProjectId = useOwningProjectId()
+ const activeProjectId = useProjects((s) => s.activeProjectId)
+ const projectId = owningProjectId ?? activeProjectId
const logEntries = useBoardLog((s) => s.entriesFor(projectId))
// selectFaces + useShallow, NOT selectOthers: the pool only needs name+color, and applyDiff
// replaces the whole PeerState on every cursor patch (~20/s per peer) — subscribing to
diff --git a/src/renderer/components/kanban/CardPullRequests.tsx b/src/renderer/components/kanban/CardPullRequests.tsx
index a203e9032..0b27f26ce 100644
--- a/src/renderer/components/kanban/CardPullRequests.tsx
+++ b/src/renderer/components/kanban/CardPullRequests.tsx
@@ -9,6 +9,7 @@ import {
unlinkPull
} from '@shared/kanban-pull-links'
import { useProjects } from '../../state/projects'
+import { useOwningProjectId } from '../../session/owning-project'
import { useGitHubIssues } from '../../state/githubIssues'
import { useSettings } from '../../state/settings'
import { pullsForCard } from '../../lib/pullLinks'
@@ -35,8 +36,13 @@ export function CardPullRequests({
board: ProjectKanban
onChangeBoard: (next: ProjectKanban) => void
}): React.JSX.Element | null {
- const projectId = useProjects((state) => state.activeProjectId)
- const ssh = useProjects((state) => !!state.projects.find((item) => item.id === state.activeProjectId)?.ssh)
+ // The project that owns `board` — the card's project under the modal's ProjectSessionScope (an
+ // Omni lane is not the active project), else the active one. Its pull board, SSH flag and
+ // auto-move target must all describe that same project.
+ const owningProjectId = useOwningProjectId()
+ const activeProjectId = useProjects((state) => state.activeProjectId)
+ const projectId = owningProjectId ?? activeProjectId
+ const ssh = useProjects((state) => !!state.projects.find((item) => item.id === projectId)?.ssh)
const pullBoard = useGitHubIssues((state) => state.projects[projectId]?.pullBoard)
const autoMoveRaw = useSettings((state) => state.settings.kanbanPullAutoMove)
const target = useMemo(() => {
diff --git a/src/renderer/components/kanban/ModalTerminal.tsx b/src/renderer/components/kanban/ModalTerminal.tsx
index 9adffa052..76060199f 100644
--- a/src/renderer/components/kanban/ModalTerminal.tsx
+++ b/src/renderer/components/kanban/ModalTerminal.tsx
@@ -21,7 +21,7 @@ import { FindBar } from '../FindBar'
import { useAgentStatus } from '../../state/agentStatus'
import { useProjects } from '../../state/projects'
import { useSession } from '../../session/session'
-import { spawnBelongsElsewhere, useOwningProjectId } from '../../session/owning-project'
+import { REMOTE_PROJECT_SPAWN_REFUSAL, spawnBelongsElsewhere, useOwningProjectId } from '../../session/owning-project'
import { isHostedReadOnly } from '../../state/hostedTeams'
import { useSettings } from '../../state/settings'
import { isMacPlatform, isWindowsPlatform } from '@shared/platform-utils'
@@ -510,7 +510,7 @@ export function ModalTerminal({
const owner = owningProjectRef.current
if (spawnBelongsElsewhere(useProjects.getState().getProject(owner ?? ''), session.source)) {
term.write(
- '\r\n\x1b[90m[this terminal belongs to a remote project that is not connected here — nothing was started on this machine]\x1b[0m\r\n'
+ `\r\n\x1b[90m${REMOTE_PROJECT_SPAWN_REFUSAL}\x1b[0m\r\n`
)
return
}
diff --git a/src/renderer/components/kanban/boardLogPanelSession.test.tsx b/src/renderer/components/kanban/boardLogPanelSession.test.tsx
new file mode 100644
index 000000000..a4f51603f
--- /dev/null
+++ b/src/renderer/components/kanban/boardLogPanelSession.test.tsx
@@ -0,0 +1,130 @@
+// @vitest-environment jsdom
+//
+// The card modal's comments panel must read and write the board log of the CARD's project, over
+// that project's session. On the Omni board a lane's card modal runs under the lane project's
+// session (ProjectSessionScope), but the panel used to key the log on the ACTIVE project: it asked
+// the lane's core for the active project's log (blank, "unsupported" on a relay), and a comment
+// typed there was inserted optimistically, appended to a project the lane's core does not know,
+// answered false and persisted nowhere. This renders the REAL panel under a real
+// ProjectSessionScope for a lane project that is not the active one.
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import type { NodeTerminalApi, Project } from '@shared/types'
+import { BoardLogPanel } from './BoardLogPanel'
+import { useBoardLog } from '../../state/boardLog'
+import { useProjects } from '../../state/projects'
+import { ProjectSessionScope } from '../../session/owning-project'
+import {
+ bindProjectToSession,
+ createSession,
+ resetSessionsForTest,
+ SessionProvider,
+ setActiveSession,
+ type WorkspaceSession
+} from '../../session/session'
+
+const ACTIVE = 'p-active'
+const LANE = 'p-lane'
+
+function fakeBoardLogApi() {
+ return {
+ boardLog: {
+ read: vi.fn(async () => ({ entries: [] })),
+ append: vi.fn(async () => true),
+ onChanged: vi.fn(() => () => {})
+ }
+ }
+}
+
+let root: Root | null = null
+let host: HTMLElement
+let local: WorkspaceSession
+let relay: WorkspaceSession
+let localApi: ReturnType<typeof fakeBoardLogApi>
+let laneApi: ReturnType<typeof fakeBoardLogApi>
+
+const project = (id: string, remote = false): Project =>
+ ({ id, name: id, color: '#7aa2f7', viewport: { x: 0, y: 0, zoom: 1 }, nodes: [], ...(remote ? { remote: true } : {}) }) as unknown as Project
+
+beforeEach(() => {
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
+ resetSessionsForTest()
+ localApi = fakeBoardLogApi()
+ laneApi = fakeBoardLogApi()
+ local = createSession('local', localApi as unknown as NodeTerminalApi, 'This computer')
+ setActiveSession(local.id)
+ relay = createSession('relay', laneApi as unknown as NodeTerminalApi, 'Team')
+ useProjects.setState({ projects: [project(ACTIVE), project(LANE, true)], activeProjectId: ACTIVE } as never)
+ bindProjectToSession(LANE, relay.id)
+ useBoardLog.setState({ entriesByProject: {}, unsupportedByProject: {}, errorByProject: {} } as never)
+})
+afterEach(() => {
+ if (root) act(() => root!.unmount())
+ root = null
+ host?.remove()
+ document.body.innerHTML = ''
+ resetSessionsForTest()
+ vi.unstubAllGlobals()
+})
+
+const flush = () => act(async () => {
+ await new Promise((r) => setTimeout(r, 0))
+})
+
+async function renderLaneModalPanel(): Promise<void> {
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ // Under App's LOCAL provider, as both boards are; the modal is scoped to the lane's project.
+ await act(async () => {
+ root!.render(
+ <SessionProvider session={local}>
+ <ProjectSessionScope projectId={LANE}>
+ <BoardLogPanel card={{ id: 'n-lane' }} />
+ </ProjectSessionScope>
+ </SessionProvider>
+ )
+ })
+ await flush()
+}
+
+async function typeAndSend(value: string): Promise<void> {
+ const ta = host.querySelector('textarea') as HTMLTextAreaElement
+ const setter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')!.set!
+ await act(async () => {
+ setter.call(ta, value)
+ ta.setSelectionRange(value.length, value.length)
+ ta.dispatchEvent(new Event('input', { bubbles: true }))
+ })
+ await act(async () => {
+ ta.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))
+ })
+ await flush()
+}
+
+describe('the card modal comments panel uses the card project, not the active one', () => {
+ it('reads and subscribes to the lane project\'s log on the lane\'s api', async () => {
+ await renderLaneModalPanel()
+ expect(laneApi.boardLog.read).toHaveBeenCalledWith(LANE)
+ expect(laneApi.boardLog.onChanged).toHaveBeenCalledWith(LANE, expect.any(Function))
+ expect(laneApi.boardLog.read).not.toHaveBeenCalledWith(ACTIVE)
+ // This machine's core is never asked about the lane's card.
+ expect(localApi.boardLog.read).not.toHaveBeenCalled()
+ expect(localApi.boardLog.onChanged).not.toHaveBeenCalled()
+ })
+
+ it('appends a typed comment to the lane project on the lane\'s api', async () => {
+ await renderLaneModalPanel()
+ await typeAndSend('hello lane')
+ expect(laneApi.boardLog.append).toHaveBeenCalledTimes(1)
+ expect(laneApi.boardLog.append).toHaveBeenCalledWith(
+ LANE,
+ expect.objectContaining({ kind: 'comment', nodeId: 'n-lane', text: 'hello lane' })
+ )
+ expect(localApi.boardLog.append).not.toHaveBeenCalled()
+ // The optimistic entry is filed under the lane project, where the panel reads it back.
+ expect(useBoardLog.getState().entriesFor(LANE).map((e) => e.text)).toEqual(['hello lane'])
+ expect(useBoardLog.getState().entriesFor(ACTIVE)).toEqual([])
+ })
+})
diff --git a/src/renderer/components/kanban/cardModalSession.test.tsx b/src/renderer/components/kanban/cardModalSession.test.tsx
index e7033efb0..df087b26e 100644
--- a/src/renderer/components/kanban/cardModalSession.test.tsx
+++ b/src/renderer/components/kanban/cardModalSession.test.tsx
@@ -20,6 +20,7 @@ import { join } from 'node:path'
import type { CanvasNodeState, NodeTerminalApi, Project, ProjectKanban } from '@shared/types'
import { KanbanView, type KanbanSession } from './KanbanView'
import { GlobalKanbanView } from './GlobalKanbanView'
+import { REMOTE_PROJECT_SPAWN_REFUSAL } from '../../session/owning-project'
import { useProjects } from '../../state/projects'
import { useViewMode } from '../../state/viewMode'
import {
@@ -145,8 +146,20 @@ describe('the Omni board mounts each lane\'s card modal under THAT lane\'s sessi
// ── Source pins (F2c, F4): TerminalNode and ModalTerminal have no render harness ─────────────────
const read = (rel: string): string => readFileSync(join(__dirname, rel), 'utf8').replace(/\r\n/g, '\n')
-const REFUSAL =
- '[this terminal belongs to a remote project that is not connected here — nothing was started on this machine]'
+// Both terminals print the ONE exported refusal; the pins below find its use, not a retyped copy.
+const REFUSAL = '${REMOTE_PROJECT_SPAWN_REFUSAL}'
+
+describe('the refusal line is one constant', () => {
+ it('names that nothing was started here, and no terminal retypes it', () => {
+ expect(REMOTE_PROJECT_SPAWN_REFUSAL).toContain('remote project that is not connected here')
+ expect(REMOTE_PROJECT_SPAWN_REFUSAL).toContain('nothing was started on this machine')
+ for (const rel of ['../../nodes/TerminalNode.tsx', 'ModalTerminal.tsx']) {
+ const src = read(rel)
+ expect(src).toContain('import { REMOTE_PROJECT_SPAWN_REFUSAL,')
+ expect(src).not.toContain('nothing was started on this machine')
+ }
+ })
+})
describe('both terminals refuse to spawn locally for a remote project (F2c)', () => {
it('TerminalNode asks spawnBelongsElsewhere after the noSpawn return, before any SSH resolve or create', () => {
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index f3d0e3023..3dd05b2f0 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -356,7 +356,7 @@ import { applyIconChoice } from '../lib/nodeIconChoice'
import { normalizeNodeIcon } from '@shared/node-icon'
import { connectHostAttachment } from '../lib/sshAttachments'
import { projectMayDialSsh } from '../session/relay-ssh'
-import { spawnBelongsElsewhere, useOwningProjectId } from '../session/owning-project'
+import { REMOTE_PROJECT_SPAWN_REFUSAL, spawnBelongsElsewhere, useOwningProjectId } from '../session/owning-project'
import { waitForSshRemote } from '../lib/sshRemoteWait'
/** Which physical modifier the registry's abstract `Cmd` resolves to for the find-bar chord. */
@@ -3586,7 +3586,7 @@ export function TerminalNode({
// offline relay session, so this is the last line: start nothing, before any SSH resolve.
if (spawnBelongsElsewhere(useProjects.getState().getProject(owningProjectRef.current ?? ''), session.source)) {
term.write(
- '\r\n\x1b[90m[this terminal belongs to a remote project that is not connected here — nothing was started on this machine]\x1b[0m\r\n'
+ `\r\n\x1b[90m${REMOTE_PROJECT_SPAWN_REFUSAL}\x1b[0m\r\n`
)
return
}
diff --git a/src/renderer/session/owning-project.ts b/src/renderer/session/owning-project.ts
index 170b79ca9..4ebbc50e1 100644
--- a/src/renderer/session/owning-project.ts
+++ b/src/renderer/session/owning-project.ts
@@ -19,6 +19,11 @@ export function useOwningProjectId(): string | null {
return useContext(OwningProjectContext)
}
+/** What a terminal prints (in gray) when `spawnBelongsElsewhere` refuses its spawn — ONE wording
+ * for the canvas node and the card modal, so the two surfaces cannot say different things. */
+export const REMOTE_PROJECT_SPAWN_REFUSAL =
+ '[this terminal belongs to a remote project that is not connected here — nothing was started on this machine]'
+
/**
* True when a spawn for a node of `project` would land on the wrong core: the project lives on
* another machine (`remote`, a hosted team / relay tab) but the session the node runs under is not