Skip to content

fix(pi): restore the session's mode after OMP session switches - #1050

Merged
DietrichGebert merged 2 commits into
DietrichGebert:mainfrom
andrebrait:fix/pi-extension-omp-compat
Oct 13, 2026
Merged

DietrichGebert merged 2 commits into
DietrichGebert:mainfrom
andrebrait:fix/pi-extension-omp-compat

Conversation

@andrebrait

Copy link
Copy Markdown
Contributor

Summary

The shared Pi extension loads in oh-my-pi (OMP), but after /new, /resume or /fork a session keeps the previous session's mode. Pi re-emits session_start on those transitions. OMP emits only the legacy session_switch and session_branch events, which the extension ignored.

This registers those two events next to the existing session_tree handler. All three call the same restoreSessionMode. Nothing else changes, and no OMP-only code is added.

Pi compatibility

Pi 0.85.1 never emits session_switch or session_branch (its changelog says it replaced them with session_start plus a reason), so the new handlers do nothing there. Older Pi versions that still emit session_switch get the same fix. The restore is idempotent and appends no entries.

Verification

  • New test: session_switch and session_branch restore the target session's mode, including the default for an empty new session. It fails without the fix.
  • node --test tests/*.test.js passes 127 tests, and npm test --prefix pi-extension passes 29.
  • I drove both hosts over RPC: set /ponytail lite, prompt, new_session, prompt, switch back to the first session, prompt. The table shows the level injected into each prompt.
Host Before After
OMP 18.6.2 lite, lite, lite lite, full, lite
Pi 0.85.1 lite, full, lite lite, full, lite

@andrebrait

Copy link
Copy Markdown
Contributor Author

A review-only companion PR with the identical diff is at andrebrait#1.

@andrebrait
andrebrait force-pushed the fix/pi-extension-omp-compat branch from a019912 to 6e8823a Compare October 8, 2026 08:37
andrebrait added a commit to andrebrait/ponytail that referenced this pull request Oct 8, 2026
… session switches

Squashed from origin/fix/pi-extension-omp-compat (6e8823a) onto upstream/main.
OMP keeps Pi's legacy session_switch and session_branch events instead of re-emitting session_start on /new, /resume, /fork and /branch, so a new session inherited the previous session's mode. Restore the mode on those events, like session_tree.
@andrebrait
andrebrait force-pushed the fix/pi-extension-omp-compat branch from 6e8823a to f8a7c60 Compare October 10, 2026 07:25
andrebrait added a commit to andrebrait/ponytail that referenced this pull request Oct 10, 2026
… session switches

Squashed from origin/fix/pi-extension-omp-compat (f8a7c60) onto upstream/main.
@DietrichGebert
DietrichGebert merged commit 6348886 into DietrichGebert:main Oct 13, 2026
1 check passed
@DietrichGebert

Copy link
Copy Markdown
Owner

Thanks! Tested it over RPC with OMP 18.10.3 and pi 0.73.1: on main a new OMP session kept the old level, with this PR it starts at the default and switching back restores the old one; pi behaves the same as before. Merged, will be in the next release.

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