Skip to content

feat(sessions): resolve each tool's session store through locate (#1221) - #1404

Merged
jeff-r2026 merged 4 commits into
mainfrom
saulmoro/1221-session-stores
Oct 27, 2026
Merged

jeff-r2026 merged 4 commits into
mainfrom
saulmoro/1221-session-stores

Conversation

@SaulMoro

@SaulMoro SaulMoro commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR is step F of #1221. Each tool's session store comes from its descriptor and locate, so a moved home moves the store too.

 TOOLS[tool]
+  sessions: [platform, ...] | 'none' | 'unknown'

 SESSION_PLATFORM_FACTS[platform]
-  tool
+  store: tool-home <home>/<dir> | xdg-data <child> | ide-history
+  resume(id)

 locate(tool, 'sessions', install)
+  own = sessionStoreDir(first platform, recorded toolRoots, host)

 session-flow/fs.ts
-  getClaudeProjectsDir, getCodexSessionsDir, getCodeBuddyProjectsDir, ...

sessionStoreDir resolves a tool-home store in this order: the member's recorded toolRoots entry, when teamai applies it, then the tool's home (recorded or env move), then the default. A recorded root is checked against HOME, as teamai init checked it when it recorded the root. Only the default store sits under os.homedir(), which on Windows is %USERPROFILE% whatever HOME says. locate reads that home from Host.profileHome, so locate and the adapters name the same default store. An entry teamai ignores, such as toolRoots.codebuddy, falls through to the tool's home, so CODEBUDDY_CONFIG_DIR still moves the store. The adapters and the registry read it, and nothing else joins a store path. So CODEBUDDY_CONFIG_DIR=/x puts CodeBuddy's sessions in /x/projects, which is where CodeBuddy 2.176.0 writes them (getHomeProjectsDir()).

Tools with no adapter state what is known:

sessions Tools Source
'none': a known store teamai does not read Copilot, ZCode, OMP, Hermes, dsh, Muse, Qoder, Qoder CN, Kiro, Trae, Trae CN, Pi, OpenClaw Qoder CLI 1.1.78 bundle, Pi 0.99 session-manager.js, OpenClaw 2026.10 openclaw-state-db, Kiro and Trae docs
'unknown' JoyCode its FAQ, changelog and plugin page name no store

Two points differ from the issue text:

  • toolRoots does not move the internal builds (claude-internal, codex-internal, tcodex, tclaude). RELOCATABLE_TOOLS and toolRootSegment ignore their entries, so the matrix asserts an ignored entry rather than the move the issue's check describes.
  • ide-history.ts, cursor-store.ts and the dashboard readers stay as they are. They read IDE data directories, and no tool home moves those.

The adapters' static isAvailable and getDefaultStoragePath had no callers once the registry passed each adapter its store, so they are gone.

Evidence

  • Before: on origin/main, with CODEBUDDY_CONFIG_DIR=<sandbox>/cb-moved, teamai session migrate <id> -s claude-code -t codebuddy reports tool_unavailable, and nothing is written under <sandbox>/cb-moved/projects.
    After: teamai session migrate <id> -s claude-code -t codebuddy at a443f10, with CODEBUDDY_CONFIG_DIR=<sandbox>/cb-moved:

    == session platforms
      claude-code: ✓ installed
      codebuddy: ✓ installed
    == migrate claude-code -> codebuddy
      ✓ Migration successful
      Target file: <sandbox>/cb-moved/projects/<encoded cwd>/faf5a894-….jsonl
    == files under CODEBUDDY_CONFIG_DIR/projects
    <sandbox>/cb-moved/projects/<encoded cwd>/faf5a894-….jsonl
    == files under ~/.codebuddy/projects
    (none)
    
  • locate-sessions.test.ts runs the store matrix through describeLocateMatrix. It covers the default, recorded and env homes for Claude, Codex, Cursor (a recorded cursor-data root moves it, cursor-config does not), CodeBuddy, WorkBuddy and OpenCode (XDG_DATA_HOME moves it, XDG_CONFIG_HOME does not), plus the ignored internal-build roots, an ignored codebuddy entry beside CODEBUDDY_CONFIG_DIR, and the none and unknown rows.

  • locate-sessions.test.ts puts a Windows default store under the profile home when HOME is D:\member and the profile is C:\Users\member, and keeps a recorded cursor-data root on D:.

  • cursor-tool-roots.test.ts keeps a recorded root when os.homedir() is not HOME, and still puts the default store under os.homedir().

  • session-platform-facts.test.ts checks the descriptor and the facts against each other: every listed platform has facts, every tool-home store names the tool that lists it, and no platform is listed twice.

  • At 9ad889d (the stack top, which carries this diff): npx tsc --noEmit, npm run lint and npm run build pass, and npx vitest run passes 17137 tests in 576 files (21 skipped).

Merge Danger

Door: two-way

Data at rest does not change. Only the directory that sessions are read from and written to moves, and only for a member whose tool home moved.

Blast Radius: sessions

For a member who set CODEBUDDY_CONFIG_DIR, teamai session now lists the sessions CodeBuddy wrote under the moved home. Sessions an earlier release migrated into ~/.codebuddy/projects while the variable was set stay there. CodeBuddy never read them, and teamai no longer lists them.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Code Erosion Report

Informational — never blocks the merge. scb-check==0.2.0 SlopCodeBench metrics; method & caveats in docs/dev/ci-code-erosion.md.

Metric Value Human band Agent band Reading
Verbosity* 0.053 0.15 0.33 human
Erosion 0.706 0.31 0.68 agent
Cognitive erosion 0.874 – – –

Scanned 480 files / 106487 SLOC · high-CC functions 838/9460

* On TypeScript, verbosity is partial and the bands are Python-calibrated.

Rule hits (TS verbosity layer)

Standalone ast-grep, separate from the number above.

Rule Hits
unnecessary-else-after-return 64
empty-catch-block 5
self-assignment 1

70 distinct lines flagged across src/.

@github-actions

Copy link
Copy Markdown
  • [P2 non-blocking] Default session paths differ between locate and adapters — src/locate.ts:937: On Windows with HOME=D:\member, %USERPROFILE%=C:\Users\member, and no recorded roots or home moves, locate('cursor', 'sessions', install) returns D:\member\.cursor\projects because it passes the default realHost() explicitly. The adapter instead uses C:\Users\member\.cursor\projects through sessionStoreDir’s profile-home default. Keep member-home validation separate from default-store resolution, and test this case through locate, not only the helper.

The PR description documents sufficient testing: a representative real-CLI migration at a443f10d9, plus type checking, lint, and unit tests. Nothing from the PR was run, built, or installed during this review.

@SaulMoro

Copy link
Copy Markdown
Collaborator Author

Agreed that the two defaults differ on Windows. Nothing reads locate(_, 'sessions') in production yet: the adapters and the registry call sessionStoreDir directly, and only the matrix test calls locate. So no command lists or writes the wrong store today. I'm tracking it in #1221's follow-ups ("locate(_, 'sessions') has no production caller"). The fix is to give the host the profile home for the default store and keep HOME for checking recorded roots, together with the first production caller.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from a443f10 to 2741a21 Compare October 26, 2026 06:44
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:913: recorded roots are validated against member HOME, while default stores use profileHome. Regression tests now exercise both cases through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, and unit tests. The older tested commit is not blocking under the review rules.

Nothing from the PR was run, built, or installed.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from 2741a21 to e1b652a Compare October 26, 2026 08:13
@SaulMoro SaulMoro assigned jeff-r2026 and unassigned jeff-r2026 Oct 26, 2026
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:913: recorded roots use member HOME, while default stores use profileHome. Tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from e1b652a to 60f4152 Compare October 26, 2026 08:37
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:913: recorded roots use member HOME, while default stores use profileHome. Regression tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:913: recorded roots use member HOME, while default stores use profileHome. Regression tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from a27d1dd to b37754b Compare October 26, 2026 11:33
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:913: recorded roots use member HOME, while default stores use profileHome. Regression tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing: a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from b37754b to 354649b Compare October 26, 2026 15:17
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:936: recorded roots use member HOME, while default stores use profileHome. Regression tests exercise both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from 354649b to 82ec440 Compare October 26, 2026 16:22
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:936: recorded roots use member HOME, while default stores use profileHome. Regression tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from 82ec440 to aa86d3f Compare October 26, 2026 21:02
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:936: recorded roots use member HOME, while default stores use profileHome. Regression tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from aa86d3f to 164b375 Compare October 26, 2026 23:50
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding is fixed in src/locate.ts:936: recorded roots use member HOME, while default stores use profileHome. Regression tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

Each TOOLS entry now declares its session platforms, and each platform
declares its store and resume command in SESSION_PLATFORM_FACTS.
locate(tool, 'sessions') and the session adapters resolve the store in one
place, sessionStoreDir, so a store follows the tool's recorded root or home.

CodeBuddy sessions now follow a moved home (CODEBUDDY_CONFIG_DIR, or a
recorded one) instead of always ~/.codebuddy.
@SaulMoro
SaulMoro force-pushed the saulmoro/1221-session-stores branch from 164b375 to 40e4480 Compare October 27, 2026 00:11
@github-actions

Copy link
Copy Markdown

No new findings in the specified PR diff.

  • Resolved: The earlier Windows-path finding remains fixed in src/locate.ts:936: recorded roots use member HOME, while default stores use profileHome. Regression tests cover both through locate in src/__tests__/locate-sessions.test.ts:44.
  • Testing: The PR description documents sufficient testing, including a representative real-CLI CodeBuddy migration at a443f10d9, plus type checking, lint, build, and unit tests. The older tested commit is not blocking under the trusted review rules.

Nothing from the PR was run, built, or installed.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on main 703d1c9: tsc, lint, build pass; related unit and E2E tests pass; CI green.

@jeff-r2026
jeff-r2026 merged commit 43b1bbc into main Oct 27, 2026
17 checks passed
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.

2 participants