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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(accounts): renamable, email-labelled System account entry
enes2e3b45386772
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 08e2e8a95..50d612ffc 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -114,6 +114,7 @@ import { useContextWindow } from '../state/contextWindow'import { useSessionNaming } from '../state/sessionNaming'import { useSshServers } from '../state/sshServers'import { useSshConn } from '../state/sshConn'+import { useSystemAccount } from '../state/systemAccount'import { requireProOr } from '../state/upgradeGate'import { useEntitlement } from '../state/entitlement'import type { SshServer } from '@shared/ssh'@@ -126,6 +127,7 @@ import {alignNodes,arrangeNodes,createAccountLoginNode,+ systemAccountDisplay,createAgentNode,createBrowserNode,createChatNode,@@ -1487,6 +1489,10 @@ export function Canvas() {// Resolves the ssh binding by host at fire time (reads stores directly), so no project dep.}, [setNodes, markDirty, viewCenter])+ // Resolve the system account's email once, so context menus (built via getState) can label+ // the "System account" entry with it.+ useEffect(() => useSystemAccount.getState().ensure(), [])+// When an account is removed in Settings, clear it off the ACTIVE project's live nodes (the// projects store only holds the other projects' serialized copies). Referencing nodes fall// back to the system account; the missing-dir spawn fallback (Task 3) is safe either way.@@ -2233,6 +2239,12 @@ export function Canvas() {useSettings.getState().settings.claudeAccounts,useProjects.getState().getProject(activeProjectId))+ // The system entry shows the user's custom label / detected email so it stays+ // distinguishable from managed accounts (falls back to "System account").+ const systemLabel = systemAccountDisplay(+ useSettings.getState().settings.systemAccountLabel,+ useSystemAccount.getState().email+ )return [...BUILTIN_AGENT_IDS.filter((aid) => !disabled.includes(aid)).map((aid): MenuItem => {// Claude gets an account picker submenu when ≥1 account exists; System = project@@ -2243,7 +2255,7 @@ export function Canvas() {label: `New ${AGENT_CONFIG[aid].label}`,icon: <AgentIcon agentId={aid} />,children: [- { label: 'System account', onClick: () => addAgentNode('claude', at, groupId) },+ { label: systemLabel, onClick: () => addAgentNode('claude', at, groupId) },...accounts.map((a): MenuItem => ({label: a.label,@@ -2275,7 +2287,7 @@ export function Canvas() {label: 'New chat',icon: <IconChat />,children: [- { label: 'System account', onClick: () => addChatNode(at, undefined, groupId) },+ { label: systemLabel, onClick: () => addChatNode(at, undefined, groupId) },...accounts.map((a): MenuItem => ({label: a.label,diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex cffb1d8ab..3107eb01d 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -3,7 +3,8 @@ import { createPortal } from 'react-dom'import { useProjects } from '../state/projects'import { useAgentStatus } from '../state/agentStatus'import { useSettings } from '../state/settings'-import { accountsForProject } from '../state/workspace'+import { accountsForProject, systemAccountDisplay } from '../state/workspace'+import { useSystemAccount } from '../state/systemAccount'interface TabBarProps {onSwitch: (id: string) => void@@ -55,6 +56,9 @@ export function TabBar({// Whether the caret menu's "Default Claude account" group is expanded (inline, in-place).const [acctOpen, setAcctOpen] = useState(false)const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)+ const systemLabelSetting = useSettings((s) => s.settings.systemAccountLabel)+ const systemEmail = useSystemAccount((s) => s.email)+ const systemLabel = systemAccountDisplay(systemLabelSetting, systemEmail)const menuProject = projects.find((p) => p.id === menuId)// Accounts eligible as the caret-menu project's default: local accounts for a local project, this@@ -250,7 +254,7 @@ export function TabBar({<span className="tab-menu__check">{menuProject.defaultAccountId ? '' : '✓'}</span>- System account+ {systemLabel}</button>{menuAccounts.map((a) => (<buttondiff --git a/src/renderer/components/UsageIndicator.tsx b/src/renderer/components/UsageIndicator.tsxindex 0f0fb3fe8..eba5bda54 100644--- a/src/renderer/components/UsageIndicator.tsx+++ b/src/renderer/components/UsageIndicator.tsx@@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'import type { ClaudeUsage, ClaudeUsageWindow } from '@shared/types'import { useSettings } from '../state/settings'import { barColor, formatResetCountdown, formatTimeAgo } from '../lib/usageFormat'+import { systemAccountDisplay } from '../state/workspace'const SESSION_LABEL = '5h'const WEEKLY_LABEL = 'wk'@@ -53,6 +54,7 @@ export function UsageIndicator(): JSX.Element | null {const popRef = useRef<HTMLDivElement>(null)const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)+ const systemLabelSetting = useSettings((s) => s.settings.systemAccountLabel)// Local logged-in accounts get their own popover row; skip pending logins + remote (host) ones.const accounts = useMemo(() => claudeAccounts.filter((a) => !a.pending && !a.host),@@ -148,7 +150,12 @@ export function UsageIndicator(): JSX.Element | null {</div>{accounts.length > 0 ? (<>- <AccountUsageBlock label="System" u={usage} />+ <AccountUsageBlock+ label={systemAccountDisplay(systemLabelSetting, usage.email)}+ // Avoid printing the email twice when it's already the display label.+ email={systemLabelSetting.trim() ? (usage.email ?? undefined) : undefined}+ u={usage}+ />{accounts.map((a) => (<AccountUsageBlock key={a.id} label={a.label} email={a.email} u={acctUsage[a.id] ?? null} />))}diff --git a/src/renderer/components/settings/sections/AccountsSection.tsx b/src/renderer/components/settings/sections/AccountsSection.tsxindex afc46f2fe..bda437d77 100644--- a/src/renderer/components/settings/sections/AccountsSection.tsx+++ b/src/renderer/components/settings/sections/AccountsSection.tsx@@ -1,7 +1,8 @@-import { useState } from 'react'+import { useEffect, useState } from 'react'import type { ClaudeAccount } from '@shared/types'import { sshHostKey } from '@shared/ssh'import { useSettings } from '../../../state/settings'+import { useSystemAccount } from '../../../state/systemAccount'import { useProjects } from '../../../state/projects'import { useSshConn } from '../../../state/sshConn'import { ConfirmDialog } from '../../ConfirmDialog'@@ -39,6 +40,9 @@ function countNodesUsing(accountId: string): number {export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.Element {const accounts = useSettings((s) => s.settings.claudeAccounts)+ const systemLabelSetting = useSettings((s) => s.settings.systemAccountLabel)+ const systemEmail = useSystemAccount((s) => s.email)+ useEffect(() => useSystemAccount.getState().ensure(), [])const activeProjectId = useProjects((s) => s.activeProjectId)const activeProject = useProjects((s) => s.projects.find((p) => p.id === activeProjectId))// The active project's SSH host key (`user@host`), when it's a connected SSH project. Present →@@ -179,9 +183,30 @@ export function AccountsSection({ isActive }: { isActive: boolean }): React.JSX.</div>) : null}- {accounts.length === 0 ? (- <p className="text-[13px] text-muted">No accounts yet.</p>- ) : (+ {/* The SYSTEM account (the machine's default ~/.claude login) is implicit — not a+ ClaudeAccount record — but gets a fixed row so it can be told apart from managed+ accounts: detected email as subtitle, renamable display label (empty = default). */}+ <div className="flex items-center justify-between gap-3 rounded-md border border-border p-3">+ <div className="min-w-0 flex-1 space-y-1">+ <div className="flex items-center gap-2">+ <Input+ className="w-56"+ placeholder="System account"+ value={systemLabelSetting}+ onChange={(e) => useSettings.getState().update({ systemAccountLabel: e.target.value })}+ />+ <span+ className="rounded-full bg-white/10 px-2 py-0.5 text-[11px] font-medium text-muted"+ title="The machine's default Claude login (~/.claude). Used when a node has no account."+ >+ system+ </span>+ </div>+ {systemEmail ? <p className="text-[12px] text-muted">{systemEmail}</p> : null}+ </div>+ </div>++ {accounts.length === 0 ? null : (accounts.map((account) => (<divkey={account.id}diff --git a/src/renderer/state/agentNodes.test.ts b/src/renderer/state/agentNodes.test.tsindex 7be5194d7..205ef5d5f 100644--- a/src/renderer/state/agentNodes.test.ts+++ b/src/renderer/state/agentNodes.test.ts@@ -58,3 +58,53 @@ describe('useAgentNodes.finish', () => {expect(v.durationMs).toBeLessThan(20000)})})++describe('loop card override persistence', () => {+ // Cron/schedule cards survive restarts (agentStatus.loop is persisted) — where the user+ // dragged the card must survive with them, or every launch teleports it back to the+ // default spot. Only loop-* overrides persist; subagent cards are per-turn anyway.+ it('persists loop-* position/size and drops them via clearLoop', async () => {+ const mem = new Map<string, string>()+ const store = {+ getItem: (k: string) => mem.get(k) ?? null,+ setItem: (k: string, v: string) => void mem.set(k, v),+ removeItem: (k: string) => void mem.delete(k)+ }+ const { vi } = await import('vitest')+ vi.stubGlobal('localStorage', store)+ vi.resetModules()+ const { useAgentNodes: fresh } = await import('./agentNodes')+ fresh.getState().setPosition('loop-n1', { x: 42, y: 43 })+ fresh.getState().setSize('loop-n1', { width: 300, height: 120 })+ fresh.getState().setPosition('tu-sub', { x: 1, y: 2 }) // subagent — must NOT persist+ const saved = JSON.parse(mem.get('nodeterm.loopCards')!)+ expect(saved.positions['loop-n1']).toEqual({ x: 42, y: 43 })+ expect(saved.sizes['loop-n1']).toEqual({ width: 300, height: 120 })+ expect(saved.positions['tu-sub']).toBeUndefined()+ fresh.getState().clearLoop('n1')+ const after = JSON.parse(mem.get('nodeterm.loopCards') ?? '{}')+ expect(after.positions?.['loop-n1']).toBeUndefined()+ vi.unstubAllGlobals()+ })++ it('hydrates persisted loop-* overrides on load', async () => {+ const mem = new Map<string, string>([+ [+ 'nodeterm.loopCards',+ JSON.stringify({ positions: { 'loop-n2': { x: 9, y: 8 } }, sizes: {}, expanded: { 'loop-n2': true } })+ ]+ ])+ const store = {+ getItem: (k: string) => mem.get(k) ?? null,+ setItem: (k: string, v: string) => void mem.set(k, v),+ removeItem: (k: string) => void mem.delete(k)+ }+ const { vi } = await import('vitest')+ vi.stubGlobal('localStorage', store)+ vi.resetModules()+ const { useAgentNodes: fresh } = await import('./agentNodes')+ expect(fresh.getState().positions['loop-n2']).toEqual({ x: 9, y: 8 })+ expect(fresh.getState().expanded['loop-n2']).toBe(true)+ vi.unstubAllGlobals()+ })+})diff --git a/src/renderer/state/agentNodes.ts b/src/renderer/state/agentNodes.tsindex a9a7d7939..dc2be29c5 100644--- a/src/renderer/state/agentNodes.ts+++ b/src/renderer/state/agentNodes.ts@@ -60,16 +60,60 @@ interface AgentNodesState {clearLoop(parentNodeId: string): void}+// Loop-card overrides survive restarts: the loop itself is persisted (agentStatus), so its+// dragged position/size must be too, or every launch teleports the card back to the default+// spot. Only `loop-*` keys are stored — subagent cards are per-turn.+const LOOP_CARDS_KEY = 'nodeterm.loopCards'++type Overrides = Pick<AgentNodesState, 'positions' | 'sizes' | 'expanded'>++function loadLoopOverrides(): Overrides {+ try {+ const raw = localStorage.getItem(LOOP_CARDS_KEY)+ if (!raw) return { positions: {}, sizes: {}, expanded: {} }+ const d = JSON.parse(raw) as Partial<Overrides>+ return { positions: d.positions ?? {}, sizes: d.sizes ?? {}, expanded: d.expanded ?? {} }+ } catch {+ return { positions: {}, sizes: {}, expanded: {} }+ }+}++function saveLoopOverrides(s: Overrides): void {+ try {+ const pick = <T>(m: Record<string, T>): Record<string, T> =>+ Object.fromEntries(Object.entries(m).filter(([k]) => k.startsWith('loop-')))+ localStorage.setItem(+ LOOP_CARDS_KEY,+ JSON.stringify({ positions: pick(s.positions), sizes: pick(s.sizes), expanded: pick(s.expanded) })+ )+ } catch {+ // ignore quota / serialization errors+ }+}+export const useAgentNodes = create<AgentNodesState>((set) => ({byId: {},activityById: {},- positions: {},- sizes: {},- expanded: {},+ ...loadLoopOverrides(),- setPosition: (id, pos) => set((s) => ({ positions: { ...s.positions, [id]: pos } })),- setSize: (id, size) => set((s) => ({ sizes: { ...s.sizes, [id]: size } })),- toggleExpanded: (id) => set((s) => ({ expanded: { ...s.expanded, [id]: !s.expanded[id] } })),+ setPosition: (id, pos) =>+ set((s) => {+ const next = { positions: { ...s.positions, [id]: pos } }+ if (id.startsWith('loop-')) saveLoopOverrides({ ...s, ...next })+ return next+ }),+ setSize: (id, size) =>+ set((s) => {+ const next = { sizes: { ...s.sizes, [id]: size } }+ if (id.startsWith('loop-')) saveLoopOverrides({ ...s, ...next })+ return next+ }),+ toggleExpanded: (id) =>+ set((s) => {+ const next = { expanded: { ...s.expanded, [id]: !s.expanded[id] } }+ if (id.startsWith('loop-')) saveLoopOverrides({ ...s, ...next })+ return next+ }),start: (toolUseId, viz) =>set((s) => ({@@ -123,6 +167,7 @@ export const useAgentNodes = create<AgentNodesState>((set) => ({delete positions[id]delete sizes[id]delete expanded[id]+ saveLoopOverrides({ positions, sizes, expanded })return { positions, sizes, expanded }})}))diff --git a/src/renderer/state/systemAccount.ts b/src/renderer/state/systemAccount.tsnew file mode 100644index 000000000..a64a6f421--- /dev/null+++ b/src/renderer/state/systemAccount.ts@@ -0,0 +1,28 @@+import { create } from 'zustand'++/**+ * Detected identity of the SYSTEM Claude account (the machine's default `~/.claude` login).+ * Managed accounts carry their captured email in settings, but the system account is implicit+ * (no ClaudeAccount record), so its email is resolved lazily from the usage endpoint's cached+ * credential lookup in main. Pickers/settings show it next to "System account" so it stays+ * distinguishable once managed accounts exist. Fail-open: no login / no network → null.+ */+interface SystemAccountState {+ email: string | null+ /** Guard so the lazy fetch runs once per app session (main caches the underlying lookup). */+ loaded: boolean+ ensure(): void+}++export const useSystemAccount = create<SystemAccountState>((set, get) => ({+ email: null,+ loaded: false,+ ensure() {+ if (get().loaded) return+ set({ loaded: true })+ void window.nodeTerminal.usage+ .fetch()+ .then((u) => set({ email: u?.email ?? null }))+ .catch(() => {})+ }+}))diff --git a/src/renderer/state/workspace.account.test.ts b/src/renderer/state/workspace.account.test.tsindex b7ef2446a..89ee3bb15 100644--- a/src/renderer/state/workspace.account.test.ts+++ b/src/renderer/state/workspace.account.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { accountChipLabel } from './workspace'+import { accountChipLabel, systemAccountDisplay } from './workspace'import type { ClaudeAccount } from '@shared/types'const acct = (over: Partial<ClaudeAccount>): ClaudeAccount => ({@@ -48,3 +48,20 @@ describe('accountChipLabel', () => {})})})++describe('systemAccountDisplay', () => {+ it('prefers the custom label', () => {+ expect(systemAccountDisplay('Kişisel', '[email protected]')).toBe('Kişisel')+ })++ it('falls back to the detected email when the label is empty/whitespace', () => {+ expect(systemAccountDisplay('', '[email protected]')).toBe('[email protected]')+ expect(systemAccountDisplay(' ', '[email protected]')).toBe('[email protected]')+ expect(systemAccountDisplay(undefined, '[email protected]')).toBe('[email protected]')+ })++ it('falls back to the generic name when nothing is known', () => {+ expect(systemAccountDisplay('', null)).toBe('System account')+ expect(systemAccountDisplay(undefined, undefined)).toBe('System account')+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 51c8bb44c..902c3fe35 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -345,6 +345,16 @@ export function accountChipLabel(return { short, tooltip }}+/**+ * Display name for the SYSTEM (default `~/.claude`) account in pickers, settings, and the+ * usage popover: the user's custom label (settings.systemAccountLabel) wins, else the+ * detected login email, else the generic "System account". Keeps the system entry+ * distinguishable once managed accounts exist.+ */+export function systemAccountDisplay(label: string | undefined, email?: string | null): string {+ return (label ?? '').trim() || email || 'System account'+}+/*** Terminal node used to log a new managed account in: the session runs under the account's* CLAUDE_CONFIG_DIR (Task-3 env injection keyed off `data.accountId`), so `claude /login`diff --git a/src/shared/types.ts b/src/shared/types.tsindex a44aad2f0..41f18f9f3 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -351,6 +351,9 @@ export interface Settings {customAgents: CustomAgent[]/** Managed Claude accounts (config-dir isolated). See ClaudeAccount. */claudeAccounts: ClaudeAccount[]+ /** Custom display label for the SYSTEM Claude account (~/.claude) in pickers/settings.+ * Empty = unset → fall back to the detected login email, else "System account". */+ systemAccountLabel: string/** Agent ids hidden from the Add menus. */disabledAgents: AgentId[]/** Which agent the ⌘⇧C shortcut / quick-add launches. Always a launchable builtin. */@@ -382,6 +385,7 @@ export const DEFAULT_SETTINGS: Settings = {notifyConsentAsked: false,customAgents: [],claudeAccounts: [],+ systemAccountLabel: '',// New users see only Claude in the Add menus; Codex/Gemini are opt-in (re-enable in Settings).// Existing users keep whatever they've saved (their persisted disabledAgents overrides this).disabledAgents: ['codex', 'gemini'],