Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
ADR 0265: Priority block and row actions for the Host-owned turn queue
- Status: Accepted for implementation
- Date: 2026-09-15
- Amends: ADR 0213 (persisted Host-owned turn queue), ADR 0118 (renderer-owned queued prompts and turn-boundary stops)
Context
ADR 0213 moved the queue into host-core, where prioritize rewrites an entry's
position below the current minimum so it jumps to the head of the whole queue.
The renderer mirrored that as one in-memory sendNowRequested flag cleared by
every other row, so only one row could wait for the next boundary and two clicks
resolved as "the last wins". The row also offered only Remove and Send now, so a
prompt could not be corrected without retyping and the plain queue could not be
reordered at all.
Decision
- A promotion block, ordered by click.
turn_queuegains a nullableprioritycolumn (schema v18). Promotion writesCOALESCE(MAX(priority), 0) + 1within the session, so the first promotion is delivered first; delivery ispriority ASC, position ASCfor promoted entries followed byposition ASCfor the rest. - Promotion is one-way and idempotent-hostile. Promoting an entry that
already carries a
priorityfails withCONFLICT/ALREADY_PRIORITIZEDinstead of moving it again, and the renderer's optimistic mirror follows the same rule. - Promotion fixes order, not cancellation. A promoted row disables move up,
move down, edit, and Send now and reads Waiting to send, while Remove survives
until delivery and waits for Host confirmation. Cancellation, promotion,
reordering, and delivery reservation share session admission serialization;
runtime delivery runs outside that lock and reserves only its own input. Once
input is reserved or accepted as steering, cancellation returns
CONFLICT, and refused steering keeps the queued input for the next turn. There is no un-promote path. - A reorder operation for the plain queue.
session.queueReorderswaps an entry'spositionwith its adjacent non-prioritized neighbour and reportsmoved: falsefor a missing or promoted entry or a block edge, so reordering never crosses into the priority block. - Edit returns the row to the composer. Editing is renderer-local: the row is
removed through the existing path and its captured
ComposerDraftSnapshot— text plus inline file references — replaces the composer input throughcomposerPrefill. The token-strippedcontentnever rebuilds the prompt, and the action is refused while the live editor is non-empty. - The promoted block is delivered into the active turn. Promotion uses
steering so the parent handles user input while delegates keep working (issue
#1607): an active
TaskWaityields to accepted steering while ordinary tools keep their boundaries. Immediate delivery accepts only the paired caller's own input under the active turn's permission mode — external Desktop turns use the stored session mode, module-admitted turns their principal ceiling — and other input keeps turn-boundary delivery. Without an active turn the first promoted entry starts the turn and later ones join as steering in click order; refusals are retried within a bounded budget, and an injected entry's own RACP turn is canceled. - The turn's owner is authoritative about its end. A runtime terminal event
is not a reliable release: Main drops one naming a turn it no longer owns
(
isStaleTerminalEvent), and an abort need not produce one at all. A turn left active in the module would hold its session's queue forever, so the settlement reported byfinishTurncloses the turn and lets the queue run, and the module's drain request is remembered while a pass runs instead of dropped.
Session collaboration completion receipts are promoted automatically, so a worker's report runs at the next turn boundary rather than behind the plain queue, under the same promotion and steering rules.
Consequences
- Existing channels keep their names:
agentQueuePrioritize/session.queuePrioritizegain the block semantics andagentQueueReorder/session.queueReorderare additive. - Rows migrate with
priority = NULL, so an upgraded database keeps its FIFO order and eight-entry bound.