Skip to content

feat(pi): send reviews to any running Pi, and take notes from Pi - #149

Merged
backnotprop merged 3 commits into
mainfrom
feat/pi-link
Nov 15, 2026
Merged

backnotprop merged 3 commits into
mainfrom
feat/pi-link

Conversation

@backnotprop

Copy link
Copy Markdown
Contributor

plannotator-tui and Pi sessions can now reach each other: Send goes to any running Pi you pick, and a Pi session can leave notes on the file you have open. The protocol is in docs/spec-pi-link.md.

What the person does

  1. plannotator-tui pi install copies a one-file extension into ~/.pi/agent/extensions/ (honours PI_CODING_AGENT_DIR). Restart Pi or /reload.
  2. In plannotator-tui, P (pick-target) opens "send to which Pi?": each live session with its name, folder and busy/idle. Sessions in the review's folder are listed first. Enter makes it the Send target until changed; the last row goes back to the target the review started with.
  3. E sends as usual. An idle Pi starts a turn; a busy one queues it, and the footer says "Pi is busy; it reads this next". A Pi that has closed reports pi · <name> has closed; pick another Pi and copies the text, like any unavailable target.
  4. Pi gets a plannotator_tui_note tool (file, quote?, line?, note). The note lands on the quoted text (nearest line when given) in a plannotator-tui that has that file open. It shows in the rail as 💬 <id> · pi · <session>, the footer says note from pi · <session>, and the exported feedback adds From: pi · <session> under the note's heading.
  5. plannotator-tui pi list [--json] and pi send --session <id or name> < file do the same from a shell.

How

  • Both sides list themselves under <data dir>/clients/plannotator-tui/sessions/{pi,tui}/ (Plannotator's own <data dir>/sessions is taken), folders 0700 and entries 0600, written by rename. Each answers one JSON line on 127.0.0.1 with a 32-byte random token. A refused connection means the entry is stale and it is deleted.
  • src/pi.rs: registry, wire client, send. src/pi/link.rs: this process's entry and a listener thread that hands notes to the event loop over a channel (App::poll_pi, every tick); the loop answers not_open, quote_not_found or busy (while the person is typing a note). src/pi/target.rs: PiSession as a Delivery. src/app/pi_target.rs: the picker and note placement. Store::credit_last records author/author_name on the note.
  • The extension (src/pi/plannotator-tui.ts, embedded with include_str! so pi install always matches the binary) registers on every session_start, removes itself on session_shutdown, tracks busy from agent_start/agent_settled (falls back to agent_end), and delivers with pi.sendUserMessage (followUp when busy).
  • New dependency: getrandom 0.3, already in the lockfile, for the token.

Tests

  • cargo test: 375 pass, including registry parsing and modes, send started/queued, token rewrite retry, stale entries, the listener round trip, note placement by quote/line, refusals, and target switching.
  • node integrations/pi/test.mjs: 53 checks against the real installed pi 0.85.1 in --mode rpc with a fake model and a fake plannotator-tui, fully isolated under /var/tmp.
  • python3 -I integrations/pi/e2e.py: 20 checks with the real pi and the real plannotator-tui binary in a pty: registry entry, a Pi note in the rail and on disk, P → Enter → E delivering the review (including the Pi note) to Pi, the busy notice, and the closed-session error. I also ran it with only PLANNOTATOR_DATA_DIR set, so both sides find the default registry: 20/20.

Not tested: Pi's interactive mode, /resume and /fork (same shutdown-then-start path as /new, which is tested), Windows, and Pi older than 0.80.4.

Known and left alone: when a long status meets the key help on a narrow footer, the two touch with no space. That predates this change; widening the gap moves existing footer layouts.

@backnotprop
backnotprop added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 470c733 Nov 15, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/pi-link branch November 15, 2026 15:43
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.

1 participant