Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3c3191c
feat(composer): let completion providers add rows beside the caret owner
LordMelkor Nov 17, 2026
4ccb32d
test(completions): a supplement removed mid-menu; docs on default and…
LordMelkor Nov 17, 2026
4f31f77
test(completions): a late supplement with a lower order moves only an…
LordMelkor Nov 17, 2026
4e10835
feat(composer): one chip for several recipients, sent as @label
LordMelkor Nov 17, 2026
fe32d10
fix(composer): protect a group chip's label like a recipient's name
LordMelkor Nov 18, 2026
5d5400b
Merge branch 'main' into clod/completion-supplement
LordMelkor Nov 18, 2026
0b2c2a1
Merge branch 'clod/completion-supplement' into clod/team-mentions-people
LordMelkor Nov 18, 2026
60e2cb4
fix(composer): escape group chip labels and keep them to one line
LordMelkor Nov 18, 2026
702e5a6
fix(composer): announce a group chip as a group; keep its label in So…
LordMelkor Nov 18, 2026
4c1a5a1
fix(composer): escape a group label picked while editing
LordMelkor Nov 18, 2026
36a7ec2
refactor(completions): shrink the supplement change
LordMelkor Nov 18, 2026
2c83894
refactor(composer): shrink the labelled-mentions change
LordMelkor Nov 18, 2026
c31e445
Merge branch 'clod/completion-supplement' into clod/team-mentions-people
LordMelkor Nov 18, 2026
b1b8ae3
refactor(composer): restore a group chip from the draft's recipients
LordMelkor Nov 18, 2026
90efaa2
Remove the prose comments this change adds
LordMelkor Nov 18, 2026
7024324
Infer the test sources' types and check them with satisfies
LordMelkor Nov 18, 2026
7c4d470
Merge branch 'clod/completion-supplement' into clod/team-mentions-people
LordMelkor Nov 18, 2026
3a633a9
Remove the prose comments this change adds
LordMelkor Nov 18, 2026
1ac9b9a
Infer the group helpers' return types
LordMelkor Nov 18, 2026
ba16073
Register supplements through their own method
LordMelkor Nov 19, 2026
01260a9
Merge branch 'clod/completion-supplement' into clod/team-mentions-people
LordMelkor Nov 19, 2026
8281a37
Merge main into clod/team-mentions-people
LordMelkor Nov 21, 2026
9ca9599
fix(composer): keep a group one chip only when its label reads as one
LordMelkor Nov 21, 2026
8912360
fix(composer): allow hyphens and combining marks in a group label
LordMelkor Nov 21, 2026
0c7f579
fix(composer): check a group label against mobile's reader, and again…
LordMelkor Nov 21, 2026
689a272
fix(composer): read a saved draft's groups only when it has one
LordMelkor Nov 21, 2026
e494b07
fix(composer): check a group label once, where the send takes its draft
LordMelkor Nov 21, 2026
b13c759
fix(composer): check a group label against a DM's agent partner
LordMelkor Nov 21, 2026
e092a10
fix(composer): check a group label against every name a reader links
LordMelkor Nov 21, 2026
bc5da8a
Merge main into clod/team-mentions-people
LordMelkor Nov 21, 2026
807beb3
refactor(composer): move three group rules into plain functions
LordMelkor Nov 22, 2026
a8ea5e3
fix(composer): check mobile's raw name, restore only chip labels
LordMelkor Nov 22, 2026
ee5ac15
test(composer): guard the raw name when a profile has no display name
LordMelkor Nov 22, 2026
764d877
fix(composer): read a name trimmed, and keep the key prefix name
LordMelkor Nov 22, 2026
b185c52
test(composer): one label row per name rule
LordMelkor Nov 22, 2026
3539c27
test(composer): a member name with regex characters
LordMelkor Nov 22, 2026
a7e4857
test(messages): restore the verified-name group label sends
LordMelkor Nov 22, 2026
39b2dde
fix(messages): stop a send whose group label a new name broke
LordMelkor Nov 22, 2026
51f6cbd
fix(messages): bind the group labels again after a main-window upload
LordMelkor Nov 22, 2026
e115bba
Merge main (e5a9b4f1fbd1) into clod/team-mentions-people
LordMelkor Nov 22, 2026
24177c5
fix(messages): send groups as names in a queued Solo follow-up
LordMelkor Nov 22, 2026
a18c87c
Merge main (4820bfd318d4) into clod/team-mentions-people
LordMelkor Nov 23, 2026
6c1dbde
test(messages): a group further in a Solo draft joins the toolbar's a…
LordMelkor Nov 23, 2026
e28da56
fix(solo): a group chip that opens a Solo draft opens it for its members
LordMelkor Nov 23, 2026
bad6c79
Merge main (47fa0d678203) into clod/team-mentions-people
LordMelkor Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/features/conversation/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,30 @@ it("copies and freezes batch recipients without allowing malformed or oversized
).toEqual([]);
}
});
it("keeps a group's label and drops one that is blank, not a string or not one plain line", () => {
const mentions = [{ pubkey: "a".repeat(64), name: "Carl" }];
const edit = (extra: object) =>
completionResult({
items: [
{
id: "crew",
label: "crew",
edit: { mentions, ...extra } as unknown as CompletionEdit,
},
],
}).items[0]?.edit;
expect(edit({ label: "crew" })).toEqual({ mentions, label: "crew" });
for (const label of [
"",
" ",
7,
null,
"crew\n\n# Title",
"\u202ecrew",
"x".repeat(257),
])
expect(edit({ label })).toBeUndefined();
});
it("keeps a host workspace edit and drops a provider's look-alike", () => {
const host = workspaceEdit("design");
const result = completionResult({
Expand Down
12 changes: 10 additions & 2 deletions src/features/conversation/completion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { MentionRecipient } from "../messages/mention-draft";
import { composerToken, type ComposerToken } from "../messages/composer-token";
import {
chipLabel,
composerToken,
type ComposerToken,
} from "../messages/composer-token";
import type { Contribution } from "../../plugins/contributions";
import { isBundledContribution } from "../../plugins/provenance";
import type {
Expand Down Expand Up @@ -149,7 +153,8 @@ export function completionResult(
!/^[0-9a-f]{64}$/.test(person.pubkey) ||
typeof person.name !== "string" ||
!person.name.trim(),
)
) ||
(edit.label !== undefined && !chipLabel(edit.label))
)
continue;
} else if ("mention" in edit) {
Expand Down Expand Up @@ -203,6 +208,9 @@ export function completionResult(
}),
),
),
...(edit.label !== undefined
? { label: edit.label }
: {}),
}
: "mention" in edit
? { mention: Object.freeze({ ...edit.mention }) }
Expand Down
6 changes: 6 additions & 0 deletions src/features/conversation/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ export type CompletionEdit =
}>
| Readonly<{
mentions: readonly Readonly<{ pubkey: string; name: string }>[];
/** One chip `@label` that notifies each of `mentions`, sent as the text
* `@label`. Kept only when it is letters, digits and spaces (a hyphen may
* sit between two letters or digits) and no name in the draft reads as a
* mention inside it; otherwise each of `mentions` is its own chip. In
* code only the text goes in, and a message edit adds no recipients. */
label?: string;
text?: never;
mention?: never;
pending?: never;
Expand Down
33 changes: 32 additions & 1 deletion src/features/direct-messages/NewMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SEARCH_DEBOUNCE_MS } from "../../shared/search-debounce";
import type { ConversationHostServices } from "../conversation/ConversationHost";
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { composerDOMFixture } from "../messages/composer-testing";
import { composerDOMFixture, typedDraft } from "../messages/composer-testing";

import {
afterEach,
Expand Down Expand Up @@ -39,6 +39,7 @@ import {
publicKeyLabels,
} from "../../shared/identity/public-key";
import type { RelaySession } from "../relay/session";
import { writeView } from "../../shared/view-state";
import { NewMessage } from "./NewMessage";
import { createAgentChoices } from "../agents/choices";
import type { LocalAgentsSnapshot } from "../agents/local";
Expand Down Expand Up @@ -1490,6 +1491,36 @@ it("locks during opening and delivery, waits for confirmation, and retries the s
expect(t.directMessages.delivered).toHaveBeenCalledTimes(2);
});

it("sends a saved group whose label no longer holds as its members", async () => {
const crew = [
{ pubkey: people[2]?.pubkey ?? "", name: "Mary Jane" },
{ pubkey: people[3]?.pubkey ?? "", name: "Wes" },
];
writeView(
scope,
"direct-message:new-draft",
typedDraft({
text: "@*ops* hi",
recipients: crew.map((person) => ({
...person,
start: 0,
end: 6,
label: "*ops*",
})),
}),
);
const t = setup();
t.mount();
await t.user.click(await screen.findByRole("option", { name: "Person 1" }));
await t.user.click(send());
await waitFor(() => expect(t.onStarted).toHaveBeenCalledOnce());
expect(t.messages.send).toHaveBeenCalledOnce();
expect(t.messages.send.mock.calls[0]?.slice(1, 3)).toEqual([
"@Mary Jane @Wes hi",
crew.map((person) => person.pubkey),
]);
});

it("preserves recipients and draft after opening fails and across remount", async () => {
const t = setup();
const view = t.mount();
Expand Down
10 changes: 8 additions & 2 deletions src/features/direct-messages/NewMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ import {
type AttachmentDraft,
} from "../messages/attachment-draft";
import { MessageComposer } from "../messages/MessageComposer";
import { mentionDraft, type MentionDraft } from "../messages/mention-draft";
import {
distinctRecipients,
mentionDraft,
type MentionDraft,
} from "../messages/mention-draft";
import { clearView, readView, writeView } from "../../shared/view-state";
import type { MessageIntent } from "../channel-navigation/routes";
import { Button } from "../../shared/design-system/ui/Button";
Expand Down Expand Up @@ -459,7 +463,9 @@ export function NewMessage({
session.messages.send(
id,
content,
draft.recipients.map((person) => person.pubkey),
distinctRecipients(draft.recipients).map(
(person) => person.pubkey,
),
uploaded,
{
key: recoveryKey,
Expand Down
116 changes: 113 additions & 3 deletions src/features/messages/EditableInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4840,7 +4840,7 @@ it("keeps retained recipients in place while adding and removing others", () =>
expect(h.input).toHaveValue("ask @Honey about X");
});

it("rejects adding a recipient when retained duplicate mentions fill the limit", () => {
it("counts a person mentioned many times once against the recipient limit", () => {
const first = { pubkey: "a".repeat(64), name: "Honey" };
const text = "@Honey ".repeat(32);
const h = mount({
Expand All @@ -4857,9 +4857,9 @@ it("rejects adding a recipient when retained duplicate mentions fill the limit",
first,
{ pubkey: "b".repeat(64), name: "Mary Jane" },
]),
).toBe(false),
).toBe(true),
);
expect(h.input).toHaveValue(text);
expect(h.input).toHaveValue(`@Mary Jane ${text}`);
});

it("toggles inline code, quote and code block with Slack's chords as well as Buzz's", async () => {
Expand Down Expand Up @@ -5025,3 +5025,113 @@ describe("quoting timeline content", () => {
expect(h.markdown()).toBe("keep");
});
});

describe("group chip", () => {
const ann = { pubkey: "1".repeat(64), name: "Ann" };
const bo = { pubkey: "2".repeat(64), name: "Bo" };
const crew = { label: "crew", members: [ann, bo] };
const on = (start: number, ...people: (typeof ann)[]) =>
people.map((person) => ({
...person,
label: "crew",
start,
end: start + "@crew".length,
}));
const add = (h: ReturnType<typeof mount>, group = crew) => {
let result: boolean | "typed" = false;
act(() => {
result = h.input.insertText("", group);
});
return result;
};

it("inserts one chip, sent as `@label`, whose span names every member", () => {
const h = mount();
expect(add(h)).toBe(true);
expect(h.markdown()).toBe("@crew ");
expect(h.input.querySelectorAll("[data-mention]")).toHaveLength(1);
expect(h.draft().recipients).toEqual(on(0, ann, bo));
});

it("is only its text in a code block", () => {
const h = mount();
act(() => h.input.toggleFormat("code_block"));
expect(add(h)).toBe(true);
expect(h.input).toHaveValue("@crew ");
expect(h.draft().recipients).toEqual([]);
});

it("keeps its members through edits and restores, and is text without them", async () => {
const h = mount();
add(h);
await h.user.keyboard("hi");
expect(h.markdown()).toBe("@crew hi");
expect(h.draft().recipients).toEqual(on(0, ann, bo));
const { text, recipients } = h.draft();
for (const saved of [h.draft(), mentionDraft({ text, recipients })]) {
const restored = mount(saved);
expect(restored.draft().recipients).toEqual(on(0, ann, bo));
expect(restored.markdown()).toBe("@crew hi");
expect(restored.input.querySelectorAll("[data-mention]")).toHaveLength(1);
act(() => restored.input.replaceRecipients([]));
expect(restored.draft().recipients).toEqual([]);
expect(restored.markdown()).toBe("@crew hi");
expect(restored.input.querySelector("[data-mention]")).toBeNull();
}
});

it("drops a removed member, and is text after the last", () => {
const h = mount();
add(h);
act(() => h.input.removeRecipient(ann.pubkey));
expect(h.draft().recipients).toEqual(on(0, bo));
act(() => h.input.removeRecipient(bo.pubkey));
expect(h.draft().recipients).toEqual([]);
expect(h.markdown()).toBe("@crew ");
expect(h.input.querySelector("[data-mention]")).toBeNull();
});

it("keeps the requested members when recipients are replaced", () => {
const h = mount();
add(h);
act(() => expect(h.input.replaceRecipients([bo])).toBe(true));
expect(h.draft().recipients).toEqual(on(0, bo));
act(() => expect(h.input.replaceRecipients([ann])).toBe(true));
expect(h.draft().recipients).toEqual([{ ...ann, start: 0, end: 4 }]);
expect(h.markdown()).toBe("@Ann @crew ");
});

it("keeps its members inside a new link, as a person's chip does", () => {
const url = "https://example.com/notes";
const h = mount("Check the ");
add(h);
act(() => h.input.insertText("notes"));
act(() => h.input.setSelectionRange(10, 21));
paste(h.input, url);
expect(h.markdown()).toBe(`Check the [@crew notes](${url})`);
expect(h.draft().recipients).toEqual(on(10, ann, bo));
});

it("notifies no one once a letter joins its label", async () => {
const h = mount();
add(h);
act(() => h.input.setSelectionRange(5, 6));
await h.user.keyboard("s");
expect(h.markdown()).toBe("@crews");
expect(h.draft().recipients).toEqual([]);
});

it("counts distinct people against the 32-recipient cap", () => {
const people = Array.from({ length: 32 }, (_, i) => ({
pubkey: i.toString(16).padStart(64, "0"),
name: `P${i}`,
}));
const h = mount();
expect(add(h, { label: "crew", members: people })).toBe(true);
act(() => expect(h.input.insertText("", people[0])).toBe(true));
expect(add(h, { label: "crew", members: [people[1] ?? ann] })).toBe(true);
act(() => expect(h.input.insertText("", [ann])).toBe(false));
expect(add(h, { label: "crew", members: [ann] })).toBe(false);
expect(new Set(h.draft().recipients.map((r) => r.pubkey)).size).toBe(32);
});
});
Loading
Loading