feat(pi): add session_tree handler for MCR state reset on branch navigation#28
Conversation
45e0244 to
d53bbfd
Compare
d53bbfd to
6f6b6dd
Compare
SummaryAdds a Strengths
IssuesImportant
Suggestions
QuestionsNone — the intent is clear once the missing persistence call is addressed. 🤖 review by |
6f6b6dd to
5e8f94e
Compare
…gation When navigating branches via /tree, MCR session state (sessionFp, safeDropBefore, etc.) becomes invalid because it is tied to a specific message sequence. Without a session_tree handler, stale MCR metadata persisted after branch switches, causing incorrect context-dropping requests and wrong status bar display. - Add session_tree event handler that resets all MCR state fields - Persist energy events via pi.appendEntry so they can be replayed from the session log when navigating to a different branch - Replay totalEnergyJoules from the new branch's custom entries - Guard entry.data with typeof check before property access - Add nwlog call for session_tree observability
5e8f94e to
07896a2
Compare
|
Important — Energy replay dead code: Already addressed in the latest push ( Suggestion — Type-unsafe property access: Valid, fixed in Suggestion — Missing observability: Valid, fixed in Suggestion — PR description mismatch: Already addressed in a prior update — the description now matches the actual diff (two changes: |
|
|
|
|
Summary
The
neuralwatt-mcrpi extension was missing asession_treeevent handler. When a user navigates branches via/tree, MCR session state (sessionFp,safeDropBefore, etc.) becomes stale because it is tied to a specific message sequence that no longer matches the new branch. This caused incorrect context-dropping requests and a wrong status bar display after branch switches.Changes
plugins/pi/extensions/neuralwatt-mcr.tsAdd
session_treeevent handler — resets all MCR state fields on branch navigation (same resets assession_start, minusuuidFallbackwhich must stay stable within the same Pi session). After clearing state, replays energy events from the new branch's session log sototalEnergyJoulesstays accurate, then refreshes the status bar.Persist energy events to session log — added
pi.appendEntry("neuralwatt-energy", { energy_joules: ... })in themessage_endhandler so thesession_treereplay loop has entries to scan.Testing
/tree) with an active MCR session:sessionFpandsafeDropBeforeas expected ✓