refactor(phase-10): complete type safety enhancement
- Add types/api-responses.ts with ApiResponse<T>, PaginatedResponse<T> - Add types/errors.ts with comprehensive error type hierarchy - Replace all any usage (53 → 0, 100% reduction) - Add RawAPI response interfaces for type-safe mapping - Update catch blocks to use unknown with type narrowing - Add getState mock to chatStore tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -404,17 +404,18 @@ export const useChatStore = create<ChatState>()(
|
||||
m.id === assistantId ? { ...m, runId: result.runId } : m
|
||||
),
|
||||
}));
|
||||
} catch (err: any) {
|
||||
} catch (err: unknown) {
|
||||
// Gateway not connected — show error in the assistant bubble
|
||||
const errorMessage = err instanceof Error ? err.message : '无法连接 Gateway';
|
||||
set((state) => ({
|
||||
isStreaming: false,
|
||||
messages: state.messages.map((m) =>
|
||||
m.id === assistantId
|
||||
? {
|
||||
...m,
|
||||
content: `⚠️ ${err.message || '无法连接 Gateway'}`,
|
||||
content: `⚠️ ${errorMessage}`,
|
||||
streaming: false,
|
||||
error: err.message,
|
||||
error: errorMessage,
|
||||
}
|
||||
: m
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user