Skip to content

fix(naming): Name with AI uses the node's Claude account; never titles a node with a CLI error - #1069

Merged
eneskirca merged 1 commit into
mainfrom
fix/ai-naming-account
Sep 30, 2026
Merged

eneskirca merged 1 commit into
mainfrom
fix/ai-naming-account

Conversation

@eneskirca

Copy link
Copy Markdown
Owner

Problem

✦ Name with AI sometimes renamed a node to Failed to authenticate: OAuth s….

Two causes:

  1. The naming agent spawned claude -p with the app's plain env, so it always ran as the system ~/.claude login, whatever managed account the node runs under. If that login was expired or logged out, the request failed even though the node's own account was fine.
  2. claude -p prints auth errors to stdout and exits nonzero. runAgent accepted any stdout text as the answer, so the error became the title.

Fix

  • pty.generateName(persistKey, cwd, accountId?) takes a trailing optional accountId. It is passed from the node header ✦, the sessions sidebar "Name with AI" and the kanban card modal.
  • Main resolves the account with the same rules as the pty spawn: it must be in claudeAccounts, not pending, not remote, and its dir must exist. The agent then runs with CLAUDE_CONFIG_DIR pointed at that dir and AUTH_ENV_STRIP removed (new claudeAccountEnv helper). If the account doesn't resolve, the request uses the system account, as before.
  • runAgent now fails on any nonzero exit. It also rejects known CLI error lines (isCliErrorOutput) even on a zero exit. This applies to AI commit messages and group names too.

Surfaces

  • Desktop: fixed.
  • Server Edition: AI naming is already stubbed as unavailable, so there is no change.
  • Relay: unchanged.
  • Mobile: N/A.

Not in scope

  • Group naming still runs under the system account, because group members can use different accounts.
  • Failure feedback: a failed ✦ still gives no toast; the title just stays unchanged.

Testing

  • npm run typecheck passes.
  • commit-message.test.ts has new tests for isCliErrorOutput and claudeAccountEnv.
  • Not yet exercised on a real expired login.

🤖 Generated with Claude Code

…r adopt CLI errors as titles

The naming agent spawned `claude -p` with the app's plain env, so every request went out as the
system ~/.claude login regardless of the node's managed account. When that login was expired,
claude printed "Failed to authenticate: OAuth …" to STDOUT with a nonzero exit, and runAgent
treated any stdout text as the answer — so the node was renamed to the error.

- generateName takes a trailing optional accountId (node header ✦, sessions sidebar, kanban card
  modal). Main resolves it like the pty spawn (known, non-pending, local account with an existing
  dir) and runs the agent with CLAUDE_CONFIG_DIR set and AUTH_ENV_STRIP removed; otherwise the
  system account, as before.
- runAgent: a nonzero exit is always a failure, and known CLI error lines (Failed to authenticate,
  Invalid API key, API Error, …) are never accepted as output. Applies to commit messages and group
  names too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@eneskirca
eneskirca enabled auto-merge September 30, 2026 13:42
@eneskirca
eneskirca merged commit 726bc12 into main Sep 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant