Plan: the terminal catches up with pivot - a dropped file reaches the model, the mouse works in our panes, and the desk gets nudged
Closes: #340 (drop-to-attach), #341 (mouse in the review pane and a pending overlay), #342 (a nudge when the session needs you). Follow-ups filed: #343-#351. Branches: feat/drop-to-attach, feat/mouse-panes, feat/nudge, one MR each. Status: Done (2026-10-07) — all three units shipped; follow-ups #343-#351 await the brainstorm
Erratum (2026-10-07): "Dropping a file" went into modes.adoc as its own section beside the terminal-title one, not inside the judge chapter’s pending section; the drop handler is registered in index.ts beside registerJudge.
Erratum (2026-10-07): OSC 9 support was verified from kitty’s docs (legacy OSC 9) and Ghostty’s (a notification unless a ConEmu sub-ID is found); WezTerm and foot rest on secondary sources, and Windows Terminal is unconfirmed (it still rings on the BEL). The nudge text is stripped of control characters, and the focus listener is focusListener in title.ts.
Erratum (2026-10-07): the pending overlay also carries a [clear all] button on its title row, ignores enter (approving stays a deliberate key), and is documented in the existing /pending list rather than a new section; away from a terminal bare /pending keeps its two selects.
TL;DR
What pivot does that the terminal does not, read from the box side
(packages/pi-remote/attach.ts, commands.ts, mirror.ts):
| pivot | how, on the box | the terminal today |
|---|---|---|
Attach a file to a prompt |
|
Drag a file onto the terminal: the emulator types its quoted path into the editor (no protocol; research below). |
Answer an ask by tapping |
the ask broker, mirrored to the phone |
pi’s dialogs, keyboard only in our panes; pi’s own transcript already scrolls by wheel in fullscreen |
Approve or deny a pending step by tapping |
the |
|
Be told the session is waiting |
the |
the title glyph and the tab’s progress state ( |
Multi-session hub and reverse paging are pivot’s architecture, not parity targets. The gaps that matter to a person at the desk are these four.
Unit one, drop-to-attach. pi’s input event lets an extension transform
a prompt and attach images: ImageContent[] (extensions/types.d.ts:874-892;
evidence below). So when the submitted prompt names an absolute path that
is an image file, pi-modes attaches the image itself - base64, with its
MIME type - and leaves the path in the text so the agent knows which file
it was. The model sees the picture. That is more than pivot does today, and
it is the one place the terminal can lead: pivot’s attach lands on disk and
could feed the same hook later (filed). Other dropped paths stay paths (the
agent has read), but the person gets a receipt: one notice naming what
was found, its kind and size, and anything that does not exist. No
copying, no staging directory: a terminal drop names a file that is already
on this box, unlike a phone’s.
Unit two, mouse in our panes. pi enables SGR mouse tracking in
fullscreen, its default, and routes events to any component with
handleMouse (pi-tui/dist/tui.d.ts:13,70; tui.md §fullscreen). Our
plan review pane (review-pane.ts) scrolls by keys and selects by arrows;
it gains wheel scroll, click to select a choice, double-click to confirm.
The pending queue gains an overlay listing the steps with per-step
approve/deny/clear, by key or click, opened by /pending with no
arguments; the typed forms stay.
Unit three, the nudge. TitleTracker (title.ts) already knows the two
moments that matter - a dialog opening (pi’s ui_prompt_start, fired for
every extension dialog, the permission system’s included) and a turn
ending with nothing open - and already writes a raw OSC to stdout, only in
a terminal. On those two transitions it also rings (BEL) and sends an OSC 9
desktop notification where the terminal shows one, unless the terminal has
told us the window is focused. pi-tui enables focus reporting in
fullscreen; a passive input listener records it.
Filed, not built: the list under "Out of scope", each an issue at implementation start so the follow-on brainstorm starts from the tracker.
Design
Unit one: drop-to-attach
Where. packages/pi-modes/drop.ts (new, pure: find paths, read an
image) and a second input handler registered beside the pending queue’s
(judge-wiring.ts:977). That one only observes - it returns continue
and "never changes the input" (judge-wiring.ts:410-418) - so there is no
ordering between them to get right. A registered slash command never
reaches either: pi dispatches /pending … before it runs input
handlers (agent-session.js:1522-1534, evidence below).
What counts as a dropped path. The emulator types a drop as text in one
of three shapes (and a paste is the same): a bare absolute path, a
shell-quoted one ('/home/u/a b.png', /home/u/a\ b.png), or a file://
URI. dropsIn(text) returns every token of those shapes whose target
exists; relative paths and words that merely contain a slash are not
drops. ~ is not expanded (the emulator never writes it).
Images. A path with extension in {png,jpg,jpeg,gif,webp} is sniffed,
and the magic bytes decide: one of those four types is attached with the
type the bytes say (a .png holding JPEG goes as image/jpeg - a
misnamed screenshot is common and the model does not read the name);
bytes that are none of the four are not attached, and the receipt says
so. Each at most IMAGE_MAX = 5 MiB and the prompt’s images together at
most 20 MiB; over the cap, the path stays and the receipt says why.
The receipt. One ctx.ui.notify per submitted prompt that had drops:
attached: shot.png (image, 212 KiB) · named: notes.md (text, 3 KiB) ·
missing: /tmp/x.txt. Nothing goes to the transcript.
What does not change. A path the rules deny to read (credential-shaped
names, ~/.pi/agent, …) is still denied when the agent tries to read it;
this unit attaches images only, and an image whose name matches the read
gate’s credential patterns is not attached, with the receipt saying so.
Those patterns are CREDENTIAL_SHAPED (authorize.ts:92), today a
module-private list tested at :119; it is exported as a predicate
credentialShaped(name) so drop.ts shares it rather than copying it. The judge is not consulted: the person
typed or dropped the path themselves, which is the consent.
Config. dropToAttach?: boolean on ModesConfig, default true,
validated with check.boolean beside the other booleans
(config.ts:427-434). false leaves prompts untouched.
Unit two: mouse in our panes
Review pane (review-pane.ts). handleMouse: wheel →
scrollBy(±wheelDelta); click on a choice row → select it;
clickCount === 2 on a choice → confirm it (the same done(choice) the
confirm action calls, review-pane.ts:257); anything else unhandled.
The legend gains · wheel/click. The pane already keeps scroll offset
and selection in one state object (:194), so this is three cases on top
of the existing action type (:268).
Pending overlay (new pending-pane.ts, wired in judge-wiring.ts:979).
/pending with no arguments opens a ctx.ui.custom overlay, the same
shape as the review pane: one row per queued step (#n, the tool, the
command’s first line, who queued it), arrows or click to choose, a/d or the row’s
buttons to approve or deny, c to clear, esc to close. Each action calls
the same pendingCommand (judge-wiring.ts:451) the typed form calls, so
the audit record and the model’s reply are identical. /pending <verb>
stays. In regular (non-fullscreen) mode the overlay works by keys; the
mouse simply does nothing there, as in pi’s own dialogs.
What does not change. No new ask kinds, no change to what is queued or why, no change to the broker. A phone and the desk still race the same dialogs.
Unit three: the nudge
Where. title.ts and its wiring in session-wiring.ts:150
(registerTitle). No new tracker: TitleTracker.apply already runs on
every change of state with write(sequence) and inTerminal() as deps.
Two additions: a focused(): boolean | undefined dep, and
nudgeSequence(from, to) beside progressSequence.
When. On the transition INTO attention (a dialog opened - a gate ask,
the plan review, a permission prompt), and on working → idle (the turn
ended with nothing open). Not on attention → idle (you just answered)
and not on attention → working. At most one nudge per 2 s, so three
back-to-back asks ring once.
What. BEL (\x07), which every terminal does something with (a sound,
a flash, a tab mark). Then ESC ] 9 ; <text> BEL, the OSC 9 desktop
notification (kitty, WezTerm, Ghostty, iTerm2, foot - each verified at
implementation, not assumed), with <text> = <app> - <dir>: waiting on
you or … : finished, the plainTitle words. The text never carries
the ask’s body or a command: a desktop notification is visible to anyone
near the screen and logged by some desktops.
Unless focused. pi-tui enables ?1004h in fullscreen, so the terminal
sends ESC[I / ESC[O. Extension input listeners run before pi-tui’s own
handling (tui.js:685-700), so a ctx.ui.onTerminalInput listener sees
them, records the state, and returns nothing (pi-tui still consumes
them). It also timestamps any other input: a keystroke in the last 3 s
counts as focused - the only signal in regular mode, where ?1004h is
not enabled and focused() is otherwise undefined (= nudge).
Config. title.nudge?: "off" | "asks" | "all", default "all",
validated with check.oneOf beside the TITLE_KEYS booleans
(config.ts:467). "asks" rings for dialogs only. title.enabled: false
turns the whole tracker off, this included, as today.
What does not change. The glyph, the OSC 9;4 progress state, the
gadhs:title bus event: untouched. A headless host writes nothing, as
today.
Failure modes, named
An image that cannot be read (permissions, vanished between drop and submit): fail-open |
The path stays in the text; the receipt names it under |
A paste that is prose containing an absolute path: fail-open |
Non-image paths change nothing but the notice. An image path in prose IS attached - that is what someone pasting |
A slash command carrying an image path ( |
pi dispatches a registered command before any |
Mouse in regular mode or under tmux without mouse on: silent, by design |
No error, keys still work; the legend’s wheel/click hint is shown only when pi reports fullscreen. |
A terminal that does not know OSC 9: fail-open |
The BEL alone; an unknown OSC is ignored, and the OSC 9 channel already carries our 9;4 progress state today. |
The nudge while you are looking: fail-open |
It rings rather than misses: focus reporting mutes it in fullscreen, the keystroke heuristic in regular mode, and the knob is there for anyone it still annoys. |
Decisions for the operator
-
Attach images to the prompt by default. The alternative is a path only, as pivot does. The person dropped the file; the caps bound the cost;
dropToAttach: falseturns it off. -
No staging copy for a terminal drop. pivot copies because the file is not on the box. A local file copied would add a directory to sweep and a second path to name, for no gain; if it is edited before the agent reads it, the agent reads the new contents, which is what a path means.
-
The pending overlay is a second UI for the same commands, not a new path into the queue: every click goes through
pendingCommand, so the audit trail does not fork. -
The nudge rides the title tracker, default
"all". A hook on the ask broker was the alternative; the tracker’sui_prompt_startcovers more (pi’s own permission dialogs) with no new state. Default on because the phone already gets this and the desk is the one left guessing.
Scope
Units
-
drop.ts (pure) + tests:
dropsIn(text)- property tests (a path round-trips through shell quoting; no false positive on prose with slashes;file://with percent-encoding) and a regression case per shape from the research;imageOf(path)- a fixture per type, the misnamed-PNG case, each cap at its boundary;receiptFor(drops);credentialShapedexported and shared. -
The handler + tests: a contract test that a registered slash command does not reach
inputhandlers (driven through pi’sprompt()); a regression test that the transform carries pre-existingimagesthrough;dropToAttach: falseleaves the prompt untouched. -
Review pane mouse + tests: the three mouse cases with
TuiMouseEventfixtures, and a regression test that a wheel over the pane does not move the selection; the legend. -
Pending pane + tests: a contract test per action that it reaches
pendingCommandwith the arguments the typed form sends; rows, keys, click, esc. -
The nudge + tests:
nudgeSequenceover every state pair (only the two named transitions produce bytes); a contract test on the focus listener against pi-tui’s exact bytes (ESC[I/ESC[Orecorded and passed through unchanged; a keystroke timestamps; mouse reports do not); the 2 s coalescing;"asks"vs"all"; nothing written headless; a negative test that the OSC 9 text isplainTitleplus the suffix and contains no ask title or body. -
Docs and notes:
modes.adocgains "Dropping a file" and "The pending overlay" beside its pending section, and "When the session needs you" beside the title section;tuning.adocthedropToAttachandtitle.nudgeknobs; CHANGELOGUnreleased(units one and three areAdded; all three together are one pi-modes minor - unit one changes what the model receives). The plan page underdocs/modules/ROOT/pages/plans/with a nav entry. -
Live check, by the operator (a terminal is needed): drag a PNG onto the terminal and see the model describe it; paste a quoted path with a space;
ctrl+va clipboard image; wheel and click in the review pane;/pendingoverlay with one queued step; switch windows during a turn and get the nudge when it ends, and none when you stay. Recorded on the issues. -
Close: each MR carries its
Closes; the follow-ups above are filed at start.
Out of scope, filed at implementation start
-
Inline rendering of the dropped image in the transcript (kitty/iTerm2 only, not sixel; pi-tui’s
Imagecomponent). -
OSC 52 clipboard copy of a SHA or URL (write-only, uneven support, a clipboard-write surface).
-
pivot’s attach feeding the image hook (pi-remote lands the file; the same
inputhandler would attach it if the prompt names it - may already work, to be verified, not assumed). -
A pending count in the status line that opens the overlay;
eto edit the draft from the review pane; OSC 8 links forfile:lineand#issue; a/sessionsswitcher from the hub’s list. -
OSC 777 (VTE’s notification form) if a GNOME-family terminal turns out to matter; drag-and-drop of a folder.
Acceptance
-
A prompt naming an existing PNG under 5 MiB reaches the model with one
ImageContentofimage/pngand the path still in the text; a.pngwith JPEG bytes is attached asimage/jpeg; a text file is named in the receipt and not attached; a 6 MiB image stays a path with the receipt saying why; an image named like a credential file is not attached. -
/pending approve #1 /tmp/a.pngsubmitted through pi’sprompt()reaches noinputhandler and attaches nothing. -
In fullscreen, wheel scrolls the review pane, click selects a choice, double-click confirms; in regular mode keys still work.
-
/pendingwith a queued step opens the overlay; approving by click produces the same audit record as/pending approve #1. -
With the window unfocused, a turn ending writes BEL (and OSC 9 where supported) once; a dialog opening does the same; answering it writes nothing; with
ESC[Iseen last, nothing is written;title.nudge: "off"writes nothing; headless writes nothing. -
node tools/task.mjs validategreen; consumer-sim loads.
Evidence outside the repository
Read on 2026-10-06 from the installed pi (1.0.x); implementation re-reads each before relying on it.
@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts:874-892:
export interface InputEvent { type: "input"; text: string; images?: ImageContent[];
source: InputSource; streamingBehavior?: "steer" | "followUp"; }
export type InputEventResult = { action: "continue" } | { action: "transform"; text: string;
images?: ImageContent[] } | { action: "handled" };
:334 sendUserMessage(content: string | (TextContent | ImageContent)[], …).
:718 agent_end; :714 agent_start (the tracker’s existing feeds).
dist/core/agent-session.js:1522-1534 prompt(): a text starting with
/ is offered to _tryExecuteExtensionCommand first and, if handled,
returns before _runInputHandlers (:1472) is reached.
@earendil-works/pi-ai/dist/types.d.ts:256 ImageContent { type: "image";
data: string; mimeType: string } (base64).
pi-tui/dist/tui.js:678-700 handleTerminalInput: extension listeners
(ctx.ui.onTerminalInput) see every chunk in both modes, in order, before
pi-tui’s own handling; one that returns nothing passes the chunk on.
tui-alt-screen.js:16-20,471,495: fullscreen enables ?1000h ?1002h
?1004h ?1006h (?1003h outside tmux); ESC[I / ESC[O are consumed
there, after the listeners. tui.d.ts:13,70: TuiMouseEvent {x,y,button,
type: press|release|move|drag|click|wheel, wheelDelta, clickCount,
modifiers}; Component.handleMouse?(e). Mouse is fullscreen-only so
regular mode keeps native scrollback. interactive-mode.js:951:
tuiMode defaults to fullscreen.
pi sends no bell and no notification: \x07, ]9;, notify-send,
osascript and bell do not occur in interactive-mode.js or
dist/core/*.js outside OSC 8 hyperlink and OSC 133 zone handling.
pi’s own paste, interactive-mode.js:2462-2500: clipboard files →
paths inserted; a clipboard image → $TMPDIR/pi-clipboard-<uuid>.png,
path inserted. So ctrl+v of a screenshot produces exactly the input
unit one attaches.
Terminals (research, 2026-10-06; sources on the issue): a drop is typed
text - plain or quoted paths (Konsole, kitty, VS Code), file:// URIs
reported for some (secondary source); no terminal sends image bytes on a
drop. SGR mouse is common; tmux forwards it only with its own mouse on.
OSC 9 notification support per terminal was not in the research and is a
named verification step in unit three.