fix(cli): restore Pi session resume - #1206
Merged
Merged
Conversation
There was a problem hiding this comment.
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
force-pushed
the
fix/pi-session-resume
branch
from
July 28, 2026 09:01
df0b174 to
6179262
Compare
There was a problem hiding this comment.
Findings
- [Major] Keep fresh Pi launches on a new session — removing
new_sessionhere changes the non-resume path as well, so a plainpilaunch can now pick up Pi's persisted session instead of starting a fresh conversation. The resume fix only needs to skipnew_sessionwhenresumeSessionIdis 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_sessionfor 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
There was a problem hiding this comment.
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 avoidnew_sessionbefore the initialget_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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--session <path|id>flagWhy
HAPI currently starts resumed Pi sessions with
pi --mode rpc --session-id <id>, but the official Pi CLI rejects--session-idand exposes--session <path|id>.Pi also creates or loads its session before RPC mode starts. Sending
new_sessionimmediately afterward replaces the selected session and can race the followingget_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 typecheckcd 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)--session-idexits withUnknown option;--session <id>returns the requested session ID and leaves the session file unchanged, without a model requestLocal 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.