Skip to content

fix(sessions): respect project cwd in readiness checks - #1652

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
XY-code1:fix/pi-project-cwd-readiness
Nov 1, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
XY-code1:fix/pi-project-cwd-readiness

Conversation

@XY-code1

@XY-code1 XY-code1 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • pass the requested project cwd into adapter readiness checks during session listing
  • let Pi recognize a project-only .pi/settings.json sessionDir even when the global store is absent and the requested project is not process.cwd()
  • add an AgentSession-level regression test for the exact tool_unavailable failure

This is the focused follow-up noted on #1418 after #1586. It does not change the remaining adapter scope of that issue.

Why

listInstalledPlatforms(toolRoots, cwd) already checked readiness against the requested project, but listPlatform performed a second readiness check without that cwd. PiAdapter.isReady() then fell back to process.cwd(), so an explicitly requested project-only Pi store could be rejected before listConversations(cwd) ran.

Testing

Regression proof before the fix:

FAIL lists Pi from a project-only store outside the process cwd
Received: [{ code: "tool_unavailable", platform: "pi", ... }]

After the fix:

  • npx vitest run src/__tests__/agent-session-list.test.ts --maxWorkers=1 — 19 passed, 1 skipped
  • npm run typecheck — passed
  • targeted type-aware oxlint on the two changed files — passed
  • npm run build — passed
  • git diff --check — passed

Real CLI verification with a missing global Pi store, a project outside the CLI cwd, project-level sessionDir, a local archive repo, and a local bare remote:

$ node dist/cli.js session push --source pi --scrub -y --limit 1 --repo-root <archive> --cwd <project>
  Redacted: 0 secret-looking value(s) (best-effort; review before sharing)

  ✓ Pushed 1 session(s) from pi
  commit: f7e8c033

EXIT=0
ARCHIVED=1

The repository-wide npm run lint completed oxlint but the documentation phase reports generated/default-workflow documentation already stale on the base revision; this PR does not change commands, descriptors, workflows, or docs.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

No findings in the specified diff.

  • Passing cwd to adapter.isReady(cwd) addresses the described readiness mismatch.
  • The regression test covers a project-only Pi store outside the process cwd.
  • The PR description includes sufficient testing: a representative real-CLI run records a successful push, EXIT=0, and ARCHIVED=1.

Review was read-only; no PR code was run, built, or installed.

@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 d7df97c4. listPlatform now passes the requested cwd to isReady, so a Pi project whose .pi/settings.json sets sessionDir is listed when the global Pi store is missing and the project is not the current directory, instead of failing with tool_unavailable. The other isReady() calls without a cwd (copy in agent-session.ts, the archive restore in archive.ts) are write paths, and Pi refuses writes, so they do not hit this case. The new AgentSession.list test fails without the change, and the description carries a built-CLI session push --cwd <project> run that archives the session.

@SaulMoro
SaulMoro merged commit 719cbdf into Tencent:main Nov 1, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
Session listing passes the requested project `cwd` to the adapter's readiness check, so a Pi project whose `.pi/settings.json` sets `sessionDir` is listed when the global Pi store is missing and the project is not the current directory, instead of failing with `tool_unavailable`.

Related to Tencent#1418
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