From ea755479f1a04ec4f750033148ea57fa735e2ef5 Mon Sep 17 00:00:00 2001 From: E66Crisp Date: Fri, 12 Dec 2025 16:41:21 +0800 Subject: [PATCH] refactor(confirmation): simplify approval type and tighten inject typing --- .../3.components/1.chatbot/confirmation.md | 17 +---------------- packages/elements/src/confirmation/context.ts | 17 +---------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/apps/www/content/3.components/1.chatbot/confirmation.md b/apps/www/content/3.components/1.chatbot/confirmation.md index d72a050..1107c6d 100644 --- a/apps/www/content/3.components/1.chatbot/confirmation.md +++ b/apps/www/content/3.components/1.chatbot/confirmation.md @@ -194,21 +194,6 @@ export type ToolUIPartApproval approved: boolean reason?: string } - | { - id: string - approved: true - reason?: string - } - | { - id: string - approved: true - reason?: string - } - | { - id: string - approved: false - reason?: string - } | undefined export interface ConfirmationContextValue { @@ -220,7 +205,7 @@ export const ConfirmationKey: InjectionKey = Symbol('ConfirmationContext') export function useConfirmationContext() { - const context = inject(ConfirmationKey, null) + const context = inject(ConfirmationKey) if (!context) throw new Error('Confirmation components must be used within ') return context diff --git a/packages/elements/src/confirmation/context.ts b/packages/elements/src/confirmation/context.ts index 0bb55d5..5b5ebbe 100644 --- a/packages/elements/src/confirmation/context.ts +++ b/packages/elements/src/confirmation/context.ts @@ -13,21 +13,6 @@ export type ToolUIPartApproval approved: boolean reason?: string } - | { - id: string - approved: true - reason?: string - } - | { - id: string - approved: true - reason?: string - } - | { - id: string - approved: false - reason?: string - } | undefined export interface ConfirmationContextValue { @@ -39,7 +24,7 @@ export const ConfirmationKey: InjectionKey = Symbol('ConfirmationContext') export function useConfirmationContext() { - const context = inject(ConfirmationKey, null) + const context = inject(ConfirmationKey) if (!context) throw new Error('Confirmation components must be used within ') return context