Registry Mirror
Skip to content

Conversation

@backnotprop

@backnotprop backnotprop commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

The server, store and connection half of the owner-approved Inbox compose: sending a new message to a connected agent (approval 2026-10-14, "Yes, as mocked with these answers"; design record .product/approved/inbox-compose-to-agent/, not in this repo). Part 2 (the window) is #1922, stacked on this branch.

What it adds

  • Threads the person starts (InboxStore.startPersonThread). The root is the person's message: started_by_person: true, reply_to: null, to: { host, session }, and a subject derived from the body. Question blocks in it stay text, with no question records.
    • It is no session's default thread, because indexRoot indexes agent roots only. Only a reply_to answer lands in it.
    • It is handed to the addressed session alone (isFor by to) and settled only by delivery.
    • The list places it by the existing rules: Sent until delivered (the delivery counts as the agent's read), then Quiet, then New once the agent answers.
    • The row carries an additive addressee, so the window can draw the agent's mark instead of the person's.
    • It is idempotent on its key.
  • Send to another session (readdressMessage, POST /api/inbox/messages/:id/to). It re-addresses a person message with to that no session has taken yet: a thread the person started, a New message, or a redirected reply. The new session must be live in the thread's project. The store writes a new snapshot of the same message. This also closes the documented gap where a New message to a session that ended was never offered elsewhere.
  • A reply in a thread the person started, written before the agent answers, goes to the session the thread is addressed to: isFor follows the root's current to. Such a reply can also be sent to another session (added in 5fab00ff7).
  • Routes (packages/server/inbox-compose.ts). Each is a window route: same origin, serverSession, the owner's tailnet page allowed, and no phone-door entry.
    • GET /api/inbox/sessions: every live session, grouped by project. A folder new to the Inbox has id: null.
    • POST /api/inbox/messages: answers 409 session_not_live when the session is not live, and writes nothing.
    • Drafts: GET /api/inbox/drafts, POST /api/inbox/drafts/:id (compare-and-set on updated_at, 409 draft_conflict), and POST /api/inbox/drafts/:id/delete.
    • POST /api/inbox/uploads: takes the raw body.
  • Drafts (packages/shared/inbox/drafts.ts). Each draft is one 0600 file under inbox/drafts/, outside the event log. Agents, the MCP, phones, the relay and search never see them. Each list entry carries its chip (live, ended or none). Sending with draft_id deletes the draft. Settings' Storage counts the drafts.
  • Uploads (packages/shared/inbox/uploads.ts).
    • The body is streamed into blobs/, never held whole. Over 100 MB is refused, which stays under the 128 MiB request bound. The kind comes from decideInboxAttachmentKind.
    • Refused names: the dotenv family, path separators, control characters, and names over 255 bytes.
    • At send, each upload becomes an ordinary InboxAttachment: a read-only hard link of the blob at inbox/uploads/<att_id>/<name>. The existing tiles, viewers and download routes carry it unchanged.
    • The store's post-deletion blob sweep keeps the blobs of uploads not sent yet. An hourly sweep forgets pending uploads older than a day that no draft names.
  • The wake.
    • The bridge command gains new_thread: true, and inboxWakeText picks a new fixed constant, INBOX_NEW_THREAD_INSTRUCTION. The existing instruction bytes are unchanged. It is pasted into the mod's inbox-contract.ts, and the parity test passes.
    • Older connections ignore the flag and use the New message line, which stays true.
    • Attached files ride the command's body as Attached: <name> (<path>) lines.
  • Pi and OpenCode poll fields. The shared InboxWake now sends project_path, started_at, busy and idle_since, and posts state events, as the Claude Code mod does. project_path is Pi's ctx.cwd, or OpenCode's session location.directory. Their sessions are now listed under their real project from the first poll.

Tests

  • Store.
    • store-person-thread.test.ts.
    • The thread-state model gains personStart and deliver ops in the property runs. The routing-determinism oracle now includes person roots.
    • A new hand trace, hand-19-person-started-thread; no existing fixture changed.
    • The model doc and the fixtures README are updated.
  • Uploads. uploads.test.ts covers the cap, the sweep, and how deletion treats pending and sent uploads.
  • Routes. inbox-compose.test.ts:
    • grouping;
    • delivery to the addressed session only, with the new-thread line and the older-connection fallback;
    • 409 with nothing written; replay; stale tab; cross-site;
    • re-addressing and already_delivered;
    • uploads into attachments (read-only, viewable, listed unchanged, named in the wake);
    • dotenv and separators refused;
    • drafts: compare-and-set, chips, kept out of the event log, deleted on send;
    • the shared InboxWake poll fields and state events.
  • Connections.
    • The mod against a real Inbox: apps/hook/hooks/mod/inbox.test.ts 11.
    • The real Pi in RPC mode: apps/pi-extension/inbox.test.ts 02b.
    • The OpenCode 2 wake's poll fields: inbox-v2-wake.test.ts.
  • Runs.
    • bun test packages/shared/inbox packages/server packages/core apps/hook/hooks/mod apps/hook/server/inbox-help.test.ts tests/never-touch-the-real-inbox.test.ts: 2369 pass, 0 fail.
    • bun test apps/opencode-plugin apps/pi-extension/inbox.test.ts: 380 pass, 0 fail.
    • bun run typecheck: clean.

Docs

  • AGENTS.md (CLAUDE.md): a "Compose" subsection under the Inbox, eight rows in the routes table, the layout, the New message poll-field note, the wake-text line, and the ended-session follow-up now resolved.
  • plannotator inbox --help: a line on threads the person starts.
  • The reference page: Pi and OpenCode listing, and drafts/ and uploads/ on disk.

Not in this part

Second review fixes (6d63e4c)

  • More words in a thread the person started now carry the root's to on their own line (sendReply), so only that session is handed them and only its delivery settles them. Another agent's read_thread or wait_for_reply no longer settles them.
  • When a follow-up is moved to a session that has seen nothing of the thread, the wake has continues_thread: true. inboxWakeText then adds inboxContinuesLine, which tells the agent to read the thread first with read_thread.
  • Two Sends that race with one key: the store's replayed is returned, and the copied files of a replayed or refused Send are removed.
  • Upload names also refuse C1 controls, U+2028/U+2029 and bidi controls (the thread-name sets, now exported from core).
  • Sent uploads are copies (COPYFILE_FICLONE, a clone where the filesystem has them), never hard links, so an agent writing to its file cannot change the blob. They are read-only outside Windows.
  • wait_for_reply's result carries the Attached: lines (inboxBodyForAgent, the one helper the bridge uses too). Re-addressing a message in an archived thread is refused with thread_resolved.
  • Merged main (Review: file kinds (Code, Tests, Generated) in the tree and Guided Reviews #1916, Inbox: a cleaner toast, one line over the pane it belongs to #1918). Inbox: fold worktrees into their main repository's project #1919 is still open.

Main merged again (a3e2efc): #1919, #1921, #1923, #1914

  • Compose resolves its project through Inbox: fold worktrees into their main repository's project #1919's resolveProject. The live sessions use the shared project-root cache, so a session working in a linked worktree is listed under its main repository, and its thread lands in that repository's project.
  • If git does not answer in time, a compose Send returns 503 project_unresolved ("…try the same call again") and writes nothing. The pending uploads stay, so the same Send goes through once git answers. Tests are in inbox-compose.test.ts, "worktrees and a slow git".

…d the Pi/OpenCode poll fields

The server, store and connections for sending a new message to a connected
agent (approval record inbox-compose-to-agent):

- InboxStore.startPersonThread: a root person message addressed to one live
  session (started_by_person, to), never a session's default thread; the
  agent's reply_to answer lands in it. readdressMessage for Send to another
  session. The list row carries the addressee.
- Routes (packages/server/inbox-compose.ts): GET /api/inbox/sessions (every
  live session, grouped by project), POST /api/inbox/messages (409
  session_not_live, nothing written), POST /api/inbox/messages/:id/to, drafts
  (inbox/drafts/, compare-and-set, outside the event log) and streamed
  uploads (inbox/uploads/, 100 MB, dotenv refused) that become ordinary
  attachments at send.
- The wake: new_thread on the bridge command and INBOX_NEW_THREAD_INSTRUCTION
  in the connection contract (mirrored into the mod); older connections fall
  back to the New message line.
- InboxWake (Pi, OpenCode) polls with project_path, started_at, busy and
  idle_since, and posts state events, as the Claude Code mod does.
- Tests: the thread-state model gains personStart and deliver (and trace
  hand-19), route tests, upload/sweep tests, the mod, the real Pi and the
  OpenCode wake. Docs: CLAUDE.md, the agent guide, the reference page.
…ressed session; such a reply can be sent to another session
…d the thread, racing Sends leave no files

- More words in a thread the person started are stamped with the root's to
  when written, so no other agent's read_thread or wait_for_reply settles them
- A follow-up moved to a session that has seen nothing of the thread wakes it
  with continues_thread (inboxContinuesLine: read the thread first)
- Two Sends racing with one key: the store's replayed is returned, and files
  copied for a replayed or refused Send are removed
- Upload names refuse C1 controls, U+2028/2029 and bidi controls (the thread
  name's sets)
- Sent uploads are copies (a clone where available), not hard links; read-only
  outside Windows
- wait_for_reply's result carries the Attached: lines; re-address refuses an
  archived thread
…rver

# Conflicts:
#	AGENTS.md
#	apps/marketing/src/content/docs/reference/inbox.md
…rver

# Conflicts:
#	adr/implementation/inbox-thread-state.md
#	apps/marketing/src/content/docs/reference/inbox.md
…rver

# Conflicts:
#	packages/server/inbox-devices.test.ts
@backnotprop
backnotprop merged commit b76c6d4 into main Oct 15, 2026
32 checks passed
@backnotprop
backnotprop deleted the feat/inbox-compose-server branch October 15, 2026 01:50
@backnotprop
backnotprop restored the feat/inbox-compose-server branch October 15, 2026 01:51
@backnotprop
backnotprop deleted the feat/inbox-compose-server branch October 15, 2026 01:51
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.

1 participant