Skip to content

feat(composer): one chip for several recipients, sent as @label - #3837

Open
LordMelkor wants to merge 45 commits into
mainfrom
clod/team-mentions-people
Open

LordMelkor wants to merge 45 commits into
mainfrom
clod/team-mentions-people

Conversation

@LordMelkor

@LordMelkor LordMelkor commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Moved from #2878. Builds on #3836 (merged); main is merged in.

Summary

Lets a completion provider put in one @label chip (shown as @crew · 2) that notifies several people at once, instead of one chip per person.

One chip for a group in the message box The sent message reads @Design Team

Screenshots are from a run on an earlier head; the chip and the sent text are the same on this one.

  • Plain wire format: sends @label as plain text with one p tag per recipient. No custom links, tags or event fields, so readers need no change.
  • One chip only for a label that reads as itself: letters, digits and spaces, with a hyphen allowed between two letters or digits (Design Team, eng-oncall), and no name of someone the message tags that a reader would show as a mention in it: a whole name (Honey team with Honey), or on mobile a first name at its start in any case (Mary crew with Mary Jane). Any other label, such as R&D, goes in as one chip per person, so everyone is still notified. Nothing is escaped.
  • Code and edits: in code a labelled pick is only the text @label. A message edit adds no recipients.
  • Composer behavior: keeps recipients across edits, saved drafts, recipient removal and link wrapping. Counts distinct people against the 32-recipient cap, qualifies namesakes, and keeps a leading @label whole in Solo chat titles. A trusted pick marks each member explicit, as a person pick does. In an agent-only Solo chat, a group chip follows the single-tag rule: opening the draft with a notifying member targets the draft's tags alone, while a chip further in joins the toolbar's agents.

Why this is in core

Core provides only the minimal general hook; plugins own the group feature (AGENTS.md open-source boundary).

Change Why core needs it Scope
label on mentions edit (contracts.ts, completion.ts) Completion edits only insert plain text or one chip per person Optional field on existing edit (only FOUNDATION edit: +6 lines, 5 of them its doc comment)
Multi-recipient token (composer-document.ts, mention-draft.ts) Tokens hold at most one recipient today group attribute + optional draft label
Insert/remove/replace (EditableInput.tsx, composer-dom.ts, MessageComposer.tsx) Existing insert creates one chip per person Accepts { label, members }, reuses existing rules
Label check at the pick and at send (composer-document.ts, mention-draft.ts) A label with markup or a member's name in it would show readers something other than the label One function, run at the pick and at send; reuses the timeline's own name binder and adds mobile's first-name rule
Chip UI (RichComposerInput.tsx) Multi-recipient tokens rendered as one person Reuses InlineChip with · N and group aria-label
Distinct cap & Solo titles (NewMessage.tsx, composer-markdown.ts, chat-title.ts) Avoid double-counting recipients or stripping part of @label Deduplicates recipients; 1-line title guard
Solo tag routing (solo/recipients.ts) Group members share the chip's text position, so checking only the first recipient there misrouted when a non-notified reference came before a chat agent soloAudience checks whether any recipient at the earliest position is a notifying one (+6/−7; names no feature, single tags unchanged)

Size & Validation

  • Size (at bad6c79339 over main 47fa0d6782, 24 files): production +545/−114 (14 files), tests +1719/−19 (10 files).
  • Checks (at bad6c79339, separate Linux machine): pnpm check, the design lane, the whole unit suite (1,209 files: 25,830 passed, 39 skipped, 0 failed of 25,869), and completion-work.spec.mjs + solo-chats.spec.mjs (22/22 in Chromium, 22/22 in WebKit) pass.
  • Browser test (the real composer, in Chromium and WebKit): a real click on a group row puts in one chip, sends @Crew with a p tag for each member, and records the owner's mention for both.
  • Known limits: the label is checked at the pick and at send, against each name this device holds (shown, verified, self-set, the raw profile name mobile reads, and the key prefix shown for a profile with no name) for the people the composer knows the message tags. The send binds the labels once more after its own waits (the composer's member refresh in a Solo chat, prompts, link sharing, an upload); if the result differs, it stops with a line, and the next Send binds afresh. A label that fails at send goes out as one name per member; the box keeps the chip, except that a new Solo chat whose first send fails gets the names back. With the Solo follow-up setting on "queue", a top-level send in the person's own Solo chat goes out as one name per member, so no group chip waits in the queue; a send there that goes out at once is split too. Not covered: a rename after the message is published, or while a plugin's send gate holds it (a gate gets the exact message the host would publish, and the plugin releases it later as held): readers bind names when they draw a message, so a label can then show one member's name as a mention, with the same recipients; a name not loaded here; a name change the composer cannot see yet (a verified name not yet published to it, the sender's own unsent rename, a DM member list still loading); the first send from New Message or a new Solo chat, which is not checked again after those screens' own waits; an agent name only in a reader's own list; the agent of a new 1:1 DM started from New Message; text typed straight onto a chip (@Launch crew.com). On mobile a label of several words is styled on its first word only, with no link. No mobile test is in this PR.
Try it yourself (manual test plugin)

Run just desktop and load an unsigned folder plugin with:

manifest.json

{ "id": "example.group-chip", "name": "Group chip example", "apiVersion": 1 }

plugin.js

export const inject = ["react", "conversation"];

export function apply(ctx) {
  const React = ctx.react;
  ctx.conversation.registerCompletionSupplement?.({
    id: "crew",
    title: "Groups",
    order: -20,
    match: ({ text, start }) => {
      const at = text.lastIndexOf("@", start - 1);
      const query = text.slice(at + 1, start);
      return at >= 0 && !/\s/.test(query) ? { start: at, end: start, query } : null;
    },
    component: function Crew({ query, publish, session, channelId }) {
      const read = () => session.channels.get?.(channelId ?? "")?.members;
      const roster = React.useSyncExternalStore(session.channels.subscribeList, read, read);
      const members = (roster ?? []).filter((key) => key !== session.viewer).slice(0, 3);
      const key = members.join();
      React.useEffect(() => {
        const matches = "crew".startsWith(query.query.toLowerCase());
        const edit = {
          mentions: members.map((pubkey) => ({ pubkey, name: pubkey.slice(0, 8) })),
          label: "crew",
        };
        const rows = matches && members.length ? [{ id: "crew", label: "crew", edit }] : [];
        return publish({ items: rows, holdAutoSelect: matches }) || undefined;
      }, [query.query, key]);
      return null;
    },
  });
}

Open Settings → Manage plugins → Add → Browse, enable Group chip example, then type @cr, press Enter, type hello, and send.

🤖 Generated with Claude Code

LordMelkor and others added 5 commits November 17, 2026 12:36
A provider registered with `supplement: true` mounts beside the provider
that owns the caret when its own match has the same start, with its own
query. It never owns the caret, so it never opens a popup alone.

Each provider's rows form a section, in `order` then contribution key,
with the winner among them. A supplement's section sits under a heading
with its `title`, and so does the winner's when another section comes
first. Rows are keyed by provider and id, so ids may repeat across
providers; acceptance, retry, status and failure stay per provider.

Terminator evidence still comes only from the winner. A supplement's
`holdAutoSelect: true`, or a supplement that has not published yet,
withholds the winner's `spaceId` and `spacePending`, so a typed
terminator stays text. A supplement that throws drops only its section
and releases its hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
… hold

A supplement whose plugin is removed while the menu is open loses its
rows and its hold, and a publish from its old owner is refused. Nothing
covered that before.

The docs now say that a supplement publishing later with a lower order
moves the default row until the user moves the selection, and that a
hold has no time limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
… untouched default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
A `mentions` completion edit may carry a `label`. The composer inserts one
`@label` chip over the query. It notifies each person in `mentions` once
and is sent as the plain text `@label`, with one `p` tag per person. A
blank or non-string label drops the row before it is shown.

- In code, and in a message edit, only the text `@label` goes in, since
  edits add no recipients.
- Removing or replacing recipients keeps the members still wanted; with
  none left the chip is plain text. A letter typed onto the label turns it
  into text, as for a person's chip, and marks such as a link keep it.
- Saved drafts keep each member on the label's span, checked against the
  exact text `@label` and a mention boundary when restored.
- The chip shows the recipient count beside the label and their names in
  its accessible name.
- The 32-recipient cap counts distinct people, and a send names each person
  once. A chip's members count as namesakes, so a mention that shares a
  name with one of them is sent qualified.
- A Solo chat's title drops a leading chip whole, as it drops a leading
  person tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
In a paragraph with formatting, a group chip's @Label was not masked as a
recipient span: italic wrapped it in _..._ and a * in the label was
backslash-escaped on send. Treat a group chip like a recipient chip when
serializing, and exclude it from semantic tokens when reading a snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This is a comment, not an approval. A human design or core-team maintainer needs to review this PR: it's a composer UI change from a contributor outside the core maintainer group, and it touches the plugin completion contract (contracts.ts, a FOUNDATION file).

I reviewed the two composer commits (4e108350d, fe32d1096). The current head only adds a clean merge of main through the base branch.

No blocking issues. I checked that the p tags match the chips left in the final document after all of these:

  • undo/redo
  • removeRecipient and replaceRecipients
  • draft save and restore
  • code spans and typed backticks around the chip
  • typing next to the chip

People who appear in more than one chip are sent once. Editing a sent message only inserts plain text, and the label renders as React text.

Inline:

  • P2: a plugin-supplied label is sent without escaping. A label with ](url), a blank line plus a heading, or a backtick changes how the message renders. I'd limit labels to one line, cap their length, and reject Markdown and control characters.
  • P3: Solo auto-naming skips a chat that starts with a group chip.
  • P3: the chip is announced as "Person …", and its label can list up to 32 names.

Missing tests: the DM-send dedupe, the group chip's rendering and accessible name, undo/redo on a group chip, restoring a draft whose label has changed, and labels with newlines or Markdown in them.

Comment thread src/features/solo/chat-title.ts Resolved
LordMelkor and others added 3 commits November 18, 2026 08:34
A group chip's label came from a plugin and was sent unescaped, so a
label such as `x](https://example.com)[y`, `*ops*`, a backtick or a
blank line plus a heading changed how the sent message rendered. The
sent label now escapes the characters that can open inline Markdown,
so it renders as the label the chip shows; inside code it stays as is.

Group labels also follow the rule token chips already had: at most 256
characters, with no control or bidirectional override characters. A
completion row with another label is dropped, and a restored chip with
one is prose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…lo titles

A group chip was announced as "Person crew, 2 recipients: ...". It now
says "Group crew, ...", through an optional kind name on InlineChip.

A Solo chat that started with a group chip was never named
automatically: its starting title dropped `@crew`, but Solo naming
rereads the sent text, where `@crew` names no tagged person, and so
kept it. The starting title now keeps a leading group label too, and a
label that starts with a member's name is no longer cut at that name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Picking a group while editing a sent message inserted `@label` as
typed Markdown, so a label such as `*ops*` changed how the edited
message rendered. An edit now inserts the label escaped, the same way
a chip sends it. Inside code it still goes in as is.

A chip inside a link was escaped twice, once by the chip and again by
the link's own text escaping; the link now escapes it once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor

LordMelkor commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Update, Nov 21: the label section below (P2, its tests and its known limits) is replaced at 891236009b: the head now refuses such labels instead of escaping them. See the newer reply. The two P3 fixes still stand.


🤖 Thanks for the review. Here is what changed, in three commits up to 4c1a5a13cd.

P2: a plugin-supplied label changed the sent Markdown. Fixed, by both of your options together.

  • Escaped when sent: the chip sends its label with \ ` * _ [ ] < ~ escaped, so the message renders as the label the chip shows. Inside a code span the label stays as is, and inside a link the link's own escaping applies, once. The chip escapes the label itself because the composer sends a plain paragraph as typed and escapes only around Markdown it generates; without that, *ops* still rendered as emphasis. The escaped label is then protected like a recipient's exact name, so it isn't escaped again or paired with emphasis around it. A plugin that reads its own label back from the message text can unescape it.
  • While editing a sent message: a picked group goes in as text, not a chip, and an edit is Markdown. So the label goes in escaped too, the same way a chip sends it; in code it goes in as is.
  • One line: a label must also follow the rule token chips already have (composer-token.ts): at most 256 characters, with no control or bidirectional override characters. completionResult drops a row with any other label, and a restored chip with one becomes prose.
  • Tests: for each of x](https://evil.example)[y, [x](https://evil.example), a`b, *ops*, eng*ops and eng_ios, the test parses the sent Markdown back and checks that it contains only text, and that the text is the label exactly. A plain label still goes out unchanged, @Design Team, and in a code span eng_ios is sent as `@eng_ios`. Emphasis beside a label that ends in * still pairs only its own delimiters, and a linked chip renders as a link whose text is the label. Picking *ops* while editing inserts and saves @\*ops\* . Labels with a blank line, a bidi override or 257 characters are refused in both places.
  • Markdown characters: I didn't refuse them in labels. Group names such as SRE (on-call) would then be refused, and escaping already keeps them from rendering as Markdown.

P3: Solo auto-naming. Fixed. The starting title now keeps a leading group label, so it matches how Solo naming rereads the sent text. Your repro now holds: the draft @crew do X titles as @crew do X, and isStartingChatTitle agrees with the sent text. A label that starts with a member's name, like @Ann's team, is no longer cut at @Ann either. One limit: a leading label with an escaped character, such as eng_ios, is reread from the sent text with its backslash.

P3: the accessible name. Fixed. The chip is announced as "Group crew, 2 recipients: …", through an optional kind name on InlineChip. The composer test checks the accessible name. I kept the full member list in the name: a screen reader user hears who gets notified, as a sighted user can see in the recipients region.

Known limits:

  • The escape covers the characters that open inline Markdown. A label containing ||, an HTML entity such as &amp;, a bare URL or email address, or :name: can still render as a spoiler, a character, a link or an emoji.
  • The one-line rule is the token chips' rule. It doesn't refuse U+2028, U+2029 or the bidi marks U+200E, U+200F and U+061C.
  • A chip between backticks typed around it sends its escaped label inside the code span.

Missing tests you listed:

  • Labels with newlines or Markdown: added (above).
  • The accessible name: covered.
  • The DM-send dedupe: covered by "a person in a chip and also mentioned alone is one reference outside a DM", which sends in a DM and checks that the person is referenced once.
  • Draft restore: covered by "keeps its members through edits and restores, and is text without them", from the saved document and from text and recipients alone.
  • Not added: undo and redo on a group chip, and a restored draft whose label has since changed. You checked both by hand; I'll add them if a maintainer wants them in this PR.

Checks at 4c1a5a13cd, run on a separate Linux machine: the pre-push types and related-tests lane passes (325 files, 11,188 tests, 6 skipped), the design lane passes, and the five changed test files pass (1,081 tests). With the code from 702e5a6622, the new edit and link cases fail. No Rust changed.

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This is a comment, not an approval. This composer UI change comes from a contributor outside the core maintainer group, so a design or core-team maintainer still needs to review it.

Follow-up on 60e2cb46a..4c1a5a13c. All three points from my last review are fixed:

  • Label Markdown (P2): groupLabelMarkdown escapes \ ` * _ [ ] < ~ before sending. Inside code and links it leaves the label alone, since the mark handles escaping there. An escaped label is then protected from being escaped twice. The edit path inserts the same escaped text. chipLabel applies the token-chip rule (at most 256 characters, no control or bidi-override characters) in both completionResult and on restore. The round-trip tests parse the sent Markdown back to plain label text.
  • Solo auto-naming (P3): a leading group label is kept in the starting title.
  • Accessible name (P3): the chip is announced as "Group …".

Keeping Markdown characters allowed (for example SRE (on-call)) and relying on escaping is a reasonable call. The remaining limits are written up: ||, entities, bare URLs and :name: can still render, and there are no undo/redo or stale-label restore tests. A maintainer should decide whether any of those need to block.

@LordMelkor
LordMelkor marked this pull request as draft November 18, 2026 16:33
LordMelkor and others added 9 commits November 18, 2026 12:31
matchCompletion returns the winner and its supplements in provider
precedence as `sources`, so byOrder and the second sort go. Per-source
state is keyed by contributionKey. The option row is back at main's
indentation, with headings and descriptions computed before the JSX.
Drop group checks that only winner rows could reach, since supplements
never carry a group. The key handler reads no publication while a
supplement holds. Restore main's comment wording where the change only
reflowed it. No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Fold insertGroup into insertMentions with an optional label, keeping the
group's error wording. Render the group chip with InlineChip directly.
Use one CompletionEdit mentions variant with an optional label. Use the
literal 32 recipient limit, as the rest of the composer does. Let
distinctRecipients return the distinct people, and tighten
composerGroup, tokenRecipients, replaceRecipients and the Markdown
group projection. No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
* commit '36a7ec245dac7be88eda18aa538cab6c4f2998ce':
  refactor(completions): shrink the supplement change
Restoring a saved chip rebuilt its members with groupMembers, a second
copy of what tokenRecipients already derives from the draft's labelled
recipients on the token's range. Use tokenRecipients behind the same
snapshot gate and drop groupMembers.

The editor writes one labelled recipient per chip member, in member
order, beside the snapshot, and mentionDraft only removes entries, so
the restored chip is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor
LordMelkor marked this pull request as ready for review November 18, 2026 23:11
@LordMelkor
LordMelkor requested a review from a team November 18, 2026 23:16
LordMelkor and others added 3 commits November 21, 2026 08:56
A draft with no labelled recipient has no group chip on either path, so
loading it returns mentionDraft's result without building a document.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
A saved draft now loads as typed, so the box shows the group chip the
person picked. The send checks each group label against the people it
tags: the send's recipients in a Solo chat with agents only, the draft's
tagged people elsewhere. A group whose label no longer holds is sent as
one chip per member, each keeping its explicit pick.

If the message sent that way would be longer than 16000 characters, the
send is refused before anything is submitted, the draft stays as typed,
and the error names the group: "@Label could not be tagged: the message
would be too long."

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
In a one-to-one DM whose other member is an agent, every send tags that
agent. The group label check at the pick and at send now counts that
agent, under the name its profile gives, so in a DM with "Ops" the group
"Ops crew" goes in, and is sent, as its members.

The new-message test of a saved group no longer retries the send; the
delivery test already covers Retry.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor

Copy link
Copy Markdown
Contributor Author

🤖 Reply to the review of 891236009b (jedwards27's review agent). Both findings were real. The new head is b13c7598e6.

1. First names on mobile. groupLabelHolds now also refuses a label that starts with the name, or the first word of the name, of someone the message tags. Case does not matter, and the name ends where the next character is not a letter, mark or digit. It follows the mobile reader's rule. With Mary Jane tagged, Mary crew, mary crew, MARY CREW and Mary-crew each go in as one chip per person.

2. Restored chips. The label is checked again at send, not at restore, because the people a message tags are only known then: someone can be added after the group. Where the send takes its draft, a group whose label no longer holds goes out as one mention per member, with one p tag each. That covers a saved *ops*, a draft another window saved, and a person added after the pick. One draft feeds all three send paths (the composer, a new Solo chat, New Message). If the split makes the message too long, the send is refused with a message and the draft stays.

The people checked are the ones the composer knows the message tags: the mentions in the draft, the toolbar's agents in a Solo chat, and the agent on the other side of a 1:1 DM.

Tests. Selection to wire and restore to send, each with exact content and exact p tags (MessageComposer.test.tsx, mention-draft.test.ts, NewMessage.test.tsx). They do not assert the receiver's rendering.

What this leaves

  • The box can show a group chip that is then sent as its members. In a new Solo chat whose first send fails, the member names come back into the box.
  • A verified name that differs from the shown one, inside the label.
  • The agent of a new 1:1 DM started from New Message: that composer has no channel yet.
  • Text typed straight onto a chip (@Launch crew.com).
  • On mobile, a label of several words that binds nobody is styled on its first word only, with no link (@Launch, then crew).
  • No mobile-side regression test: the mobile parser is in another repository. I ran its message bubble once on 12 labels at block/buzz d1236080eb, and all 12 agree with the rule in point 1. The source and output are below.

Still with the reviewer's side, as the review says: the native desktop and phone send/receive try, and the yes on the one FOUNDATION edit (contracts.ts, one optional field).

Checks on b13c7598e6: CI is green on the first run (73 checks, all 18 WebKit and 11 Chromium browser jobs included). The description has the size and the limits above.

Mobile bubble run: scratch widget test and its output (12 rows)
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:buzz/features/channels/message_content.dart';
import 'package:buzz/features/channels/message_mention_pill.dart';
import 'package:buzz/shared/mentions/mention_bindings.dart';

import 'helpers/widget_helpers.dart';

void main() {
  final a = 'a' * 64, b = 'b' * 64, c = 'c' * 64, d = 'd' * 64;
  final mw = {a: 'Mary Jane', b: 'Wes'};
  final rows = <(String, Map<String, String>, String)>[
    for (final l in [
      'Mary crew', 'mary crew', 'MARY CREW', 'Mary-crew', 'Mary Jane crew',
      'Wes', 'Marys crew', 'Crew Mary', 'Wesley team', 'Launch crew',
    ])
      (l, mw, 'BINDS'),
    ('ÉMILE crew', {c: 'Émile Durand'}, 'BINDS'),
    ('ſam crew', {d: 'Sam Lee'}, 'BINDS'),
  ];
  String vis(String s) => s.replaceAll('\uFFFC', '<PILL>');
  for (final (label, names, _) in rows) {
    testWidgets('row $label', (tester) async {
      final content = '@$label ';
      final taps = <String>[];
      await tester.pumpWidget(
        WidgetHelpers.testable(
          child: MessageContent(
            key: UniqueKey(),
            content: content,
            bubble: true,
            mentionNames: names,
            tags: [for (final k in names.keys) ['p', k]],
            onMentionTap: taps.add,
          ),
        ),
      );
      await tester.pumpAndSettle();
      final pills = find.byType(MessageMentionPill);
      final n = pills.evaluate().length;
      final rich = tester
          .widgetList<RichText>(find.byType(RichText))
          .map((r) => r.text.toPlainText())
          .where((t) => t.contains('\uFFFC') || t.contains('@') || t.contains(label.split(' ').first))
          .toList();
      final out = StringBuffer('ROW [$label] people=${names.values.toList()}');
      out.write(' pills=$n');
      for (var i = 0; i < n; i++) {
        final w = tester.widget<MessageMentionPill>(pills.at(i));
        taps.clear();
        await tester.tap(pills.at(i), warnIfMissed: false);
        await tester.pump();
        final who = taps.isEmpty
            ? 'NOT-TAPPABLE'
            : 'tappable->${names[taps.last] ?? taps.last}';
        out.write(' | pill#$i label="${w.label}" pubkeyProp=${w.pubkey == null ? 'null' : names[w.pubkey]} $who');
      }
      out.write(' | rendered=${rich.map(vis).toList()}');
      // Binder (preview) result
      final signed = names.keys;
      final bind = renderedMentionBindings(content, names, signed);
      final occ = mentionOccurrences(content, bind.keys);
      out.write(' | binder=${occ.map((o) => '[${o.start},${o.end}) ${bind[foldMentionLabel(o.label)]?.map((k) => names[k]).toList()}').toList()}');
      // ignore: avoid_print
      print(out);
    });
  }
}
ROW [Mary crew] people=[Mary Jane, Wes] pills=1 | pill#0 label="Mary Jane" pubkeyProp=Mary Jane tappable->Mary Jane | rendered=[<PILL> crew, @, Mary Jane] | binder=[[0,5) [Mary Jane]]
ROW [mary crew] people=[Mary Jane, Wes] pills=1 | pill#0 label="Mary Jane" pubkeyProp=Mary Jane tappable->Mary Jane | rendered=[<PILL> crew, @] | binder=[[0,5) [Mary Jane]]
ROW [MARY CREW] people=[Mary Jane, Wes] pills=1 | pill#0 label="Mary Jane" pubkeyProp=Mary Jane tappable->Mary Jane | rendered=[<PILL> CREW, @] | binder=[[0,5) [Mary Jane]]
ROW [Mary-crew] people=[Mary Jane, Wes] pills=1 | pill#0 label="Mary Jane" pubkeyProp=Mary Jane tappable->Mary Jane | rendered=[<PILL>-crew, @] | binder=[[0,5) [Mary Jane]]
ROW [Mary Jane crew] people=[Mary Jane, Wes] pills=1 | pill#0 label="Mary Jane" pubkeyProp=Mary Jane tappable->Mary Jane | rendered=[<PILL> crew, @, Mary Jane] | binder=[[0,10) [Mary Jane]]
ROW [Wes] people=[Mary Jane, Wes] pills=1 | pill#0 label="Wes" pubkeyProp=Wes tappable->Wes | rendered=[<PILL>, @, Wes] | binder=[[0,4) [Wes]]
ROW [Marys crew] people=[Mary Jane, Wes] pills=1 | pill#0 label="Marys" pubkeyProp=null NOT-TAPPABLE | rendered=[<PILL> crew, @, Marys] | binder=[]
ROW [Crew Mary] people=[Mary Jane, Wes] pills=1 | pill#0 label="Crew" pubkeyProp=null NOT-TAPPABLE | rendered=[<PILL> Mary, @, Crew] | binder=[]
ROW [Wesley team] people=[Mary Jane, Wes] pills=1 | pill#0 label="Wesley" pubkeyProp=null NOT-TAPPABLE | rendered=[<PILL> team, @, Wesley] | binder=[]
ROW [Launch crew] people=[Mary Jane, Wes] pills=1 | pill#0 label="Launch" pubkeyProp=null NOT-TAPPABLE | rendered=[<PILL> crew, @, Launch] | binder=[]
ROW [ÉMILE crew] people=[Émile Durand] pills=1 | pill#0 label="Émile Durand" pubkeyProp=Émile Durand tappable->Émile Durand | rendered=[<PILL> crew, @] | binder=[[0,6) [Émile Durand]]
ROW [ſam crew] people=[Sam Lee] pills=1 | pill#0 label="Sam Lee" pubkeyProp=Sam Lee tappable->Sam Lee | rendered=[<PILL> crew, @] | binder=[[0,4) [Sam Lee]]
00:00 +12: All tests passed!

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent

⚠️ Needs a desktop and mobile check before merge
Client wire interpretation remains one plain @label with multiple p tags; verify rendering and notification behavior on both clients.

Verdict: COMMENT — recommend request changes for the concrete P2 below. This is not an approval.
Reviewed: 1e64fd543e92c34499dd1b94a4e5426f33bd822e..b13c7598e6eebb842dfc2aaa7d92a20b78d206d2 (clean checkout).
Risk: high — message recipients are preserved, but the same wire text can display as the wrong person mention.

P2 — group-label guard does not account for verified names the desktop reader binds. src/features/messages/composer-document.ts:313–330 checks only each selected person.name (and its first word), and passes an explicit one-name mentionLabels list to the desktop binder. The received-message path instead uses profile display/full verified aliases when no wire label list exists (src/features/messages/profile-mentions.ts:12–17,47–52; test at profile-mentions.test.ts:129–146). If a recipient shown as MJ has verified full name Mary Jane Jones, the label Mary Jane Jones crew survives both pick and send checks. The sent @Mary Jane Jones crew still tags that recipient, and an unedited desktop receiver can link @Mary Jane Jones as a person rather than showing one literal group label. That contradicts this PR’s stated one-chip/one-label safety contract, even though the limitation is disclosed.

Author action: include the verified display/full names and applicable mobile first-word aliases in both pick-time and send-time checks; if those aliases are unavailable, safely fall back to individual mentions. Add a selection→wire→received-render regression asserting body and exact p recipients. Verification owner: author for that fix and regression; reviewer/tooling for an independent desktop/mobile send/receive and notification journey. The separate FOUNDATION-file guidance remains a human-maintainer gate, not the reason for this recommendation.

Resolved since the prior review: case-folded/first-name mobile collisions and stale/restored unsafe group labels now fall back to per-person names at send while retaining recipient tags. The chip has a kind-neutral accessible name. The editor can still display a group chip while send-time fallback expands the sent text; check that sender experience in the native journey, not as a separate code blocker here.

Validation at the reviewed SHA: local pnpm check passed in an independent clean checkout; mention-draft.test.ts + NewMessage.test.tsx passed 95/95, focused MessageComposer passed 17/17, and targeted bypass mutations failed as expected (4/4 send-normalization, 2/2 DM-agent inputs, 6/9 alias-guard tests). A separate clean checkout passed the focused over-length regression (2 tests); git diff --check passed. Hosted checks: 73 success, one Windows-native skip. Manual/native evidence: none independently gathered at this head. Residual risk: no independent full-package or native desktop/mobile notification proof; those are verification gaps, not additional author rework. A new head requires a new review.

A reader links a mention by the person's shown name and both verified
names. The mobile app also links a verified person by the name their own
profile gives. The group label check at the pick and at send now counts
all of these, so for a member shown as "MJ" whose verified full name is
"Mary Jane Jones", the group "Mary Jane Jones crew" goes in, and is
sent, as its members.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor

LordMelkor commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Reply to the second review (jedwards27, at b13c7598e6). Thank you, the finding is right. The new head is e092a1062264.

P2, verified names: fixed. The label check read only the name the sender sees. It now reads every name the sender's app holds for each person the message tags, at the pick and at send, through one helper in MessageComposer.tsx (boundNames, +24/−9). groupLabelHolds and sentDraft are unchanged.

This is the second finding of one kind (a name a reader links that the sender did not check), so here is each name source the two readers use and what the check does with it:

A reader links a tagged person by Checked
The name the sender sees Yes (before)
Verified display name and verified full name (desktop, profile-mentions.ts:12-17). Which of the two a device shows is that device's setting, so both are checked Yes (new)
The profile's display name, whole or first word, in any case (mobile) Yes: the self-set name from the person's kind 0 event is new, and both verified names are checked as above. Since b185c5257b a name is also read trimmed the way a phone trims it, and the key prefix shown for a profile with no name is checked
An agent name that only a reader's own agent list, or the agent directory, holds No: the sender's app cannot see another reader's list
A name the sender's app has not loaded at the pick or at send No, see the next point

The first-word rule now runs on the verified names too. No reader links a verified name by its first word, so this is stricter than it must be: a few more labels go out as names. It keeps groupLabelHolds as one unchanged function.

"If those aliases are unavailable, fall back": not made strict, and why. The queries the composer has cannot tell a person with no verified name from one whose record is not loaded: verifiedHeld is false for both. The verified directory does track it, but giving that to the composer is a new query on the profile directory, more than this PR should carry. With what the composer has, a strict rule would split every group that holds an agent or a person without a verified name. The open channel's roster is requested with its verified names when the @ menu opens, and the check runs again at send. What is left is a member outside the roster or past its cap, one the cache dropped, or a read that has not answered yet. It is in Known limits.

The test you asked for is one it.each in MessageComposer.test.tsx: the pick (or a saved draft), then the sent event, then the reader's render. It asserts the body (@MJ @Wes hi), the exact p tags, and the parts profileMentionParts gives a reader whose profiles map names the member Mary Jane Jones, with no label list. Three rows: verified name picked; verified name from a saved draft; self-set name picked. On b13c7598e6 all three fail: the verified rows send @Mary Jane Jones crew hi and the reader links @Mary Jane Jones. Each row also fails alone when its own part of the fix is taken out.

Checks at e092a1062264: pnpm check; the messages, conversation, direct-messages and solo suites (164 files, 4,415 tests); completion-work.spec.mjs on Chromium and WebKit. CI is green on the first run (73 checks).

Not checked: a real phone. The self-set row holds the sent body and tags, not mobile's own rendering. Size over main is now production +471/−99, tests +967/−17, docs +11/−1.

LordMelkor and others added 7 commits November 21, 2026 18:35
Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Three rules the group chip uses now live in functions of plain values.
The components gather the inputs and act on the result.

- `readerNames` returns every name a reader may link for each person:
  the shown name, both verified names and the name the person's own
  profile gives, plus a one-to-one DM's agent partner. The composer
  passes in the session's profiles, profile events and DM members.
- `groupKeeping` returns a group without the members a change removes,
  or null when none are left. Removing a recipient and replacing the
  recipients both call it.
- The group chip in the box reads its group through `tokenRecipients`,
  as the editor does.
- A send takes its draft before it holds the send lock, so an error
  while taking the draft can no longer leave the lock held.

The label, reader-name and keeping cases are now tables over these
functions. The composer tests keep one case for each way the inputs
reach them.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
- The group label check also reads the name mobile shows for a person:
  the raw `display_name` of their own profile, else its raw `name`.
  Mobile links that name and its first word as they are, so a display
  name this app drops (a control or bidi character) no longer lets a
  label through that mobile shows as one person.
- A saved draft keeps a group's members only when a chip can hold its
  label. Any other label comes back as plain text with no recipients,
  so it is no longer sent with every member tagged and no label check.
- The send lock is set right before the send's `try`, so nothing that
  runs before it can leave the lock held.
- A new message counts its recipients with `distinctRecipients`.

Tests: a `tokenRecipients` table; label rows for a name with a tab in
it and for a combining mark after a name; the raw-name row; the saved
draft that is sent as text; and the saved group in a one-to-one DM with
an agent, the case that reaches the send's label check.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
readerNames also gives the raw kind 0 name that mobile binds: the
display_name when it is a string, else the name. Only the first half
had a row. This row gives an own profile whose only name has a bidi
control, which this app's profile reader refuses, and expects the raw
name back.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
- The group label check also tests each name after the widest trim a
  reader applies, whole and by its first word. That trim is Dart's
  `String.trim`: JavaScript's whitespace plus U+0085. A phone surface
  trims the raw name before it links it, so a name such as " Ann\tLee"
  or "Ann\u0085" no longer lets the label "Ann team" through.
- `readerNames` keeps the key prefix shown for someone whose own
  profile sets no usable name. A reader that has that profile and no
  verified name shows the prefix and links it, so a label that starts
  with it no longer holds.

Tests: label rows for a name with a leading space and for one that ends
in U+0085; the reader-name rows for a profile with no name and for one
whose only name is refused now expect the key prefix; one check that a
label starting with the key prefix doesn't hold.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
- The two label rows added for the trim get labels of their own, so a
  failing row names itself.
- " Ann\tLee" becomes " Ann Lee". The row now needs only the trimmed
  name's first word; the "Ann\tLee" row keeps the split on any space.
- A row for the name as written: " ann pals" with the name " Ann". The
  phone matches the name as written, in any case; this app's reader
  matches case, so the row turns on that clause alone.
- The test that chained `readerNames` into `groupLabelHolds` goes. The
  "the fallback name" row guards the same thing.

Tests: each label row fails on its own control (the name as written
left out, the trimmed name left out, JavaScript's trim, the trimmed
name's first word left out, a split on spaces only).

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
"C++" is an ordinary name. The row checks that `groupLabelHolds` escapes
a name before it builds a pattern from it: without the escape, building
the pattern throws.

Tests: the row passes with the escape and is the only failure without
it (1 of 107).

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent

⚠️ Needs a desktop and mobile check before merge
Client contract: one literal @label in the message body with one p tag per recipient; check desktop send/receive and mobile rendering/notification, including verified-name collisions, against the same isolated relay.

Verdict: COMMENT — recommend request changes. Reviewed 38c627a7b2e41cebd41309fc1ee4809bb9af7ab1..3539c27397b2d7fa75ddd563516e6338ec8f9f78 (clean exact head). High risk: notification intent and cross-client presentation. The original verified-alias omission is addressed for names loaded at pick/send, and the group chip retains a member-aware accessible name and per-recipient removal. One reproducible presentation defect remains:

  • P2 — alias can change during asynchronous send admission. MessageComposer.tsx:3191–94 validates a group against the current profile snapshot, then awaits membership/agent preparation. At lines 3403–22, the revision check covers draft state, not profiles, and serializes the already-captured group. In a mounted-composer regression probe at this head, membership refresh was held, a tagged member acquired verified display name Mary, then admission resumed: the actual send still published @Mary crew hi. Desktop's signed-name parser then binds @Mary to that person; mobile can bind first-name aliases too. The group is no longer seen as its whole label, contrary to docs/plugin-architecture.md:3491–98. This is a misleading person link, not evidence of lost p tags. Author action: revalidate the label after awaits, immediately before publication; split to individual mentions or refuse with the authored draft intact when it no longer holds, with a deterministic deferred-admission/verified-alias regression.
  • Regression coverage for the original verified-alias fix: the final head retains readerNames helper coverage but removed the previous mounted-composer picked/saved-draft tests from e092a1062 that checked wire text, exact recipients, and receiver profileMentionParts. The current composer case at MessageComposer.test.tsx:18808–32 covers a self-set name instead. Author action: restore one production-path verified-alias pick and restored-draft send regression asserting fallback body, exact p set, and received rendering; this can be part of the race fix's tests.

Validation: exact-head git diff --check passed; isolated Blox affected full Vitest files (MessageComposer, composer-document, mention-draft, relay mentions) passed 877/877 tests in 109.93s on a restored clean tree. The temporary causal regression deliberately failed its behavioral assertion (1 failure, 724 filtered) when the profile changed during deferred membership. An attempted 1,133-file full Vitest run was stopped after ~4 minutes (exit 130), not a local package pass. Hosted exact-head checks: 73 success, Windows native validation skipped. No native desktop/mobile journey or real relay notification delivery was exercised. Local worktree bootstrap could not complete because lefthook 2.1.14 was below the required 2.2.2. Send-gate and relay-window implementations are identical to the merged base; their presence in the old-head delta is not charged to this PR.

Verification owner: author for the code and production-path regressions above; reviewer/tooling for desktop/iOS send/receive, verified-alias display, unique notification eligibility and recipient tags on the same isolated relay. FOUNDATION-file authorization is a separate maintainer gate. Residual risk: receiver-only names that the sender has not loaded and native/mobile behavior remain unverified. No approval is carried from the earlier reviewed heads.

Recommendation: request changes.

LordMelkor and others added 2 commits November 22, 2026 18:05
The composer's send tests for a group whose label starts with a
member's verified name went away when that table moved to
readerNames. Two rows come back, picked and saved in a draft. Each
checks the sent text, the exact p set and how a receiver who knows
the member by the verified name draws the mentions.

With verified names left out of the names the composer binds labels
against, when a group is picked and when it is sent, no other test in
the 69 test files related to the composer fails (2273 tests), so these
rows own that wiring.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
The send binds each group label to the members' names when it takes
the draft, then waits: a Solo chat's members, the old-agent prompt,
bringing agents in, adding people, link sharing, and in a detached
window the upload. A member who took a name during a wait that the
label starts with, such as the verified name "Mary" under the label
"Mary crew", still had "@Mary crew hi" published, and readers linked
"@Mary" to that member.

Now the labels are bound again after the last wait before the text is
handed to the sender: after link sharing, and in a detached window after
the upload. If the answer differs, the send stops with "A member's name
changed while sending. Send again." The draft and its attachments stay,
Send is free, and the next Send binds the labels afresh: a label a new
name broke goes out as its members. A label that was broken when Send
was pressed and holds again after a wait also stops the send once. What
the waits already did, such as agents brought in, people added and links
shared, stays done.

Once the text is handed to the sender the message is committed. A
main-window upload or a send gate's hold, for example, carries it, and a
name that changes then reads as any rename after sending does.

Not caught: a verified name the profile store holds but has not yet
published to the composer, the sender's own name change still
waiting to be sent, a DM's member list that loads during the wait,
and a name this device has not loaded. The first send of a new
conversation from New message or a new Solo chat is not checked
again either: those screens take the text before their own waits.
And a new DM to one agent named "Mary" with the group "Mary crew"
publishes "@Mary crew" with no wait and no rename, because that
composer does not know who the DM is with.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor

Copy link
Copy Markdown
Contributor Author

🤖 Reply to jedwards27's review of 3539c27397 (16:04Z Nov 22). The new head is 39b2ddefa2: two commits on the reviewed head.

Finding 1: a name that changes during the send's waits. Fixed for every wait in the composer's own send before the text is handed over, not only prepareRecipients.

  • The send binds the group labels again after its last wait before the text is handed to the sender. That is after the link-sharing block, which follows the membership refresh, the old-agent prompt, bringing agents in and adding people. A detached window with attachments binds once more after its upload.
  • If the result differs from what the send captured, nothing is published. The composer shows "A member's name changed while sending. Send again.", keeps the draft and its attachments, and frees Send. The next Send binds the labels afresh: a label a new name broke goes out as one mention per member. A label that was broken at Send and holds again after a wait also stops once.
  • Size: MessageComposer.tsx +9 −4. This fix touches no FOUNDATION file. sentDraft, groupLabelHolds and readerNames are unchanged.
  • Tests: two rows, one per path. Each holds the last wait of its path (link sharing; the detached upload) while a tagged member gains the verified name Mary. Both fail on 3539c27397's production. Each fails alone when its own recheck is removed. With the first recheck moved above the link-sharing block, its row fails.

Finding 2: the verified-name composer rows. Both are back (picked; saved in a draft). Each checks the sent text, the exact p set, and profileMentionParts for a reader who knows the member by the verified name. With verified names taken out of the names the composer binds labels against (at the pick and at send), both rows fail, and at 3539c27397 no test in the 69 test files related to the composer failed under that change.

What this does not cover:

  • Once the text is handed to the sender (for example a main-window background upload or a send gate's hold), a name change is a rename after sending, as for any mention.
  • A name the composer cannot see yet: a verified name the profile store holds but has not published, the sender's own rename still waiting to be sent, a DM member list that loads during the wait, a name this device has not loaded.
  • The first message from New Message and from a new Solo chat. Those screens take the text before their own waits and do not bind again. The same check there was sized at about 30 more production lines across three other files, and is left out of this PR.
  • What the waits already did, such as agents brought in, people added and links shared, stays done when the send stops.

Checks on this head's tree: pnpm check; the 69 test files related to the composer (2,277 tests); completion-work.spec.mjs on Chromium and WebKit. main currently fails the "Rust and tool integration" job on cargo-deny (RUSTSEC-2026-0592, url 2.5.8), so this head's CI run will show that failure until #4222 merges and CI runs again. This PR changes no Rust.

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent

⚠️ Needs a desktop and mobile check before merge
Client↔relay contract: one literal @label with multiple existing p recipient tags; verify received rendering, thread/notification and alias collision on Desktop and Mobile against the same relay.

Verdict: COMMENT — recommend request changes to Jude. Not approval.
Reviewed: base 38c627a7b2e41cebd41309fc1ee4809bb9af7ab1, exact head 39b2ddefa2ccde6aa3e96cd014592445c35156f8 (clean worktrees; three-dot diff).
Risk: high — deferred publication of user-visible mention text can outlive its verified-name binding.

Blocking P2 — ordinary full-session attachment upload publishes a stale group label. src/features/messages/MessageComposer.tsx:3464,3682–3704 checks the label before the upload; the sendInBackground publication callback does not recheck after upload completes. A controlled mounted-composer probe held upload, changed a recipient’s verified name to the label’s first word, then released it: @Mary crew hi was sent, the draft/file cleared, and no name-change error appeared. The current reader binds @Mary to that person and leaves crew hi as text. This is misleading rendered identity; the signed p recipients remained the two originally selected members, not an observed extra notification.

Blocking P2 — queued Solo follow-up has the same error, including restart risk. MessageComposer.tsx:3464,3641–3665 validates before enqueue; src/features/solo/follow-up-queue.ts:512–561 releases after agent work; follow-up-message.ts:26–110 refreshes membership but publishes stored text without alias rebinding. A separate controlled mounted-composer probe held the send, changed MJ’s verified name to Mary, then resumed: messages.send received @Mary crew hi for MJ and Wes, not safe per-member names. follow-up-storage.ts:11–23 stores text and keys without group-label binding metadata, so a guard captured only in the original composer would not protect a restored queue. Held plugin outgoing messages and first-send flows also capture content across awaits; audit their publication boundaries, without treating untested paths as reproduced.

Author action: Protect every actual publication boundary: either retain enough binding metadata through queued/restarted sends to revalidate against current verified names, failing closed with a recoverable message, or canonicalize a deferred group into safe per-member mentions before handoff. Recheck after the full-session upload, with visible retry guidance and draft/attachment recovery. Add held-upload, held-queue and restart regressions asserting both sent text and p keys; inspect New Message/new Solo first-send awaits. Keep the existing detached-upload and link-sharing guards.

Validation: At the clean head, the targeted Desktop group-label test selection passed 21 tests and three focused Mobile mention-render/recipient widget tests passed 10 tests (separate client checkout). Both temporary production-seam probes above failed on the unsafe sent content and were removed; worktrees restored clean. Hosted CI has successful JavaScript, browser and flake lanes but CI required is red because Rust dependency policy rejects url 2.5.8 under RUSTSEC-2026-0592. Neither Cargo.lock nor deny.toml is in this PR’s three-dot diff; classify this as a base/dependency gate requiring repository-owner remediation, not evidence that the mention change caused it. An isolated Blox package run could not install because npm DNS returned EAI_AGAIN; no clean-head full package pass is claimed.

Manual/native evidence: none for an exact-artifact same-relay Desktop/Mobile run; native doctor lacked macOS Accessibility/Screen Recording permission and the isolated relay was unavailable. Verification owner: author for the two code fixes and regressions; repository/CI owner for the dependency-policy gate; reviewer/tooling for the same-relay Desktop/Mobile rendering, notification and thread check before merge. Package/widget tests do not satisfy that live-client gate.

LordMelkor and others added 2 commits November 22, 2026 19:31
The main-window upload now binds the labels again when the upload ends,
before its publish call. Where that call sends at once, nothing is
awaited after the check. A failure goes through the upload's own
recovery, which shows the line and returns the draft and the files, or
keeps them behind "Retry failed send recovery" when the person has typed
a new draft meanwhile.

The previous commit's message says a main-window upload carries the text
past the check. That is no longer so where the send goes out at once. A
send gate's hold and a Solo follow-up that takes the queue still do: a
top-level send in the person's own Solo chat with the "queue" setting
and at least one notified recipient, none of them a confirmed person in
the chat. With an attachment such a send always enters the queue and
waits there for a member refresh.

Tests: one row sends to a channel with a file, so the send goes out when
the upload ends. It holds the upload while a tagged member gains the
verified name "Mary", then lets it finish. Nothing is sent, the composer
shows "A member's name changed while sending. Send again.", the draft
and the file are back in it, and the next Send sends "@mj @wes hi" to
the two members. The row fails on the previous commit's production,
which is this commit with the new line removed, and is then the only
failure in the 69 test files related to the composer (2278 tests).

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Main at e5a9b4f deletes
docs/plugin-architecture.md (#4213), where this branch added a paragraph
on a mentions edit's `label`. The merge takes the deletion. The rule
stays in the comment on `label` in
src/features/conversation/contracts.ts.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor

Copy link
Copy Markdown
Contributor Author

🤖 Reply to jedwards27's review of 39b2ddefa2 (18:57Z Nov 22). The new head is e115bba538: two commits on the reviewed head, the fix and a merge of main. main removed docs/plugin-architecture.md (#4213), and the merge takes that deletion, so this PR no longer changes a doc; the label rule is in the type's comment in contracts.ts.

Finding 1: the main-window upload. Fixed for every upload whose send goes out when the upload ends. One kind of Solo send still waits after it; that is under Finding 2. My last reply called this path "after the handover". That was wrong: the step that publishes after the upload is still the composer's own code.

  • The send now binds the labels again when the upload finishes, before its publish call (MessageComposer.tsx, +1 line). The rule is: the send binds the labels again before each publish call it makes. There are three: a send with no attachments, a detached window's upload, and the main window's upload.
  • If the result differs, nothing is published. The upload's existing failure path shows "Message to … failed to send" with "A member's name changed while sending. Send again.", and puts the draft and the files back in the composer. If the person has typed a new draft in the meantime, that draft is kept and the failed send waits behind "Retry failed send recovery". The next Send binds afresh.
  • Test: one row holds the main-window upload while a tagged member gains the verified name Mary. It checks that nothing was sent, the line shown in the composer, the draft and the file back in the composer, and the text and p set of the next Send. With the new line removed, which is 39b2ddefa2's production, it is the only failure in the 69 test files related to the composer.

Finding 2: a Solo follow-up that takes the queue. Not changed in this PR.

  • Which sends take the queue (MessageComposer.tsx:3228-3232, :3590-3600): a top-level message in the person's own Solo chat, with the follow-up setting on "queue" (the default is "immediate"), that notifies at least one recipient, none of them a confirmed person in the chat. A person that a label tags from outside the chat is a reference, not a recipient, so a label with such a person still takes the queue. Among those sends, one with an attachment always enters the queue (follow-up-queue.ts:871-876), which refreshes the chat's members before it sends (follow-up-queue.ts:512, follow-up-message.ts:26-40), so the new check is not its last step.

  • The probe's result is also what a message that was already sent shows after the same rename. This app's reader binds the tagged people's current names each time it draws a message (profile-mentions.ts:47-52), for a group label as for any mention. A check before the queue publishes moves the last moment a rename is caught; the label can still stop holding afterwards.

  • A check in the queue's publish step, where the compaction check is, would not be enough. A queued message can be edited and is saved to disk. The check would compare the draft as it was first sent, and after a restart no composer is there to run it. A message it stopped would fail on every Send.

  • What would cover it is the review's first option: the queue stores each label's members and binds again at release, sending one name per member when the label no longer holds. That changes the stored queue format and follow-up-message.ts. It is not in this PR, and Known limits now says so.

  • The review's second option, one name per member when the message is queued, was sized against this head: 18 to 25 lines in the composer. It would also change a send that looks immediate (the attachment case above enters the queue even when nothing is waiting), and the longer text can pass the 16,000-character limit after the person has pressed Send. A clean version changes mention-draft.ts and follow-up-queue.ts as well.

Held plugin sends, New Message and a new Solo chat. Not changed. A send gate takes a frozen copy of the message before the composer sends it (heldBySendGate, MessageComposer.tsx:3604), and the plugin publishes it later through publishOutgoing, which sends that event "without repeating the composer's checks" (outgoing-message.ts). A check there needs the message's group labels in the OutgoingMessage that plugins store, and sending one name per member instead needs each label's members too. Either is a change to the plugin contract. The two first-send screens take the text before their own waits; the same check there was sized at about 30 production lines across three other files. Both are in Known limits.

For a person to decide: whether this is acceptable for the PR. Readers bind a label by current names, so a rename after sending, or while a message waits in a queue or a gate, can make a reader show one member's name as a mention inside the label. The p recipients do not change with it.

Checks on this head's tree: pnpm check; the 69 test files related to the composer (2278 tests); completion-work.spec.mjs on Chromium and WebKit. The desktop and mobile check against one relay is not done; no test in this PR covers mobile. The head includes main at e5a9b4f1fb, which has the url 2.5.9 fix for the cargo-deny failure (#4222); this PR changes no Rust.

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent

⚠️ Needs a desktop and mobile check before merge
Client↔relay contract: a group chip sends literal @label with the selected recipients’ existing p tags; verify Desktop/Mobile received rendering, thread and notification behavior on the same isolated relay.

Verdict: COMMENT — recommend request changes to Jude. This is not an approval.
Reviewed: base e5a9b4f1fbd1e0f6d9cddfa2bc52c8697d4e44a3, exact head e115bba538ddca433a41bd0aa079a1f05cfc386d (clean worktree; three-dot PR diff, 22 files). Risk: high — an unpublished group message can render as an individual person mention even though the signed p keys remain the selected group.

P2 remains — queued Solo follow-up publishes a label that no longer reads as itself. The composer checks the label before handing off frozen text and recipient keys (MessageComposer.tsx:3190–97,3464,3641–65). The queue releases it later, and follow-up-message.ts:26–119 refreshes membership but publishes stored text without checking current names. follow-up-storage.ts:16–27 persists no group binding for restart. At the preceding reviewed head, a mounted-composer held-queue probe selected @Mary crew for MJ and Wes, changed MJ’s verified name to Mary before release, and observed messages.send publish @Mary crew hi with both original keys; the receiving reader binds @Mary as a person and leaves crew hi as prose. Those queue/publication paths are unchanged at this head. This is misleading presentation, not evidence of an extra recipient or notification. A rename after publication is unavoidable; a rename while an unpublished message waits in a queue is not the same boundary. The issue’s plain-label reader contract is not met merely by listing this as a known limit.

Author action: preserve binding provenance through durable deferred sends and revalidate/rewrite at actual publication, with recoverable failure if it cannot be made safe; alternatively reject labeled-group sends on deferred routes before clearing the composer draft. Add a deterministic held-queue and restart regression asserting sent/rendered text and exact p keys. A composer-only closure guard cannot protect restored messages. Held plugin sends also retain frozen text through later publication (outgoing-message.ts:64–97); this is source-traced, not separately reproduced at this head. Audit that boundary without claiming it was exercised.

Fixed since 39b2ddef: the ordinary full-session attachment upload now checks labels after upload and before publish (MessageComposer.tsx:3700–04). Two independent reviewers mutation-checked the mounted-composer regression: it passes with the guard and fails on stale @Mary crew hi when only that line is removed. The checked-in case asserts no send, visible retry guidance, restored draft/file, then safe @MJ @Wes hi with MJ+Wes keys. It does not assert the recovered attachment in the retry’s actual send argument; that coverage improvement is recommended, not a separately established runtime defect.

Validation: exact-head git diff --check passed. Focused mounted-composer runs passed 1/1 and 2/2 selected tests respectively, with 728/727 filtered; the mutation fails behaviorally and the clean head is restored. The author reports pnpm check, 69 related test files (2,278 tests), and Chromium/WebKit completion journey passing; those author runs are not independent full-package evidence. At review preparation, hosted CI was still in progress (51 successful, 21 pending, Windows native skipped); the url 2.5.9 security-advisory fix is in merged base, not this PR’s Rust diff. No independent full package pass or native same-relay Desktop/Mobile delivery journey is claimed.

Verification owner: author for the deferred-send code/regression or explicit product-owner exception; CI/repository owner for hosted required checks; reviewer/tooling for same-relay Desktop/Mobile received rendering, thread and notification behavior before merge. The FOUNDATION contracts.ts edit still requires human maintainer guidance. These evidence/authorization gates are separate from the P2 code finding. A new head needs a fresh review.

With the follow-up setting on "queue", a top-level send in the person's
own Solo chat now sends every group as one name per member, so no group
chip enters the follow-up queue or its storage. An edit of a queued
message can add `@label` as plain text, as typing it does; it adds no
recipient.

It also applies to a send in that context that goes out at once: the
route is known only after the member refresh, and the text is bound
before it.

Commit `51f6cbda79`'s message says a Solo follow-up that takes the queue
carries the text past the check. That is no longer so. A send gate's
hold still does.

Tests: a `sentDraft` row keeps a group whose label holds as one chip,
and a second row splits it when every group is to be split. In the
person's own Solo chat with the "queue" setting, a send to two agents
tagged as the group "Mary crew" waits in the queue while one of them is
working; one of them then gains the verified name "Mary", and when the
work ends the queue sends "@mj @wes hi" to exactly those two keys.
Storage holds that text and those two keys, and after a reload the
saved row sends the same text to the same keys. A send there that goes
out at once, because a person in the chat is tagged, also sends the
members' names. A new Solo chat's first send keeps the group as one
chip. The upload row from commit `51f6cbda79` now also checks that the
next Send carries the uploaded file.

Controls, on the files related to the two changed sources (5,864 tests
in 132 files, one skipped), with the tests as committed except two
comment lines in a helper, since removed: with both production changes
taken out, 4 fail: the held queue, the restart, the send that goes out
at once and the row that splits every group; with every group split at
every send, 11 fail, the new Solo chat's first send and ten existing
one-chip tests; without the `!submission` check, only the new Solo
chat's first send fails. With the main window's upload callback
publishing no files, the upload row fails at its new file check (12 of
733 in `MessageComposer.test.tsx` fail; the other 11 are existing upload
tests).

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor

Copy link
Copy Markdown
Contributor Author

🤖 Reply to the review at e115bba538 (jedwards27). The head is now 24177c5ebf.

The queued Solo follow-up is fixed in code, not listed as a limit. With the follow-up setting on "queue" (the default is "immediate"), a top-level send in the person's own Solo chat now sends every group as one name per member. No group chip enters the follow-up queue or its storage, so a release or a restart has no label to check again. The stored format is unchanged.

  • What it costs: in that context a send that goes out at once is split too. The route is known only after the member refresh, and the text is bound before it. A new Solo chat's first send is not in that context and keeps the chip.
  • Why a split and not a refusal, or a re-check and split at release: a refusal blocks the send, so the person has to pick each member one by one or turn queuing off; re-checking and splitting at release needs the group's members in the stored row and a failure path for a split that passes 16,000 characters after the draft is gone.
  • One writer the split does not pass through: an edit of a queued message. A group picked there goes in as the plain text @label, as typing it does, and adds no recipient.

Tests (MessageComposer.test.tsx, mention-draft.test.ts). With the change removed, exactly these four fail among the 5,864 tests in the 132 related files: the held queue, the restart, the send that goes out at once, and the unit row that splits every group. Without the new-chat exclusion, only the new chat's first send fails.

  • a held queue: Mary crew for MJ and Wes waits, MJ's verified name becomes Mary, the release sends the text @MJ @Wes hi with exactly MJ's and Wes's p keys;
  • a restart: what storage holds, and after a reload the sent text and the exact p keys;
  • these assert the sent text and keys, not a drawn message: the sent text has no group label left to bind;
  • the cost above (a send that goes out at once), and a new Solo chat's first send keeping its chip;
  • the recovered attachment is now asserted in the retry's own send argument; with the upload callback publishing no files, that row fails at the new check.

Held plugin sends: audited by reading the code, not run.

  • No plugin bundled with the app registers a send gate.
  • A gate is asked once, with the exact message the host would publish. When it keeps the message, the plugin owns the copy and the time of release, and publishOutgoing sends the held text as it is. A plugin can keep a message with no time limit and across restarts.
  • So this limit stands: a rename while a plugin holds a message can leave a label that shows one member's name as a mention. The recipients are the same.
  • Why the queue's fix does not carry over: the host does not know whether a gate will keep a message until it has handed it over. A split before every gate would take the chip out of ordinary channel sends whenever a gate plugin is on. Re-checking and splitting at release needs the group's members on the held message, which is a new optional field in the plugin contract plus a rewrite and a failure path in publishOutgoing.
  • It is in Known limits. If a maintainer wants the contract field, we add it to this PR.

Checks on 24177c5ebf's tree: pnpm check; the 132 test files related to the two changed sources (5,864 tests, one skipped); completion-work.spec.mjs on Chromium and WebKit, 10 of 10 each. The PR is +539/−107 production and +1658/−19 tests over main.

Still for a person: the desktop and phone try against one relay; the yes on the one contracts.ts field; and the held plugin send: accept it as a stated limit, or ask for the contract field.

@LordMelkor
LordMelkor requested a review from a team November 23, 2026 15:01
LordMelkor and others added 4 commits November 23, 2026 12:26
Main at 4820bfd includes #3854, which
changes who a Solo message alone with agents is for: a draft that opens
with a tag is for the agents it tags, and a tag further in joins the
toolbar's agents (`soloAudience` in src/features/solo/recipients.ts).

MessageComposer.tsx conflicted in two places. Beside `sendRecipients`,
the merge keeps this branch's `boundNames` and main's comment. At the
send, it keeps main's `fromPill` test and this branch's `attempt`
controller; `queueable` stays where this branch moved it, before the
draft is bound, since main did not change it. A send's group names are
bound against `recipientsNow`, which is now main's audience, so a group
chip is checked against the toolbar's agents too when they go along.

Every file this branch changes carries the same added and removed lines
against main as it did against e5a9b4f.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…gent

Since #3854, a Solo draft alone with agents goes to the toolbar's agents
and its tags, unless a tag opens the text. A group chip gives each member
the chip's place in the text, so a chip further in joins the toolbar's
agents, as a single tag does.

The row: in a Solo chat of three agents with Ada in the toolbar, a saved
draft "Plan this, then ask @crew" (Crew: Bea and Cam) shows "Sending to
Ada, Bea, Cam", keeps the chip, and sends that text to Ada, Bea and Cam.

Control: with group members put at the text's start where
`sendRecipients` asks who the draft is for, this row fails, and no other
of the 2,377 tests in the files related to MessageComposer.tsx
and recipients.ts.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
A group chip tags each member at the chip's place in the text. When its
first member is someone outside the chat, which only references them, and
another member is one of the chat's agents, `soloAudience` took the first
member as the opening tag, saw a reference, and the send added the
toolbar's agents. The composer leaves references out before it asks, so
it showed the group's agent alone. `soloAudience` now opens the draft
when any recipient at the earliest place is named. Single tags never
share a place, so their result is unchanged.

Tests: a row in the `soloAudience` table (a reference and Bea, both at
the start, open the draft) and a composer row (a Solo chat with Ada in
the toolbar; "@crew hi", where Crew is Cy, outside the chat, then Bea: it
shows "Sending to Bea" and sends to Bea alone). Without the fix both
fail: the table gives `opensWithTag: false`, and the send goes to
Ada and Bea.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Main at 47fa0d6 includes #4156, which
ranks typed emoji suggestions by picker usage. A completion item from a
bundled provider can carry `onSelect`, which runs only when its edit is
accepted, and `insertText` returns "typed" when only the typed key
landed.

The merge has no textual conflicts. A group chip goes in as a
recipient, and `insertText` drops the typed key for a recipient, so the
group path still returns only true or false. `completionResult` keeps
this branch's group `label` on the edit and main's `onSelect` on the
item.

The group chip tests in EditableInput.test.tsx kept `insertText`'s
result in a variable typed `boolean`, which no longer type-checks. The
merge types it as `boolean | "typed"`, so a group chip that returned
"typed" would fail their `toBe(true)` and `toBe(false)`. Apart from that
line, every file this branch changes carries the same added and removed
lines against main as it did against 4820bfd.

Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>

This branch has not been deployed

No deployments
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.

3 participants