Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
ADR 0333: A plugin-owned suggestion in the Composer placeholder
- Status: Accepted
- Date: 2026-10-24
- Related: ADR 0324 · ADR 0331 · 07-plugins/03-plugin-api
Context
After a turn ends a plugin often knows what the user would plausibly type next,
but its only surfaces are announcements that interrupt (toast, notification,
work-panel view) or a rewrite of text the user already wrote
(composer.transform). A suggestion must be visible where the user is looking
and trivial to ignore, yet producing one is slow — listen for
session:turnEnded, read with pi.session.getLlmContext, run a
pi.agent.complete — so by the time text arrives the user may have typed,
switched session, or started another turn.
Decision
- Add
pi.composer.suggest({ sessionId, turnId?, text, ttlMs? })andpi.composer.clearSuggestion({ sessionId? })under a newcomposer.suggestpermission, wheresuggestresolves{ shown: true }or{ shown: false, reason }withsession-not-visible,draft-not-empty,stale-turn,replaced, orunsupported, and only malformed input throwsINVALID_PARAMS. - Split the decision by ownership: main refuses what it can see without the
renderer, meaning a session that is not on screen or a
turnIda lateronTurnStartedovertook, then relays the rest and waits for the renderer, which refuses a missing or blocked composer and a draft with text or an attachment over a dedicated invoke. Main never writes renderer state. - Model the suggestion as a slot beside the draft, not inside it: the text is
drawn in the existing
.composer-placeholderlayer whilevalueis empty,Tabwrites it into the draft, andEsc, a first character, a send, a session switch, a new turn, a plugin stop, a reload, or a window close drops it, with one suggestion per session and a newer offer replacing the older one. - Keep the existing key owners: an open
@//completion list keepsTabandEsc, and the suggestion acts only when neither claims the key, decided by a pure function so ordering is testable without a DOM. - Draw it brighter than the shell placeholder with a
Tab/Eschint on one ellipsized line, announce it once through ansr-onlypolite live region, and leavearia-placeholderdescribing the input. - Classify
composer.suggestas medium risk and confirm it at install: it cannot read the draft, cannot send, and cannot outlive an empty draft.
Consequences
- A plugin can propose the next message where the user is looking without a notification or panel, and learns immediately whether it was taken up.
- The shell keeps the composer authoritative, since a suggestion is decorative state the Composer discards on its own terms and a plugin cannot promote.
- The answer costs one renderer round trip with a bounded 2 s wait reporting
unsupportedrather than hanging, text is capped at 200 characters after whitespace folding, and no manifest schema, host-core schema, or persisted format changes.
Alternatives considered
- Let a plugin renderer module set the suggestion directly: the SDK has no process → renderer-module channel for text produced by a long completion.
- Store the suggestion as a draft value the user deletes: it makes plugin text indistinguishable from typed text and breaks the empty-draft invariant.
- Report
shownoptimistically:draft-not-emptyandsession-not-visibleare exactly the cases where a guess would be wrong.