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(test): stub settings.save so a swatch click cannot poison a shared run
Uri Bloch36e6b33093ee
diff --git a/src/renderer/components/settings/sections/AccountsSection.color.test.tsx b/src/renderer/components/settings/sections/AccountsSection.color.test.tsxindex 28bb3db2a..ac3dd206c 100644--- a/src/renderer/components/settings/sections/AccountsSection.color.test.tsx+++ b/src/renderer/components/settings/sections/AccountsSection.color.test.tsx@@ -49,7 +49,13 @@ beforeEach(() => {;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {usage: { fetch: async () => null },ssh: { list: async () => [] },- codexAccounts: { systemIdentity: async () => null, identity: async () => null }+ codexAccounts: { systemIdentity: async () => null, identity: async () => null },+ // Every swatch click is a `useSettings.update()`, which schedules a real 300 ms coalesced+ // save. Whether that timer fires before the worker exits is pure timing — and when it does,+ // an absent `settings.save` throws INSIDE the timer, which vitest reports as an unhandled+ // error and exits 1 on even though every test passed. Stubbed so the file cannot poison a+ // longer run it happens to share a worker with.+ settings: { save: async () => {} }}})@@ -61,7 +67,7 @@ describe('AccountsSection — default node color', () => {it('stores the picked color on the account', () => {const { host, root } = renderSection([account])act(() => {- swatch(host, 'work', '#0a84ff').click()+ swatch(host, 'work', 'Node color #0a84ff').click()})expect(colorOf('a1')).toBe('#0a84ff')root.unmount()@@ -78,8 +84,8 @@ describe('AccountsSection — default node color', () => {it('marks the picked swatch as selected', () => {const { host, root } = renderSection([{ ...account, color: '#0a84ff' }])- expect(swatch(host, 'work', '#0a84ff').getAttribute('aria-pressed')).toBe('true')- expect(swatch(host, 'work', '#32d74b').getAttribute('aria-pressed')).toBe('false')+ expect(swatch(host, 'work', 'Node color #0a84ff').getAttribute('aria-pressed')).toBe('true')+ expect(swatch(host, 'work', 'Node color #32d74b').getAttribute('aria-pressed')).toBe('false')expect(swatch(host, 'work', 'Default').getAttribute('aria-pressed')).toBe('false')root.unmount()})@@ -94,7 +100,7 @@ describe('AccountsSection — default node color', () => {const other: ClaudeAccount = { id: 'a2', label: 'personal', createdAt: 0, color: '#ff453a' }const { host, root } = renderSection([account, other])act(() => {- swatch(host, 'work', '#0a84ff').click()+ swatch(host, 'work', 'Node color #0a84ff').click()})expect(colorOf('a1')).toBe('#0a84ff')expect(colorOf('a2')).toBe('#ff453a')@@ -107,7 +113,7 @@ describe('AccountsSection — default node color', () => {it('stores the picked color on a Codex account', () => {const { host, root } = renderSection([], [{ id: 'c1', label: 'codex work' }])act(() => {- swatch(host, 'codex work', '#32d74b').click()+ swatch(host, 'codex work', 'Node color #32d74b').click()})expect(codexColorOf('c1')).toBe('#32d74b')root.unmount()@@ -127,7 +133,7 @@ describe('AccountsSection — default node color', () => {it('colors a Codex account without touching a Claude account of the same id', () => {const { host, root } = renderSection([{ ...account, id: 'x1' }], [{ id: 'x1', label: 'codex' }])act(() => {- swatch(host, 'codex', '#32d74b').click()+ swatch(host, 'codex', 'Node color #32d74b').click()})expect(codexColorOf('x1')).toBe('#32d74b')expect(colorOf('x1')).toBeUndefined()diff --git a/src/renderer/components/settings/sections/AccountsSection.tsx b/src/renderer/components/settings/sections/AccountsSection.tsxindex ad7ea2057..6ca99efb3 100644--- a/src/renderer/components/settings/sections/AccountsSection.tsx+++ b/src/renderer/components/settings/sections/AccountsSection.tsx@@ -142,7 +142,9 @@ function AccountColorSwatches({<buttonkey={c}type="button"- aria-label={c}+ // "<what> <hex>", the convention the Appearance accent picker set — a bare hex is not a+ // name a screen reader can do anything with.+ aria-label={`Node color ${c}`}aria-pressed={color === c}onClick={() => onPick(c)}style={{ background: c }}diff --git a/src/renderer/state/workspace.account-color.test.ts b/src/renderer/state/workspace.account-color.test.tsindex e31273ded..a53c99f8f 100644--- a/src/renderer/state/workspace.account-color.test.ts+++ b/src/renderer/state/workspace.account-color.test.ts@@ -140,6 +140,23 @@ describe('createAgentNode — account default color', () => {expect(node.data.accountId).toBeUndefined()})+ // `mergeSettings` merges without checking, so a hand-edited `"claudeAccounts": null` survives+ // load and reaches this read. That would throw on `.find` one level ABOVE the `typeof color`+ // guard — the same class of failure that guard exists to prevent, one layer out.+ it('survives a null account list from a hand-edited settings.json', () => {+ useSettings.setState({+ settings: {+ ...DEFAULT_SETTINGS,+ claudeAccounts: null as unknown as ClaudeAccount[],+ codexAccounts: null as unknown as CodexAccount[]+ }+ })+ const claude = createAgentNode('claude', 0, undefined, undefined, undefined, undefined, 'a1')+ const codex = createAgentNode('codex', 0, undefined, undefined, undefined, undefined, 'c1')+ expect(claude.data.color).toBe(AGENT_COLOR('claude'))+ expect(codex.data.color).toBe(AGENT_COLOR('codex'))+ })+it('leaves an account-less node exactly where it was before the feature', () => {withAccounts([account('a1', '#0a84ff')])expect(createAgentNode('claude', 0).data.color).toBe(AGENT_COLOR('claude'))diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex cdad416ed..4d5b76655 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -568,11 +568,14 @@ export function createAgentNode(// so a second login of either builtin is recognizable on the canvas at a glance. `agentAccountColor`// asks the list that OWNS this agent's accounts — the two are keyed independently, so a Claude// account must never color a Codex node that happens to share its id.+ // `?? []` on both lists, matching the phone path in `src/main`: `mergeSettings` merges without+ // checking, so a hand-edited `"claudeAccounts": null` survives load and would throw on `.find`+ // one level ABOVE the `typeof color` guard — i.e. the very failure that guard exists to prevent.const settings = useSettings.getState().settingsconst color =agentAccountColor(agentId, boundAccountId, {- claude: settings.claudeAccounts,- codex: settings.codexAccounts+ claude: settings.claudeAccounts ?? [],+ codex: settings.codexAccounts ?? []}) ?? agentColor// The launch-command override (this project's `.nodeterm/settings.json` first, then Settings →// Agents → Launch commands — see `agentLaunchOverride`) replaces the bare CLI in the assembled