Open History to see the last commit
1import {
2 codexFeedbackNotice,
3 type CodexFeedbackSubmission,
4} from "@t3tools/client-runtime/state/threads";
5import { MessageSquareIcon } from "lucide-react";
6
7import { writeTextToClipboard } from "../../hooks/useCopyToClipboard";
8import { Button } from "../ui/button";
9import { toastManager } from "../ui/toast";
10import type { ComposerBannerStackItem } from "./ComposerBannerStack";
11
12export function feedbackBannerItem(
13 submission: CodexFeedbackSubmission,
14 onDismiss: () => void,
15): ComposerBannerStackItem | null {
16 const notice = codexFeedbackNotice(submission);
17 if (!notice) return null;
18 return {
19 id: `feedback:${submission.id}`,
20 variant:
21 submission.status === "failed" ? "error" : submission.status === "sent" ? "success" : "info",
22 icon: <MessageSquareIcon />,
23 ...notice,
24 actions:
25 submission.status === "sent" ? (
26 <Button
27 size="xs"
28 variant="ghost"
29 onClick={() => {
30 void writeTextToClipboard(submission.feedbackId, "Codex feedback thread ID").catch(
31 (error: unknown) => {
32 toastManager.add({
33 type: "error",
34 title: "Could not copy thread ID",
35 description: error instanceof Error ? error.message : "An error occurred.",
36 });
37 },
38 );
39 }}
40 >
41 Copy ID
42 </Button>
43 ) : undefined,
44 ...(submission.status !== "uploading"
45 ? { dismissLabel: "Dismiss feedback notice", onDismiss }
46 : {}),
47 };
48}