legacy-fish: remove daemon-stop (sync with plugin)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
mysqtoandClaude Opus 4.8 committed 2026-07-22 11:17:05 +08:00
1 parent 10eb761141
commit 9695b6d7a6
2 files changed
+7 -28

No files matched your search

+7 -11
View File
@@ -244,20 +244,16 @@ plaintext tokens to a shared or public repo.
- Quit any running `claude` session before switching — an open session can
rewrite `~/.claude.json` on exit and clobber the swap. `ccswitch` warns when it
detects one.
- Recent Claude Code releases keep a background **daemon** (and per-session
workers) that cache each account's auth in memory. On every switch `ccswitch`
stops the daemon and its workers (`claude daemon stop --any`) so the next
session re-reads the restored credential. Workers are stopped too because a
kept worker holds the account it was started under, so a `claude --resume`
would reattach to it and ignore the switch. It is best-effort: on an older
Claude Code, or when no daemon is running, it is a harmless no-op and the
switch proceeds regardless. **Note:** this ends any detached background
Claude Code sessions when you switch.
- Access tokens expire, but the refresh token is restored too, so Claude Code
re-refreshes automatically after a switch.
- OAuth refresh tokens rotate on every use. To keep snapshots valid, `ccswitch`
re-captures the outgoing account into its matching profile automatically on
every switch — so an account you actively use won't go stale.
re-captures the outgoing profile's own credential automatically on every
switch — so an account you actively use won't go stale.
- **Same login, multiple orgs:** a Claude Code OAuth token is bound
server-side to the organization it was minted under, so each org profile
needs its own token. Run `claude auth login` and pick the org, then
`ccswitch save <name>` — this tool keys profiles by `(account, org)` and
never copies one org's token onto another.
## License
-17
View File
@@ -147,19 +147,6 @@ function __ccswitch_add -d "log in a new account and save it as a profile"
__ccswitch_save "$home" "$config" "$name"
end
function __ccswitch_stop_daemon -d "stop the Claude Code daemon so a switch takes effect"
# Recent Claude Code releases keep a background daemon (and per-session
# workers) that cache each account's auth in memory. A kept worker holds
# the account it was started under, so `claude --resume` would reattach to
# it and ignore the switch. Stop the daemon and its workers so the next
# session — including a resume — re-reads the restored credential.
# Best-effort — an older Claude Code or no running daemon is a harmless
# no-op, and a failure never blocks the switch.
command -sq claude; or return 0
command claude daemon stop --any >/dev/null 2>&1
return 0
end
function __ccswitch_sync_current -d "re-snapshot the live account into its matching profile"
# OAuth refresh tokens rotate on every use, so a profile saved earlier goes
# stale as its account keeps running. Before switching away, copy the live
@@ -218,10 +205,6 @@ function __ccswitch_use -d "restore a profile as the active account"
echo "ccswitch: warning — a running 'claude' may overwrite ~/.claude.json on exit; quit it first" >&2
end
# a running daemon caches this account's auth; stop its supervisor so the
# next session picks up the restored credential (background sessions kept)
__ccswitch_stop_daemon
# refresh the outgoing account's snapshot (its token may have rotated)
__ccswitch_sync_current "$home" "$config"