From 3b0ab1a7b77b01112de0d0bba82f6c2f27e1d16e Mon Sep 17 00:00:00 2001 From: iven Date: Sun, 5 Apr 2026 01:30:29 +0800 Subject: [PATCH] fix(types): Desktop type safety hardening (TYPE-01) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Unify ConnectionState: kernel-types.ts now canonical source with 'handshaking', gateway-types.ts re-exports - PromptTemplateInfo source/status → union literals - PromptVariable.type → union literal - CreateRoleRequest id/permissions → optional - PropertyPanel: replace 13 as any with typed accessor pattern - chatStore: window cast via as unknown as Record --- .../WorkflowBuilder/PropertyPanel.tsx | 35 +++++++++++-------- desktop/src/lib/gateway-types.ts | 4 +-- desktop/src/lib/kernel-types.ts | 2 +- desktop/src/lib/saas-types.ts | 10 +++--- desktop/src/store/chatStore.ts | 2 +- docs/features/AUDIT_TRACKER.md | 5 +-- 6 files changed, 32 insertions(+), 26 deletions(-) diff --git a/desktop/src/components/WorkflowBuilder/PropertyPanel.tsx b/desktop/src/components/WorkflowBuilder/PropertyPanel.tsx index f60095e..9057ed1 100644 --- a/desktop/src/components/WorkflowBuilder/PropertyPanel.tsx +++ b/desktop/src/components/WorkflowBuilder/PropertyPanel.tsx @@ -87,8 +87,13 @@ function renderTypeSpecificFields( data: Partial, onChange: (field: string, value: unknown) => void ) { - // Type-safe property accessor for union-typed node data + // Type-safe property accessors for union-typed node data const d = data as Record; + const str = (key: string): string => (d[key] as string) || ''; + const num = (key: string): number | string => (d[key] as number) ?? ''; + const bool = (key: string): boolean => (d[key] as boolean) || false; + const arr = (key: string): string[] => (d[key] as string[]) || []; + const obj = (key: string): Record => (d[key] as Record) || {}; switch (type) { case 'input': return ( @@ -99,7 +104,7 @@ function renderTypeSpecificFields( onChange('variableName', e.target.value)} className="w-full px-3 py-2 border border-gray-300 rounded-lg font-mono" /> @@ -109,7 +114,7 @@ function renderTypeSpecificFields( Default Value