Skip to content

fix(extmgr): support Pi 0.70 session startup#16

Merged
ayagmar merged 1 commit intomasterfrom
fix/pi-0.70.6-compat
Apr 29, 2026
Merged

fix(extmgr): support Pi 0.70 session startup#16
ayagmar merged 1 commit intomasterfrom
fix/pi-0.70.6-compat

Conversation

@ayagmar
Copy link
Copy Markdown
Owner

@ayagmar ayagmar commented Apr 29, 2026

Summary

  • Bump Pi dev dependencies to 0.70.6.
  • Remove the removed session_switch extension hook and rely on session_start for session bootstrapping.
  • Update the auto-update regression test to exercise replacement-session startup via session_start.

Closes #15.

Verification

  • pnpm run check

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed session initialization to only hydrate configuration and reset auto-update timers on session start, not during session switches.
  • Tests

    • Updated auto-update timer validation test.
  • Chores

    • Updated development dependency versions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

The extensions manager is updated to work with Pi API v0.70.6, which deprecated the session_switch event. The session_switch handler registration is removed from src/index.ts since session_start already handles necessary initialization, and the corresponding test is updated accordingly.

Changes

Cohort / File(s) Summary
Dependency Updates
package.json
Upgraded @mariozechner/pi-coding-agent and @mariozechner/pi-tui from ^0.63.1 to ^0.70.6 to address API compatibility.
Session Switch Removal
src/index.ts
Removed the session_switch event handler registration; initialization now occurs solely through session_start which was already present and handles the same bootstrapping logic.
Test Migration
test/auto-update.test.ts
Updated auto-update timer shutdown test to invoke session_start with { reason: "resume" } instead of session_switch event, validating timer behavior during replacement session initialization with auto-update disabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Old events hop away today,
session_switch goes on its way,
session_start hops in with grace,
Taking over its rightful place!
Version bumps and tests refound,
The manager's back—hip hip, hooray! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective: updating to Pi 0.70 compatibility by fixing session startup handling.
Linked Issues check ✅ Passed All requirements from issue #15 are met: session_switch removed, session_start properly used, test updated, and dependencies bumped to 0.70.6.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives: dependency updates, session hook migration, and test updates align with issue #15 requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pi-0.70.6-compat

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/auto-update.test.ts (1)

76-151: ⚠️ Potential issue | 🟡 Minor

Add session_shutdown call to test the replacement session lifecycle.

The test title states "replacement session" but doesn't exercise the actual replacement flow. Per Pi's session lifecycle, when a session is replaced, session_shutdown is fired on the old session first, then session_start on the new one. Your code registers a session_shutdown handler that stops the timer (in src/index.ts), but the test never invokes it, leaving that cleanup path untested. Additionally, when session_start receives reason: "resume", Pi includes previousSessionFile in the payload, which the test omits.

🧪 Suggested test adjustment
-    await handlers.session_start?.({}, enabledCtx);
+    await handlers.session_start?.({ reason: "startup" }, enabledCtx);
     assert.equal(isAutoUpdateRunning(), true);

-    await handlers.session_start?.({ reason: "resume" }, disabledCtx);
+    await handlers.session_shutdown?.({ reason: "switch" }, enabledCtx);
+    await handlers.session_start?.(
+      { reason: "resume", previousSessionFile: "/tmp/previous-session.pi" },
+      disabledCtx,
+    );
     assert.equal(isAutoUpdateRunning(), false);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/auto-update.test.ts` around lines 76 - 151, The test should simulate the
full replacement lifecycle by invoking the registered session_shutdown on the
old session before starting the new one and include previousSessionFile in the
resume payload; specifically, call the stored handlers.session_shutdown with the
enabledCtx (to trigger the timer-stop cleanup path in your extension's
session_shutdown handler) and then call handlers.session_start with { reason:
"resume", previousSessionFile: "<some path>" } and disabledCtx so the
replacement path in session_start is exercised and the auto-update timer is
correctly stopped.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@test/auto-update.test.ts`:
- Around line 76-151: The test should simulate the full replacement lifecycle by
invoking the registered session_shutdown on the old session before starting the
new one and include previousSessionFile in the resume payload; specifically,
call the stored handlers.session_shutdown with the enabledCtx (to trigger the
timer-stop cleanup path in your extension's session_shutdown handler) and then
call handlers.session_start with { reason: "resume", previousSessionFile: "<some
path>" } and disabledCtx so the replacement path in session_start is exercised
and the auto-update timer is correctly stopped.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 31127b59-3ba7-4f03-a79a-9f559d05dac9

📥 Commits

Reviewing files that changed from the base of the PR and between cd32efc and cb9a2dd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • package.json
  • src/index.ts
  • test/auto-update.test.ts
💤 Files with no reviewable changes (1)
  • src/index.ts

@ayagmar ayagmar merged commit 60c4943 into master Apr 29, 2026
2 checks passed
@dmg-egg
Copy link
Copy Markdown

dmg-egg commented Apr 30, 2026

lgtm

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.

pi-extmgr is broken by a Pi API change in v0.65.0

2 participants