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.

Merge remote-tracking branch 'origin/feat/session-abstraction'

enes9df1665c7a38
diff --cc src/renderer/canvas/Canvas.tsx
index 8028925ff,400a7d5d2..f4437a3b4
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@@ -132,7 -131,8 +132,8 @@@ import
import { relativeTime } from '../lib/relativeTime'
import { AgentIcon } from '../lib/agentIcons'
import { branchClaudeSession } from '../lib/claudeBranch'
+ import { useSession } from '../session/session'
-import { buildContextLinkNote, buildLinkMap, buildNotePushMessage, classifyLink, type LinkEndpoint } from '../lib/noteLink'
+import { buildBackgroundLinkMaps, buildContextLinkNote, buildLinkMap, buildNotePushMessage, classifyLink, type LinkEndpoint } from '../lib/noteLink'
import { useSettings } from '../state/settings'
import { activePermissionMode } from '../state/permissionMode'
import { useRemoteHosting } from '../state/remoteHosting'
@@@ -1116,14 -1040,11 +1120,14 @@@ export function Canvas()
})
}, [reloadActiveProject])
- // One-shot note after a v2→v3 on-disk migration (dismissible, non-blocking strip).
+ // One-shot note after an on-disk migration (dismissible, non-blocking strip). Both kinds change
+ // where the user's data lives, so neither may happen silently.
useEffect(() => {
- return window.nodeTerminal.workspace.onMigrated((kind) => {
- return api.workspace.onMigrated(() => {
++ return api.workspace.onMigrated((kind) => {
setMigrationNote(
- 'Projects now live in a .nodeterm folder inside each project directory — commit it to share the canvas, or add it to .gitignore.'
+ kind === 'exec'
+ ? 'Custom shells and advanced SSH options (e.g. a ProxyCommand jump host) are no longer stored in the shared .nodeterm/project.json — a cloned repo could use them to run code. They still work here: they moved to this machine only, and your teammates no longer receive them.'
+ : 'Projects now live in a .nodeterm folder inside each project directory — commit it to share the canvas, or add it to .gitignore.'
)
})
}, [])
@@@ -2652,50 -2554,21 +2656,50 @@@
// Ask-first worktree removal. Gather any uncommitted-work info, then open a safety dialog
// before doing anything destructive. GitStatus has no `files` field — the dirty count is
// staged + unstaged changes.
- const requestRemoveWorktree = useCallback(async (groupId: string) => {
- const wt = nodesRef.current.find((n) => n.id === groupId)?.data.worktree
- if (!wt) return
- // The probe is a courtesy (it only enriches the warning), so a rejected IPC (WS-RPC transport
- // error on the Server Edition) must not swallow the whole action: without this catch the dialog
- // silently never opens and Remove looks broken. Fail open — ask without the dirty-file count.
- const status = await api.git.status(wt.path).catch(() => null)
- const dirtyCount = (status?.staged.length ?? 0) + (status?.changes.length ?? 0)
- const warning = dirtyCount > 0 ? `${dirtyCount} uncommitted file(s) in the worktree.` : ''
- // A worktree the user created outside nodeterm is not ours to delete: Unbind is the default
- // and deleting it from disk is an opt-in checkbox. One we created may be deleted (still behind
- // the confirm).
- setDeleteFromDisk(wt.createdByApp)
- setRemoveTarget({ groupId, warning, canDelete: wt.createdByApp })
- }, [])
+ const requestRemoveWorktree = useCallback(
+ async (
+ groupId: string,
+ opts?: { requestedBy?: string }
+ ): Promise<{ ok: boolean; error?: string }> => {
+ // One confirm at a time — for EVERY caller, not just the agent one. Two rapid requests used
+ // to swap `removeTarget` under an open dialog (the user reads worktree A, approves the
+ // deletion of worktree B), and an unrelated confirm stacked on top of this one used to make
+ // it invisible while still live (see `confirmOpenRef`). Refuse instead.
+ if (confirmBusy()) return { ok: false, error: 'a confirmation is already pending — try again' }
+ const wt = nodesRef.current.find((n) => n.id === groupId)?.data.worktree
+ if (!wt) return { ok: false, error: `${groupId} is not a worktree-bound group` }
+ // Held across the `await` below: without it a second call slips through the gap before
+ // `removeTarget` exists.
+ removePendingRef.current = true
+ try {
+ // The probe is a courtesy (it only enriches the warning), so a rejected IPC (WS-RPC
+ // transport error on the Server Edition) must not swallow the whole action: without this
+ // catch the dialog silently never opens and Remove looks broken. Fail open — ask without
+ // the dirty-file count.
- const status = await window.nodeTerminal.git.status(wt.path).catch(() => null)
++ const status = await api.git.status(wt.path).catch(() => null)
+ const dirtyCount = (status?.staged.length ?? 0) + (status?.changes.length ?? 0)
+ const warning = dirtyCount > 0 ? `${dirtyCount} uncommitted file(s) in the worktree.` : ''
+ // A worktree the user created outside nodeterm is not ours to delete: Unbind is the default
+ // and deleting it from disk is an opt-in checkbox. One we created may be deleted (still
+ // behind the confirm).
+ setDeleteFromDisk(wt.createdByApp)
+ setRemoveTarget({
+ groupId,
+ warning,
+ canDelete: wt.createdByApp,
+ branch: wt.branch,
+ path: wt.path,
+ requestedBy: opts?.requestedBy
+ })
+ return { ok: true }
+ } catch (e) {
+ // Nothing opened → nothing is pending. Never leave the guard latched.
+ removePendingRef.current = false
+ return { ok: false, error: e instanceof Error ? e.message : String(e) }
+ }
+ },
+ [confirmBusy]
+ )
/** Clear a group's worktree binding and re-read git's facts (the worktree, if it still exists,
* becomes an orphan the dialog can offer again). The one place a binding is dropped. */
@@@ -3769,18 -3634,13 +3773,18 @@@
// reply on BOTH confirm and cancel. Every path replies EXACTLY ONCE so the awaiting CLI call in
// main never hangs to its 120s timeout.
useEffect(() => {
- return window.nodeTerminal.onAgentControl(async ({ requestId, sourceNodeId, verb, args }) => {
+ return api.onAgentControl(async ({ requestId, sourceNodeId, verb, args }) => {
const reply = (r: { ok: boolean; message?: string; result?: unknown; error?: string }) =>
- window.nodeTerminal.sendAgentControlResult({ requestId, ...r })
+ api.sendAgentControlResult({ requestId, ...r })
// Authorization boundary: the source must be a live, control-capable agent node.
+ // The `?? 'claude'` MIRRORS pty-manager's spawn-time default (`options.agentId ?? 'claude'`):
+ // a PLAIN terminal node (no agentId — including the account "Claude login" node) received
+ // the claude hook env at spawn, so a manual `claude` there holds NODETERM_CANVAS_CONTROL —
+ // rejecting it here contradicted the env it was handed and surfaced as a baffling
+ // "not a control-capable agent" from a session that plainly runs claude.
const src = nodesRef.current.find((n) => n.id === sourceNodeId)
- if (!src || !canControlCanvas((src.data.agentId as AgentId | undefined) ?? '')) {
+ if (!src || !canControlCanvas((src.data.agentId as AgentId | undefined) ?? 'claude')) {
reply({ ok: false, error: 'source node is not a control-capable agent' })
return
}