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): account chip on node headers + ChatPanel account threading
enes58f322d5dc53
diff --git a/src/renderer/nodes/ChatNode.tsx b/src/renderer/nodes/ChatNode.tsxindex d1cd65edf..cf092dfb4 100644--- a/src/renderer/nodes/ChatNode.tsx+++ b/src/renderer/nodes/ChatNode.tsx@@ -15,7 +15,8 @@ import { NodeResizer, useReactFlow, type NodeProps } from '@xyflow/react'import { MarkdownText } from './ChatPanel'import { useChatSessions } from '../state/chatSessions'import { useAgentStatus } from '../state/agentStatus'-import { createDiffNode, type CanvasNode } from '../state/workspace'+import { accountChipLabel, createDiffNode, type CanvasNode } from '../state/workspace'+import { useSettings } from '../state/settings'import type { ChatImageAttachment, ChatToolSummary } from '@shared/types'const MAX_IMAGES = 5@@ -32,6 +33,8 @@ export default function ChatNode({ id, data, selected }: NodeProps<CanvasNode>)// chat.working, so OR both — this drives the badge, Stop button and typing indicator.const working = !!chat?.working || status?.state === 'working'const { setNodes, addNodes } = useReactFlow()+ const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)+ const accountChip = accountChipLabel(data.accountId as string | undefined, claudeAccounts)const [input, setInput] = useState('')const [images, setImages] = useState<ChatImageAttachment[]>([])const [attachNote, setAttachNote] = useState<string | null>(null)@@ -244,6 +247,11 @@ export default function ChatNode({ id, data, selected }: NodeProps<CanvasNode>)<NodeResizer isVisible={selected} minWidth={360} minHeight={280} /><div className="chat-node__header"><span className="chat-node__title">{(data.title as string) || 'Chat'}</span>+ {accountChip && (+ <span className="node-account-chip" title={accountChip.tooltip}>+ {accountChip.short}+ </span>+ )}{working && <span className="chat-node__badge chat-node__badge--working">RUNNING</span>}{perm && <span className="chat-node__badge chat-node__badge--needs">NEEDS YOU</span>}{/* Cost chip intentionally hidden: the SDK reports an API-equivalent estimate even ondiff --git a/src/renderer/nodes/ChatPanel.tsx b/src/renderer/nodes/ChatPanel.tsxindex 3d6fea5bd..ad049dd57 100644--- a/src/renderer/nodes/ChatPanel.tsx+++ b/src/renderer/nodes/ChatPanel.tsx@@ -14,6 +14,8 @@ interface ChatPanelProps {nodeId: stringsessionId?: stringcwd?: string+ /** Managed Claude account this node runs under; resolves the transcript in the right root. */+ accountId?: string}/**@@ -22,7 +24,7 @@ interface ChatPanelProps {* session via pty.sendText. Phase 1 reloads the transcript whenever a turn finishes* (working -> idle); live streaming is a later phase. Replaces the markdown-of-output overlay.*/-export function ChatPanel({ nodeId, sessionId, cwd }: ChatPanelProps) {+export function ChatPanel({ nodeId, sessionId, cwd, accountId }: ChatPanelProps) {const [messages, setMessages] = useState<ChatMessage[]>([])const [input, setInput] = useState('')const [readonly, setReadonly] = useState(false)@@ -31,8 +33,8 @@ export function ChatPanel({ nodeId, sessionId, cwd }: ChatPanelProps) {const prevState = useRef(state)const load = useCallback(() => {- void window.nodeTerminal.chat.readTranscript(sessionId, cwd).then(setMessages)- }, [sessionId, cwd])+ void window.nodeTerminal.chat.readTranscript(sessionId, cwd, accountId).then(setMessages)+ }, [sessionId, cwd, accountId])// Initial load.useEffect(() => {diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 5fe1a29d9..0cd1cadc7 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -30,7 +30,7 @@ import { useAgentStatus, inferInterruptAfterSettle } from '../state/agentStatus'import { useAgentNodes } from '../state/agentNodes'import { useProjects } from '../state/projects'import { useSshConn } from '../state/sshConn'-import { COLLAPSED_HEIGHT, NODE_COLORS, type CanvasNode } from '../state/workspace'+import { accountChipLabel, COLLAPSED_HEIGHT, NODE_COLORS, type CanvasNode } from '../state/workspace'import { hasHooks, canRecur, canContextLink, hasUsage, canChat, canResume, canRename, resumeCommand, agentConfig, type AgentId } from '@shared/agents/config'import { buildSshArgs, type SshConnection } from '@shared/ssh'@@ -123,6 +123,8 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasNconst fontSize = useSettings((s) => s.settings.fontSize)const fontFamily = useSettings((s) => s.settings.fontFamily)const cursorBlink = useSettings((s) => s.settings.cursorBlink)+ const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)+ const accountChip = accountChipLabel(data.accountId, claudeAccounts)const bodyRef = useRef<HTMLDivElement>(null)const termRef = useRef<Terminal | null>(null)const fitRef = useRef<FitAddon | null>(null)@@ -832,6 +834,11 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN{status.session}</span>)}+ {accountChip && (+ <span className="node-account-chip" title={accountChip.tooltip}>+ {accountChip.short}+ </span>+ )}{data.ssh ? (<spanclassName="term-ssh-chip"@@ -977,7 +984,12 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN)}{mdMode &&(useChat ? (- <ChatPanel nodeId={id} sessionId={status?.sessionId} cwd={data.cwd as string | undefined} />+ <ChatPanel+ nodeId={id}+ sessionId={status?.sessionId}+ cwd={data.cwd as string | undefined}+ accountId={data.accountId}+ />) : (<div className="term-md nodrag nowheel"><div className="term-md__bar">diff --git a/src/renderer/state/workspace.account.test.ts b/src/renderer/state/workspace.account.test.tsnew file mode 100644index 000000000..b7ef2446a--- /dev/null+++ b/src/renderer/state/workspace.account.test.ts@@ -0,0 +1,50 @@+import { describe, it, expect } from 'vitest'+import { accountChipLabel } from './workspace'+import type { ClaudeAccount } from '@shared/types'++const acct = (over: Partial<ClaudeAccount>): ClaudeAccount => ({+ id: 'a1',+ label: '[email protected]',+ email: '[email protected]',+ createdAt: 0,+ ...over+})++describe('accountChipLabel', () => {+ it('returns null when there is no accountId (no chip)', () => {+ expect(accountChipLabel(undefined, [acct({})])).toBeNull()+ expect(accountChipLabel('', [acct({})])).toBeNull()+ })++ it('takes the part before @ and tooltips as "label (email)"', () => {+ const r = accountChipLabel('a1', [acct({ label: '[email protected]', email: '[email protected]' })])+ expect(r).toEqual({ short: 'work', tooltip: '[email protected] ([email protected])' })+ })++ it('caps the short label at 10 chars with an ellipsis', () => {+ const r = accountChipLabel('a1', [acct({ label: '[email protected]' })])+ expect(r?.short).toBe('verylongac…')+ expect(r?.short.length).toBe(11) // 10 chars + ellipsis+ })++ it('does not truncate a base of exactly 10 chars', () => {+ const r = accountChipLabel('a1', [acct({ label: '[email protected]' })])+ expect(r?.short).toBe('tenletters')+ })++ it('omits the "(email)" suffix when the account has no email', () => {+ const r = accountChipLabel('a1', [acct({ label: 'personal', email: undefined })])+ expect(r).toEqual({ short: 'personal', tooltip: 'personal' })+ })++ it('falls back to "Unknown account" when the id no longer resolves', () => {+ expect(accountChipLabel('gone', [acct({ id: 'a1' })])).toEqual({+ short: 'Unknown account',+ tooltip: 'Unknown account'+ })+ expect(accountChipLabel('gone', [])).toEqual({+ short: 'Unknown account',+ tooltip: 'Unknown account'+ })+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex a2f4cc355..6c497994b 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -309,6 +309,26 @@ export function createClaudeNode(return createAgentNode('claude', index, cwd, center)}+/**+ * Chip text for an account-bound node header. Given a node's `accountId` and the known+ * accounts, returns the short chip label (the part of the account label before `@`, capped+ * at ~10 chars with an ellipsis) plus a tooltip (`label (email)`, or just the label when no+ * email). Returns `null` when there's no `accountId` (render no chip). An `accountId` that no+ * longer resolves to a known account (removed) yields `Unknown account` for both.+ */+export function accountChipLabel(+ accountId: string | undefined,+ accounts: ClaudeAccount[]+): { short: string; tooltip: string } | null {+ if (!accountId) return null+ const acct = accounts.find((a) => a.id === accountId)+ if (!acct) return { short: 'Unknown account', tooltip: 'Unknown account' }+ const base = acct.label.split('@')[0]+ const short = base.length > 10 ? `${base.slice(0, 10)}…` : base+ const tooltip = acct.email ? `${acct.label} (${acct.email})` : acct.label+ return { short, tooltip }+}+/*** 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/renderer/styles.css b/src/renderer/styles.cssindex 0144d12e5..6287e51ac 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -700,6 +700,22 @@ body,border-radius: 6px;}+/* Account-bound node: which managed Claude account this node runs under. Mirrors the session+ chip with a distinct accent-tinted background so it reads apart from the plain session chip. */+.node-account-chip {+ margin-left: 8px;+ max-width: 120px;+ padding: 1px 8px;+ flex-shrink: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ font-size: 11px;+ color: var(--muted);+ background: rgba(10, 132, 255, 0.14);+ border-radius: 6px;+}+/* Claude Code status: RUNNING badge while working, unread dot when finished. */.term-node__status {display: inline-flex;