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.

feat(accounts): account pickers in menus, palette, dock + project default

enes36d289fb53f6
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 6ebc2b71b..5a48ed05f 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -135,6 +135,7 @@ import {
nodeStatesToFlow,
reorderNodeBefore,
reparentNode,
+ resolveNewNodeAccount,
ungroupNodes,
type CanvasNode
} from '../state/workspace'
@@ -1219,8 +1220,16 @@ export function Canvas() {
/** Open a Claude node seeded with a commit-explanation prompt. */
const explainCommit = useCallback(
(prompt: string) => {
- const cwd = useProjects.getState().getProject(activeProjectId)?.cwd
- setNodes((ns) => [...ns, createAgentNode('claude', ns.length, cwd, viewCenter(), prompt)])
+ const project = useProjects.getState().getProject(activeProjectId)
+ const account = resolveNewNodeAccount(
+ undefined,
+ project,
+ useSettings.getState().settings.claudeAccounts
+ )
+ setNodes((ns) => [
+ ...ns,
+ createAgentNode('claude', ns.length, project?.cwd, viewCenter(), prompt, undefined, account)
+ ])
markDirty()
},
[setNodes, markDirty, activeProjectId, viewCenter]
@@ -1287,9 +1296,17 @@ export function Canvas() {
)
const addChatNode = useCallback(
- (center?: { x: number; y: number }) => {
- const cwd = useProjects.getState().getProject(activeProjectId)?.cwd
- setNodes((ns) => [...ns, createChatNode(ns.length, cwd, center ?? viewCenter())])
+ (center?: { x: number; y: number }, accountId?: string) => {
+ const project = useProjects.getState().getProject(activeProjectId)
+ const account = resolveNewNodeAccount(
+ accountId,
+ project,
+ useSettings.getState().settings.claudeAccounts
+ )
+ setNodes((ns) => [
+ ...ns,
+ createChatNode(ns.length, project?.cwd, center ?? viewCenter(), undefined, account)
+ ])
markDirty()
},
[setNodes, markDirty, activeProjectId, viewCenter]
@@ -1371,11 +1388,26 @@ export function Canvas() {
}, [setNodes, markDirty])
const addAgentNode = useCallback(
- (agentId: AgentId, center?: { x: number; y: number }, groupId?: string) => {
+ (agentId: AgentId, center?: { x: number; y: number }, groupId?: string, accountId?: string) => {
const project = useProjects.getState().getProject(activeProjectId)
const cwd = cwdForNewNodeIn(groupId) ?? project?.cwd
+ // Funnel through resolveNewNodeAccount so the project default applies even without an
+ // explicit pick. The factory drops the account for non-claude agents.
+ const account = resolveNewNodeAccount(
+ accountId,
+ project,
+ useSettings.getState().settings.claudeAccounts
+ )
setNodes((ns) => {
- const node = createAgentNode(agentId, ns.length, cwd, center ?? viewCenter(), undefined, project?.ssh)
+ const node = createAgentNode(
+ agentId,
+ ns.length,
+ cwd,
+ center ?? viewCenter(),
+ undefined,
+ project?.ssh,
+ account
+ )
return [...ns, groupId ? parentInto(node, groupId) : node]
})
markDirty()
@@ -2072,18 +2104,40 @@ export function Canvas() {
e.preventDefault()
const at = screenToFlowPosition({ x: e.clientX, y: e.clientY })
const disabled = useSettings.getState().settings.disabledAgents
+ // Local, logged-in accounts only (pending logins + remote/host accounts are excluded).
+ const accounts = useSettings
+ .getState()
+ .settings.claudeAccounts.filter((a) => !a.pending && !a.host)
setMenu({
x: e.clientX,
y: e.clientY,
items: [
{ label: 'New terminal', icon: <IconTerminal />, onClick: () => addTerminal(at) },
- ...BUILTIN_AGENT_IDS.filter((aid) => !disabled.includes(aid)).map(
- (aid): MenuItem => ({
+ ...BUILTIN_AGENT_IDS.filter((aid) => !disabled.includes(aid)).map((aid): MenuItem => {
+ // Claude gets an account picker submenu when ≥1 account exists; System = project
+ // default (resolved). Other agents stay flat (accounts are Claude-only).
+ if (aid === 'claude' && accounts.length > 0) {
+ return {
+ type: 'submenu',
+ label: `New ${AGENT_CONFIG[aid].label}`,
+ icon: <AgentIcon agentId={aid} />,
+ children: [
+ { label: 'System account', onClick: () => addAgentNode('claude', at) },
+ ...accounts.map(
+ (a): MenuItem => ({
+ label: a.label,
+ onClick: () => addAgentNode('claude', at, undefined, a.id)
+ })
+ )
+ ]
+ }
+ }
+ return {
label: `New ${AGENT_CONFIG[aid].label}`,
icon: <AgentIcon agentId={aid} />,
onClick: () => addAgentNode(aid, at)
- })
- ),
+ }
+ }),
...useSettings
.getState()
.settings.customAgents.filter((c) => !disabled.includes(c.id))
@@ -2094,7 +2148,22 @@ export function Canvas() {
onClick: () => addAgentNode(c.id, at)
})
),
- { label: 'New chat', icon: <IconChat />, onClick: () => addChatNode(at) },
+ accounts.length > 0
+ ? {
+ type: 'submenu',
+ label: 'New chat',
+ icon: <IconChat />,
+ children: [
+ { label: 'System account', onClick: () => addChatNode(at) },
+ ...accounts.map(
+ (a): MenuItem => ({
+ label: a.label,
+ onClick: () => addChatNode(at, a.id)
+ })
+ )
+ ]
+ }
+ : { label: 'New chat', icon: <IconChat />, onClick: () => addChatNode(at) },
{ label: 'New browser', icon: <IconRemote />, onClick: () => addBrowser(at) },
{ label: 'New sticky note', icon: <IconNote />, onClick: () => addSticky(at) },
{ label: 'New dino game', icon: <IconDino />, onClick: () => addDino(at) },
@@ -2934,6 +3003,14 @@ export function Canvas() {
[persist]
)
+ const setProjectDefaultAccount = useCallback(
+ (id: string, accountId: string | undefined) => {
+ useProjects.getState().setProjectDefaultAccount(id, accountId)
+ void persist()
+ },
+ [persist]
+ )
+
// Close a project: hide it from the tab bar but keep it (and its tmux/agent sessions) intact
// so it can be reopened later from the start screen. Non-destructive — the inverse of the old
// "Delete project". Switching away unmounts its nodes (a detach, not a kill); the sessions
@@ -3036,6 +3113,19 @@ export function Canvas() {
run: () => addAgentNode(c.id)
})
),
+ // One "New Claude — <label>" per logged-in local account. Plain "New Claude" above uses
+ // the resolved project default; these pin a specific account.
+ ...useSettings
+ .getState()
+ .settings.claudeAccounts.filter((a) => !a.pending && !a.host)
+ .map(
+ (a): Command => ({
+ id: `new-claude-${a.id}`,
+ label: `New Claude — ${a.label}`,
+ icon: <AgentIcon agentId="claude" />,
+ run: () => addAgentNode('claude', undefined, undefined, a.id)
+ })
+ ),
{ id: 'new-chat', label: 'New chat', icon: <IconChat />, run: () => addChatNode() },
{ id: 'new-sticky', label: 'New sticky note', icon: <IconNote />, run: () => addSticky() },
{ id: 'new-dino', label: 'New dino game', icon: <IconDino />, run: () => addDino() },
@@ -3147,6 +3237,7 @@ export function Canvas() {
onSetFolder={setProjectFolder}
onCloseProject={closeProject}
onRemoteAccess={() => setRemoteDialogOpen(true)}
+ onSetDefaultAccount={setProjectDefaultAccount}
/>
<div className="top-banners">
@@ -3518,7 +3609,7 @@ export function Canvas() {
onAddTerminal={addTerminal}
onAddSticky={addSticky}
onAddDino={addDino}
- onAddAgent={(aid) => addAgentNode(aid)}
+ onAddAgent={(aid, accountId) => addAgentNode(aid, undefined, undefined, accountId)}
onAddChat={() => addChatNode()}
onOpenFile={() => void openFileDialog()}
onAddRemote={() => openRemotePicker({ x: window.innerWidth / 2, y: window.innerHeight / 2 })}
diff --git a/src/renderer/components/ContextMenu.tsx b/src/renderer/components/ContextMenu.tsx
index 8ed6c1092..2cb268dbd 100644
--- a/src/renderer/components/ContextMenu.tsx
+++ b/src/renderer/components/ContextMenu.tsx
@@ -1,4 +1,4 @@
-import type { ReactNode } from 'react'
+import { useState, type ReactNode } from 'react'
import { createPortal } from 'react-dom'
import { NODE_COLORS } from '../state/workspace'
@@ -14,6 +14,7 @@ export type MenuItem =
| { type: 'separator' }
| { type: 'label'; label: string }
| { type: 'colors'; onPick: (color: string) => void }
+ | { type: 'submenu'; label: string; icon?: ReactNode; children: MenuItem[] }
interface ContextMenuProps {
x: number
@@ -36,6 +37,8 @@ export function ContextMenu({ x, y, items, onClose, zIndex }: ContextMenuProps)
// Keep the menu one above its backdrop (matches the default 46/45 CSS ordering).
const backdropStyle = zIndex != null ? { zIndex } : undefined
const menuStyle = zIndex != null ? { top: y, left: x, zIndex: zIndex + 1 } : { top: y, left: x }
+ // Index of the row whose submenu flyout is currently open (hover-driven).
+ const [openSub, setOpenSub] = useState<number | null>(null)
return createPortal(
<>
<div
@@ -64,6 +67,43 @@ export function ContextMenu({ x, y, items, onClose, zIndex }: ContextMenuProps)
</div>
)
}
+ if (item.type === 'submenu') {
+ return (
+ <div
+ key={i}
+ className="ctx-item ctx-item--submenu"
+ onMouseEnter={() => setOpenSub(i)}
+ onMouseLeave={() => setOpenSub((cur) => (cur === i ? null : cur))}
+ >
+ <span className="ctx-icon">{item.icon}</span>
+ {item.label}
+ {openSub === i && (
+ <div className="ctx-menu ctx-submenu" onClick={(e) => e.stopPropagation()}>
+ {item.children.map((child, j) => {
+ if (child.type === 'separator') return <div key={j} className="ctx-sep" />
+ if (child.type === 'label')
+ return <div key={j} className="ctx-label">{child.label}</div>
+ if (child.type === 'colors' || child.type === 'submenu') return null
+ return (
+ <button
+ key={j}
+ className={`ctx-item${child.danger ? ' danger' : ''}`}
+ disabled={child.disabled}
+ onClick={() => {
+ child.onClick()
+ onClose()
+ }}
+ >
+ <span className="ctx-icon">{child.icon}</span>
+ {child.label}
+ </button>
+ )
+ })}
+ </div>
+ )}
+ </div>
+ )
+ }
return (
<button
key={i}
diff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsx
index 6ddaf15dc..e46695a91 100644
--- a/src/renderer/components/Dock.tsx
+++ b/src/renderer/components/Dock.tsx
@@ -11,7 +11,7 @@ interface DockProps {
onAddTerminal: () => void
onAddSticky: () => void
onAddDino: () => void
- onAddAgent: (agentId: AgentId) => void
+ onAddAgent: (agentId: AgentId, accountId?: string) => void
onAddChat: () => void
onOpenFile: () => void
onAddRemote: () => void
@@ -51,6 +51,10 @@ export function Dock({
const [menuOpen, setMenuOpen] = useState(false)
const customAgents = useSettings((s) => s.settings.customAgents)
const disabledAgents = useSettings((s) => s.settings.disabledAgents)
+ const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)
+ // Local, logged-in accounts only. The flat dock menu can't nest, so Claude gets one
+ // "New Claude — <label>" entry per account (plus the base "Claude" = project default).
+ const localAccounts = claudeAccounts.filter((a) => !a.pending && !a.host)
const pick = (fn: () => void) => () => {
fn()
@@ -72,12 +76,25 @@ export function Dock({
<TerminalIcon />
<span>Remote…</span>
</button>
- {BUILTIN_AGENT_IDS.filter((aid) => !disabledAgents.includes(aid)).map((aid) => (
- <button key={aid} onClick={pick(() => onAddAgent(aid))}>
- <AgentIcon agentId={aid} size={18} />
- <span>{AGENT_CONFIG[aid].label}</span>
- </button>
- ))}
+ {BUILTIN_AGENT_IDS.filter((aid) => !disabledAgents.includes(aid)).flatMap((aid) => {
+ const base = (
+ <button key={aid} onClick={pick(() => onAddAgent(aid))}>
+ <AgentIcon agentId={aid} size={18} />
+ <span>{AGENT_CONFIG[aid].label}</span>
+ </button>
+ )
+ // Claude picks up one flat entry per logged-in local account (dock can't nest).
+ if (aid !== 'claude' || localAccounts.length === 0) return [base]
+ return [
+ base,
+ ...localAccounts.map((a) => (
+ <button key={`${aid}-${a.id}`} onClick={pick(() => onAddAgent(aid, a.id))}>
+ <AgentIcon agentId={aid} size={18} />
+ <span>Claude — {a.label}</span>
+ </button>
+ ))
+ ]
+ })}
{customAgents
.filter((c) => !disabledAgents.includes(c.id))
.map((c) => (
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsx
index d025b4e0c..bbf435a47 100644
--- a/src/renderer/components/TabBar.tsx
+++ b/src/renderer/components/TabBar.tsx
@@ -2,6 +2,7 @@ import { useMemo, useState } from 'react'
import { createPortal } from 'react-dom'
import { useProjects } from '../state/projects'
import { useAgentStatus } from '../state/agentStatus'
+import { useSettings } from '../state/settings'
interface TabBarProps {
onSwitch: (id: string) => void
@@ -13,6 +14,8 @@ interface TabBarProps {
onCloseProject: (id: string) => void
/** Open the Remote access dialog (host/share + connect). Shown for every project. */
onRemoteAccess: () => void
+ /** Set (or clear, with undefined) the project's default Claude account for new nodes. */
+ onSetDefaultAccount: (id: string, accountId: string | undefined) => void
}
/**
@@ -27,7 +30,8 @@ export function TabBar({
onRename,
onSetFolder,
onCloseProject,
- onRemoteAccess
+ onRemoteAccess,
+ onSetDefaultAccount
}: TabBarProps) {
// Select the raw array and filter in a memo — a `.filter()` inside the selector returns a
// fresh array every store snapshot, which re-rendered the TabBar on EVERY projects change.
@@ -47,12 +51,21 @@ export function TabBar({
const [menuPos, setMenuPos] = useState<{ top: number; left: number } | null>(null)
const [editingId, setEditingId] = useState<string | null>(null)
const [draft, setDraft] = useState('')
+ // Whether the caret menu's "Default Claude account" group is expanded (inline, in-place).
+ const [acctOpen, setAcctOpen] = useState(false)
+ // Local, logged-in accounts only (pending logins + remote/host accounts excluded).
+ const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)
+ const localAccounts = useMemo(
+ () => claudeAccounts.filter((a) => !a.pending && !a.host),
+ [claudeAccounts]
+ )
const menuProject = projects.find((p) => p.id === menuId)
const closeMenu = () => {
setMenuId(null)
setMenuPos(null)
+ setAcctOpen(false)
}
const openMenu = (id: string, anchor: HTMLElement) => {
@@ -201,6 +214,46 @@ export function TabBar({
>
Remote access…
</button>
+ {localAccounts.length > 0 && (
+ <>
+ <button
+ className={`tab-menu__group${acctOpen ? ' open' : ''}`}
+ onClick={() => setAcctOpen((v) => !v)}
+ >
+ Default Claude account
+ <span className="tab-menu__caret">▸</span>
+ </button>
+ {acctOpen && (
+ <div className="tab-menu__sub">
+ <button
+ onClick={() => {
+ onSetDefaultAccount(menuProject.id, undefined)
+ closeMenu()
+ }}
+ >
+ <span className="tab-menu__check">
+ {menuProject.defaultAccountId ? '' : '✓'}
+ </span>
+ System account
+ </button>
+ {localAccounts.map((a) => (
+ <button
+ key={a.id}
+ onClick={() => {
+ onSetDefaultAccount(menuProject.id, a.id)
+ closeMenu()
+ }}
+ >
+ <span className="tab-menu__check">
+ {menuProject.defaultAccountId === a.id ? '✓' : ''}
+ </span>
+ {a.label}
+ </button>
+ ))}
+ </div>
+ )}
+ </>
+ )}
<button
onClick={() => {
onCloseProject(menuProject.id)
diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.ts
index c8fe0f31b..cec070280 100644
--- a/src/renderer/state/projects.ts
+++ b/src/renderer/state/projects.ts
@@ -14,6 +14,8 @@ interface ProjectsState {
addProject(name?: string, cwd?: string, ssh?: Project['ssh']): Project
renameProject(id: string, name: string): void
setProjectCwd(id: string, cwd: string): void
+ /** Sets (or clears, with undefined) the project's default Claude account for new nodes. */
+ setProjectDefaultAccount(id: string, accountId: string | undefined): void
/** Writes the serialized canvas (nodes + viewport + bridge links) back into a project. */
commitCanvas(id: string, nodes: CanvasNodeState[], viewport: Viewport, bridges?: BridgeLink[]): void
/** Renames a node within a project (source of truth for inactive projects). */
@@ -107,6 +109,12 @@ export const useProjects = create<ProjectsState>((set, get) => ({
}))
},
+ setProjectDefaultAccount(id, accountId) {
+ set((s) => ({
+ projects: s.projects.map((p) => (p.id === id ? { ...p, defaultAccountId: accountId } : p))
+ }))
+ },
+
commitCanvas(id, nodes, viewport, bridges) {
set((s) => ({
projects: s.projects.map((p) =>
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 31e122d6d..0144d12e5 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -269,6 +269,32 @@ body,
background: rgba(247, 118, 142, 0.15);
}
+/* "Default Claude account" inline expandable group inside the caret menu. */
+.tab-menu__group .tab-menu__caret {
+ margin-left: auto;
+ opacity: 0.5;
+ transition: transform 0.12s ease;
+}
+.tab-menu__group.open .tab-menu__caret {
+ transform: rotate(90deg);
+}
+.tab-menu__sub {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+.tab-menu__sub button {
+ padding-left: 8px;
+}
+.tab-menu__check {
+ display: inline-flex;
+ justify-content: center;
+ width: 16px;
+ flex-shrink: 0;
+ margin-right: 6px;
+ color: var(--accent);
+}
+
/* ---- Bottom-center dock ---- */
.dock-backdrop {
position: fixed;
@@ -1693,6 +1719,22 @@ body,
background: rgba(247, 118, 142, 0.15);
}
+/* Submenu row + its flyout. The flyout nests inside the row so moving the cursor across
+ the overlap doesn't fire the row's mouseleave (hover bridge). */
+.ctx-item--submenu {
+ position: relative;
+}
+.ctx-item--submenu::after {
+ content: '▸';
+ margin-left: auto;
+ opacity: 0.5;
+}
+.ctx-submenu {
+ position: absolute;
+ left: calc(100% - 4px);
+ top: -6px;
+}
+
.ctx-sep {
height: 1px;
background: var(--border);