The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { |
| 2 | codexFeedbackNotice, |
| 3 | type CodexFeedbackSubmission, |
| 4 | } from "@t3tools/client-runtime/state/threads"; |
| 5 | import { msg } from "gt-react"; |
| 6 | import { MessageSquareIcon } from "lucide-react"; |
| 7 | |
| 8 | import { writeTextToClipboard } from "../../hooks/useCopyToClipboard"; |
| 9 | import { m, type MessageResolver } from "../../i18n/messages"; |
| 10 | import { Button } from "../ui/button"; |
| 11 | import { toastManager } from "../ui/toast"; |
| 12 | import type { ComposerBannerStackItem } from "./ComposerBannerStack"; |
| 13 | |
| 14 | export function feedbackBannerItem( |
| 15 | submission: CodexFeedbackSubmission, |
| 16 | onDismiss: () => void, |
| 17 | resolve: MessageResolver = m, |
| 18 | ): ComposerBannerStackItem | null { |
| 19 | const notice = codexFeedbackNotice(submission, resolve); |
| 20 | if (!notice) return null; |
| 21 | return { |
| 22 | id: `feedback:${submission.id}`, |
| 23 | variant: |
| 24 | submission.status === "failed" ? "error" : submission.status === "sent" ? "success" : "info", |
| 25 | icon: <MessageSquareIcon />, |
| 26 | ...notice, |
| 27 | actions: |
| 28 | submission.status === "sent" ? ( |
| 29 | <Button |
| 30 | size="xs" |
| 31 | variant="ghost" |
| 32 | onClick={() => { |
| 33 | void writeTextToClipboard(submission.feedbackId, { |
| 34 | target: "Codex feedback thread ID", |
| 35 | unavailableMessage: msg( |
| 36 | "Clipboard API is unavailable while copying Codex feedback thread ID.", |
| 37 | ), |
| 38 | failureMessage: msg("Failed to copy Codex feedback thread ID to the clipboard."), |
| 39 | }).catch((error: unknown) => { |
| 40 | toastManager.add({ |
| 41 | type: "error", |
| 42 | title: m(msg("Could not copy thread ID")), |
| 43 | description: error instanceof Error ? error.message : m(msg("An error occurred.")), |
| 44 | }); |
| 45 | }); |
| 46 | }} |
| 47 | > |
| 48 | {resolve(msg("Copy ID"))} |
| 49 | </Button> |
| 50 | ) : undefined, |
| 51 | ...(submission.status !== "uploading" |
| 52 | ? { dismissLabel: resolve(msg("Dismiss feedback notice")), onDismiss } |
| 53 | : {}), |
| 54 | }; |
| 55 | } |