Skip to content

fix(cli): restore Pi session resume - #1206

Merged
tiann merged 2 commits into
tiann:mainfrom
nannant666:fix/pi-session-resume
Jul 28, 2026
Merged

fix(cli): restore Pi session resume#1206
tiann merged 2 commits into
tiann:mainfrom
nannant666:fix/pi-session-resume

Conversation

@nannant666

Copy link
Copy Markdown
Contributor

Summary

  • pass Pi resume IDs with the supported --session <path|id> flag
  • preserve the session Pi creates or resumes before entering RPC mode
  • cover the child-process arguments and initial RPC sequence with a focused regression test

Why

HAPI currently starts resumed Pi sessions with pi --mode rpc --session-id <id>, but the official Pi CLI rejects --session-id and exposes --session <path|id>.

Pi also creates or loads its session before RPC mode starts. Sending new_session immediately afterward replaces the selected session and can race the following get_state, so HAPI may persist an ID for a session that will not receive subsequent prompts.

This change lets Pi own startup session initialization and only queries its initial state.

Testing

  • bun typecheck
  • cd cli && bunx vitest run src/pi/runPi.test.ts src/pi/session.test.ts (9 passed)
  • bun run test:hub (643 passed, 3 skipped)
  • cd web && bunx vitest run --maxWorkers=1 (1556 passed)
  • bun run test:shared (142 passed)
  • Pi 0.73.1 isolated manual check: --session-id exits with Unknown option; --session <id> returns the requested session ID and leaves the session file unchanged, without a model request

Local environment limits

The full CLI run completed 1518 tests with 5 unrelated host failures: four difftastic tests require glibc 2.32-2.34 while this host has 2.31, and the 20-process runner stress test exceeded the container 512-PID limit. The Pi tests pass independently.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings
No findings.

Questions
None.

Summary
Review mode: initial
No high-confidence issues found in the latest diff. Residual risk: I did not run the PR code; coverage is focused on the resume startup path and does not add a separate fresh Pi launch regression test for the removed new_session RPC.

Testing
Not run (automation).

HAPI Bot

Use Pi's supported --session flag and keep the session initialized by the CLI instead of replacing it with a racing new_session RPC.
@nannant666
nannant666 force-pushed the fix/pi-session-resume branch from df0b174 to 6179262 Compare July 28, 2026 09:01

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • [Major] Keep fresh Pi launches on a new session — removing new_session here changes the non-resume path as well, so a plain pi launch can now pick up Pi's persisted session instead of starting a fresh conversation. The resume fix only needs to skip new_session when resumeSessionId is present. cli/src/pi/runPi.ts:391-394
    Suggested fix:
    if (!opts.resumeSessionId) {
        transport.send({ type: 'new_session' });
    }
    transport.send({ type: 'get_state' });

Summary

  • Review mode: follow-up after new commits
  • One major regression: the new startup path drops new_session for every Pi launch, not just resumed ones, so fresh launches may attach to the previous persisted session.
  • Coverage gap: the added test only covers the resume branch; the non-resume startup path is still untested.

Testing

  • Not run (automation)

HAPI Bot

Comment thread cli/src/pi/runPi.ts Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • No issues found in the latest diff.

Summary

  • Review mode: follow-up after new commits
  • The previous regression around fresh Pi launches was addressed in the current head: non-resume startup now omits only Pi-native resume args, resumed startup passes --session, and both paths avoid new_session before the initial get_state.
  • Residual risk: I did not execute PR code; review is based on diff and surrounding source context only.

Testing

  • Not run (automation; PR code execution disabled)

HAPI Bot

@tiann
tiann merged commit 25dfa63 into tiann:main Jul 28, 2026
3 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