Files
buzz/mobile/lib/shared/me
Logan Johnson 851250524e feat(mobile): show your agents working in a thread on its root message (#8754)
## Summary

When you mention one of your agents in an ordinary channel on mobile,
nothing in the channel showed that the agent was working until its reply
landed. The agent answers in the mention's thread, so its typing (kind
20002) is thread-scoped, and the channel timeline hides thread typing.
The header working dot that used to cover this was removed in #8052,
#8075 and #8082.

This change brings buzz-app's behaviour to mobile. In buzz-app, the
thread summary under a message shows the viewer's own agents while they
type in that thread (`MessageRow.tsx` `useThreadAgents`, described in
`docs/agents.md`). Mobile now does the same. The root message's reply
row shows the working agents' avatars and the typing dots, and the row
appears even under a mention that has no replies yet. It then reads
"View thread". Tapping it opens the thread. When the reply arrives and
the typing ends, the dots go away and the row reads "1 reply".

The details follow buzz-app:

- Only your agents count. buzz-app's "your agents"
(`agentChoices.identities`) are your agent inventory, which is the kind
30177 records you author with archived agents included, plus your local
agents. It does not read the NIP-OA owner tag. Mobile uses the same
inventory. An agent that only names you as owner in its profile does not
count. People and other agents typing in a thread stay inside the thread
view.
- Working agents leave the participant stack for their own group: up to
two agent-shaped avatars side by side, then "+N", then the dots.
- The curved reply branch shows only when the message has replies.
- buzz-app's channel indicator by the composer also includes your agents
working in any thread ("Channel views include threads" in
`current-activity.ts`). Mobile's channel-level surface is the typing row
at the end of the timeline. In ordinary channels, that row now also
shows your agents that are typing in a thread, with the agent avatar
shape. It goes away when the agent's reply arrives.
- The spoken labels use buzz-app's strings: "View thread: Morty is
working", "View thread: 3 agents are working" and "View thread: 1 reply.
Morty working".
- Me and DMs already show thread typing inline, so they are unchanged.

Code changes:

- `TypingDots` is extracted from `AgentTypingBubble`, so the reply row
and the bubble share one animation. It respects reduce motion.
- `ReplySummaryLink` accepts a nullable summary and a list of working
agents with their names. `SmallAvatar` gains an `agent` flag for the
working group, and `InlineAgentTyping` a `knownAgents` set so the
channel typing row gives inventory agents the agent shape.
- `meAgentInventoryProvider` holds the inventory keys. It is read only
while a thread in the channel has typing. Each read, failed ones
included, is reused for 30 seconds, then read again if still watched, or
dropped. So the inventory refreshes every 30 seconds while it is
watched, and a short gap between an agent's messages does not query
again.
- The page selects a "pubkey root" key from channel typing, so typing
expiry refreshes do not rebuild it.

Less than buzz-app, not in this PR:
- buzz-app prefers lifecycle evidence (local agent state and kind 24200
observer turns) and falls back to typing. Mobile uses typing only. So
when an agent stops without replying, mobile keeps its dots until the
typing expires (8 seconds). A second buzz-app device without that
evidence behaves the same way. I found no 24200 publisher in buzz-app
itself. buzz-app publishes typing (kind 20002) for the agents it runs.
- The channel typing row reads "Morty is typing" where buzz-app's
indicator says "working". It has no popover that names the thread and no
tap action. It sits after the newest message, so it scrolls away with
the timeline, while buzz-app's indicator stays by the composer.

### Related issue

N/A. Reported in Buzz #buzz-bugs. Searched issues and PRs for
duplicates: none found.

### Testing

Android emulator, local relay, build of `3caa17a20`. Demo User mentions
Morty. Morty, Summer, Jerry and Rick send thread typing:
- Morty is a channel bot in Demo User's agent inventory.
- Summer and Jerry are in the inventory but are ordinary members, so
only the inventory gives them the agent shape.
- Rick names Demo User as owner in his profile but is not in the
inventory.

In the video:
1. The root message shows Morty and Summer, "+1", the dots and "View
thread", with no reply branch. The channel typing row reads "Morty and 2
others" with three agent avatars. Rick does not show.
2. Tapping "View thread" opens the thread before the first reply. Back
to the channel.
3. Summer and Jerry stop. Their typing expires, and only Morty is left
on both rows.
4. Morty replies. The typing row goes away, the reply branch shows, and
the root row reads "1 reply".

The UI tree confirmed "View thread: 3 agents are working", "Morty and 2
others are typing", "View thread: Morty is working", "Morty is typing"
and "View thread: 1 reply".


https://github.com/user-attachments/assets/2237e565-aa48-405a-84ca-39ab9a06b7a6

- The widget test "an agent working in a thread shows on its root
message" (`channel_detail_page_test.dart`, Typing indicator group)
covers these cases:
- A person, and an agent outside the inventory that names you as owner,
show no row and no channel typing row.
- Inventory agents also show in the channel typing row ("Morty and 2
others are typing", checked in the semantics tree), with the agent
shape. That row goes away when the reply arrives.
- Three inventory agents show two avatars with the agent shape, "+1",
"View thread", no branch, and "View thread: 3 agents are working".
  - The row opens the thread before the first reply.
- After the reply, Morty shows once, the branch shows, and the label is
"View thread: 1 reply. Morty working".
- With Summer still typing, Morty removed from the inventory stops
counting after the 30-second refresh.
- Each check was made to fail on purpose by removing the code it guards.
- `just mobile-check` and the full `just mobile-test` passed on
`3caa17a20` (3996 passed, 28 skipped).
- Auto and Cerveau reviewed it adversarially against buzz-app
origin/main. Their findings are fixed, and their last pass found
nothing.
- Not yet tested on iOS or by a human.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Logan Johnson <loganj@squareup.com>
Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 17:17:33 -04:00
..