Registry Mirror
Skip to content

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Builds the owner-approved "tag agents in a reply or a comment" (approval inbox-tag-agents, Lines variant).

What it does

  • @ in the reply box opens the live agent sessions of every project, grouped by agent: the owner first ("Owns this thread"), then each agent, and last the agents that read the Inbox through MCP only ("Reads the Inbox, not woken"). It follows the skill picker's rules: nothing is active until you arrow onto a row, Enter/Tab/Mod+Enter keep their meaning, Escape closes the picker before the reply box, the field has aria-autocomplete/aria-controls/aria-activedescendant, and a live region says what a pick means. @ is only a composer trigger; no new shortcut.
  • Labels never collide in the text: "Claude Code (another session)" in the same project, "Claude Code (plannotator)" in another one.
  • Under the field: "Goes to" with a chip per recipient, plus one of two heads-ups: one for a session that does not own the thread, another for an agent that can't be woken. A live session on an older Plannotator is listed as "Update Plannotator to tag this session" and cannot be picked.
  • File comments (markdown, text, HTML): the same agents in ui's comment composer, with "Goes to" and the heads-up. A tag there sends the whole reply to that agent, and the exported feedback marks the comment ("Tagged Pi: this comment sends the reply to it too."). The image, video, code and diagram comment boxes take no tags yet.
  • Sent reply (Lines): "to Claude Code · tagged Pi, Codex", the @ tokens painted, and one line per recipient, each with its own Delivered/Queued/Sending/Saved state and its own Send now. The list row reads "1 of 3 delivered · Pi queued". The thread head and the row show the agents' marks overlapping.
  • An untagged next reply goes to the agent that wrote last (unchanged). Agents don't tag each other.

Wire (all additive)

  • One person reply carries tags: [{ host, session, name?, label?, wakes, delivery?, deliver_now_at?, read_at? }]. It never includes the owner; there is no copy per agent. The reply route takes tags: [{ host?, session, label? }] and checks them before anything is written. The store parses them again, fail-closed.
  • GET /api/inbox/threads/:id/taggable lists who can be tagged; ?recipients= on the sessions route returns each tagged session's connection; send-now takes { session }. The device door forwards tags unchanged, and GET threads/:id/taggable is on it (contract 7.60).
  • Connection contract (connection.ts, with a byte-equal copy in the mod): the poll capability tags: true, the command fields tagged: { owner } / also_tagged, INBOX_TAGGED_INSTRUCTION, inboxTaggedLine and inboxAlsoTaggedLine. A connection that does not send the capability is never handed what it was only tagged in, so an older plugin can never word a tag as "the person replied to you". The mod, Pi and OpenCode send it. On Pi and OpenCode a tagged command's claim is <reply id>.<session>, so two sessions that share one data dir are each delivered once.
  • MCP: wait_for_reply without a thread also waits on threads the caller was tagged in (in any project) and returns tagged_you: true. The windowed read_thread shows to (the owner) and tagged: [{ agent, session, you }] on each message, and the transcript reads "to another session (…) · tagged you". Tagged threads appear in the list with tagged_you. An MCP agent's own read records read_at on its tag.

The required bug fix

Before this change, a reply without to counted as read when ANY agent read the thread. So a tagged agent that followed its wake's instruction to read the thread first would swallow the owner's wake. A reply with tags now counts as received for each recipient only when that recipient's own connection delivers it, or that session's own wait_for_reply returns it. A tagged session's delivery marks nothing for the owner. This is proved in inbox-tags.test.ts (the tagged read happens before the owner's poll, and the owner is still handed the reply), in the mod test, in the e2e, and by a property in store.test.ts (the op model sends tagged replies and tagged deliveries; routing determinism and the round trip still hold).

ui seam (additive, byte-identical when absent)

  • MentionSource.kinds
  • MentionSource.matchDetail
  • MentionSource.renderNotice
  • MentionPerson.group (MentionPicker draws runs of one group as role="group" under a heading; mentionGroups is exported)

These are documented in packages/ui/README.md and HANDOFF.md.

Merged origin/main

Merged with a merge commit after #2001, #2002 and #2003. Conflicts in the poll fields, the live sessions, the MCP read path, CSS and docs were kept on both sides. Tags are carried into #2002's windowed read_thread transcript.

Tests

  • Store and server: inbox-tags.test.ts (the delivery rule and the bug, the capability, refusals, MCP tags, cross-project answers, Send now, recipients, the windowed transcript; Pi and OpenCode InboxWake with stand-in targets sharing one claims folder), connection-tags.test.ts, the door's 7.60 in inbox-devices.test.ts, and the property in store.test.ts.
  • Mod: a real Inbox in apps/hook/hooks/mod/inbox.test.ts 10b: the owner and one tagged session are each woken once with the right wake text, and the tagged read never swallows the owner's wake.
  • Window and ui: packages/inbox/tags.test.ts; the DOM test packages/inbox/tagAgents.test.tsx over inbox-dom-server.ts tags (added to the test.yml DOM list); the ui seam tests in CommentPopover.mentionSource.test.tsx and mentions.test.ts.
  • e2e: tests/e2e/inbox-tags.spec.ts on the compiled binary, desktop and phone (44 px rows; nothing overflows at 320 px).

Locally: the full bun test run, typecheck, the DOM lists, and the tags, send-now, ended-session and new-message e2e specs all pass.

Not covered / follow-ups

  • Tags in image, video, code and diagram comments.
  • The phone app's own composer (only the wire and the door are ready).
  • Agents tagging each other.
  • In the e2e, the phone-width file-comment shot uses a 390 px mouse context; touch selection goes through the system menu.

# Conflicts:
#	.github/workflows/test.yml
#	AGENTS.md
#	apps/hook/hooks/mod/inbox.ts
#	apps/hook/server/inbox-help.ts
#	packages/inbox/inbox.css
#	packages/server/inbox-mcp.ts
#	packages/server/inbox-sessions.ts
#	packages/shared/inbox/agent-link.ts
#	tests/e2e/playwright.config.ts
#	tests/helpers/inbox-dom-server.ts
A tagged agent is told to read the thread first. Its read_thread (and its
wait_for_reply) marked the thread agent-checked, which settles every plain
reply up to that point, so an earlier untagged reply still queued for the
owner's connection was never delivered. A session that only has a tag in
a thread (never wrote there, owns none of the person's messages) no longer
marks the thread checked or its acks seen.
- One Send tags once: every tag in the words and in every comment it
  carries rides the last reply only, deduped (sendTagsByTarget), so an
  agent tagged twice gets one reply and one wake, and a comment tag on an
  earlier target still sends the whole reply.
- Wake lines naming another agent (tagged owner, also_tagged,
  redirected_from) carry only a host's own name: the server maps hosts
  through INBOX_HOST_NAMES, and inboxWakeText keeps only a name in
  INBOX_WAKE_AGENT_NAMES; anything else reads "another agent". An MCP
  agent's self-chosen agent_host no longer reaches another session's
  prompt. Contract copied into the mod.
- A tag whose host does not match the known session: 409
  tag_host_mismatch, not "not live any more".
- A reply with no owner tagging only MCP agents stays Sent until one of
  them takes or reads it.
- wait_for_reply reads the tagged threads once per call.
- A sent reply's tag chip carries the agent's mark over the @ (approved
  shot 5), drawn in a layer of the message's own.
An Escape that lands right after a Save, before the effect re-binds its
listener, saw the edit as still open and closed nothing, so the list stayed
up (the Inbox window e2e on CI). The listener now reads the edit state from
a ref. The tag marks' painter also stops once disposed (a fonts.ready that
settles after unmount painted again).
@backnotprop
backnotprop merged commit 77cd527 into main Oct 20, 2026
32 checks passed
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