Repository navigation
fix(last): under Rex, Pi's last opens the focused session, not the newest in the folder - #156
Merged
Merged
Conversation
…west in the folder With two Pi sessions in one folder, `last --pid` ignored the pid and opened the most recently written transcript. A Pi running our extension lists its pid and transcript in the Pi link registry; `last` now uses that entry when the pid matches, and keeps the newest-in-folder choice otherwise. Reported and diagnosed in #145. Co-authored-by: KG <[email protected]>
1 task
backnotprop
added a commit
to kaushikgopal/plannotator-tui
that referenced
this pull request
Nov 22, 2026
…ocket Main already has a Pi extension that lists each session in the Pi link registry, and plannotator#156 uses its pid and transcript for `last --pid`. This drops the parts of this branch that the registry already covers, and keeps what it did not: - Dropped: the second extension in pi/ (its Unix socket server, tests, package files), the root package.json, the CI Node jobs, the socket reader in rex/pi.rs, and the `--pi-leaf-id` flag that carried its answer to the pane. Pi users without our extension keep the folder's newest transcript, as on main, instead of an error. - /tree position: `/tree` moves Pi's leaf in memory and writes nothing to the transcript, so `last` showed the reply at the end of the newest branch, not the one Pi was on. The extension now writes `leaf` (Pi's current entry) and `tip` (the newest entry) into its registry entry, and rewrites it on `session_tree`. While the transcript's newest entry is still `tip`, `last` reads the branch ending at `leaf`; once Pi has appended, the newest entry is the leaf again. This uses this branch's branch walk in the hosts crate, with its tests adapted. It applies to any Pi transcript a registry entry names, so it also covers `--session` from the Herdr and herdr-core launchers. - Session check before Send: a Rex `last` review of a Pi records the session id the registry lists for its pid, and Send refuses when Pi has since moved to another session (`/new`, `/resume`) or the entry is gone, as this branch's guard did with the socket. - No guessing for a registered Pi with no saved reply: when the entry for the pid has no transcript file yet (a new session before its first reply, or `--no-session`), `last` says so instead of opening the folder's newest transcript, which belongs to another session. Tests: hosts tests on the two-branch fixture (moved to the other branch, moved back along the same branch, appended since, empty, missing, dangling and cyclic leaves); `tests/last.rs` cases through the binary with a fake registry entry, by pid and by --session; Rex unit tests for the session check; and the extension's e2e test (real pi in RPC mode, fake model) now navigates the tree and checks the entry. Co-authored-by: KG <[email protected]>
sebastianst
pushed a commit
to sebastianst/plannotator-tui
that referenced
this pull request
Nov 23, 2026
* fix(rex): select the focused Pi session * fix(pi): last follows /tree through the link registry, not a second socket Main already has a Pi extension that lists each session in the Pi link registry, and plannotator#156 uses its pid and transcript for `last --pid`. This drops the parts of this branch that the registry already covers, and keeps what it did not: - Dropped: the second extension in pi/ (its Unix socket server, tests, package files), the root package.json, the CI Node jobs, the socket reader in rex/pi.rs, and the `--pi-leaf-id` flag that carried its answer to the pane. Pi users without our extension keep the folder's newest transcript, as on main, instead of an error. - /tree position: `/tree` moves Pi's leaf in memory and writes nothing to the transcript, so `last` showed the reply at the end of the newest branch, not the one Pi was on. The extension now writes `leaf` (Pi's current entry) and `tip` (the newest entry) into its registry entry, and rewrites it on `session_tree`. While the transcript's newest entry is still `tip`, `last` reads the branch ending at `leaf`; once Pi has appended, the newest entry is the leaf again. This uses this branch's branch walk in the hosts crate, with its tests adapted. It applies to any Pi transcript a registry entry names, so it also covers `--session` from the Herdr and herdr-core launchers. - Session check before Send: a Rex `last` review of a Pi records the session id the registry lists for its pid, and Send refuses when Pi has since moved to another session (`/new`, `/resume`) or the entry is gone, as this branch's guard did with the socket. - No guessing for a registered Pi with no saved reply: when the entry for the pid has no transcript file yet (a new session before its first reply, or `--no-session`), `last` says so instead of opening the folder's newest transcript, which belongs to another session. Tests: hosts tests on the two-branch fixture (moved to the other branch, moved back along the same branch, appended since, empty, missing, dangling and cyclic leaves); `tests/last.rs` cases through the binary with a fake registry entry, by pid and by --session; Rex unit tests for the session check; and the extension's e2e test (real pi in RPC mode, fake model) now navigates the tree and checks the entry. Co-authored-by: KG <[email protected]> * fix(pi): trust only a running Pi's own entry; Send refusals copy nothing Review follow-ups on the registry-based Pi session and tree position: - The tree position comes from the entry of the pid `last` was given, not from whichever entry names the transcript last: two Pis can resume one session file, each at its own place. Without a pid (a plain --session or the folder), the entry written last. - An entry counts only when its Pi answers a ping, as the agent picker already requires (`live_pi_sessions`, which deletes an entry whose port refuses). A crashed Pi's place no longer steers a read, and a reused pid no longer gets a stale entry's refusal. - Clearer messages: a Pi moved with /tree to before its first reply is told so instead of "no assistant messages yet", and `pi --no-session` is told the session is not being saved. - Rex Send refusals for a Pi that changed session, or whose link does not answer, are `Failed`, not `Unavailable`: nothing is copied and the notes stay pending for E (decision 13 as amended). The messages say what to do. /fork and /clone stay refused; the spec says why. - The launcher hands the pane the registry root it found Pi in, and a pane that cannot read a registry at all sends without the check. - The extension reads the session's entries inside its try, and its comment says how stale entries are found. - README: run `plannotator-tui pi install` again after upgrading; the binary has no check for an older extension. Tests: two Pis on one file, a Pi that is gone, --no-session, a move to before the first reply, `deliver()` against a fake rex and a real registry for each refusal, and the launcher's pin. --------- Co-authored-by: Michael Ramos <[email protected]>
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.
With two Pi sessions in one folder,
plannotator-tui last --pid(which the Rex launcher passes) ignored the pid and opened the most recently written transcript, so it could open the other session's reply.A Pi running our extension already lists its
pidandtranscriptin the Pi link registry.lastnow uses that entry when the pid matches, and keeps today's newest-in-folder choice otherwise, so Pi users without the extension see no change. The herdr and hc launchers get the same fix, since they pass--pidtoo.Reported and diagnosed by @kaushikgopal in #145, credited as co-author.
Tests: a new
tests/last.rscase with two fake Pi transcripts in one folder (the other one newer) and a fake registry entry. With the entry's pid it opens the focused session; with an unregistered pid it still opens the newest. It fails on main with the reported bug.