Skip to content

Commit d77f2f9

Browse files
grimmerkclaude
andcommitted
feat(multi-account): global-default resume routing (Batch 2e)
buildResumeCommand now emits `command claude` (bypassing the accounts.sh `claude` dispatcher) so a configured non-anchor global-default can't re-route an anchor-account resume to the wrong account. Behavior is unchanged when the default IS the anchor; a no-op for single-account users (command claude == claude). 2e's shell + CLI side already shipped in 2a (`codev account default` plus the dispatcher `*)` -> defaultAccount). Also documents the 2c <-> Batch 3 coupling (cross-account resume needs shared session data). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017kCK4t5JSVynVZxGcrTGGp
1 parent 5d0ac66 commit d77f2f9

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## 1.0.77
44

5-
- Feat: multi-account Batch 2a — `codev account` CLI to manage the registry
5+
- Feat: multi-account Batch 2a + 2e `codev account` CLI + configurable global-default
66
- `codev account list | add <label> [--dir D] | default <label> | remove <label> | regenerate | show | install | uninstall`
77
- One shared generator (`src/cli/account-manager.ts`) produces both `~/.config/codev/accounts.json` and `accounts.sh`, replacing Batch 1's hand-editing; run in dev via `yarn account <cmd>` (PATH install + Settings UI land in Batch 2b)
8+
- Batch 2e (global-default): `codev account default <label>` + the shell dispatcher route bare `claude` to a chosen account; CodeV resume now uses `command claude` (bypasses the dispatcher) so a non-anchor global-default can't misroute an anchor-account resume
89
- Adds Vitest + a generator test suite, and a real CI workflow (replacing the placeholder)
910

1011
## 1.0.76

docs/multi-account-support-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ good. But the hook must be **registered** in each account's `settings.json`. Opt
351351
- New-session launch (Projects `⌘+Enter`): allow an account override, e.g. extend the
352352
planned `>` command mode (`> claude @work myrepo`) or an account segment in the
353353
expanded project row.
354+
- **Coupled with Batch 3 (§5).** Truly resuming/sharing a *transcript* across accounts
355+
only works if the session data (and global config: CLAUDE.md/skills) is shareable
356+
across config dirs — i.e. it depends on Batch 3's cross-account reuse. So design 2c
357+
and Batch 3 **together**: without sharing, 2c is limited to "new session in this cwd
358+
under account Y"; with sharing, genuine cross-account resume becomes possible.
354359

355360
### 6.H pyenv-style auto-switch by folder (requirement 6, nice-to-have, "reverse" priority)
356361

src/claude-session-utility.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,16 +1075,22 @@ const getResumeConfigDirEnv = (sessionId: string): string | null => {
10751075
};
10761076

10771077
/**
1078-
* Build `claude --resume <id>`, prefixed with CLAUDE_CONFIG_DIR when the session
1079-
* belongs to a non-default account so it resumes under the right account.
1078+
* Build `command claude --resume <id>`, prefixed with CLAUDE_CONFIG_DIR when the
1079+
* session belongs to a non-default account so it resumes under the right account.
10801080
*/
10811081
const buildResumeCommand = (sessionId: string): string => {
10821082
const configDir = getResumeConfigDirEnv(sessionId);
10831083
// Single-quote the value: some terminal injections (Ghostty `initial input`)
10841084
// don't escape the command, so a double-quoted prefix would break their
10851085
// AppleScript string. Single quotes are safe across all terminals + handle spaces.
10861086
const prefix = configDir ? `CLAUDE_CONFIG_DIR='${configDir}' ` : '';
1087-
return `${prefix}claude --resume ${sessionId}`;
1087+
// `command claude` bypasses the accounts.sh `claude` dispatcher. CodeV has
1088+
// already resolved the exact account (the prefix, or none for the anchor), so
1089+
// the shell must NOT re-route a bare `claude` to a configured non-default
1090+
// global-default (§2e) — that would resume an anchor-account session under the
1091+
// wrong account. Every terminal here runs the string through a shell, so the
1092+
// `command` builtin is available.
1093+
return `${prefix}command claude --resume ${sessionId}`;
10881094
};
10891095

10901096
/**

0 commit comments

Comments
 (0)