Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): keep reply mentions and sent content visible (#976)

Gener0e546f81dc83
diff --git a/src/web/src/app/c/me/[dmId]/page.dismissal.dom.test.ts b/src/web/src/app/c/me/[dmId]/page.dismissal.dom.test.ts
index a2546a8f9..d1822ead1 100644
--- a/src/web/src/app/c/me/[dmId]/page.dismissal.dom.test.ts
+++ b/src/web/src/app/c/me/[dmId]/page.dismissal.dom.test.ts
@@ -165,7 +165,6 @@ vi.mock("@/hooks/community/use-notification-settings", () => ({
useNotificationSettings: () => ({ channel: {} }),
}))
vi.mock("@/lib/api/client", () => ({ toastApiError: vi.fn() }))
-vi.mock("@/lib/community/reply-content", () => ({ displayReplyContent: () => "" }))
vi.mock("@/lib/community-db/projections", async (importOriginal) => ({ ...await importOriginal<typeof import("@/lib/community-db/projections")>(),
useCanonicalProfilesByUserId: () => new Map(),
}))
diff --git a/src/web/src/components/community/channels/dm-view.tsx b/src/web/src/components/community/channels/dm-view.tsx
index 91b2ccaf9..350dadb5d 100644
--- a/src/web/src/components/community/channels/dm-view.tsx
+++ b/src/web/src/components/community/channels/dm-view.tsx
@@ -56,7 +56,6 @@ import { notifLevelDisplay, type NotifLevel } from "@alook/shared"
import { useNotificationSettings } from "@/hooks/community/use-notification-settings"
import { useSetChannelNotif } from "@/hooks/community/mutations"
import { toastApiError } from "@/lib/api/client"
-import { displayReplyContent } from "@/lib/community/reply-content"
import {
useCanonicalProfilesByUserId,
} from "@/lib/community-db/projections"
@@ -353,14 +352,15 @@ export function DmView({ dmId }: { dmId: string }) {
if (m) {
setReplyTo({
id: m.id,
+ ...(m.authorId ? { authorId: m.authorId } : {}),
authorName: m.authorName ?? "",
- text: displayReplyContent(m.content ?? "", m.replyTo),
+ text: m.content ?? "",
})
}
},
onCopy: (id: string) => {
const m = messages.find((x) => x.id === id)
- const content = m ? displayReplyContent(m.content ?? "", m.replyTo) : ""
+ const content = m ? (m.content ?? "") : ""
if (content) { navigator.clipboard?.writeText(content); toast("Copied to clipboard") }
},
// A DM is a channel (type='dm'), so its id IS the mark route's channelId.
diff --git a/src/web/src/components/community/messages/composer-facade.contract.test.ts b/src/web/src/components/community/messages/composer-facade.contract.test.ts
index 8fc1a796a..b5f75b470 100644
--- a/src/web/src/components/community/messages/composer-facade.contract.test.ts
+++ b/src/web/src/components/community/messages/composer-facade.contract.test.ts
@@ -17,6 +17,7 @@ describe("Composer public facade", () => {
expectTypeOf<ComponentRef<typeof Composer>>().toEqualTypeOf<ComposerHandle>()
expectTypeOf<ComposerMention>().toEqualTypeOf<{ id: string; label: string }>()
expectTypeOf<NonNullable<ComposerProps["replyingTo"]>>().toEqualTypeOf<{
+ authorId?: string
authorName: string
text: string
}>()
diff --git a/src/web/src/components/community/messages/composer-suggestion-focus.dom.test.tsx b/src/web/src/components/community/messages/composer-suggestion-focus.dom.test.tsx
index b9f0c3244..c9b4db704 100644
--- a/src/web/src/components/community/messages/composer-suggestion-focus.dom.test.tsx
+++ b/src/web/src/components/community/messages/composer-suggestion-focus.dom.test.tsx
@@ -234,7 +234,7 @@ describe("composer suggestion focus with installed TipTap", () => {
await act(async () => { fireEvent.mouseDown(screen.getByTestId(rowId)) })
const nodeType = trigger === "@" ? "mention" : "channelRef"
expect(editor.getJSON().content?.[0].content?.filter((node) => node.type === nodeType)).toEqual([
- expect.objectContaining({ attrs: expect.objectContaining({ id: trigger === "@" ? ada.id : general.id }) }),
+ expect.objectContaining({ attrs: expect.objectContaining({ id: trigger === "@" ? ada.userId : general.id }) }),
])
expect(screen.queryByTestId(rowId)).toBeNull()
expect(readComposerDraft("viewer:autofocus-boundary")).toEqual(editor.getJSON())
@@ -267,7 +267,7 @@ describe("composer suggestion focus with installed TipTap", () => {
await act(async () => { fireEvent.mouseDown(row) })
expect(editor.isFocused).toBe(true)
expect(editor.getJSON().content?.[0].content?.filter((node) => node.type === "mention")).toEqual([
- expect.objectContaining({ attrs: expect.objectContaining({ id: ada.id, label: "Ada#0001" }) }),
+ expect.objectContaining({ attrs: expect.objectContaining({ id: ada.userId, label: "Ada#0001" }) }),
])
expect(probeRef.current!.mentionPopup.command).toBeNull()
expect(readComposerDraft("viewer:clicked")).toEqual(editor.getJSON())
diff --git a/src/web/src/components/community/messages/composer-types.ts b/src/web/src/components/community/messages/composer-types.ts
index f1b645e13..700f7ca48 100644
--- a/src/web/src/components/community/messages/composer-types.ts
+++ b/src/web/src/components/community/messages/composer-types.ts
@@ -7,6 +7,7 @@ import type { Member } from "@/lib/community/models/people"
type ComposerMode = "chat" | "forumThreadBody"
export type ComposerReplyTarget = {
+ authorId?: string
authorName: string
text: string
}
diff --git a/src/web/src/components/community/messages/message-channel-controller-actions.test.ts b/src/web/src/components/community/messages/message-channel-controller-actions.test.ts
index b050c37bd..8c2d4c792 100644
--- a/src/web/src/components/community/messages/message-channel-controller-actions.test.ts
+++ b/src/web/src/components/community/messages/message-channel-controller-actions.test.ts
@@ -109,7 +109,7 @@ describe("createMessageActions", () => {
it("routes reply, reactions, marks, previews, retry, and dismiss exactly", async () => {
const harness = setup()
harness.actions.onReply("m1")
- expect(harness.setReplyTo).toHaveBeenCalledWith({ id: "m1", authorName: "Viewer", text: "hello" })
+ expect(harness.setReplyTo).toHaveBeenCalledWith({ id: "m1", authorId: "viewer_1", authorName: "Viewer", text: "hello" })
harness.actions.onToggleReaction("m1", "πŸ‘")
harness.actions.onReact("m1", "πŸ”₯")
expect(harness.toggleReactionApi).toHaveBeenNthCalledWith(1, {
@@ -345,7 +345,7 @@ describe("createMessageActions", () => {
})
})
- it("uses projected reply text for actions and restores one canonical prefix on edit", async () => {
+ it("uses the complete visible reply body for actions and keeps edits exact", async () => {
const harness = setup()
harness.messages.setState(() => [{
...harness.messages.get()[0],
@@ -356,24 +356,25 @@ describe("createMessageActions", () => {
harness.actions.onReply("m1")
expect(harness.setReplyTo).toHaveBeenCalledWith({
id: "m1",
+ authorId: "viewer_1",
authorName: "Viewer",
- text: "> quote\n\nbody",
+ text: "@Alice Smith\n> quote\n\nbody",
})
await harness.actions.onCopy("m1")
- expect(navigator.clipboard.writeText).toHaveBeenCalledWith("> quote\n\nbody")
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith("@Alice Smith\n> quote\n\nbody")
await harness.actions.onCreateThread("m1")
- expect(mocks.deriveThreadName).toHaveBeenCalledWith("> quote\n\nbody", "general")
+ expect(mocks.deriveThreadName).toHaveBeenCalledWith("@Alice Smith\n> quote\n\nbody", "general")
vi.stubGlobal("window", { prompt: vi.fn(() => "edited") })
harness.actions.onEdit("m1")
- expect(window.prompt).toHaveBeenCalledWith("Edit message", "> quote\n\nbody")
+ expect(window.prompt).toHaveBeenCalledWith("Edit message", "@Alice Smith\n> quote\n\nbody")
expect(harness.editMessage).toHaveBeenCalledWith({
serverId: "server_1",
channelId: "channel_1",
messageId: "m1",
- content: "@Alice Smith\nedited",
+ content: "edited",
assertActive: expect.any(Function),
}, expect.objectContaining({ onError: expect.any(Function) }))
})
diff --git a/src/web/src/components/community/messages/message-channel-controller-actions.ts b/src/web/src/components/community/messages/message-channel-controller-actions.ts
index 6712ac1b4..82028b079 100644
--- a/src/web/src/components/community/messages/message-channel-controller-actions.ts
+++ b/src/web/src/components/community/messages/message-channel-controller-actions.ts
@@ -4,7 +4,6 @@ import { toastApiError } from "@/lib/api/client"
import type { FileAttachment, ImagePreview, Msg } from "@/lib/community/models/message"
import type { CommunityRuntime } from "@/stores/community/runtime"
import { isAbortError } from "@/lib/errors"
-import { canonicalizeReplyContent, displayReplyContent } from "@/lib/community/reply-content"
import type {
MessageActions,
MessageUiHandlers,
@@ -109,8 +108,9 @@ export function createMessageActions({
if (message) {
setReplyTo({
id: message.id,
+ ...(message.authorId ? { authorId: message.authorId } : {}),
authorName: message.authorName ?? "",
- text: displayReplyContent(message.content ?? "", message.replyTo),
+ text: message.content ?? "",
})
}
},
@@ -139,7 +139,7 @@ export function createMessageActions({
original()
const message = getMessage(id)
const content = message
- ? displayReplyContent(message.content ?? "", message.replyTo)
+ ? (message.content ?? "")
: undefined
const name = deriveThreadName(content, context.channelName)
try {
@@ -155,7 +155,7 @@ export function createMessageActions({
original()
const message = getMessage(id)
if (!message) return
- const content = displayReplyContent(message.content ?? "", message.replyTo)
+ const content = message.content ?? ""
if (!content) return
if (!navigator.clipboard) return
try { await navigator.clipboard.writeText(content); original(); toast("Copied to clipboard") }
@@ -166,11 +166,11 @@ export function createMessageActions({
original()
const message = getMessage(id)
if (!message || message.authorId !== viewerUserId || message.seq === undefined) return
- const visibleContent = displayReplyContent(message.content ?? "", message.replyTo)
+ const visibleContent = message.content ?? ""
if (!visibleContent) return
const editedContent = window.prompt("Edit message", visibleContent)
if (!editedContent || editedContent === visibleContent) return
- const content = canonicalizeReplyContent(editedContent, message.replyTo)
+ const content = editedContent
original()
editMessage({ serverId, channelId, messageId: id, content, assertActive: original }, {
onError: (error) => toastApiError(error, "Failed to edit message", original),
diff --git a/src/web/src/components/community/messages/message-channel-controller-facade.contract.test.ts b/src/web/src/components/community/messages/message-channel-controller-facade.contract.test.ts
index dad0ac0cc..f083379a8 100644
--- a/src/web/src/components/community/messages/message-channel-controller-facade.contract.test.ts
+++ b/src/web/src/components/community/messages/message-channel-controller-facade.contract.test.ts
@@ -14,7 +14,7 @@ import type {
} from "@/lib/community/models/message"
import type { useChannelMessageFeed } from "@/hooks/community/use-channel-message-feed"
-type ExpectedReplyTarget = { id: string; authorName: string; text: string }
+type ExpectedReplyTarget = { id: string; authorId?: string; authorName: string; text: string }
type ExpectedContextTarget = {
serverId: string
channelId: string
diff --git a/src/web/src/components/community/messages/message-channel-controller-send.test.ts b/src/web/src/components/community/messages/message-channel-controller-send.test.ts
index e82ad593f..91816d363 100644
--- a/src/web/src/components/community/messages/message-channel-controller-send.test.ts
+++ b/src/web/src/components/community/messages/message-channel-controller-send.test.ts
@@ -102,7 +102,7 @@ describe("message channel send helpers", () => {
authorId: "viewer_1",
authorName: "Viewer",
authorAvatar: "V",
- content: "@Alice\nhello",
+ content: "hello",
createdAt: "2026-01-02T03:04:05.000Z",
replyTo: { id: "reply_1", authorName: "Alice", text: "prior" },
},
@@ -180,7 +180,7 @@ describe("message channel send helpers", () => {
expect(clearReply).toHaveBeenCalledOnce()
})
- it("stores the canonical author prefix for an attachment-only reply", () => {
+ it("keeps an attachment-only reply empty after the user removes the mention", () => {
const file = new File(["abc"], "only.txt", { type: "text/plain" })
mocks.accept.mockReturnValue(true)
@@ -198,7 +198,7 @@ describe("message channel send helpers", () => {
expect(mocks.accept).toHaveBeenCalledWith(scope, expect.objectContaining({
message: expect.objectContaining({
- content: "@Alice Smith\n",
+ content: "",
replyTo: { id: "reply_1", authorName: "Alice Smith", text: "prior" },
}),
}))
diff --git a/src/web/src/components/community/messages/message-channel-controller-state.dom.test.ts b/src/web/src/components/community/messages/message-channel-controller-state.dom.test.ts
index 1b4183c1c..9844e7f8e 100644
--- a/src/web/src/components/community/messages/message-channel-controller-state.dom.test.ts
+++ b/src/web/src/components/community/messages/message-channel-controller-state.dom.test.ts
@@ -519,7 +519,7 @@ describe("useMessageChannelController", () => {
})
it("handles same-channel and pending replies plus loaded/fallback seq jumps", () => {
- const pendingTarget = { id: "pending", authorName: "Pending", text: "reply" }
+ const pendingTarget = { id: "pending", authorId: "pending-author", authorName: "Pending", text: "reply" }
mocks.storeState.pendingReply = { channelId: "channel_1", target: pendingTarget }
let renderer: ReturnType<typeof rtlRender>
act(() => {
@@ -531,7 +531,7 @@ describe("useMessageChannelController", () => {
act(() => latest.setContextTarget({
serverId: "server_1", channelId: "channel_1", label: "general", seq: 1,
}))
- const localTarget = { id: "local", authorName: "Local", text: "same" }
+ const localTarget = { id: "local", authorId: "local-author", authorName: "Local", text: "same" }
act(() => latest.onSheetReply(localTarget))
expect(latest.replyTo).toEqual(localTarget)
expect(latest.contextTarget).toBeNull()
diff --git a/src/web/src/components/community/messages/message-context-sheet.navigation.dom.test.ts b/src/web/src/components/community/messages/message-context-sheet.navigation.dom.test.ts
index 46b0a3a5b..6468d2860 100644
--- a/src/web/src/components/community/messages/message-context-sheet.navigation.dom.test.ts
+++ b/src/web/src/components/community/messages/message-context-sheet.navigation.dom.test.ts
@@ -4,6 +4,7 @@ import { act } from "@/test/react-dom-harness"
import { renderCommunity as render } from "@/test/community-owner-harness"
import { createCommunityQueryOwner } from "@/test/community-query-owner"
import { beginCommunityProfileSeed } from "@/lib/community/profile-seed"
+import type { MessageInput } from "@/lib/community/models/message"
const mocks = vi.hoisted(() => ({
push: vi.fn(),
@@ -11,6 +12,7 @@ const mocks = vi.hoisted(() => ({
close: vi.fn(),
openThread: undefined as undefined | ((threadId: string) => void),
pin: undefined as undefined | ((messageId: string) => void),
+ reply: undefined as undefined | ((messageId: string) => void),
toggleReaction: undefined as undefined | ((messageId: string, emoji: string) => void),
addReaction: undefined as undefined | ((messageId: string, emoji: string) => void),
toggleReactionApi: vi.fn(),
@@ -21,7 +23,7 @@ const mocks = vi.hoisted(() => ({
toastApiError: vi.fn(),
apiFetch: vi.fn(),
noData: false,
- canonicalMessages: vi.fn<(_ids?: readonly string[]) => undefined>(() => undefined),
+ canonicalMessages: vi.fn<(_ids?: readonly string[]) => ReadonlyMap<string, MessageInput> | undefined>(() => undefined),
}))
vi.mock("next/navigation", () => ({
@@ -77,16 +79,19 @@ vi.mock("./message-row", () => ({
MessageRow: ({
onOpenThread,
onPinId,
+ onReplyId,
onToggleReactionId,
onReactId,
}: {
onOpenThread: (threadId: string) => void
onPinId?: (messageId: string) => void
+ onReplyId?: (messageId: string) => void
onToggleReactionId?: (messageId: string, emoji: string) => void
onReactId?: (messageId: string, emoji: string) => void
}) => {
mocks.openThread = onOpenThread
mocks.pin = onPinId
+ mocks.reply = onReplyId
mocks.toggleReaction = onToggleReactionId
mocks.addReaction = onReactId
return null
@@ -182,11 +187,28 @@ describe("MessageContextSheet thread navigation", () => {
vi.clearAllMocks()
mocks.openThread = undefined
mocks.pin = undefined
+ mocks.reply = undefined
+ mocks.canonicalMessages.mockReturnValue(undefined)
mocks.toggleReaction = undefined
mocks.addReaction = undefined
mocks.noData = false
})
+ it("carries the source author ID and complete visible body into a sheet reply", () => {
+ mocks.canonicalMessages.mockReturnValue(new Map([["message_1", {
+ id: "message_1", type: "chat", authorId: "author_1", authorName: "Author",
+ content: "@Author#1234 body", replyTo: { id: "prior", authorName: "Author", text: "old" },
+ }]]))
+ const onReply = vi.fn()
+ render(React.createElement(MessageContextSheet, {
+ open: true, onOpenChange: mocks.close, channelId: "parent_1", targetSeq: 1, onReply,
+ }))
+ act(() => mocks.reply?.("message_1"))
+ expect(onReply).toHaveBeenCalledExactlyOnceWith({
+ id: "message_1", authorId: "author_1", authorName: "Author", text: "@Author#1234 body",
+ })
+ })
+
it("selects only context window IDs and no canonical rows without query data", () => {
const view = render(React.createElement(MessageContextSheet, {
open: true, onOpenChange: mocks.close, channelId: "parent_1", targetSeq: 1,
diff --git a/src/web/src/components/community/messages/message-context-sheet.tsx b/src/web/src/components/community/messages/message-context-sheet.tsx
index 41787d34a..669a5f28c 100644
--- a/src/web/src/components/community/messages/message-context-sheet.tsx
+++ b/src/web/src/components/community/messages/message-context-sheet.tsx
@@ -10,7 +10,6 @@ import { deriveThreadName } from "@alook/shared"
import { CommunitySheet } from "@/components/community/shell/community-sheet"
import { MessageRow } from "./message-row"
import { MessageShareDialog } from "./message-share-dialog"
-import { displayReplyContent } from "@/lib/community/reply-content"
import { ChannelIcon } from "../channels/channel-icon"
import { Skeleton } from "@/components/ui/skeleton"
import { apiFetch, toastApiError } from "@/lib/api/client"
@@ -277,7 +276,7 @@ export function MessageContextSheet({
const onCopyId = useCallback((id: string) => {
const m = findMessage(id)
- const content = m ? displayReplyContent(m.content ?? "", m.replyTo) : ""
+ const content = m ? (m.content ?? "") : ""
if (content) {
navigator.clipboard?.writeText(content)
toast("Copied to clipboard")
@@ -290,8 +289,9 @@ export function MessageContextSheet({
if (!m) return
onReply({
id: m.id,
+ ...(m.authorId ? { authorId: m.authorId } : {}),
authorName: m.authorName ?? "",
- text: displayReplyContent(m.content ?? "", m.replyTo),
+ text: m.content ?? "",
})
}, [findMessage, onReply])
@@ -329,7 +329,7 @@ export function MessageContextSheet({
const serverId = routeParams?.serverId
if (!serverId) return
const m = findMessage(id)
- const content = m ? displayReplyContent(m.content ?? "", m.replyTo) : undefined
+ const content = m ? (m.content ?? "") : undefined
const name = deriveThreadName(content, "channel")
try {
await createThreadMut.mutateAsync({ serverId, channelId, messageId: id, name })
diff --git a/src/web/src/components/community/messages/message-share-dialog.dom.test.ts b/src/web/src/components/community/messages/message-share-dialog.dom.test.ts
index 18a2c6beb..298e28550 100644
--- a/src/web/src/components/community/messages/message-share-dialog.dom.test.ts
+++ b/src/web/src/components/community/messages/message-share-dialog.dom.test.ts
@@ -242,7 +242,7 @@ describe("MessageShareDialog session lifecycle", () => {
expect(preview.querySelector("[data-share-timestamp]")?.textContent).toBe(formatMessageTime(createdAt))
expect(preview.querySelector('[data-testid="message-share-reply-m1"]')?.textContent)
.toContain("Original body")
- expect(preview.querySelector("[data-mock-message-body]")?.textContent).toBe("**visible** body")
+ expect(preview.querySelector("[data-mock-message-body]")?.textContent).toBe("@Bob\n**visible** body")
expect(preview.querySelector('[data-testid="message-share-image-m1-0"]')).not.toBeNull()
expect(preview.textContent).not.toContain("notes.txt")
expect(preview.querySelector("[data-share-identity-id=u1]")).not.toBeNull()
@@ -355,7 +355,7 @@ describe("MessageShareDialog message projection", () => {
])
})
- it("keeps the reply header while sharing only projected message content", async () => {
+ it("keeps the reply header while sharing the full visible body", async () => {
const renderer = await renderReady(message({
content: "@Bob Smith\n**visible** body",
replyTo: {
@@ -366,7 +366,7 @@ describe("MessageShareDialog message projection", () => {
}))
expect(componentMocks.bodyProps).toHaveBeenCalledWith(expect.objectContaining({
- text: "**visible** body",
+ text: "@Bob Smith\n**visible** body",
}))
const reply = renderer.container.querySelector('[data-testid="message-share-reply-m1"]')!
expect([...reply.querySelectorAll("span")].map((span) => span.textContent)).toEqual([
@@ -375,14 +375,14 @@ describe("MessageShareDialog message projection", () => {
])
})
- it("omits a standalone body for an attachment-only canonical reply", async () => {
+ it("retains a visible mention-only body beside an attachment", async () => {
const renderer = await renderReady(message({
content: "@Bob\n",
replyTo: { id: "original", authorName: "Bob", text: "Original body" },
attachments: [{ kind: "image", name: "photo.png", url: "/photo.png" }],
}))
- expect(renderer.container.querySelectorAll("[data-mock-message-body]")).toHaveLength(0)
+ expect(renderer.container.querySelectorAll("[data-mock-message-body]")).toHaveLength(1)
expect(renderer.container.querySelector(`[data-testid="${tid.messageShareImage("m1", 0)}"]`))
.not.toBeNull()
})
diff --git a/src/web/src/components/community/messages/message-share-dialog.tsx b/src/web/src/components/community/messages/message-share-dialog.tsx
index 44b087bf0..846bf2cef 100644
--- a/src/web/src/components/community/messages/message-share-dialog.tsx
+++ b/src/web/src/components/community/messages/message-share-dialog.tsx
@@ -21,7 +21,6 @@ import { tid } from "@/lib/community/testids"
import { applyHighlightToRange, clearHighlights, hasHighlights } from "@/lib/community/highlight-range"
import { formatMessageTime } from "@/lib/community/format-time"
import type { RenderMsg } from "@/lib/community/models/message"
-import { displayReplyContent } from "@/lib/community/reply-content"
import { useCanonicalProfilesByUserId } from "@/lib/community-db/projections"
import { readCommunityProfile } from "@/lib/community/profile-read"
import { AnimatedAlookLogo } from "@/components/community/shell/animated-alook-logo"
@@ -315,7 +314,7 @@ export function MessageShareDialog({ m, open, onClose }: {
msg.replyTo.authorId,
)
: null
- const visibleContent = displayReplyContent(msg.content ?? "", msg.replyTo)
+ const visibleContent = msg.content ?? ""
return (
<div key={msg.id} className={msg.grouped ? "mt-0.5" : "mt-3 first:mt-0"}>
{msg.replyTo && (
diff --git a/src/web/src/components/community/messages/message.render.dom.test.ts b/src/web/src/components/community/messages/message.render.dom.test.ts
index c73f78117..a35fd39b1 100644
--- a/src/web/src/components/community/messages/message.render.dom.test.ts
+++ b/src/web/src/components/community/messages/message.render.dom.test.ts
@@ -514,8 +514,8 @@ describe("Message memo comparator", () => {
})
})
-describe("Message reply content projection", () => {
- it("keeps the reply header and renders only the projected Markdown body", () => {
+describe("Message visible reply body", () => {
+ it("keeps the reply header and renders the full visible Markdown body", () => {
let renderer: DomRenderer
act(() => {
renderer = render(makeTree({
@@ -528,7 +528,7 @@ describe("Message reply content projection", () => {
})
const body = renderer!.root.findByProps({ "data-community-message-body": true })
- expect(textContent(body)).not.toContain("@Bob Smith")
+ expect(textContent(body)).toContain("@Bob Smith")
expect(textContent(body)).toContain("visible")
expect(renderer!.root.findAllByType("button").some((button) => (
textContent(button).includes("@Bob Smith")
@@ -536,7 +536,7 @@ describe("Message reply content projection", () => {
))).toBe(true)
})
- it("keeps a different leading mention visible and hides prefix-only reply text", () => {
+ it("keeps both different leading mentions and prefix-only reply text shareable", () => {
let different: DomRenderer
act(() => {
different = render(makeTree({
@@ -553,7 +553,7 @@ describe("Message reply content projection", () => {
expect(messageCanShare(baseMsg({
content: "@Bob\n",
replyTo: { id: "prior", authorName: "Bob", text: "original" },
- }))).toBe(false)
+ }))).toBe(true)
})
})
diff --git a/src/web/src/components/community/messages/message.tsx b/src/web/src/components/community/messages/message.tsx
index 75adbcbdd..8e99b8967 100644
--- a/src/web/src/components/community/messages/message.tsx
+++ b/src/web/src/components/community/messages/message.tsx
@@ -32,7 +32,6 @@ import type { FileAttachment, ImagePreview, RenderMsg } from "@/lib/community/mo
import type { OpenProfile } from "@/components/community/social/profile-types"
import { attachmentImageFrameStyle } from "./attachment-layout"
import { AttachmentCard } from "./attachment-card"
-import { displayReplyContent } from "@/lib/community/reply-content"
import {
advanceMobileReplyGesture,
beginMobileReplyGesture,
@@ -58,7 +57,7 @@ export function messageCanShare(m: RenderMsg, compact?: boolean): boolean {
return !compact
&& !m.approval
&& (
- !!displayReplyContent(m.content ?? "", m.replyTo)
+ !!(m.content ?? "")
|| !!m.attachments?.some((attachment) => attachment.kind === "image")
)
}
@@ -229,7 +228,7 @@ function MessageImpl({
const replyAuthorName = m.replyTo?.authorId
? (replyAuthorProfile?.name ?? "Deleted user")
: (m.replyTo?.authorName ?? "Deleted user")
- const visibleContent = displayReplyContent(m.content ?? "", m.replyTo)
+ const visibleContent = m.content ?? ""
// keep the hover toolbar pinned open while its β‹― dropdown is open
const [toolbarOpen, setToolbarOpen] = useAtom(useCreateAtom(false))
// Right-click context-menu open state β€” tracked so the Mark/Unmark label's
diff --git a/src/web/src/components/community/messages/prepend-reply-mention.ts b/src/web/src/components/community/messages/prepend-reply-mention.ts
new file mode 100644
index 000000000..b71efe9f4
--- /dev/null
+++ b/src/web/src/components/community/messages/prepend-reply-mention.ts
@@ -0,0 +1,40 @@
+import type { Editor } from "@tiptap/react"
+import type { Node as ProseMirrorNode } from "@tiptap/pm/model"
+import { closeHistory } from "@tiptap/pm/history"
+import type { ComposerMention } from "./composer-types"
+
+export function prependReplyMention(
+ editor: Editor,
+ mention: ComposerMention,
+ identityIds: readonly string[] = [mention.id],
+ resolveUserId?: (id: string) => string | undefined,
+): void {
+ const { state } = editor
+ let existing: { node: ProseMirrorNode; position: number } | undefined
+ state.doc.descendants((node, position) => {
+ if (existing) return false
+ if (node.type.name !== "mention") return
+ const userId = resolveUserId?.(node.attrs.id)
+ const matches = userId !== undefined
+ ? userId === mention.id
+ : identityIds.includes(node.attrs.id) || node.attrs.label === mention.label
+ if (matches) {
+ existing = { node, position }
+ return false
+ }
+ })
+ if (existing?.position === 1 && state.doc.firstChild?.type.name === "paragraph") return
+
+ const transaction = closeHistory(state.tr)
+ const node = existing?.node ?? state.schema.nodes.mention.create(mention)
+ if (existing) transaction.delete(existing.position, existing.position + node.nodeSize)
+ const first = transaction.doc.firstChild
+ const separator = state.schema.text(" ")
+ if (first?.type.name === "paragraph") {
+ const needsSeparator = !first.firstChild?.isText || !/^\s/u.test(first.firstChild.text ?? "")
+ transaction.insert(1, needsSeparator ? [node, separator] : node)
+ } else {
+ transaction.insert(0, state.schema.nodes.paragraph.create(null, [node, separator]))
+ }
+ editor.view.dispatch(transaction)
+}
diff --git a/src/web/src/components/community/messages/reply-visible-mention.dom.test.ts b/src/web/src/components/community/messages/reply-visible-mention.dom.test.ts
new file mode 100644
index 000000000..c0830686e
--- /dev/null
+++ b/src/web/src/components/community/messages/reply-visible-mention.dom.test.ts
@@ -0,0 +1,239 @@
+import { createElement, forwardRef, createRef } from "react"
+import { Editor, EditorContent, type JSONContent } from "@tiptap/react"
+import { beforeEach, afterEach, describe, expect, it, vi } from "vitest"
+import { act } from "@/test/react-dom-harness"
+import { renderCommunity as render } from "@/test/community-owner-harness"
+import { buildCommunityMentionExtension, EMPTY_MENTION_STATE } from "@/lib/community/mention-extension"
+import { readComposerDraft, writeComposerDraft } from "@/lib/community/composer-draft"
+import { composerDocumentExtensions, serializeComposerDocument } from "./composer-ordered-list"
+import { prependReplyMention } from "./prepend-reply-mention"
+import { useComposerController } from "./use-composer-controller"
+import type { ComposerHandle, ComposerProps } from "./composer-types"
+
+const profiles = vi.hoisted(() => ({ value: new Map<string, { id: string; name: string; discriminator: string }>() }))
+vi.mock("@/lib/community-db/projections", async (importOriginal) => ({
+ ...await importOriginal<typeof import("@/lib/community-db/projections")>(),
+ useCanonicalProfilesByUserId: (userIds?: readonly string[]) => userIds === undefined
+ ? profiles.value
+ : new Map([...profiles.value].filter(([id]) => userIds.includes(id))),
+}))
+
+const author = { id: "author", label: "Same#1234" }
+const mentionNode = (id = author.id, label = author.label): JSONContent => ({ type: "mention", attrs: { id, label } })
+const text = (value: string): JSONContent => ({ type: "text", text: value })
+const paragraph = (...content: JSONContent[]): JSONContent => ({ type: "paragraph", content })
+const doc = (...content: JSONContent[]): JSONContent => ({ type: "doc", content })
+const editors: Editor[] = []
+
+function makeEditor(content = doc(paragraph())) {
+ const editor = new Editor({
+ element: document.createElement("div"),
+ extensions: [
+ ...composerDocumentExtensions(false),
+ buildCommunityMentionExtension({
+ editorRef: { current: null }, canSuggest: () => false,
+ membersRef: { current: [] }, contextRef: { current: "dm" },
+ popupRef: { current: EMPTY_MENTION_STATE }, setPopup: () => {},
+ }),
+ ],
+ content,
+ })
+ editors.push(editor)
+ return editor
+}
+
+function mentionIds(editor: Editor) {
+ const ids: string[] = []
+ editor.state.doc.descendants((node) => { if (node.type.name === "mention") ids.push(node.attrs.id) })
+ return ids
+}
+
+beforeEach(() => {
+ localStorage.clear()
+ const rect = new DOMRect(10, 20, 1, 18)
+ Object.defineProperty(Range.prototype, "getBoundingClientRect", { configurable: true, value: () => rect })
+ Object.defineProperty(Range.prototype, "getClientRects", { configurable: true, value: () => [rect] })
+ profiles.value = new Map([["author", { id: "author", name: "Same", discriminator: "1234" }]])
+})
+afterEach(() => {
+ editors.splice(0).forEach((editor) => editor.destroy())
+ delete (Range.prototype as Partial<Range>).getBoundingClientRect
+ delete (Range.prototype as Partial<Range>).getClientRects
+})
+
+describe("native reply mention transaction", () => {
+ it.each(["", "draft"])("prepends a visible real atom to %s and reuses it", (draft) => {
+ const editor = makeEditor(doc(paragraph(...(draft ? [text(draft)] : []))))
+ prependReplyMention(editor, author)
+ expect(editor.state.doc.firstChild?.firstChild?.type.name).toBe("mention")
+ expect(serializeComposerDocument(editor)).toBe(`@Same#1234 ${draft}`)
+ const before = editor.getJSON()
+ prependReplyMention(editor, author)
+ expect(editor.getJSON()).toEqual(before)
+ expect(mentionIds(editor)).toEqual(["author"])
+ })
+
+ it("reuses an old membership atom by its complete account handle when the roster is empty", () => {
+ const editor = makeEditor(doc(paragraph(text("before "), mentionNode("legacy-membership"), text(" after"))))
+ prependReplyMention(editor, author)
+ expect(mentionIds(editor)).toEqual(["legacy-membership"])
+ expect(serializeComposerDocument(editor)).toBe("@Same#1234 before after")
+ })
+
+ it("moves a membership-ID atom once and preserves structured draft and other identities", () => {
+ const editor = makeEditor(doc(
+ paragraph(text("start "), mentionNode("other", "Same#5678"), text(" keep")),
+ { type: "orderedList", attrs: { start: 3 }, content: [{ type: "listItem", content: [
+ paragraph(text("item "), mentionNode("member-author"), text(" end")),
+ ] }] },
+ ))
+ const before = editor.getJSON()
+ prependReplyMention(editor, author, ["author", "member-author"])
+ expect(mentionIds(editor)).toEqual(["member-author", "other"])
+ expect(serializeComposerDocument(editor)).toBe("@Same#1234 start @Same#5678 keep\n\n3. item end")
+ const after = editor.getJSON()
+ expect(editor.commands.undo()).toBe(true)
+ expect(editor.getJSON()).toEqual(before)
+ expect(editor.commands.redo()).toBe(true)
+ expect(editor.getJSON()).toEqual(after)
+ })
+
+ it("preserves an initial list and separates the reply operation from preceding typing", () => {
+ const list = { type: "orderedList", attrs: { start: 9 }, content: [{ type: "listItem", content: [paragraph(text("item"))] }] }
+ const editor = makeEditor(doc(list))
+ editor.commands.insertContent("typed")
+ const before = editor.getJSON()
+ prependReplyMention(editor, author)
+ expect(editor.getJSON().content?.[1]).toEqual(before.content?.[0])
+ expect(mentionIds(editor)).toEqual(["author"])
+ expect(editor.commands.undo()).toBe(true)
+ expect(editor.getJSON()).toEqual(before)
+ })
+
+ it("switches same-name targets by ID, preserving the previous mention and whitespace", () => {
+ const editor = makeEditor(doc(paragraph(mentionNode(), text(" draft"))))
+ prependReplyMention(editor, { id: "other", label: "Same#5678" })
+ expect(mentionIds(editor)).toEqual(["other", "author"])
+ expect(serializeComposerDocument(editor)).toBe("@Same#5678 @Same#1234 draft")
+ prependReplyMention(editor, author)
+ expect(mentionIds(editor)).toEqual(["author", "other"])
+ })
+})
+
+let view: ReturnType<typeof useComposerController>
+const Harness = forwardRef<ComposerHandle, ComposerProps>(function Harness(props, ref) {
+ view = useComposerController(props, ref)
+ return createElement(EditorContent, { editor: view.editor })
+})
+const reply = { authorId: "author", authorName: "Same", text: "original" }
+function props(onAcceptSend = vi.fn(() => true)): ComposerProps {
+ return { channel: "dm", context: "dm", members: [], sendContract: "accepted", onAcceptSend, draftKey: "dm-reply" }
+}
+
+describe("real common composer reply lifecycle", () => {
+ it.each(["canonical user", "membership"])("does not reuse a restored conflicting %s identity", async (identity) => {
+ profiles.value.set("other", { id: "other", name: "Other", discriminator: "5678" })
+ const id = identity === "canonical user" ? "other" : "member-other"
+ const saved = makeEditor(doc(paragraph(text("before "), mentionNode(id), text(" after")))).getJSON()
+ writeComposerDraft("viewer:dm-reply", saved)
+ const accept = vi.fn(() => true)
+ const base = props(accept)
+ if (identity === "membership") base.members = [{
+ id, userId: "other", name: "Other", discriminator: "5678", avatar: "", avatarVersion: 0,
+ status: "offline", sub: "", role: "member",
+ }]
+ await act(async () => { render(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(mentionIds(view.editor!)).toEqual(["author", id])
+ const body = "@Same#1234 before @Same#1234 after"
+ expect(serializeComposerDocument(view.editor!)).toBe(body)
+ expect(readComposerDraft("viewer:dm-reply")).toEqual(view.editor!.getJSON())
+ const after = view.editor!.getJSON()
+ await act(async () => { expect(view.editor!.commands.undo()).toBe(true) })
+ expect(view.editor!.getJSON()).toEqual(saved)
+ await act(async () => { expect(view.editor!.commands.redo()).toBe(true) })
+ expect(view.editor!.getJSON()).toEqual(after)
+ await act(async () => { view.onSend() })
+ expect(accept).toHaveBeenCalledWith(body, undefined, undefined)
+ })
+
+ it.each([true, false])("reuses a restored legacy target atom with current mapping=%s", async (mapped) => {
+ const id = "member-author"
+ writeComposerDraft("viewer:dm-reply", doc(paragraph(text("before "), mentionNode(id), text(" after"))))
+ const base = props()
+ if (mapped) base.members = [{
+ id, userId: "author", name: "Same", discriminator: "1234", avatar: "", avatarVersion: 0,
+ status: "offline", sub: "", role: "member",
+ }]
+ await act(async () => { render(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(mentionIds(view.editor!)).toEqual([id])
+ expect(serializeComposerDocument(view.editor!)).toBe("@Same#1234 before after")
+ })
+
+ it("completes a pending selection when its canonical profile becomes ready", async () => {
+ profiles.value = new Map()
+ const base = props()
+ let renderer!: ReturnType<typeof render>
+ await act(async () => { renderer = render(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(mentionIds(view.editor!)).toEqual([])
+ profiles.value = new Map([["author", { id: "author", name: "Same", discriminator: "1234" }]])
+ await act(async () => { renderer.rerender(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(mentionIds(view.editor!)).toEqual(["author"])
+ })
+
+ it("restores first, inserts once, persists the atom and does not reinsert after deletion or send", async () => {
+ writeComposerDraft("viewer:dm-reply", doc(paragraph(text("draft"))))
+ const accept = vi.fn(() => true)
+ const base = props(accept)
+ let renderer!: ReturnType<typeof render>
+ await act(async () => { renderer = render(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(view.editor).not.toBeNull()
+ expect(serializeComposerDocument(view.editor!)).toBe("@Same#1234 draft")
+ expect(readComposerDraft("viewer:dm-reply")).toEqual(view.editor!.getJSON())
+ expect(renderer.container.querySelector("[data-type=mention]")?.textContent).toBe("@Same")
+ await act(async () => { view.editor!.commands.deleteRange({ from: 1, to: 2 }) })
+ profiles.value = new Map(profiles.value)
+ await act(async () => { renderer.rerender(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(mentionIds(view.editor!)).toEqual([])
+ await act(async () => { view.onSend() })
+ expect(accept).toHaveBeenCalledWith("draft", undefined, undefined)
+ expect(view.editor!.isEmpty).toBe(true)
+ expect(readComposerDraft("viewer:dm-reply")).toBeNull()
+ })
+
+ it("waits for a canonical identity, cancels safely, and reuses after reselection", async () => {
+ profiles.value = new Map()
+ const base = props()
+ let renderer!: ReturnType<typeof render>
+ await act(async () => { renderer = render(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(mentionIds(view.editor!)).toEqual([])
+ profiles.value = new Map([["author", { id: "author", name: "Same", discriminator: "1234" }]])
+ await act(async () => { renderer.rerender(createElement(Harness, base)) })
+ expect(mentionIds(view.editor!)).toEqual([])
+ await act(async () => { renderer.rerender(createElement(Harness, { ...base, replyingTo: reply })) })
+ expect(mentionIds(view.editor!)).toEqual(["author"])
+ await act(async () => { renderer.rerender(createElement(Harness, base)) })
+ expect(mentionIds(view.editor!)).toEqual(["author"])
+ await act(async () => { renderer.rerender(createElement(Harness, { ...base, replyingTo: { ...reply, text: "another message" } })) })
+ expect(mentionIds(view.editor!)).toEqual(["author"])
+ })
+
+ it("keeps the visible body and attachment on rejection and sends the same body again", async () => {
+ const accept = vi.fn(() => false)
+ const base = props(accept)
+ const handle = createRef<ComposerHandle>()
+ await act(async () => { render(createElement(Harness, { ...base, replyingTo: reply, ref: handle })) })
+ const file = new File(["draft attachment"], "draft.txt", { type: "text/plain" })
+ await act(async () => { view.onFileSelect({ target: { files: [file], value: "" } } as never) })
+ expect(view.pendingFiles).toHaveLength(1)
+ const before = view.editor!.getJSON()
+ await act(async () => { handle.current!.submitNow() })
+ expect(view.editor!.getJSON()).toEqual(before)
+ expect(view.pendingFiles).toHaveLength(1)
+ expect(accept.mock.calls[0]?.[0]).toBe("@Same#1234")
+ accept.mockReturnValue(true)
+ await act(async () => { handle.current!.submitNow() })
+ expect(accept.mock.calls[1]).toEqual(accept.mock.calls[0])
+ expect(view.editor!.isEmpty).toBe(true)
+ expect(view.pendingFiles).toHaveLength(0)
+ })
+})
diff --git a/src/web/src/components/community/messages/thread-opener.dom.test.ts b/src/web/src/components/community/messages/thread-opener.dom.test.ts
index 8a43307da..f44923864 100644
--- a/src/web/src/components/community/messages/thread-opener.dom.test.ts
+++ b/src/web/src/components/community/messages/thread-opener.dom.test.ts
@@ -68,7 +68,7 @@ describe("ThreadOpener image attachment layout", () => {
expect(next).toHaveClass("opacity-0")
})
- it("renders projected reply content in the opener", () => {
+ it("renders the full visible reply body in the opener", () => {
useMessageMock.mockReturnValue({
isLoading: false,
isError: false,
@@ -96,7 +96,7 @@ describe("ThreadOpener image attachment layout", () => {
})
const body = renderer!.container.querySelector('[data-community-message-body="true"]')!
- expect(body.textContent).not.toContain("@Bob Smith")
+ expect(body.textContent).toContain("@Bob Smith")
expect(body).toHaveTextContent("visible")
})
diff --git a/src/web/src/components/community/messages/thread-opener.tsx b/src/web/src/components/community/messages/thread-opener.tsx
index 2f3ee56aa..5b77dca03 100644
--- a/src/web/src/components/community/messages/thread-opener.tsx
+++ b/src/web/src/components/community/messages/thread-opener.tsx
@@ -12,7 +12,6 @@ import { tid } from "@/lib/community/testids"
import type { FileAttachment, ImagePreview } from "@/lib/community/models/message"
import type { OpenProfile } from "@/components/community/social/profile-types"
import { AttachmentCard } from "./attachment-card"
-import { displayReplyContent } from "@/lib/community/reply-content"
import { useMobileAvatarMention } from "./use-mobile-avatar-mention"
import { useCanonicalCommunityProfile } from "@/lib/community-db/projections"
import { useHoverCapable } from "@/hooks/use-hover-capable"
@@ -106,7 +105,7 @@ export function ThreadOpener({
const avatarLabel = msg.authorId
? (authorProfile?.avatar ?? avatarInitial(authorName))
: (msg.authorAvatar ?? avatarInitial(authorName))
- const visibleContent = displayReplyContent(msg.content ?? "", msg.replyTo)
+ const visibleContent = msg.content ?? ""
return (
<div data-thread-opener className="group relative flex flex-col gap-2">
diff --git a/src/web/src/components/community/messages/use-author-mention-insertion.dom.test.ts b/src/web/src/components/community/messages/use-author-mention-insertion.dom.test.ts
index 72b5df659..1c69b748f 100644
--- a/src/web/src/components/community/messages/use-author-mention-insertion.dom.test.ts
+++ b/src/web/src/components/community/messages/use-author-mention-insertion.dom.test.ts
@@ -41,7 +41,7 @@ describe("author mention insertion", () => {
expect(insertMentionAtCaret).toHaveBeenCalledOnce()
expect(insertMentionAtCaret).toHaveBeenCalledWith({
- id: "member_1",
+ id: "alice_1",
label: "Alice Smith#0042",
})
})
diff --git a/src/web/src/components/community/messages/use-author-mention-insertion.ts b/src/web/src/components/community/messages/use-author-mention-insertion.ts
index 504208165..9dd1ffa19 100644
--- a/src/web/src/components/community/messages/use-author-mention-insertion.ts
+++ b/src/web/src/components/community/messages/use-author-mention-insertion.ts
@@ -38,7 +38,7 @@ export function useAuthorMentionInsertion({
return new Map(identities.map((identity) => [
identity.userId,
{
- id: identity.id,
+ id: identity.userId,
label: formatHandle(identity.name, identity.discriminator),
} satisfies ComposerMention,
]))
diff --git a/src/web/src/components/community/messages/use-composer-controller.ts b/src/web/src/components/community/messages/use-composer-controller.ts
index c4da46ca7..967917f7b 100644
--- a/src/web/src/components/community/messages/use-composer-controller.ts
+++ b/src/web/src/components/community/messages/use-composer-controller.ts
@@ -35,6 +35,7 @@ import type { ComposerHandle, ComposerProps } from "./composer-types"
import { mentionNodesForCaretInsertion, textNodeForCaretInsertion } from "./caret-text-insertion"
import type { ComposerViewProps } from "./composer-view"
import { useComposerSuggestions } from "./use-composer-suggestions"
+import { useComposerReplyMention } from "./use-composer-reply-mention"
export function useComposerController(
{
@@ -347,14 +348,7 @@ export function useComposerController(
suppressSuggestions(() => editor.commands.focus("end"))
}, [autoFocus, editor, channel, isForumThreadBody, suppressSuggestions])
- const previousReplyingToRef = useRef(replyingTo)
- useEffect(() => {
- const targetChanged = previousReplyingToRef.current !== replyingTo
- previousReplyingToRef.current = replyingTo
- if (targetChanged && replyingTo && editor && !isForumThreadBody) {
- suppressSuggestions(() => editor.commands.focus("end"))
- }
- }, [replyingTo, editor, isForumThreadBody, suppressSuggestions])
+ useComposerReplyMention({ editor, isForumThreadBody, replyingTo, members, suppressSuggestions })
const handleDrop = (event: DragEvent<HTMLDivElement>) => {
handleDropRaw(event)
diff --git a/src/web/src/components/community/messages/use-composer-reply-mention.ts b/src/web/src/components/community/messages/use-composer-reply-mention.ts
new file mode 100644
index 000000000..f3be81a03
--- /dev/null
+++ b/src/web/src/components/community/messages/use-composer-reply-mention.ts
@@ -0,0 +1,42 @@
+import { useEffect, useRef } from "react"
+import type { Editor } from "@tiptap/react"
+import { formatHandle } from "@alook/shared"
+import { useCanonicalProfilesByUserId } from "@/lib/community-db/projections"
+import type { Member } from "@/lib/community/models/people"
+import type { ComposerReplyTarget } from "./composer-types"
+import { prependReplyMention } from "./prepend-reply-mention"
+
+export function useComposerReplyMention({
+ editor, isForumThreadBody, replyingTo, members, suppressSuggestions,
+}: {
+ editor: Editor | null
+ isForumThreadBody: boolean
+ replyingTo?: ComposerReplyTarget
+ members: Member[]
+ suppressSuggestions: (operation: () => void) => void
+}) {
+ const replyProfiles = useCanonicalProfilesByUserId()
+ const previousReplyingToRef = useRef<ComposerReplyTarget | undefined>(undefined)
+ useEffect(() => {
+ if (!replyingTo) {
+ previousReplyingToRef.current = undefined
+ return
+ }
+ if (previousReplyingToRef.current === replyingTo || !editor || isForumThreadBody) return
+ const authorId = replyingTo.authorId
+ const profile = authorId ? replyProfiles.get(authorId) : undefined
+ if (authorId && (!profile?.name || !profile.discriminator)) {
+ suppressSuggestions(() => editor.commands.focus("end"))
+ return
+ }
+ if (authorId && profile?.name && profile.discriminator) {
+ prependReplyMention(editor, {
+ id: authorId,
+ label: formatHandle(profile.name, profile.discriminator),
+ }, [authorId, ...members.filter((member) => member.userId === authorId).map((member) => member.id)],
+ (id) => replyProfiles.has(id) ? id : members.find((member) => member.id === id)?.userId)
+ }
+ previousReplyingToRef.current = replyingTo
+ suppressSuggestions(() => editor.commands.focus("end"))
+ }, [replyingTo, replyProfiles, members, editor, isForumThreadBody, suppressSuggestions])
+}
diff --git a/src/web/src/hooks/community/use-dm-message-sender.dom.test.ts b/src/web/src/hooks/community/use-dm-message-sender.dom.test.ts
index cd3de2658..213b8e59e 100644
--- a/src/web/src/hooks/community/use-dm-message-sender.dom.test.ts
+++ b/src/web/src/hooks/community/use-dm-message-sender.dom.test.ts
@@ -118,20 +118,20 @@ describe("Native DM sender", () => {
const receipt = owner.accept({ content: "replying", replyTo: { id: "prior", authorName: "Peer", text: "x".repeat(MESSAGE_PREVIEW_LENGTH + 1) } })
expect(await owner.settle(receipt)).toEqual({ ok: false, error: expect.any(Error) })
const expected = `${"x".repeat(MESSAGE_PREVIEW_LENGTH - 1)}…`
- expect(owner.overlay().outboxByNonce.get("fresh_nonce")?.message).toMatchObject({ content: "@Peer\nreplying", replyTo: { text: expected } })
+ expect(owner.overlay().outboxByNonce.get("fresh_nonce")?.message).toMatchObject({ content: "replying", replyTo: { text: expected } })
expect(await owner.retry()).toEqual({ ok: false, error: expect.any(Error) })
expect(owner.overlay().outboxByNonce.get("fresh_nonce")?.message.replyTo?.text).toBe(expected)
- expect(mocks.post.mock.calls.map(([body]) => body)).toEqual(Array(2).fill({ content: "@Peer\nreplying", replyToId: "prior", nonce: "fresh_nonce" }))
+ expect(mocks.post.mock.calls.map(([body]) => body)).toEqual(Array(2).fill({ content: "replying", replyToId: "prior", nonce: "fresh_nonce" }))
})
- it("sends a canonical prefix for an attachment-only DM reply", async () => {
+ it("sends an exact empty body for an attachment-only reply after mention removal", async () => {
mocks.upload.mockResolvedValueOnce({ id: "att_x", filename: "x.txt", contentType: "text/plain", size: 1 })
- mocks.post.mockResolvedValueOnce(posted("server_file", 9, "@Peer Name\n"))
+ mocks.post.mockResolvedValueOnce(posted("server_file", 9, ""))
const owner = await setup(), file = new File(["x"], "x.txt", { type: "text/plain" })
const receipt = owner.accept({ content: "", replyTo: { id: "prior", authorName: "Peer Name", text: "quoted" }, attachments: [{ file, previewObjectUrl: "blob:x" }] })
expect(await owner.settle(receipt)).toMatchObject({ ok: true, message: { id: "server_file", seq: 9 } })
- expect(materializeMessageStream([], owner.overlay(), canonicalMessageReader(owner.client)).find(({ id }) => id === "server_file")?.content).toBe("@Peer Name\n")
- expect(mocks.post).toHaveBeenCalledExactlyOnceWith({ content: "@Peer Name\n", replyToId: "prior", attachments: ["att_x"], nonce: "fresh_nonce" })
+ expect(materializeMessageStream([], owner.overlay(), canonicalMessageReader(owner.client)).find(({ id }) => id === "server_file")?.content).toBe("")
+ expect(mocks.post).toHaveBeenCalledExactlyOnceWith({ content: "", replyToId: "prior", attachments: ["att_x"], nonce: "fresh_nonce" })
})
it("reuses settled remote attachments on retry without a second upload", async () => {
diff --git a/src/web/src/hooks/community/use-scroll-anchor.repin.dom.test.ts b/src/web/src/hooks/community/use-scroll-anchor.repin.dom.test.ts
index 104432825..c2b6ad89b 100644
--- a/src/web/src/hooks/community/use-scroll-anchor.repin.dom.test.ts
+++ b/src/web/src/hooks/community/use-scroll-anchor.repin.dom.test.ts
@@ -463,6 +463,66 @@ describe("locked native adapter and existing message scroll owner", () => {
h.move(300)
expect(scrollFixture.latest.readPositionReady).toBe(true)
})
+ it.each([0, 2, 100, 300])("preserves a retired unconfirmed reader through composer shrink and grow at %ipx", distance => {
+ const h = mount({ initialScrollReady: false, hasMoreNewer: true })
+ act(() => vi.advanceTimersByTime(2000))
+ runFrames()
+ const native = scrollFixture.latest.virtualizer
+ const end = vi.spyOn(native, "scrollToEnd")
+ const index = vi.spyOn(native, "scrollToIndex")
+ act(() => h.root.scrollTo({ top: h.root.scrollHeight - h.root.clientHeight - 8 }))
+ runFrames()
+ act(() => h.root.scrollTo({ top: h.root.scrollHeight - h.root.clientHeight - distance }))
+ runFrames()
+ const before = h.root.scrollTop
+ expect(scrollFixture.latest.readPositionReady).toBe(false)
+ expect(native.options.followOnAppend).toBe(false)
+ scrollFixture.height += 168
+ resize()
+ if (distance <= 100) expect(h.root.scrollHeight - h.root.clientHeight - h.root.scrollTop).toBe(distance)
+ else expect(h.root.scrollTop).toBe(before)
+ scrollFixture.height -= 168
+ resize()
+ if (distance <= 100) expect(h.root.scrollHeight - h.root.clientHeight - h.root.scrollTop).toBe(distance)
+ else expect(h.root.scrollTop).toBe(before)
+ const settled = h.root.scrollTop
+ h.update({ items: [...h.input.items, message("late-peer-after-resize")] })
+ expect(h.root.scrollTop).toBe(settled)
+ expect(scrollFixture.latest.readPositionReady).toBe(false)
+ expect(native.options).toMatchObject({ anchorTo: "start", followOnAppend: false })
+ expect(end).not.toHaveBeenCalled()
+ expect(index).not.toHaveBeenCalled()
+ })
+ it.each(["rectangle", "row"])("rejects an invalid %s during an unconfirmed reader resize", async invalid => {
+ const h = mount({ initialScrollReady: false, hasMoreNewer: true })
+ act(() => vi.advanceTimersByTime(2000))
+ runFrames()
+ act(() => h.root.scrollTo({ top: h.root.scrollHeight - h.root.clientHeight }))
+ runFrames()
+ const native = scrollFixture.latest.virtualizer
+ const offset = vi.spyOn(native, "scrollToOffset")
+ if (invalid === "rectangle") native.scrollRect = { width: 640, height: 500 }
+ else {
+ const bounds = vi.mocked(HTMLElement.prototype.getBoundingClientRect)
+ const original = bounds.getMockImplementation()!
+ bounds.mockImplementation(function (this: HTMLElement) {
+ const rect = original.call(this)
+ return this.matches("[data-index]")
+ ? DOMRect.fromRect({ x: rect.x, y: rect.y + 8, width: rect.width, height: rect.height })
+ : rect
+ })
+ }
+ scrollFixture.height -= 168
+ await act(async () => {
+ h.root.closest('[data-slot="community-conversation-surface"]')!
+ .querySelector('[data-slot="community-conversation-footer"]')!.textContent = "changed draft"
+ })
+ runFrames(1)
+ expect(offset).not.toHaveBeenCalled()
+ expect(scrollFixture.frames.size).toBe(0)
+ expect(scrollFixture.latest.readPositionReady).toBe(false)
+ expect(native.options.followOnAppend).toBe(false)
+ })
it("preserves and settles a prefix page after deadline retirement without opening read or peer follow", () => {
const h = mount({ initialScrollReady: false, hasMoreNewer: true })
expect(scrollFixture.latest.paginationEnabled).toBe(false)
diff --git a/src/web/src/hooks/community/use-scroll-anchor.ts b/src/web/src/hooks/community/use-scroll-anchor.ts
index 31a2fcba2..91b975d4d 100644
--- a/src/web/src/hooks/community/use-scroll-anchor.ts
+++ b/src/web/src/hooks/community/use-scroll-anchor.ts
@@ -548,7 +548,7 @@ export function useScrollAnchor({
&& (previous.clientHeight !== next.clientHeight || previous.paddingEnd !== next.paddingEnd)
&& previous.scrollTop <= Math.max(0, next.scrollHeight - next.clientHeight) + 1
&& previous.scrollTop !== next.scrollTop
- if (positionKind.get() === "idle" && readReady.get()
+ if (positionKind.get() === "idle"
&& (!previous || scrolledAfterResize || (previous.epoch === next.epoch
&& previous.clientHeight === next.clientHeight && previous.clientWidth === next.clientWidth
&& previous.paddingEnd === next.paddingEnd
@@ -563,14 +563,14 @@ export function useScrollAnchor({
}
holdNativeOrigin(next.scrollTop <= 1 && !next.pinEligible ? currentItemsRef.current[0]?.key ?? null : null)
}
- }, [holdNativeOrigin, positionKind, readReady])
+ }, [holdNativeOrigin, positionKind])
const reconcileGeometry = useCallback((viewportOnly = false) => {
const root = scrollRef.current
const native = virtualizerRef.current
const owner = positionOwnerRef.current
if (!owner.active || !root || !native) return false
- if (viewportOnly && (positionKind.get() !== "idle" || !readReady.get()
+ if (viewportOnly && (positionKind.get() !== "idle"
|| acceptedGeometryRef.current?.epoch !== owner.epoch
|| (acceptedGeometryRef.current.clientHeight === root.clientHeight
&& acceptedGeometryRef.current.clientWidth === root.clientWidth
@@ -581,7 +581,7 @@ export function useScrollAnchor({
setShortGap(gap)
return true
}
- if (positionKind.get() !== "idle" || (!readReady.get() && !userInputRef.current.handover && !paginationRef.current)) return false
+ if (positionKind.get() !== "idle") return false
const next = readGeometry(viewportOnly)
const input = userInputRef.current
const max = Math.max(0, root.scrollHeight - root.clientHeight)
@@ -595,6 +595,8 @@ export function useScrollAnchor({
}
const clampedByResize = viewportResized && !previous.isScrolling && previous.scrollTop > max
&& Math.abs(root.scrollTop - max) <= 1
+ if (!readReady.get() && !input.handover && !paginationRef.current
+ && (!next || (native.isScrolling && !clampedByResize))) return false
if (input.touch || input.pointers.size > 0 || (native.isScrolling && !clampedByResize)
|| root.scrollTop < 0 || root.scrollTop > max + 1
) return true
@@ -613,7 +615,7 @@ export function useScrollAnchor({
if (!viewportResized && paginationRef.current?.phase === "settling" && geometrySampleRef.current.frames < 2) return true
let offset = root.scrollTop
let originHeld = false
- if (viewportResized && previous?.epoch === owner.epoch && readReady.get()) {
+ if (viewportResized && previous?.epoch === owner.epoch) {
originHeld = !previous.pinEligible && previous.scrollTop <= 1
&& previous.key === currentItemsRef.current[0]?.key && previous.itemStart <= 1
if (originHeld) offset = previous.scrollTop
diff --git a/src/web/src/lib/community/mention-extension.test.ts b/src/web/src/lib/community/mention-extension.test.ts
index 5f75b28b6..8cb4b716d 100644
--- a/src/web/src/lib/community/mention-extension.test.ts
+++ b/src/web/src/lib/community/mention-extension.test.ts
@@ -454,6 +454,17 @@ describe("buildCommunityMentionExtension β€” suggestion.render callbacks", () =>
"ad",
)
+ it("inserts the existing user's ID while preserving the membership picker ID", () => {
+ const harness = setup(), raw = vi.fn()
+ const ranked = rankMentionItems([{
+ ...member("membership", "Ada", "0001"), userId: "user-ada",
+ }], "channel", "ad")
+ expect(ranked[0].id).toBe("membership")
+ harness.callbacks.onStart({ items: ranked, query: "ad", command: raw })
+ harness.popup().command!({ id: "membership", label: "Ada#0001" })
+ expect(raw).toHaveBeenCalledExactlyOnceWith({ id: "user-ada", label: "Ada#0001" })
+ })
+
it("rejects unfocused publication and late updates; a retired command cannot insert", () => {
const harness = setup(), raw = vi.fn()
editor.isFocused = false
diff --git a/src/web/src/lib/community/mention-extension.ts b/src/web/src/lib/community/mention-extension.ts
index 6ca25de86..636eda87c 100644
--- a/src/web/src/lib/community/mention-extension.ts
+++ b/src/web/src/lib/community/mention-extension.ts
@@ -160,7 +160,8 @@ export function buildCommunityMentionExtension(opts: {
const commandFor = (props: SuggestionProps) => {
const command: NonNullable<MentionPopupState["command"]> = (value) => {
if (!eligible(props.editor) || popupRef.current.command !== command) return
- props.command(value)
+ const item = popupRef.current.items.find((candidate) => candidate.id === value.id && candidate.label === value.label)
+ props.command({ ...value, id: item?.kind === "member" ? item.userId : value.id })
}
return command
}
diff --git a/src/web/src/lib/community/message-send-intent.ts b/src/web/src/lib/community/message-send-intent.ts
index 5922b0f69..4bd3955ec 100644
--- a/src/web/src/lib/community/message-send-intent.ts
+++ b/src/web/src/lib/community/message-send-intent.ts
@@ -4,7 +4,6 @@ import { toastApiError } from "@/lib/api/client"
import type { CommunityRuntime } from "@/stores/community/runtime"
import type { MessageScope } from "./message-stream"
import type { SendAttachment } from "./models/message"
-import { canonicalizeReplyContent } from "./reply-content"
import { toOptimisticReplyPreview } from "./reply-preview"
export function messageSendError(error: unknown): Error {
@@ -15,7 +14,7 @@ export function acceptMessageIntent(runtime: CommunityRuntime, scope: MessageSco
input: Pick<SendMessageArgs, "content" | "author" | "replyTo" | "nonce" | "mentionType"> & { attachments?: SendAttachment[] },
): string | undefined {
if (!input.content && !input.attachments?.length) return undefined
- const content = canonicalizeReplyContent(input.content, input.replyTo)
+ const content = input.content
const nonce = input.nonce ?? sendNonce()
const createdPreviewUrls: string[] = []
const accepted = runtime.messageStream.actions.accept(scope, {
diff --git a/src/web/src/lib/community/models/message.ts b/src/web/src/lib/community/models/message.ts
index d97fac8a5..9cb1566bc 100644
--- a/src/web/src/lib/community/models/message.ts
+++ b/src/web/src/lib/community/models/message.ts
@@ -36,7 +36,7 @@ export const MessageEmbedSchema = z.object({
type Embed = z.infer<typeof MessageEmbedSchema>
export type Reaction = NonNullable<CommunityMessageResource["reactions"]>[number]
-export type ReplyTarget = Pick<NonNullable<CommunityMessageResource["replyTo"]>, "id" | "authorName" | "text">
+export type ReplyTarget = Pick<NonNullable<CommunityMessageResource["replyTo"]>, "id" | "authorId" | "authorName" | "text">
export type Msg = Pick<CommunityMessageResource, "id" | "type"> & Partial<Omit<CommunityMessageResource,
"id" | "type" | "channelId" | "replyToId" | "clientNonce" | "attachments" | "embeds" | "authorAvatar" | "thread"
diff --git a/src/web/src/lib/community/reply-content.test.ts b/src/web/src/lib/community/reply-content.test.ts
deleted file mode 100644
index 25436f7ae..000000000
--- a/src/web/src/lib/community/reply-content.test.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { describe, expect, it } from "vitest"
-import { canonicalizeReplyContent, displayReplyContent } from "./reply-content"
-
-describe("reply content", () => {
- const alice = { authorName: "Alice Smith" }
-
- it("adds one exact author prefix to plain text and Markdown blocks", () => {
- expect(canonicalizeReplyContent("hello", alice)).toBe("@Alice Smith\nhello")
- expect(canonicalizeReplyContent("> quote\n\n- one", alice)).toBe(
- "@Alice Smith\n> quote\n\n- one",
- )
- })
-
- it("keeps an existing same-author mention only at an exact boundary", () => {
- expect(canonicalizeReplyContent("@Alice Smith\nhello", alice)).toBe(
- "@Alice Smith\nhello",
- )
- expect(canonicalizeReplyContent("@Alice Smith hello", alice)).toBe(
- "@Alice Smith hello",
- )
- expect(canonicalizeReplyContent("@Alice Smith", alice)).toBe("@Alice Smith")
- expect(canonicalizeReplyContent("@Alice Smithers hello", alice)).toBe(
- "@Alice Smith\n@Alice Smithers hello",
- )
- expect(canonicalizeReplyContent("@Bob hello", alice)).toBe(
- "@Alice Smith\n@Bob hello",
- )
- })
-
- it("canonicalizes attachment-only reply content", () => {
- expect(canonicalizeReplyContent("", alice)).toBe("@Alice Smith\n")
- })
-
- it("strips one matching prefix and one logical boundary", () => {
- expect(displayReplyContent("@Alice Smith\nhello", alice)).toBe("hello")
- expect(displayReplyContent("@Alice Smith\r\nhello", alice)).toBe("hello")
- expect(displayReplyContent("@Alice Smith hello", alice)).toBe(" hello")
- expect(displayReplyContent("@Alice Smith\thello", alice)).toBe("hello")
- expect(displayReplyContent("@Alice Smith", alice)).toBe("")
- })
-
- it("leaves legacy, different-author, longer-name, and non-reply content unchanged", () => {
- expect(displayReplyContent("legacy", alice)).toBe("legacy")
- expect(displayReplyContent("@Bob\nhello", alice)).toBe("@Bob\nhello")
- expect(displayReplyContent("@Alice Smithers\nhello", alice)).toBe(
- "@Alice Smithers\nhello",
- )
- expect(displayReplyContent("@Alice Smith\nhello", undefined)).toBe(
- "@Alice Smith\nhello",
- )
- })
-
- it("does not manufacture a bare mention for a missing author name", () => {
- expect(canonicalizeReplyContent("hello", { authorName: "" })).toBe("hello")
- expect(displayReplyContent("@\nhello", { authorName: "" })).toBe("@\nhello")
- })
-})
diff --git a/src/web/src/lib/community/reply-content.ts b/src/web/src/lib/community/reply-content.ts
deleted file mode 100644
index c1125e5f1..000000000
--- a/src/web/src/lib/community/reply-content.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-type ReplyAuthor = { authorName: string } | null | undefined
-
-function replyAuthorPrefix(replyTo: ReplyAuthor): string | null {
- if (!replyTo?.authorName) return null
- return `@${replyTo.authorName}`
-}
-
-function matchingReplyPrefixLength(content: string, replyTo: ReplyAuthor): number {
- const prefix = replyAuthorPrefix(replyTo)
- if (!prefix || !content.startsWith(prefix)) return 0
- const boundary = content.slice(prefix.length, prefix.length + 1)
- return boundary === "" || /\s/u.test(boundary) ? prefix.length : 0
-}
-
-/**
- * Canonical raw content for a reply. This runs once when a send/edit intent is
- * accepted; optimistic state, POST, and retry all reuse the returned string.
- */
-export function canonicalizeReplyContent(content: string, replyTo: ReplyAuthor): string {
- const prefix = replyAuthorPrefix(replyTo)
- if (!prefix || matchingReplyPrefixLength(content, replyTo) > 0) return content
- return `${prefix}\n${content}`
-}
-
-/**
- * User-facing projection of canonical reply content. Only a prefix matching
- * the actual replied-to author is hidden. One following whitespace boundary
- * is removed as well; CRLF is treated as one line-break boundary.
- */
-export function displayReplyContent(content: string, replyTo: ReplyAuthor): string {
- const prefixLength = matchingReplyPrefixLength(content, replyTo)
- if (prefixLength === 0) return content
- const remainder = content.slice(prefixLength)
- if (remainder.startsWith("\r\n")) return remainder.slice(2)
- return /^\s/u.test(remainder) ? remainder.slice(1) : remainder
-}
diff --git a/src/web/src/stores/community/ui-store.test.ts b/src/web/src/stores/community/ui-store.test.ts
new file mode 100644
index 000000000..a93806890
--- /dev/null
+++ b/src/web/src/stores/community/ui-store.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from "vitest"
+import { createCommunityStore } from "./ui-store"
+
+describe("pending reply identity", () => {
+ it("preserves author identity through navigation and does not discard an identity update", () => {
+ const store = createCommunityStore()
+ const target = { id: "message", authorName: "Author", text: "@Author#1234 body" }
+ store.actions.setPendingReply({ channelId: "destination", target })
+ const withIdentity = { channelId: "destination", target: { ...target, authorId: "author" } }
+ store.actions.setPendingReply(withIdentity)
+ expect(store.get().pendingReply).toBe(withIdentity)
+ const before = store.get()
+ store.actions.setPendingReply({ ...withIdentity, target: { ...withIdentity.target } })
+ expect(store.get()).toBe(before)
+ store.actions.setPendingReply(null)
+ expect(store.get().pendingReply).toBeNull()
+ })
+})
diff --git a/src/web/src/stores/community/ui-store.ts b/src/web/src/stores/community/ui-store.ts
index 6b8d3c53b..192693cfa 100644
--- a/src/web/src/stores/community/ui-store.ts
+++ b/src/web/src/stores/community/ui-store.ts
@@ -1,6 +1,6 @@
import { createStore } from "@tanstack/store"
import type React from "react"
-import type { FileAttachment, ImagePreview } from "@/lib/community/models/message"
+import type { FileAttachment, ImagePreview, ReplyTarget } from "@/lib/community/models/message"
import type { CommunityOnboardingState } from "@/lib/community-onboarding"
// ── Types ────────────────────────────────────────────────────────────────────
@@ -59,7 +59,7 @@ export type CommunityUiHandlers = {
* reply lands in the right channel (Gus #449/#452). */
type PendingReply = {
channelId: string
- target: { id: string; authorName: string; text: string }
+ target: ReplyTarget
}
function samePendingReply(left: PendingReply | null, right: PendingReply | null): boolean {
@@ -68,6 +68,7 @@ function samePendingReply(left: PendingReply | null, right: PendingReply | null)
right !== null &&
left.channelId === right.channelId &&
left.target.id === right.target.id &&
+ left.target.authorId === right.target.authorId &&
left.target.authorName === right.target.authorName &&
left.target.text === right.target.text
)
diff --git a/src/web/src/test/e2e-ui/39-mobile-message-interactions.spec.ts b/src/web/src/test/e2e-ui/39-mobile-message-interactions.spec.ts
index 72486b083..ab909b580 100644
--- a/src/web/src/test/e2e-ui/39-mobile-message-interactions.spec.ts
+++ b/src/web/src/test/e2e-ui/39-mobile-message-interactions.spec.ts
@@ -472,12 +472,14 @@ test("mobile reply, avatar mention, and typing rail keep exact backend and WS id
await dispatchSwipe(alice.page, channelBobMessageId, { x: 72, y: 2 })
const replyPreview = alice.page.locator('[data-slot="composer-reply-preview"]')
await expect(replyPreview).toHaveText(`Replying to ${bobInfo.name} Β· channel target ${stamp}`)
+ await expect(composerEditable(alice.page).locator(`[data-type="mention"][data-id="${userId("bob")}"]`)).toHaveCount(1)
await alice.page.getByRole("button", { name: "Cancel reply" }).click()
await expect(replyPreview).toHaveCount(0)
expect(await latestSeq(alice.page, channelId)).toBe(beforeRejectedSwipeSeq)
await dispatchSwipe(alice.page, channelBobSecondMessageId, { x: 72, y: 2 })
await expect(replyPreview).toHaveText(`Replying to ${bobInfo.name} Β· channel alternate ${stamp}`)
+ await expect(composerEditable(alice.page).locator(`[data-type="mention"][data-id="${userId("bob")}"]`)).toHaveCount(1)
const replyBody = `swipe reply ${stamp}`
const replyResponsePromise = alice.page.waitForResponse((response) => (
response.request().method() === "POST"
@@ -491,7 +493,7 @@ test("mobile reply, avatar mention, and typing rail keep exact backend and WS id
message: { id: string; content: string; replyToId: string | null }
}
expect(replyPayload.message.replyToId).toBe(channelBobSecondMessageId)
- expect(replyPayload.message.content).toContain(replyBody)
+ expect(replyPayload.message.content).toBe(replyBody)
await expect.poll(() => bobProxy.frames.some((frame) => (
frameHasMessage(frame, channelId, replyPayload.message.id)
&& communityFrameEvents(frame).some((event) => (
@@ -547,7 +549,7 @@ test("mobile reply, avatar mention, and typing rail keep exact backend and WS id
await expect(editable).toHaveText(`hello @${bobInfo.name} world`)
const insertedMention = editable.locator(".mention-highlight")
await expect(insertedMention).toHaveText(`@${bobInfo.name}`)
- await expect(insertedMention).toHaveAttribute("data-id", bobInfo.id)
+ await expect(insertedMention).toHaveAttribute("data-id", userId("bob"))
await expect(insertedMention).toHaveAttribute(
"data-label",
`${bobInfo.name}#${bobInfo.discriminator}`,
@@ -572,6 +574,7 @@ test("mobile reply, avatar mention, and typing rail keep exact backend and WS id
await dispatchSwipe(alice.page, threadBobMessageId, { x: 72, y: 1 })
await expect(replyPreview).toHaveText(`Replying to ${bobInfo.name} Β· thread target ${stamp}`)
+ await expect(composerEditable(alice.page).locator(`[data-type="mention"][data-id="${userId("bob")}"]`)).toHaveCount(1)
const threadReplyBody = `thread swipe reply ${stamp}`
const threadReplyResponsePromise = alice.page.waitForResponse((response) => (
response.request().method() === "POST"
@@ -585,7 +588,7 @@ test("mobile reply, avatar mention, and typing rail keep exact backend and WS id
message: { id: string; content: string; replyToId: string | null }
}
expect(threadReplyPayload.message.replyToId).toBe(threadBobMessageId)
- expect(threadReplyPayload.message.content).toContain(threadReplyBody)
+ expect(threadReplyPayload.message.content).toBe(threadReplyBody)
await expect.poll(() => bobProxy.frames.some((frame) => (
frameHasMessage(frame, threadId, threadReplyPayload.message.id)
&& communityFrameEvents(frame).some((event) => (
@@ -788,6 +791,7 @@ test("mobile reply, avatar mention, and typing rail keep exact backend and WS id
await expect(dmReplyTarget).toBeVisible()
await dispatchSwipe(alice.page, dmWsReadyId, { x: 72, y: 1 })
await expect(replyPreview).toHaveText(`Replying to ${bobInfo.name} Β· dm reply target ${stamp}`)
+ await expect(composerEditable(alice.page).locator(`[data-type="mention"][data-id="${userId("bob")}"]`)).toHaveCount(1)
await expect(composerEditable(alice.page)).toBeFocused()
const dmReplyBody = `dm swipe reply ${stamp}`
const dmReplyResponsePromise = alice.page.waitForResponse((response) => (
@@ -802,6 +806,7 @@ test("mobile reply, avatar mention, and typing rail keep exact backend and WS id
message: { id: string; content: string; replyToId: string | null }
}
expect(dmReplyPayload.message.replyToId).toBe(dmWsReadyId)
+ expect(dmReplyPayload.message.content).toBe(dmReplyBody)
await expect.poll(() => bobProxy.frames.some((frame) => (
frameHasMessage(frame, dmId, dmReplyPayload.message.id)
&& communityFrameEvents(frame).some((event) => (