# Composer interaction layout

Ownership and delivery: [composer and user decision output](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/composer/composer-interaction-modes.html). No new theme or dependency; existing neutral palette, 12px spacing and 28px decision controls.

## Surfaces

| Surface | Shows | Actions |
| --- | --- | --- |
| Tool approval | "Your input is needed", 1/1, "Allow this command?", the operation in `OperationCode` | Deny and Allow once share the bottom row and submit directly. No selection, discussion or Send step. |
| Question panel | Progress badge, current question, full-width option rows (title, optional description, number), Other with its input visible | Back on the left; Skip and Next or Submit on the right |
| Function form | Task inputs only, 12px padding on every side | Existing header: Run, Close |

## Question panel

Same width as the composer; fonts, size and colours are the application's.

| Action | Result |
| --- | --- |
| Next | Validates the current answer, shows the next question, sends nothing |
| Back | Keeps all selections |
| Submit | Sends one ordered answer list through the acknowledged execution command |
| Skip | Declines the whole request. The backend requires a valid answer per question, so there are no partial or empty answers. |
| Collapse, close | Reduce to the header. Reopening keeps answers; no command is sent. |
| Digits | Select options, outside editable text only |
| Ctrl/Cmd+Enter | Advances or submits. IME composition and multiline discussion keep editing. |
| Arrival | Never moves focus |
| Short screens | The body scrolls; header and actions stay |

Optional `question_title` and `option_descriptions` supply the row layout. Only explicit string entries render; inherited object properties are not metadata and do not restrict labels. Plain answers and prompts remain for other clients. Multiple pending requests are separate keyed panels.

## Discussion

| Aspect | Rule |
| --- | --- |
| Where | Ordinary questions: Chat about this. Approvals have only Allow once and Deny. |
| Field | Inline in the card; heading names discussion; 96px minimum; shared `Textarea`. The original question stays read-only, without duplicate answer controls. Progress is hidden. |
| Open, cancel | Send nothing; the wait stays unresolved |
| Send | Binds question, tool details and feedback to the exact canonical wait, as the decline reason in the same turn |
| Deny | Declines without a discussion turn |
| During submission | Competing approval controls are blocked. Unknown delivery keeps the command and feedback for retry. Switching conversations cannot retarget it. |
| Identity | Session and wait jointly identify the request; feedback, command id and delivery state survive remounts |

Like the [Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/user-input) and [OpenCode](https://opencode.ai/v2/docs/permissions), feedback attaches to the original call. OpenProgram synthesizes no first-person rejection and does not treat questions as tool permissions.

## Typography and alignment

- **Text**: Application sans-serif at the base token, line height 1.5, no shrink at desktop breakpoints. Prompts and field headings 600; values, hints and placeholders 400.
- **Code**: Commands and JSON: shared `OperationCode`, monospace, language label sized as the first code line, secondary background, inset 1px theme border, copy icon on the first line. No separate toolbar.
- **Copy**: Success only after clipboard acknowledgment; failure is announced
- **Edges**: Headings, body and editor border share one left edge, 12px inside the container. No negative margins.
- **Actions**: A non-shrinking sibling of the scrolling body, anchored to the bottom through height transitions and overflow
- **Command details**: Native disclosure, 12px gap; the working directory appears only in the JSON arguments. Sandbox escalation explanations stay visible.

## Function forms

| Item | Rule |
| --- | --- |
| Inputs | Task inputs only, in Programs Use, favorites and reopened forms. Limits, timeouts, backends and session handles are internal with working defaults; no disclosure or hint. |
| Single-purpose forms | Browser Workflow: task and optional URL. Text polishing picks a style from the text. Page ranges, output destinations and revision targets remain inputs. |
| Pending Use | Pending Use requests are consumed after chat initialization, which therefore cannot clear the form. |
| Height | Height measurement releases textarea flex growth and includes the native row height and border, so the last field keeps its padding. |
| Goal details | Goal details keep progress and task controls, without agent or budget editors. New Goals pick reasoning effort with one tool-free model request, falling back to defaults; resumed Goals keep saved roles. |

## Keyboard ownership

| Feature | Rule |
| --- | --- |
| History recall | Keeps the exact draft; Down after the newest restores it. Editing recalled text starts a new cycle. State is scoped to the composer owner, so another split pane does not reset it. Selection, modifier arrows, IME, file and slash menus keep precedence. |
| File mention results | Bound to the token location and query. A changed query invalidates them; a late response cannot restore them after Escape, replacement or unmount. Escape dismisses until the token changes. |
| Mention pending | Enter and Tab keep the draft and neither select nor send. Escape works. IME and Shift+Enter keep editing. No timeout or retry. |
| Mention empty or failed | Enter sends; Tab moves focus |
| Rejected send intent | The owner reservation keeps the unsent body even when only attachments or settings differ, across focused and bound composers. An accepted frame keeps its payload; success clears only matching text. The reservation token is released in `finally`. |

**Long-lived approvals**

| Item | Rule |
| --- | --- |
| Expiry | Human tool approvals have no default expiry. The durable wait keeps the exact operation and file fingerprints; the safe-point handoff ends the attempt and frees the slot. Explicit deadlines remain for other waits. |
| Resume | Resume loads the checkpoint and reuses the saved system prompt and browser-tool selection. Model, tool implementation, permissions and location are validated; live Page access is checked per call. An incompatible continuation reports that execution did not resume. |
| Clearing errors | Once recovery reaches running or completed, prior continuation error metadata is cleared. Replay repairs a completed message without rerunning. |
| Cancellation | Cancellation and terminal events remove pending decisions, including after reconnect. Expired requests stay expired. Job recovery handles only Job admissions. An operation that paused again does not retry on its old answer. |
| File approvals | File edit, write and patch approvals bind paths and contents, checked before dispatch and before mutation. Changed or missing targets are not written; the agent gets a non-executed result and must re-read. Opaque shell commands cannot claim this guarantee. |
| Declined or expired | A terminal declined or expired wait projects an outcome into its assistant node through the durable DAG outbox, with no execution or new turn; replay does not duplicate it. |
| Terminal release | A terminal execution releases the active conversation's composer, unless a newer execution is active; the reply's terminal row arrives as a transcript update, with no reload. A continuation opening another approval publishes it on the shared WebSocket stream. |
| Peers | Claude Agent SDK indefinite `canUseTool` waits, OpenCode `permission/next.ts`, Codex `tools/approvals.rs`. |

**Project rule management**

| Item | Rule |
| --- | --- |
| Requests | Correlated permission-rule requests as non-coalescing WebSocket frames |
| Broadcasts | Coalesce within one project and update other open views |
| Writes | Read back before acknowledgment; failed or unknown writes keep the draft. Persistent approval grants are verified after writing |
| Authorization | Owner operations read merged rules at the next boundary; authorized calls and admitted children keep their captured authorization |

**Acceptance**

- Discussion: empty field with context; cancel keeps the request; sending declines and returns feedback in the turn with no extra message; Deny alone adds none; pending submission cannot approve; retries keep one command.
- Questions, on real Composer and QuestionMode: Back, Next, Submit order, digits, custom and multiple answers, remounts, narrow and short views, collapse, session isolation, uncertain retry, receipts.
- Mentions, on the real hook and menu: changed-query Enter cannot select old results; Escape survives a delayed response; failed and empty fallbacks; pending input and IME do not submit; disposal suppresses late work.

## Implementation status

Implemented. Installed-App verification of the file-mention lifecycle and the rejected-intent body is pending.
