Skip to content

fix(session): find Pi sessions through workspace symlinks - #1798

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
ydflow:fix/pi-session-workspace-aliases
Nov 9, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
ydflow:fix/pi-session-workspace-aliases

Conversation

@ydflow

@ydflow ydflow commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Pi and Oh My Pi session lookup compares path.resolve() results for the requested workspace and the JSONL header's cwd. A symbolic link or Windows directory junction gives the same workspace two absolute spellings, so session migrate <id> -s pi -t claude-code --cwd <link> --json fails with not_found even though the session exists. The reverse direction fails too, when the header records the link and the command uses the real path.

  • Use the existing resolveRealCwd helper for both sides of the Pi-family workspace comparison.
  • Add regression coverage through AgentSession.list and id-based AgentSession.find, for both platforms and both path directions, including a different workspace that must stay excluded.
  • Document workspace links in the English and Chinese session guides.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Test Plan

Windows, Node.js 24.19.0, upstream baseline a03ca33d8a02304cc22be8425cc1854d4686716c.

  • npm run typecheck passed.
  • npm run lint passed, including documentation checks.
  • npm run build passed.
  • npx vitest run src/__tests__/agent-session-list.test.ts src/__tests__/pi-session-adapter.test.ts --maxWorkers=2 passed with 34 tests passed and 1 platform skip. Before the runtime fix, the two new Pi/OMP cases both failed because listing returned [].
  • git diff --check passed.

Real CLI verification

Built both the clean upstream baseline and this branch. An external fixture script created an isolated temporary home, a real workspace, a Windows junction to that workspace, and synthetic native v3 JSONL logs containing a user message, a tool call and its result. The target Claude Code store was also isolated in that temporary home.

For each of pi and omp, the script ran the following real command once with a real-path header and a junction --cwd, then with a junction header and a real-path --cwd.

node dist/index.js session migrate <id> -s <pi-or-omp> -t claude-code --cwd <other-spelling> --json

All four combinations on the clean baseline exited 1 with error.code = not_found. All four on this branch exited 0 and migrated the session. A second invocation of each returned reused = true with the same target session id. The written Claude Code transcript contained the source user message, tool call id and tool result.

Expanded regression check

npx vitest run src/__tests__/agent-session-copy.test.ts src/__tests__/agent-session-find.test.ts --maxWorkers=2 --reporter=json gave 124 passed, 20 failed and 3 skipped on both this branch and a separate clean baseline worktree. The failed test-name sets were identical. All 20 failures concern Cursor/WorkBuddy copy expectations on Windows, where the existing platform gate returns no_adapter. The find suite passed. The full suite is left to CI as CONTRIBUTING requests for this scope of change.

Related Issues

Found during source inspection. Searches across open and merged PRs and issues for Pi workspace, cwd, symlink and realpath fixes found no matching fix. The current open tool-package and connected-driver PRs do not modify these files.

Notes for Reviewers

The existing helper retains its fallback to an absolute path when a directory no longer exists. Verification used synthetic Pi-family logs and the built TeamAI CLI. Native Pi/OMP client verification is pending.

Codex assisted issue discovery, implementation, validation and this PR description.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

No findings in the scoped PR diff.

The description satisfies the testing requirement: it records build, lint, typecheck, regression tests, and real-CLI migration verification for both Pi and OMP in both junction/path directions, including reuse and transcript checks.

Review was read-only; I did not run, build, or install PR code.

@SaulMoro SaulMoro 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.

This was generated by AI during triage.

Approving at 99fb277.

I reproduced the bug on main (a03ca33) with a built CLI. With the workspace reached through a symbolic link, from either side (the path in the session header or the one passed in), every Pi and Oh My Pi lookup returned not_found. At this head all six combinations succeed, and a second run reports reused: true. The controls behave the same on both builds, and a different workspace is still excluded (exit 1). I also ran it with TMPDIR set to a symlinked directory. resolveRealCwd is the helper the other adapters already use, so Pi now compares paths the same way they do.

Hidden scope: none. Any pair of paths that matched before still matches. The guide sentence on both pages describes the fix.

[P3 nit] agent-session-list.test.ts is not in src/__tests__/helpers/windows-tests.ts, so the Windows CI job does not run the new junction case. Adding it there would let CI back the Windows claim, which today rests on your own run.

The CI review found nothing, and I agree.

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.

3 participants