isolate: block with a confirm when shared memory is unseeded

Warn and prompt y/N before launching an isolated session while shared/
has no memory/history, so you don't start fresh by accident. The prompt
disappears once shared/ has content (from seed or a prior session).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
mysqtoandClaude Opus 4.8 committed 2026-07-05 21:39:35 +08:00
1 parent 3d98e3aeab
commit d71ac42bb6
2 files changed
+28

No files matched your search

+5
View File
@@ -124,6 +124,11 @@ ccswitch seed <dir> # ... or from another config dir
Re-run `ccswitch seed` anytime to re-sync from the source (source wins on
same-named files).
While `shared/` is empty, `ccswitch isolate` warns and asks for confirmation
before launching (so you don't start with no memory by accident). The prompt
stops appearing once `shared/` has content — from `ccswitch seed` or from your
first session.
> Note: this pattern relies on `CLAUDE_CONFIG_DIR` (supported) plus symlinking of
> account-agnostic paths (a community pattern, not officially documented). Auth
> stays isolated; only memory/history is shared. Two sessions writing the same
+23
View File
@@ -313,6 +313,17 @@ function __ccswitch_link -d "symlink a shared path into a profile dir, non-destr
end
end
function __ccswitch_seeded -d "true if the shared isolate dir has any seeded memory/history"
set -l shared $argv[1]
test -s "$shared/history.jsonl"; and return 0
test -s "$shared/CLAUDE.md"; and return 0
if test -d "$shared/projects"
set -l first (find "$shared/projects" -mindepth 1 -maxdepth 1 2>/dev/null | head -1)
test -n "$first"; and return 0
end
return 1
end
function __ccswitch_isolate -d "launch a concurrent session isolated to a profile, memory shared"
set -l base (__ccswitch_isolate_home)
set -l shared "$base/shared"
@@ -349,6 +360,18 @@ function __ccswitch_isolate -d "launch a concurrent session isolated to a profil
__ccswitch_link "$shared/history.jsonl" "$dir/history.jsonl"
__ccswitch_link "$shared/CLAUDE.md" "$dir/CLAUDE.md"
# blocking warning while the shared memory is still empty (unseeded)
if not __ccswitch_seeded "$shared"
echo "⚠ shared isolate memory is empty — this session starts with no" >&2
echo " history or CLAUDE.md. Run 'ccswitch seed' first to import your" >&2
echo " ~/.claude memory/history." >&2
read -l -P " launch '$name' anyway? [y/N] " ans
if not string match -rqi '^y(es)?$' -- "$ans"
echo "aborted — nothing launched" >&2
return 1
end
end
echo "launching isolated '$name' — CLAUDE_CONFIG_DIR=$dir (memory shared via $shared)"
echo "(first run for a profile will ask you to sign in)"
env CLAUDE_CONFIG_DIR="$dir" claude $argv[2..-1]