Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 不能引用的消息行「回复」继续插入消息链接

zqchris4256bc7579ef
diff --git a/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx b/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx
index 301f9b77a6..9faa04a3a5 100644
--- a/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx
+++ b/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx
@@ -626,4 +626,20 @@ describe("companion menu with a screen reader", () => {
h.unmount();
}
});
+
+ it("keeps inserting the link from rows that cannot be quoted", () => {
+ const onQuote = vi.fn();
+ const onAddMessageToComposer = vi.fn();
+ const h = mount([{ ...msg("e1", "Boom", { turnCompleted: true }), role: "error" }], {
+ companion: true,
+ companionQuote: { names: { owner: "你", companion: "Vela" }, showReplyTargets: false, onQuote, onLocate: vi.fn(), onSelectText: vi.fn() },
+ onAddMessageToComposer,
+ });
+ try {
+ const reply = h.host.querySelector('[data-testid="companion.messageReply"]')!;
+ act(() => reply.dispatchEvent(new MouseEvent("click", { bubbles: true })));
+ expect(onQuote).not.toHaveBeenCalled();
+ expect(onAddMessageToComposer).toHaveBeenCalledExactlyOnceWith("e1");
+ } finally { h.unmount(); }
+ });
});
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index 32b82de712..5813ff8ae2 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -4198,7 +4198,9 @@ function MessageBubble({
...(absoluteTime ? [{ id: 'time', title: t('message.renderer.sentTime', { time: absoluteTime }), disabled: true }] : []),
]}
onAction={id => {
- if (id === 'add-to-chat' && companionQuote) selectCompanionMenuAction('reply');
+ // Reply quotes what can be quoted; other rows (errors, system cards) keep inserting their link.
+ const quote = id === 'add-to-chat' && companionQuote ? companionReplyQuoteFor(item.message) : null;
+ if (quote) companionQuote?.onQuote(quote);
else if (id === 'copy') selectControlAction(id);
else if (id === 'share') actions.onEnterShareSelection?.(clientId);
else if (messageMenu.some(item => item.id === id)) selectMenuAction(id as MobileMessageMenuActionId);