Repository navigation
fix(rex): select the focused Pi session - #145
Conversation
|
Thanks for tracking this down. The diagnosis is right: Could you check whether it covers your setup? One case it leaves out: moving within the Pi tree ( |
…west in the folder (plannotator#156) 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 plannotator#145. Co-authored-by: KG <[email protected]>
Conflict in rex/launch.rs: main split the launcher into run and open and added tab placement. The Pi session lookup moves into open; the new picker and argv call sites pass no Pi session.
…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]>
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.
|
Thanks again for this. Rather than leave it conflicting, we pushed three commits to your branch: a merge of current main, a commit that keeps the parts of your work main was still missing and drops the parts the Pi link registry (from #156) already covers, and a round of review fixes. Kept, built on the registry instead of the socket:
Dropped: the second extension in We're merging it now so it ships in the next release. Could you check that it covers your setup? Run |
Rex can open a reply from another Pi session when multiple sessions share a working directory. The launcher passes the foreground PID, but Pi transcript discovery ignores it and picks the most recently modified session in that directory.
This adds a Pi extension that reports the live session path, ID, and active branch over a private Unix socket. Rex reads that snapshot for the focused process and refuses to guess if it is unavailable. It also checks the session again before sending feedback. Pi users need to install the extension and restart Pi or run
/reload; the README includes the command.The session check and terminal paste are separate operations. A session switch between them can still direct feedback to the replacement session.
Validation
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspacenpm test --prefix pipython3 herdr/test-manifest.py/reloadand/newendpoint lifecycle.The live test used a fake Rex CLI, not the Rex UI. Linux, musl, and Windows builds are left to CI.