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): root login terminals in the project cwd, not $HOME
enes97280fe2b63a
diff --git a/CLAUDE.md b/CLAUDE.mdindex f951fb8c0..c0f2c5620 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1484,7 +1484,18 @@ else, and its context links must keep classifying across restarts).guessing "not codex" would let `codex login` write into the system `~/.codex`. A dispatch withno listener is a silent no-op, which is how the Codex half shipped inert (#346) — pinned now by`renderer/lib/nodeterm-events.test.ts`, which fails on any `nodeterm:*` event that is sent but- never heard.+ never heard. **All THREE login factories take a `cwd`** (`createAccountLoginNode`,+ `createCodexAccountLoginNode`, `createSystemLoginNode`), and every call site passes the active+ project's — a login node with none starts in `$HOME`, and an agent CLI whose trust check is+ keyed on the cwd (Claude Code's is) then asks the user to trust their entire home directory,+ SSH keys and cloud credentials included, before an OAuth round trip that touches no files+ (issue #553; a persisted "yes" there grants that workspace for good). It is not a promise the+ prompt disappears — an untrusted project still prompts — it makes it the exception rather than+ the rule, without nodeterm writing another tool's trust config on the user's behalf. A+ **remote** login ignores the local path: `createTerminalNode` prefers `ssh.remoteCwd`, which is+ the only cwd that means anything for a session running on the host. An SSH project has no local+ `cwd`, so a LOCAL account added from one still opens in `$HOME` — the honest answer, since that+ project owns no local directory.- **The lifecycle is CORE, and both shells register it** (issue #313) —`core/claude-accounts-service.ts` owns the four `claude-accounts:*` channels (add / wait-login/ cancel-wait / remove) behind `platform().handle`; `main/claude-accounts.ts` is a thin desktopdiff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 93d83e322..40c94b882 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -4004,9 +4004,19 @@ export function Canvas() {if (!project) return // defensive: mismatched/disconnected remote login — never spawn locallyssh = project.ssh}+ // Start the login shell in the active project's directory rather than `$HOME` (issue #553):+ // Claude Code's trust check is keyed on the cwd, so a home-rooted login asks the user to+ // trust everything they own before an OAuth round trip that touches no files. Read live, at+ // fire time, like the ssh binding above. A REMOTE login ignores this local path —+ // `createAccountLoginNode` hands it to `createTerminalNode`, which prefers `ssh.remoteCwd`+ // — which is correct: the session runs on the host, where a local path names nothing. An+ // SSH project has no `cwd` of its own, so a LOCAL account added from one still starts in+ // `$HOME`; there is no local directory that project could honestly offer.+ const { getProject, activeProjectId: pid } = useProjects.getState()+ const cwd = getProject(pid)?.cwdsetNodes((ns) => [...ns.map((n) => ({ ...n, selected: false })),- { ...createAccountLoginNode(accountId, ns.length, viewCenter(), ssh), selected: true }+ { ...createAccountLoginNode(accountId, ns.length, viewCenter(), ssh, cwd), selected: true }])markDirty()// The event fires from the full-screen Settings overlay — close it so the user actually@@ -4029,9 +4039,14 @@ export function Canvas() {const onAddCodexAccountLogin = (ev: Event): void => {const accountId = (ev as CustomEvent<{ accountId?: string }>).detail?.accountIdif (!accountId) return+ // Same cwd reasoning as the Claude branch above (issue #553). Local only, so `project.cwd`+ // is the only field that can be read here — an SSH project's `remoteCwd` names a directory+ // on the host and would send this local shell somewhere that does not exist.+ const { getProject, activeProjectId: pid } = useProjects.getState()+ const cwd = getProject(pid)?.cwdsetNodes((ns) => [...ns.map((n) => ({ ...n, selected: false })),- { ...createCodexAccountLoginNode(accountId, ns.length, viewCenter()), selected: true }+ { ...createCodexAccountLoginNode(accountId, ns.length, viewCenter(), cwd), selected: true }])markDirty()// Same reason as the Claude branch: the event fires from the full-screen Settings overlay,@@ -4051,15 +4066,19 @@ export function Canvas() {// the only machine whose ~/.claude the action claims to switch.useEffect(() => {const onSwitchSystemAccount = (): void => {+ // The reported case of issue #553: this login started in `$HOME` and Claude Code asked the+ // user to trust their whole home directory. Local by construction (see above), so the local+ // `project.cwd` is the only cwd that applies.+ const { getProject, activeProjectId: pid } = useProjects.getState()+ const cwd = getProject(pid)?.cwdsetNodes((ns) => [...ns.map((n) => ({ ...n, selected: false })),- { ...createSystemLoginNode(ns.length, viewCenter()), selected: true }+ { ...createSystemLoginNode(ns.length, viewCenter(), cwd), selected: true }])markDirty()// The popover is reachable from over the kanban board too (`overBoard`) — leave the board// so the user actually sees the login node they must interact with. Same rationale as the// Settings-overlay close in the add-account listeners above.- const pid = useProjects.getState().activeProjectIdif (pid && isKanbanOpen(pid)) useViewMode.getState().toggle(pid)}window.addEventListener('nodeterm:switch-system-account', onSwitchSystemAccount)diff --git a/src/renderer/state/workspace.test.ts b/src/renderer/state/workspace.test.tsindex e765e20e3..65e4c6d0f 100644--- a/src/renderer/state/workspace.test.ts+++ b/src/renderer/state/workspace.test.ts@@ -23,6 +23,7 @@ import {ungroupNodes} from './workspace'import type { CanvasNode } from './workspace'+import type { Project } from '@shared/types'const term = (id: string, pos: { x: number; y: number }, parentId?: string): CanvasNode =>({@@ -739,6 +740,33 @@ describe('createAccountLoginNode', () => {expect(node.data.accountId).toBe('acct-1')expect(node.data.initialCommand).toBe('claude /login')})++ // Issue #553: a login node with no cwd starts in $HOME, and Claude Code's trust check is keyed+ // on the cwd — so the user was asked to trust their entire home directory before an OAuth round+ // trip that touches no files.+ it('roots the login shell in the cwd it is given', () => {+ expect(createAccountLoginNode('acct-1', 0, undefined, undefined, '/work/repo').data.cwd).toBe(+ '/work/repo'+ )+ })++ it('roots a REMOTE login at the host cwd, never at a local path', () => {+ // The local cwd belongs to whichever project was active when Settings fired the event; the+ // session runs on the host, where that path names nothing (or, worse, something else).+ const ssh = {+ server: { host: 'h', user: 'u' },+ remoteCwd: '/srv/app'+ } as unknown as NonNullable<Project['ssh']>+ const node = createAccountLoginNode('acct-1', 0, undefined, ssh, '/local/repo')+ expect(node.data.cwd).toBe('/srv/app')+ expect(node.data.sshRemoteTmux).toBe(true)+ })++ it('still opens with no cwd when the caller has none to offer', () => {+ // An SSH project has no local `cwd`, so a LOCAL account added from one falls back to $HOME —+ // unchanged behavior, and the honest answer: that project owns no local directory.+ expect(createAccountLoginNode('acct-1', 0).data.cwd).toBeUndefined()+ })})describe('createCodexAccountLoginNode', () => {@@ -755,6 +783,13 @@ describe('createCodexAccountLoginNode', () => {// terminal is scoped purely because its account id is a managed CODEX one (see #345/#346).expect(createCodexAccountLoginNode('acct-2', 0).data.agentId).toBeUndefined()})++ it('roots the login shell in the cwd it is given (issue #553)', () => {+ expect(createCodexAccountLoginNode('acct-2', 0, undefined, '/work/repo').data.cwd).toBe(+ '/work/repo'+ )+ expect(createCodexAccountLoginNode('acct-2', 0).data.cwd).toBeUndefined()+ })})describe('createSystemLoginNode (issue #420)', () => {@@ -785,6 +820,13 @@ describe('createSystemLoginNode (issue #420)', () => {const back = nodeStatesToFlow([persisted])[0]expect(isAccountLoginNode(back.data)).toBe(false)})++ it('roots the login shell in the cwd it is given (issue #553)', () => {+ // The reported case: the popover's Switch account button opened in $HOME, so Claude Code's+ // trust prompt stood between the click and the OAuth flow.+ expect(createSystemLoginNode(0, undefined, '/work/repo').data.cwd).toBe('/work/repo')+ expect(createSystemLoginNode(0).data.cwd).toBeUndefined()+ })})describe('dino node serialization', () => {diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex eeefdac20..12ba58708 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -734,14 +734,24 @@ export function systemAccountDisplay(label: string | undefined, email?: string |* In an SSH project, pass the project's `ssh` binding: the node then runs in REMOTE tmux (Task 12),* so `CLAUDE_CONFIG_DIR` resolves to the account dir ON THE HOST and `claude /login` writes the* remote `.claude.json` (the main process polls it over ssh). For a local account, omit `ssh`.+ *+ * `cwd` is the directory the login shell starts in, and it is not cosmetic: Claude Code's trust+ * check is keyed on the cwd, so a login node with none lands in `$HOME` and asks the user to trust+ * their entire home directory — SSH keys and cloud credentials included — before an OAuth round+ * trip that touches no files at all (issue #553). Callers pass the active project's directory:+ * a workspace the user is already in is the one they are most likely to have trusted. The trailing+ * position keeps every existing call byte-identical. On an SSH project `createTerminalNode` prefers+ * `ssh.remoteCwd`, so a REMOTE login roots itself on the host and a local path can never override+ * it — which is the only resolution that means anything for a session running over there.*/export function createAccountLoginNode(accountId: string,index: number,center?: { x: number; y: number },- ssh?: Project['ssh']+ ssh?: Project['ssh'],+ cwd?: string): CanvasNode {- const node = createTerminalNode(index, undefined, center, undefined, ssh)+ const node = createTerminalNode(index, cwd, center, undefined, ssh)node.data = {...node.data,title: 'Claude login',@@ -762,13 +772,18 @@ export function createAccountLoginNode(* A plain terminal (not an agent node), like the Claude one: no session-name tracking, and the* agent-less shape is what keeps the node out of the Codex AGENT paths while still being scoped.* Local only — `codexAccounts.add()` mints on THIS machine, so there is no ssh binding to pass.+ * `cwd` carries the same weight as it does on the Claude sibling above (issue #553): a login node+ * with none starts in `$HOME`, and a CLI whose trust check is keyed on the cwd then asks about the+ * whole home directory. Being local-only, the caller must pass a LOCAL directory — the active+ * project's cwd, which an SSH project does not have.*/export function createCodexAccountLoginNode(accountId: string,index: number,- center?: { x: number; y: number }+ center?: { x: number; y: number },+ cwd?: string): CanvasNode {- const node = createTerminalNode(index, undefined, center)+ const node = createTerminalNode(index, cwd, center)node.data = {...node.data,title: 'Codex login',@@ -796,10 +811,23 @@ export function createCodexAccountLoginNode(* this node is an inert plain terminal, not a login prompt nobody requested.** Local only, on purpose: on an SSH project a system login would rewrite THAT host's ~/.claude,- * so the popover does not offer the action there (see UsageIndicator).+ * so the popover does not offer the action there (see UsageIndicator). `cwd` must therefore be a+ * LOCAL directory — the active project's, which an SSH project does not have (its terminals are+ * rooted at `ssh.remoteCwd`, a path that means nothing on this machine).+ *+ * Issue #553: this node is where the missing cwd was first noticed. `claude /login` is an OAuth+ * round trip that touches no files, but Claude Code's trust check is keyed on the cwd, so starting+ * in `$HOME` made the button cost a "do you trust /Users/<me>?" answer whose persisted `yes` grants+ * a trusted workspace over everything the user owns. A project directory is not a guaranteed+ * escape (an untrusted project still prompts) — it makes the prompt the exception rather than the+ * rule, without nodeterm writing another tool's trust config on the user's behalf.*/-export function createSystemLoginNode(index: number, center?: { x: number; y: number }): CanvasNode {- const node = createTerminalNode(index, undefined, center)+export function createSystemLoginNode(+ index: number,+ center?: { x: number; y: number },+ cwd?: string+): CanvasNode {+ const node = createTerminalNode(index, cwd, center)node.data = {...node.data,title: 'Switch Claude account',