Registry Mirror
Skip to content

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Fixes #1589
Fixes #1412

Two small Pi extension features, approved in the 2026-10-21 feature triage.

Session events (#1589)

Pi now emits plannotator:session-opened when a review opens and plannotator:session-closed when it ends. This covers every review: the /plannotator-* commands, the plannotator tool, plan review, and plannotator:request. A tool like Herdr can show "needs review" between the two.

  • Opened: { id, action, url, openedAt, piSessionId?, reviewId?, requestId? }
    • id is the pn- id that the tool's list and the decision heading use.
    • action is plan-review, code-review, annotate or annotate-last.
  • Closed: the same fields, plus outcome (approved, submitted or closed), closedBy (only when the outcome is closed: reviewer, agent, stopped or error) and closedAt.
  • Each review sends exactly one of each, opened first. The archive browser sends neither.

After /reload (#1864). Every emit runs on a microtask inside try/catch. It goes through the opener's pi when the opener's session was live at the time of the call. Otherwise it goes through the instance that holds a process-wide slot: an instance claims the slot at session_start and releases it at session_shutdown. If no instance holds the slot, the event is dropped without an error. A review that ends after /reload therefore reaches the new instance's bus and never throws out of a handler. session_shutdown now stops an open plan review first, so that review's closed event goes out on its own session's bus.

plannotator-events.ts now starts the session and waits for the decision itself, instead of calling the open* helpers. This makes the URL known before the decision arrives. Behavior is otherwise unchanged.

Checklist widget (#1412)

Pi draws at most 10 lines of a widget. For a longer checklist, checklistWindow (checklist-window.ts) now sends 10 items:

  • The first 10, until the next open item is past them.
  • Then a window that ends on the next open item and moves down one item per completed step, as the issue proposes.
  • The last 10, once every item is done.

The status line still shows the full count.

Prompt-cache safety

Neither feature changes what the model receives. The events go only to pi.events, and the widget only to ctx.ui.setWidget. No messages, no custom entries, no system prompt, no tool-list changes.

Proved in apps/pi-extension/session-events.test.ts, over a fake Pi where every extension instance shares one bus and a replaced instance throws Pi's stale-ctx error:

  • Each model request is recorded: the active tools with their full definitions, the results of before_agent_start, and every message the extension sent. Reviews are then opened by a command, closed, opened again, carried across /reload, and closed after it. All 6 requests are byte-identical, and the events did go out.
  • The same lifecycle with a bus that always throws produces identical requests and no fatal errors.
  • One event pair per entry point (command, tool, plan review), with each outcome. A review that ends after /reload closes without throwing. A stale slot holder is forgotten without logging.
  • In a running 15-step plan, the widget never sends more than 10 lines, always shows the next open step, and none of its lines reach the conversation.
  • Mutation checks: emitting synchronously through the opener fails 3 tests; dropping the window fails the widget test.

plannotator-events.test.ts adds the plannotator:request cases: the pair carries requestId and reviewId, and after a replacement nothing is emitted to the dead bus or logged.

Typecheck: tsc -p apps/pi-extension passes. Pi suite: 565 pass, 0 fail.

The Pi README event API section and CLAUDE.md ("Pi: session events and the checklist window") are updated.

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.

Feature: session lifecycle events (session-opened / session-closed) on the event bus Better display for long checklists in Pi

1 participant