From 9d1cf89532f7a6f364e5cb456935c88f66fb2081 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Sat, 17 Jan 2026 10:09:43 +0800 Subject: [PATCH] chore: remove unused components --- .../components/ai-elements/confirmation.tsx | 182 ------------------ .../components/ai-elements/prompt-input.tsx | 2 +- frontend/src/components/ai-elements/tool.tsx | 165 ---------------- 3 files changed, 1 insertion(+), 348 deletions(-) delete mode 100644 frontend/src/components/ai-elements/confirmation.tsx delete mode 100644 frontend/src/components/ai-elements/tool.tsx diff --git a/frontend/src/components/ai-elements/confirmation.tsx b/frontend/src/components/ai-elements/confirmation.tsx deleted file mode 100644 index 1cd9b7f..0000000 --- a/frontend/src/components/ai-elements/confirmation.tsx +++ /dev/null @@ -1,182 +0,0 @@ -"use client"; - -import { Alert, AlertDescription } from "@/components/ui/alert"; -import { Button } from "@/components/ui/button"; -import { cn } from "@/lib/utils"; -import type { ToolUIPart } from "ai"; -import { - type ComponentProps, - createContext, - type ReactNode, - useContext, -} from "react"; - -type ToolUIPartApproval = - | { - id: string; - approved?: never; - reason?: never; - } - | { - id: string; - approved: boolean; - reason?: string; - } - | { - id: string; - approved: true; - reason?: string; - } - | { - id: string; - approved: true; - reason?: string; - } - | { - id: string; - approved: false; - reason?: string; - } - | undefined; - -type ConfirmationContextValue = { - approval: ToolUIPartApproval; - state: ToolUIPart["state"]; -}; - -const ConfirmationContext = createContext( - null -); - -const useConfirmation = () => { - const context = useContext(ConfirmationContext); - - if (!context) { - throw new Error("Confirmation components must be used within Confirmation"); - } - - return context; -}; - -export type ConfirmationProps = ComponentProps & { - approval?: ToolUIPartApproval; - state: ToolUIPart["state"]; -}; - -export const Confirmation = ({ - className, - approval, - state, - ...props -}: ConfirmationProps) => { - if (!approval || state === "input-streaming" || state === "input-available") { - return null; - } - - return ( - - - - ); -}; - -export type ConfirmationTitleProps = ComponentProps; - -export const ConfirmationTitle = ({ - className, - ...props -}: ConfirmationTitleProps) => ( - -); - -export type ConfirmationRequestProps = { - children?: ReactNode; -}; - -export const ConfirmationRequest = ({ children }: ConfirmationRequestProps) => { - const { state } = useConfirmation(); - - // Only show when approval is requested - // @ts-expect-error state only available in AI SDK v6 - if (state !== "approval-requested") { - return null; - } - - return children; -}; - -export type ConfirmationAcceptedProps = { - children?: ReactNode; -}; - -export const ConfirmationAccepted = ({ - children, -}: ConfirmationAcceptedProps) => { - const { approval, state } = useConfirmation(); - - // Only show when approved and in response states - if ( - !approval?.approved || - // @ts-expect-error state only available in AI SDK v6 - (state !== "approval-responded" && - // @ts-expect-error state only available in AI SDK v6 - state !== "output-denied" && - state !== "output-available") - ) { - return null; - } - - return children; -}; - -export type ConfirmationRejectedProps = { - children?: ReactNode; -}; - -export const ConfirmationRejected = ({ - children, -}: ConfirmationRejectedProps) => { - const { approval, state } = useConfirmation(); - - // Only show when rejected and in response states - if ( - approval?.approved !== false || - // @ts-expect-error state only available in AI SDK v6 - (state !== "approval-responded" && - // @ts-expect-error state only available in AI SDK v6 - state !== "output-denied" && - state !== "output-available") - ) { - return null; - } - - return children; -}; - -export type ConfirmationActionsProps = ComponentProps<"div">; - -export const ConfirmationActions = ({ - className, - ...props -}: ConfirmationActionsProps) => { - const { state } = useConfirmation(); - - // Only show when approval is requested - // @ts-expect-error state only available in AI SDK v6 - if (state !== "approval-requested") { - return null; - } - - return ( -
- ); -}; - -export type ConfirmationActionProps = ComponentProps; - -export const ConfirmationAction = (props: ConfirmationActionProps) => ( -