Skip to content

Key conversation history by project path, not workspace identity#210

Open
leonidasbarkas98-cpu wants to merge 1 commit into
andrepimenta:mainfrom
leonidasbarkas98-cpu:fix/history-project-scope
Open

Key conversation history by project path, not workspace identity#210
leonidasbarkas98-cpu wants to merge 1 commit into
andrepimenta:mainfrom
leonidasbarkas98-cpu:fix/history-project-scope

Conversation

@leonidasbarkas98-cpu

Copy link
Copy Markdown

Conversation files (storageUri/conversations) and the index (workspaceState) were both scoped to the VS Code workspace identity, so opening the same folder directly vs. through a .code-workspace file produced two separate histories (#123).

Changes:

  • New project key: sha256 over the normalized (win32: lowercased) path of the primary workspace folder; conversation files now live in globalStorageUri/conversations/<projectKey>/, the index in globalState['claude.conversationIndex::<projectKey>'].
  • One-time idempotent migration copies (never moves or deletes) legacy files and merges the legacy index; the migrated flag is only set once every copy succeeded, so a failed copy is retried on the next start and the legacy data stays in place as rollback.
  • The legacy index fallback is gated on the migration flag, so an intentionally cleared history stays empty instead of resurrecting legacy entries.
  • Multi-root workspaces (Difficult working in multi-folder workspaces #22): a new setting claudeCodeChat.workspace.root picks the workspace folder used as Claude's cwd and backup root; the empty default keeps today's behavior (first folder).

Out of scope (possible follow-ups): storing history inside the project (#124), moving the backup git repo and permissions.json off the workspace identity.

Addresses #123 and #22. Based on current main (ab6e307), tsc --noEmit clean, no new dependencies.

Conversation files (storageUri/conversations) and the index
(workspaceState) were both scoped to the VS Code workspace identity, so
opening the same folder directly vs. through a .code-workspace file
produced two separate histories (andrepimenta#123).

- new project key: sha256 over the normalized (win32: lowercased) path
  of the primary workspace folder, 16 hex chars; 'no-workspace' when no
  folder is open,
- conversation files now live in
  globalStorageUri/conversations/<projectKey>/, the index in
  globalState['claude.conversationIndex::<projectKey>'],
- one-time idempotent migration copies (never moves) legacy files and
  merges the legacy index (dedupe by filename, cap 50); the migrated
  flag is only set once every copy succeeded, so a failed copy is
  retried on the next start; legacy data stays in place as rollback,
- the legacy index fallback in the constructor is gated on the
  migration flag so an intentionally cleared history stays empty
  instead of resurrecting legacy entries,
- multi-root (andrepimenta#22): new setting claudeCodeChat.workspace.root picks
  the workspace folder used as Claude's cwd and backup root; empty
  default keeps today's behavior (first folder). Claude runs and
  checkpoints follow the chosen root via _getPrimaryWorkspaceFolder().

Out of scope (follow-ups): storing history inside the project (andrepimenta#124),
moving the backup git repo and permissions.json off the workspace
identity.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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