Conversation
…gent changes directory (backnotprop#2197) Fixes backnotprop#2197. Plan history was keyed by the git repo of the process cwd at each submit, so a shell cd into a nested repo between submits started a new history at version 1 and the UI showed no previous versions. - Name the history project from the session's project root: $.session.root() in the mod, CLAUDE_PROJECT_DIR in the classic hook. - Pin each plan's project per (session, date-free slug) on first save, so /cd or a worktree move mid-plan keeps later versions in the same history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eep the cwd's project (backnotprop#2197) Drop the session-root default (projectRoot from $.session.root() / CLAUDE_PROJECT_DIR): a new plan's history project stays the current folder's, exactly as before. Keep the per-session pin, hardened: keyed by (session, date-free slug), session id validated before it names a file, one 0600 JSON file per session written atomically, pins live for the 48 h continue window and only while the pinned project holds the chain, at most 50 per session, stale session files swept, a corrupt file ignored. The mod sends its session id on claude-mod-plan's stdin. Co-authored-by: aomalov <12465803+aomalov@users.noreply.github.com>
|
Heads-up: I saw #2199 after opening this, and it covers #2197 in a way that keeps where new plans land unchanged, so it's the better base. Feel free to close this one. The one piece here #2199 lists as not covered is a plan started inside a nested clone and resubmitted from the root or another clone. The one red check here (Pi extension AI runtime, Windows) is a |
Fixes #2197. Diagnosis and the per-session pin by @aomalov; a maintainer follow-up commit narrowed the fix so nothing changes for existing users.
The bug
startPlannotatorServernames the history project withdetectProjectName(), which readsgit rev-parse --show-toplevelfromprocess.cwd(). The plan CLI inherits the session's current directory, so a shellcdinto a nested git clone between two submits writes the next version tohistory/<other-repo>/<slug>/001.md, and the Versions tab never opens. Same class as #1679, on theprojecthalf ofhistory/{project}/{slug}.The fix: pin a plan's project per session
ServerOptions.sessionTag(claude-code:<id>): the mod sends its session id onclaude-mod-plan's stdin (sessionId, falling back toPLANNOTATOR_SESSION_TAG); the classicPermissionRequesthook uses the payload'ssession_id, Claude Code origin only (never Gemini).pinPlanProject(sessionTag, slug, detected)(packages/shared/storage.ts) keys a pin by (session, date-free slug, the partresolveHistorySlugmatches on). When this session saved this plan within the 48 h continue window and that project still holds the chain, the resubmit uses that project wherever the cwd is now (root → clone, clone → root, clone → clone). Otherwise the current folder's project is used and recorded. Each save and in-session revision refreshes the pin.<data dir>/plan-projects/<host>/<session id>.json, 0700 folders, a 0600 file written whole (temp + rename), at most 50 plans per session, expired entries dropped, session files untouched for 7 days swept. The session id is validated (charset, length, no..) before it names a file; a missing or corrupt file, or a pinned project that is not one path segment, is ignored and never fails a submit.uninstall --purgeremovesplan-projects/.What does not change
projectRoot) was dropped./api/doc,projectRooton/api/plan,repoInfoand thesessions/label keep the cwd.sessionIdis ignored. New CLI + old mod:PLANNOTATOR_SESSION_TAGor nothing.Tests
apps/hook/server/plan-history-session.test.ts: the CLI as real processes, with a scratch data dir andNO_BROWSER, against a workspace repository holding two clones:previousPlan= v1) through both the mod and the classic hook, and the two paths share one session's pins;pinPlanProjectunit tests inpackages/shared/storage.test.ts(keying, 0600, gone chain, expiry, corrupt file, unsafe tags, cap). The mod's stdin carriessessionId(controller.test.ts).docs/agent-guides/server-and-storage.md, the stdin inclaude-code-mod.md.🤖 Generated with Claude Code