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
fix(accounts): name an SSH project's system account after the host
reviewf5c961e5d580
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex f84574c90..526666c0a 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -946,7 +946,7 @@ import {createCodexAccountLoginNode,createSystemLoginNode,isAccountLoginNode,- systemAccountDisplay,+ systemAccountDisplayOn,createAgentNode,createBrowserNode,createDinoNode,@@ -11375,9 +11375,16 @@ export function Canvas() {const accounts = accountsForProject(useSettings.getState().settings.claudeAccounts, project)// 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+ // On an SSH project the system row is the HOST's `~/.claude`, so it is named after the host+ // (its detected email when known) — never after this machine's label or login.+ const projectHostKey = project?.ssh ? sshHostKey(project.ssh.server) : undefined+ const systemLabel = systemAccountDisplayOn(+ projectHostKey,+ {+ label: useSettings.getState().settings.systemAccountLabel,+ email: useSystemAccount.getState().email+ },+ projectHostKey ? useSystemAccount.getState().remoteEmails[projectHostKey] : undefined)// ✓ marks what a bare "New Claude" resolves to: the project default while it still// exists, else the system account (mirrors resolveNewNodeAccount's stale-id guard).@@ -11398,9 +11405,10 @@ export function Canvas() {.settings.codexAccounts.filter((a) => !a.pending && (codexHostKey ? a.host === codexHostKey : !a.host))- const codexSystemLabel = systemAccountDisplay(- undefined,- useSystemCodexAccount.getState().email+ const codexSystemLabel = systemAccountDisplayOn(+ codexHostKey,+ { email: useSystemCodexAccount.getState().email },+ codexHostKey ? useSystemCodexAccount.getState().remoteEmails[codexHostKey] : undefined)const itemForBuiltin = (aid: (typeof BUILTIN_AGENT_IDS)[number]): MenuItem => {// Claude gets an account picker submenu when ≥1 account exists. The System row is andiff --git a/src/renderer/components/AccountChip.tsx b/src/renderer/components/AccountChip.tsxindex 01a0ec8f7..1f15bf085 100644--- a/src/renderer/components/AccountChip.tsx+++ b/src/renderer/components/AccountChip.tsx@@ -50,11 +50,15 @@ export function useAccountChip(observed: ObservedClaudeAccount | undefined,/** The agent-status store of the session the node's project belongs to. Absent = the default* store. */- statusStore?: AgentStatusSession['store']+ statusStore?: AgentStatusSession['store'],+ /** `user@host` when the node's pane runs on an SSH host (absent = this machine). */+ hostKey?: string): AccountChipInfo | null {const accounts = useSettings((s) => s.settings.claudeAccounts)const systemLabel = useSettings((s) => s.settings.systemAccountLabel)const systemEmail = useSystemAccount((s) => s.email)+ // A primitive selector, for the same reason as `multiple` below.+ const remoteSystemEmail = useSystemAccount((s) => (hostKey ? (s.remoteEmails[hostKey] ?? null) : null))// A PRIMITIVE selector (the `usageScopeKey` rule): this subscription lives on every node header// on the canvas, and returning the key set itself would re-render all of them on every hook// event of every node. `hasMultipleAccountKeys` early-exits at the second key. `accounts` rides@@ -68,7 +72,17 @@ export function useAccountChip(if (known) useSystemAccount.getState().ensure()}, [known])return useMemo(- () => accountChipFor({ dataAccountId, observed, accounts, systemLabel, systemEmail, multiple }),- [dataAccountId, observed, accounts, systemLabel, systemEmail, multiple]+ () =>+ accountChipFor({+ dataAccountId,+ observed,+ accounts,+ systemLabel,+ systemEmail,+ hostKey,+ remoteSystemEmail,+ multiple+ }),+ [dataAccountId, observed, accounts, systemLabel, systemEmail, hostKey, remoteSystemEmail, multiple])}diff --git a/src/renderer/components/SessionRow.tsx b/src/renderer/components/SessionRow.tsxindex aab5dc373..146c7d303 100644--- a/src/renderer/components/SessionRow.tsx+++ b/src/renderer/components/SessionRow.tsx@@ -55,7 +55,7 @@ export function SessionRow({const percentMode = useSettings((s) => s.settings.usagePercentMode)// The sidebar is one more view of the same nodes, so it gets the canvas header's account chip// under the same visibility rule — two rows on two Claude logins are otherwise indistinguishable.- const accountChip = useAccountChip(row.accountId, row.account)+ const accountChip = useAccountChip(row.accountId, row.account, undefined, row.sshHostKey)const commit = (): void => {const t = draft.trim()diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex 35b0eff2e..7859a6805 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -5,7 +5,8 @@ import { isOmniKanbanEnabled, toggleBoardView, useViewMode, viewFor } from '../simport { useAgentStatusSig, type AgentStatusLookup } from '../session/agent-status-lookup'import { usePauseCounts } from '../state/pauseCounts'import { useSettings } from '../state/settings'-import { accountsForProject, sshAccountsHint, systemAccountDisplay } from '../state/workspace'+import { accountsForProject, sshAccountsHint, systemAccountDisplayOn } from '../state/workspace'+import { sshHostKey } from '@shared/ssh'import { useSshConn } from '../state/sshConn'import { sshAutoModeHint } from '../state/permissionMode'import { useSystemAccount } from '../state/systemAccount'@@ -206,7 +207,7 @@ export function TabBar({const globalMode = useSettings((s) => s.settings.claudePermissionMode)const systemLabelSetting = useSettings((s) => s.settings.systemAccountLabel)const systemEmail = useSystemAccount((s) => s.email)- const systemLabel = systemAccountDisplay(systemLabelSetting, systemEmail)+ const remoteSystemEmails = useSystemAccount((s) => s.remoteEmails)// Session labels appear only once a second session exists (4c: remote tabs). For a solo user// this is always false, so the tab strip renders exactly as before. Plain call, not a@@ -218,6 +219,14 @@ export function TabBar({// Accounts eligible as the caret-menu project's default: local accounts for a local project, this// host's accounts for an SSH project (pending logins always excluded).const menuAccounts = accountsForProject(claudeAccounts, menuProject)+ // The system row belongs to the machine the MENU's project runs on: an SSH project's is the+ // host's own `~/.claude`, which this machine's label / email says nothing about.+ const menuHostKey = menuProject?.ssh ? sshHostKey(menuProject.ssh.server) : undefined+ const systemLabel = systemAccountDisplayOn(+ menuHostKey,+ { label: systemLabelSetting, email: systemEmail },+ menuHostKey ? remoteSystemEmails[menuHostKey] : undefined+ )// SSH project with no accounts on its host: say where accounts for this host come from instead// of presenting a bare System-only list (which read as "multi-account is broken on SSH").const menuAccountsHint = sshAccountsHint(menuProject, menuAccounts)diff --git a/src/renderer/components/UsageIndicator.tsx b/src/renderer/components/UsageIndicator.tsxindex fbe0cd7d3..ce6b005da 100644--- a/src/renderer/components/UsageIndicator.tsx+++ b/src/renderer/components/UsageIndicator.tsx@@ -36,6 +36,7 @@ import {providerPillSegments} from '@shared/usage-limits'import { systemAccountDisplay } from '../state/workspace'+import { noteRemoteSystemEmails } from '../state/systemAccount'/** Grace period before a hover-opened popover closes, so the pointer can cross the pill's own* gap (or clip a corner en route elsewhere) without the panel flickering shut. */@@ -517,7 +518,9 @@ export function UsageIndicator({}let cancelled = falsevoid window.nodeTerminal.usage.remote({ hostKey: scopeHostKey }).then((rows) => {- if (!cancelled) setRemote(rows)+ if (cancelled) return+ setRemote(rows)+ noteRemoteSystemEmails(rows)})return () => {cancelled = true@@ -650,6 +653,7 @@ export function UsageIndicator({.remote({ hostKey: scope.hostKey, force: true }).catch((): RemoteAccountUsage[] => [])if (remoteScope.current === requestedScope) setRemote(rows)+ noteRemoteSystemEmails(rows)} else {// The other providers sit behind the same debounce, so a stale failure (an expired token// the CLI has since renewed) would otherwise stay on screen until it runs out. Settleddiff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsxindex f427e979a..4aa0a07f6 100644--- a/src/renderer/components/kanban/CardModal.tsx+++ b/src/renderer/components/kanban/CardModal.tsx@@ -1,4 +1,5 @@import { Suspense, lazy, useCallback, useEffect, useRef, useState } from 'react'+import { sshHostKey } from '@shared/ssh'import { createPortal } from 'react-dom'import { isTopDialog, nextDialogId, popDialog, pushDialog } from '../dialog-stack'import {@@ -197,7 +198,12 @@ export function CardModal({ session, projectId, projectName, projectColor, colum// hides the node, carries it here so the session's name is never two views away.const sessionName = agentStatusStore((st) => st.byId[session.id]?.session)const portsRemote = useProjects((s) => !!(portsProjectId && s.getProject(portsProjectId)?.ssh))- const accountChip = useAccountChip(session.spawn.accountId, observedAccount, agentStatusStore)+ const accountChip = useAccountChip(+ session.spawn.accountId,+ observedAccount,+ agentStatusStore,+ session.spawn.ssh ? sshHostKey(session.spawn.ssh) : undefined+ )const [naming, setNaming] = useState(false)// The board funnel's progress for this node (`onAiName`), shared with the card menu's row.const funnelNaming = useSessionNaming((st) => !!st.byId[session.id])diff --git a/src/renderer/components/kanban/SessionCard.tsx b/src/renderer/components/kanban/SessionCard.tsxindex 5224a1dff..033c637d5 100644--- a/src/renderer/components/kanban/SessionCard.tsx+++ b/src/renderer/components/kanban/SessionCard.tsx@@ -1,4 +1,5 @@import { memo, useState } from 'react'+import { sshHostKey } from '@shared/ssh'import type { KanbanCardMeta, KanbanColumnCategory, KanbanLabel, KanbanPriority } from '@shared/types'import { useAgentStatus, type AgentStatusSession } from '../../state/agentStatus'import { AccountChip, useAccountChip } from '../AccountChip'@@ -97,7 +98,12 @@ export const SessionCard = memo(function SessionCard({// The board is the canvas's other view of the same node (CONTRIBUTING), so the card carries the// node header's account chip from the same helper — created-with account, else what the session// was observed running as.- const accountChip = useAccountChip(session.spawn.accountId, status?.account, statusStore)+ const accountChip = useAccountChip(+ session.spawn.accountId,+ status?.account,+ statusStore,+ session.spawn.ssh ? sshHostKey(session.spawn.ssh) : undefined+ )// Local drag state only styles THIS card (ghost look) — the drag payload lives in KanbanView.const [dragging, setDragging] = useState(false)// Which edge a drag is hovering over → shows the drop line (top = before, bottom = after).diff --git a/src/renderer/components/settings/sections/ProjectSettingsSection.tsx b/src/renderer/components/settings/sections/ProjectSettingsSection.tsxindex df0b8e4d2..82d3a0854 100644--- a/src/renderer/components/settings/sections/ProjectSettingsSection.tsx+++ b/src/renderer/components/settings/sections/ProjectSettingsSection.tsx@@ -17,7 +17,7 @@ import {SYSTEM_NODE_COLORS,accountsForProject,sshAccountsHint,- systemAccountDisplay+ systemAccountDisplayOn} from '../../../state/workspace'import { FieldRow } from '../FieldRow'import { FAMILY_SEARCH_ENTRIES, ProjectFamilyEditors } from '../ProjectSettingsFamilies'@@ -29,6 +29,7 @@ import { projectSectionId } from '../project-settings-targets'import { matchesQuery, type SettingsSearchEntry } from '../search'import { useProjectSettings } from '../useProjectSettings'import { PROJECT_NAME_MAX, clampProjectName } from '@shared/project-name'+import { sshHostKey } from '@shared/ssh'/*** Persists an identity/defaults edit. The store setters (`renameProject`, `setProjectColor`,@@ -174,7 +175,13 @@ function EditableProjectSection({const globalMode = useSettings((s) => s.settings.claudePermissionMode)const systemLabelSetting = useSettings((s) => s.settings.systemAccountLabel)const systemEmail = useSystemAccount((s) => s.email)- const systemLabel = systemAccountDisplay(systemLabelSetting, systemEmail)+ const remoteSystemEmails = useSystemAccount((s) => s.remoteEmails)+ const projectHostKey = project.ssh ? sshHostKey(project.ssh.server) : undefined+ const systemLabel = systemAccountDisplayOn(+ projectHostKey,+ { label: systemLabelSetting, email: systemEmail },+ projectHostKey ? remoteSystemEmails[projectHostKey] : undefined+ )const accounts = accountsForProject(claudeAccounts, project)const accountsHint = sshAccountsHint(project, accounts)diff --git a/src/renderer/lib/accountChip.test.ts b/src/renderer/lib/accountChip.test.tsindex d10f70cd8..1aa5efbb1 100644--- a/src/renderer/lib/accountChip.test.ts+++ b/src/renderer/lib/accountChip.test.ts@@ -133,6 +133,17 @@ describe('configDirLabel', () => {})describe('accountChipFor (chip visibility, and naming an unlinked dir)', () => {++ it('names an SSH pane\'s system account after the HOST, never this machine', () => {+ const base = { observed: system, accounts, systemLabel: 'Personal', systemEmail: '[email protected]', multiple: true }+ const unknown = accountChipFor({ ...base, hostKey: 'root@box' })+ expect(unknown?.short).toBe('System')+ expect(unknown?.tooltip).toContain('System account (root@box)')+ expect(unknown?.tooltip).not.toContain('Personal')+ const known = accountChipFor({ ...base, hostKey: 'root@box', remoteSystemEmail: '[email protected]' })+ expect(known?.tooltip).toContain('[email protected]')+ expect(known?.tooltip).toContain('~/.claude on root@box')+ })const accounts = [acct(), acct({ id: 'a2', label: 'personal', email: undefined, configDir: '/home/me/.claude-2' })]it('shows no chip for a system node while one identity is in play', () => {diff --git a/src/renderer/lib/accountChip.ts b/src/renderer/lib/accountChip.tsindex 521b87b42..6189ba012 100644--- a/src/renderer/lib/accountChip.ts+++ b/src/renderer/lib/accountChip.ts@@ -1,6 +1,6 @@import type { ClaudeAccount, ObservedClaudeAccount } from '@shared/types'import { isRemoteSessionNode } from '@shared/worktree'-import { accountChipLabel, systemAccountDisplay } from '../state/workspace'+import { accountChipLabel, systemAccountDisplayOn } from '../state/workspace'/*** Per-node Claude account labelling — the pure half of the account chip.@@ -427,6 +427,8 @@ export function accountChipFor({accounts,systemLabel,systemEmail,+ hostKey,+ remoteSystemEmail,multiple}: {dataAccountId?: string@@ -436,6 +438,11 @@ export function accountChipFor({systemLabel?: string/** The detected `~/.claude` login email (`state/systemAccount`), when known. */systemEmail?: string | null+ /** `user@host` when the pane runs on an SSH host: its system account is the HOST's `~/.claude`,+ * which this machine's label / email says nothing about. Absent = this machine. */+ hostKey?: string+ /** The host's detected system login email (`state/systemAccount` `remoteEmails`), when known. */+ remoteSystemEmail?: string | null/** Are ≥ 2 distinct account keys in play on this core? (`hasMultipleAccountKeys`) */multiple?: boolean}): AccountChipInfo | null {@@ -445,7 +452,20 @@ export function accountChipFor({if (!key) return null // nothing known — no chip, and nothing counted eitherif (key === SYSTEM_ACCOUNT_KEY) {if (!multiple) return null // one identity in play: the system pane is the unremarkable case- const display = systemAccountDisplay(systemLabel, systemEmail)+ const display = systemAccountDisplayOn(+ hostKey,+ { label: systemLabel, email: systemEmail },+ remoteSystemEmail+ )+ if (hostKey) {+ // The short form cannot carry the host tag, so an unknown host login reads "System" and the+ // tooltip says whose `~/.claude` it is.+ return {+ short: remoteSystemEmail ? shortAccountLabel(display) : 'System',+ tooltip: `${display} — system Claude account (~/.claude on ${hostKey})`,+ kind: 'system'+ }+ }return {// With neither a custom label nor a detected email the display is the generic "System// account", which the 10-char cap turns into "System acc…" — an ellipsis that promises adiff --git a/src/renderer/lib/nodeActionItems.tsx b/src/renderer/lib/nodeActionItems.tsxindex 35b726d3e..31746273e 100644--- a/src/renderer/lib/nodeActionItems.tsx+++ b/src/renderer/lib/nodeActionItems.tsx@@ -52,6 +52,7 @@ import {canToggleCollapse,selectedRootIds,systemAccountDisplay,+ systemAccountDisplayOn,type CanvasNode} from '../state/workspace'import { clearEnvEligibility, restartEligibility, restartSessionId } from '../terminal/agent-restart'@@ -830,9 +831,11 @@ export function buildAccountSwitchRows(nodeId: string, ctx: NodeActionCtx): Menuconst currentAccountId = (n?.data.accountId as string | undefined) || undefined// The system row names the machine it is on: an SSH node's is the HOST's// `~/.claude`, whose identity this machine's system email says nothing about.- const systemLabel = hostKey- ? `System account (${hostKey})`- : systemAccountDisplay(settingsNow.systemAccountLabel, useSystemAccount.getState().email)+ const systemLabel = systemAccountDisplayOn(+ hostKey,+ { label: settingsNow.systemAccountLabel, email: useSystemAccount.getState().email },+ hostKey ? useSystemAccount.getState().remoteEmails[hostKey] : undefined+ )const row = (id: string | undefined, label: string): MenuItem => {const isCurrent = (id || undefined) === currentAccountIdreturn {diff --git a/src/renderer/lib/sessionList.ts b/src/renderer/lib/sessionList.tsindex d112ed253..1c4b7117b 100644--- a/src/renderer/lib/sessionList.ts+++ b/src/renderer/lib/sessionList.ts@@ -5,7 +5,7 @@ import type { AgentState } from '@shared/agents/normalize'import type { NodeKind, ObservedClaudeAccount } from '@shared/types'import type { NodeIcon } from '@shared/node-icon'import { hasUsage } from '@shared/agents/config'-import type { SshConnection } from '@shared/ssh'+import { sshHostKey, type SshConnection } from '@shared/ssh'import type { ProjectIcon } from '@shared/project-icon'import { relativeTime } from './relativeTime'@@ -306,6 +306,8 @@ export interface SessionRowVM {loop?: { kind: 'loop' | 'schedule' | 'cron'; count: number }cwd?: stringsshHost?: string+ /** `user@host` of the SSH host the pane runs on — keys the account chip's system identity. */+ sshHostKey?: stringsessionId?: string/** Creation-time account + what the session was OBSERVED running as — the two halves the* account chip resolves (`lib/accountChip`). */@@ -396,6 +398,7 @@ function toRow(: undefined,cwd: n.cwd,sshHost: n.ssh?.host,+ sshHostKey: n.ssh ? sshHostKey(n.ssh) : undefined,sessionId: status?.sessionId,accountId: n.accountId,account: status?.account,diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 07e1f1f20..03b460976 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -1967,7 +1967,12 @@ export function TerminalNode({* stays creation-time (`transport.create` keeps passing `data.accountId`).*/const observedAccount = status?.account- const accountChip = useAccountChip(data.accountId, observedAccount, agentStatusStore)+ const accountChip = useAccountChip(+ data.accountId,+ observedAccount,+ agentStatusStore,+ data.ssh ? sshHostKey(data.ssh as SshConnection) : undefined+ )// This node's team (the stations it opened), published by Canvas from the live ropes. The store// keeps each unchanged team's array identity, so this re-renders only when THIS team changes.const team = useTeamStations((s) => s.byNode.get(id))diff --git a/src/renderer/session/agent-status-lookup.test.tsx b/src/renderer/session/agent-status-lookup.test.tsxindex ba8863c6b..31f33d290 100644--- a/src/renderer/session/agent-status-lookup.test.tsx+++ b/src/renderer/session/agent-status-lookup.test.tsx@@ -306,15 +306,16 @@ describe('the board surfaces read the store of the project they show', () => {)const node = read('nodes/TerminalNode.tsx')- expect(node).toContain('const accountChip = useAccountChip(data.accountId, observedAccount, agentStatusStore)')+ // The store stays the THIRD argument; a fourth (the pane's SSH host key) follows it.+ expect(node).toMatch(/const accountChip = useAccountChip\(\s*data\.accountId,\s*observedAccount,\s*agentStatusStore,/)expect(node).toContain('{team && <TeamProgressChip stations={team} onTravel={travelToStation} menuZIndex={60} statusStore={agentStatusStore} />}')const cardSrc = read('components/kanban/SessionCard.tsx')- expect(cardSrc).toContain('const accountChip = useAccountChip(session.spawn.accountId, status?.account, statusStore)')+ expect(cardSrc).toMatch(/const accountChip = useAccountChip\(\s*session\.spawn\.accountId,\s*status\?\.account,\s*statusStore,/)expect(cardSrc).toContain('<TeamProgressChip stations={team} onTravel={onTravel} statusStore={statusStore} />')const modal = read('components/kanban/CardModal.tsx')- expect(modal).toContain('const accountChip = useAccountChip(session.spawn.accountId, observedAccount, agentStatusStore)')+ expect(modal).toMatch(/const accountChip = useAccountChip\(\s*session\.spawn\.accountId,\s*observedAccount,\s*agentStatusStore,/)expect(modal).toContain('<TeamProgressChip stations={team} onTravel={onTravel} statusStore={agentStatusStore} />')})})diff --git a/src/renderer/state/systemAccount.test.ts b/src/renderer/state/systemAccount.test.tsnew file mode 100644index 000000000..a65337980--- /dev/null+++ b/src/renderer/state/systemAccount.test.ts@@ -0,0 +1,43 @@+import { beforeEach, describe, expect, it } from 'vitest'+import type { ClaudeUsage, RemoteAccountUsage } from '@shared/types'+import { noteRemoteSystemEmails, useSystemAccount } from './systemAccount'+import { systemAccountDisplayOn } from './workspace'++const usage = (email: string | null): ClaudeUsage => ({ email }) as ClaudeUsage++describe('systemAccountDisplayOn', () => {+ const local = { label: 'Personal', email: '[email protected]' }++ it('names a local project after this machine', () => {+ expect(systemAccountDisplayOn(undefined, local)).toBe('Personal')+ expect(systemAccountDisplayOn(undefined, { email: '[email protected]' })).toBe('[email protected]')+ })++ it('never borrows this machine\'s label or email for an SSH project', () => {+ expect(systemAccountDisplayOn('root@box', local)).toBe('System account (root@box)')+ })++ it('shows the host\'s own login once it is known', () => {+ expect(systemAccountDisplayOn('root@box', local, '[email protected]')).toBe('[email protected]')+ })+})++describe('noteRemoteSystemEmails', () => {+ beforeEach(() => useSystemAccount.setState({ remoteEmails: {} }))++ it('records only a host\'s SYSTEM Claude row', () => {+ const rows = [+ { hostKey: 'root@box', accountId: null, label: 'root@box', usage: usage('[email protected]') },+ { hostKey: 'root@box', accountId: 'acct1', label: 'Work', usage: usage('[email protected]') },+ { hostKey: 'root@other', accountId: null, label: 'x', provider: 'codex', usage: {} }+ ] as RemoteAccountUsage[]+ noteRemoteSystemEmails(rows)+ expect(useSystemAccount.getState().remoteEmails).toEqual({ 'root@box': '[email protected]' })+ })++ it('keeps a known email when a later read carries none', () => {+ noteRemoteSystemEmails([{ hostKey: 'root@box', accountId: null, label: 'h', usage: usage('[email protected]') }])+ noteRemoteSystemEmails([{ hostKey: 'root@box', accountId: null, label: 'h', usage: usage(null) }])+ expect(useSystemAccount.getState().remoteEmails['root@box']).toBe('[email protected]')+ })+})diff --git a/src/renderer/state/systemAccount.ts b/src/renderer/state/systemAccount.tsindex a64a6f421..edfe1c1db 100644--- a/src/renderer/state/systemAccount.ts+++ b/src/renderer/state/systemAccount.ts@@ -1,4 +1,5 @@import { create } from 'zustand'+import type { RemoteAccountUsage } from '@shared/types'/*** Detected identity of the SYSTEM Claude account (the machine's default `~/.claude` login).@@ -11,12 +12,24 @@ interface SystemAccountState {email: string | null/** Guard so the lazy fetch runs once per app session (main caches the underlying lookup). */loaded: boolean+ /** The system (`~/.claude`) login email of each SSH host (`user@host`) we have read usage+ * from. Fed by the usage indicator's on-demand remote read — never probed for a label alone,+ * since every remote read is an ssh exec plus an HTTPS request on the host. Absent = unknown. */+ remoteEmails: Record<string, string>ensure(): void+ noteRemote(hostKey: string, email: string | null | undefined): void}export const useSystemAccount = create<SystemAccountState>((set, get) => ({email: null,loaded: false,+ remoteEmails: {},+ noteRemote(hostKey, email) {+ // A failed read carries no email; that is not evidence the host is signed out, so a known+ // email is kept rather than blanked.+ if (!email || get().remoteEmails[hostKey] === email) return+ set((s) => ({ remoteEmails: { ...s.remoteEmails, [hostKey]: email } }))+ },ensure() {if (get().loaded) returnset({ loaded: true })@@ -26,3 +39,15 @@ export const useSystemAccount = create<SystemAccountState>((set, get) => ({.catch(() => {})}}))++/**+ * Record the host system-account emails carried by a remote usage read. Only a host's SYSTEM+ * Claude row counts (`accountId === null`, not codex): a managed account's email names that+ * account, not the `~/.claude` login the "System account" row launches under.+ */+export function noteRemoteSystemEmails(rows: RemoteAccountUsage[]): void {+ for (const row of rows) {+ if (row.accountId !== null || row.provider === 'codex') continue+ useSystemAccount.getState().noteRemote(row.hostKey, row.usage.email)+ }+}diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 8c417a27e..dc1d78123 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -1022,6 +1022,23 @@ export function systemAccountDisplay(label: string | undefined, email?: string |return (label ?? '').trim() || email || 'System account'}+/**+ * The system-account name for the machine a PROJECT runs on. A local project's is this machine's+ * (`systemAccountDisplay`). An SSH project's is the HOST's own `~/.claude` / `~/.codex` login —+ * a "New Claude" there launches under that identity, so naming the row after this machine's+ * custom label or email mislabels the account the session will actually run as. The host's+ * detected email when one is known, else the generic name tagged with the host; never anything+ * borrowed from this machine.+ */+export function systemAccountDisplayOn(+ hostKey: string | undefined,+ local: { label?: string; email?: string | null },+ remoteEmail?: string | null+): string {+ if (!hostKey) return systemAccountDisplay(local.label, local.email)+ return remoteEmail || `System account (${hostKey})`+}+/*** 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`