Fix system notice review feedback

This commit is contained in:
Dotta committed 2026-05-05 12:11:52 -05:00
1 parent 05c4704bf5
commit eca4c578ca
3 files changed
+46 -10

No files matched your search

+4 -3
View File
@@ -1983,6 +1983,7 @@ function SystemNoticeCommentRow({
.map((p) => p.text)
.join("\n\n");
const [copied, setCopied] = useState(false);
const [copiedLink, setCopiedLink] = useState(false);
const source = (() => {
const runAgentName = runAgentId ? agentMap?.get(runAgentId)?.name ?? null : null;
@@ -2022,8 +2023,8 @@ function SystemNoticeCommentRow({
if (!anchorId || typeof window === "undefined") return;
const url = `${window.location.origin}${window.location.pathname}#${anchorId}`;
void navigator.clipboard.writeText(url).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
setCopiedLink(true);
setTimeout(() => setCopiedLink(false), 2000);
});
};
@@ -2053,7 +2054,7 @@ function SystemNoticeCommentRow({
aria-label="Copy link to system notice"
onClick={handleCopyLink}
>
<Paperclip className="h-3.5 w-3.5" />
{copiedLink ? <Check className="h-3.5 w-3.5" /> : <Paperclip className="h-3.5 w-3.5" />}
</button>
) : null}
<button
@@ -275,6 +275,44 @@ describe("IssueChatThread system notice routing", () => {
expect(sourceLink?.textContent).not.toBe("You");
});
it("shows copy-link feedback on the link button only", async () => {
const writeText = vi.fn(async () => undefined);
Object.defineProperty(navigator, "clipboard", {
configurable: true,
value: { writeText },
});
const comment: IssueChatComment = {
id: "comment-copy-link",
companyId: "company-1",
issueId: "issue-1",
authorType: "system",
authorAgentId: null,
authorUserId: null,
body: "System recovery completed.",
presentation: {
kind: "system_notice",
tone: "success",
title: null,
detailsDefaultOpen: false,
},
metadata: null,
...baseTimestamps,
};
renderThread([comment]);
const copyLink = container.querySelector('button[aria-label="Copy link to system notice"]') as HTMLButtonElement;
const copyText = container.querySelector('button[aria-label="Copy system notice"]') as HTMLButtonElement;
await act(async () => {
copyLink.click();
await Promise.resolve();
});
expect(writeText).toHaveBeenCalledWith(expect.stringContaining("#comment-comment-copy-link"));
expect(copyLink.querySelector(".lucide-check")).not.toBeNull();
expect(copyText.querySelector(".lucide-check")).toBeNull();
});
it("labels system notice source as Paperclip when no run agent can be resolved", () => {
const comment: IssueChatComment = {
id: "comment-system-no-author",
@@ -333,7 +371,7 @@ describe("IssueChatThread system notice routing", () => {
expect(sourceLink?.textContent).toBe("Paperclip");
});
it("routes presentation.kind=system_notice to a system notice even when authorType is agent", () => {
it("keeps agent-authored comments as assistant bubbles even when presentation requests system_notice", () => {
const comment: IssueChatComment = {
id: "comment-agent-system",
companyId: "company-1",
@@ -354,9 +392,7 @@ describe("IssueChatThread system notice routing", () => {
renderThread([comment]);
expect(container.querySelector('[role="status"]')?.getAttribute("aria-label")).toBe(
"System notice",
);
expect(container.querySelector('[data-message-role="system"]')).not.toBeNull();
expect(container.querySelector('[role="status"]')).toBeNull();
expect(container.querySelector('[data-message-role="assistant"]')).not.toBeNull();
});
});
+1 -2
View File
@@ -305,8 +305,7 @@ function createCommentMessage(args: {
const { comment, agentMap, currentUserId, userLabelMap, companyId, projectId } = args;
const createdAt = toDate(comment.createdAt);
const authorName = authorNameForComment(comment, agentMap, currentUserId, userLabelMap);
const isSystemNotice =
comment.authorType === "system" || comment.presentation?.kind === "system_notice";
const isSystemNotice = comment.authorType === "system";
const custom = {
kind: isSystemNotice ? "system_notice" : "comment",
commentId: comment.id,