Repository navigation
Conversation
OMP emits session_start once per process. Opening a session with /new, /resume or /fork emits session_switch, which the extension ignored, so the new session never got the ruleset. Restore state on session_switch the same way as on session_start. Pi does not emit session_switch. The OMP smoke test now opens a new session and checks for the ruleset. Fixes ayghri#291
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
On OMP, a session opened with
/new,/resumeor/forkinside a running process never gets the ruleset, so ADHD mode is silently off there, even withalwaysOnor--adhd.OMP emits
session_startonce per process. Session changes emitsession_switch(reasonnew,resumeorfork), which the extension did not handle. This PR restores state onsession_switchthe same way as onsession_start. Pi 1.5.2 has nosession_switchevent (it emitssession_startwith a reason), so nothing changes on Pi. Pi'sExtensionAPItypes do not declare the event, hence the narrow cast.new_session, the new session has noi-have-adhd-rulesmessage.The OMP branch of
scripts/check_pi_extension.pynow opens a new session and checks for the ruleset.Fixes #291. #228 also covers this, together with
session_branchhandling and unrelated eval-budget changes. This PR is only the session-switch part; close it if #228 lands first.Authorship and provenance — select exactly one
Agent/tool and model/version: oh-my-pi (omp) 18.20.0 with Claude Opus 5.5 (
claude-opus-5-5)Agent contribution: Diagnosis from session files and an RPC repro, the code change, the smoke-test step, the checks below, and this description.
Human verification: The submitter reported the missing ruleset after
/new, reviewed the complete diff, and approved submitting it. The checks below were run by the agent, not by the submitter.Known limitations or uncertain results:
/resumeand/forkuse the same handler but were not exercised separately. Checked on Windows 11 only. Threetest_judge.EndToEndTesttests fail on this machine on bothmainand this branch.Labels
Target label: Target:Integrations
Author label: Author:AI
Workflow labels: bug
Safety and side effects
Side effects, permissions, network access, and cost:
None. On OMP the handler re-runs the existing state restore when the session changes. The smoke-test step adds one
new_sessionRPC call to the existing--no-sessionrun; no model request.Compatibility
piandompfields inpackage.json.)Migration or rollback notes: None. Revert the commit to roll back.
Verification
Windows 11, OMP 18.20.0,
PYTHONUTF8=1for the smoke tests (see #245).python scripts/check_pi_extension.py --runtime omp, new smoke step withmain's extension — fails:AssertionError: Rules were not injected into the session opened by /newpython scripts/check_pi_extension.py --runtime ompon this branch —omp extension smoke test passedpython scripts/check_pi_extension.pywith Pi 1.5.2 (npm install --prefix <tmp> --ignore-scripts @earendil-works/pi-coding-agent@1.5.2) —pi extension smoke test passedpython -m unittest discover -s tests— 78 tests, 3 failures intest_judge.EndToEndTest; the same 3 fail onmaintsc --noEmit --strict(TypeScript 5) onextensions/i-have-adhd.tsagainst Pi 1.5.2 types — 0 errors onmainand on this branch; an uncastpi.on("session_switch", ...)fails with TS2769Behavior evals: Not run; the ruleset text does not change.
Final accountability