feat: Fix SEO agent behavior and add z.ai API validation
- Add "SEO-First" mode to prevent unwanted agent switching - SEO agent now stays locked and answers queries through SEO lens - Add [SUGGEST_AGENT:xxx] marker for smart agent suggestions - Add suggestion banner UI with Switch/Dismiss buttons - Prevent auto-switching mid-response - Add validateConnection() method to ZaiPlanService - Add debounced API key validation (500ms) in Settings - Add inline status indicators (valid/validating/error) - Add persistent validation cache (5min) in localStorage - Add "Test Connection" button for manual re-validation - Add clear error messages for auth failures - Add ApiValidationStatus interface - Add apiValidationStatus state for tracking connection states - Add setApiValidationStatus action - Real-time API key validation in Settings panel - Visual status indicators (✓/✗/🔄) - Agent suggestion banner with Switch/Dismiss actions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
21
lib/store.ts
21
lib/store.ts
@@ -10,6 +10,13 @@ interface AIAssistTab {
|
||||
showCanvas?: boolean;
|
||||
}
|
||||
|
||||
interface ApiValidationStatus {
|
||||
valid: boolean;
|
||||
error?: string;
|
||||
lastValidated?: number;
|
||||
models?: string[];
|
||||
}
|
||||
|
||||
interface AppState {
|
||||
currentPrompt: string;
|
||||
enhancedPrompt: string | null;
|
||||
@@ -29,6 +36,7 @@ interface AppState {
|
||||
selectedModels: Record<ModelProvider, string>;
|
||||
availableModels: Record<ModelProvider, string[]>;
|
||||
apiKeys: Record<ModelProvider, string>;
|
||||
apiValidationStatus: Record<ModelProvider, ApiValidationStatus>;
|
||||
qwenTokens?: {
|
||||
accessToken: string;
|
||||
refreshToken?: string;
|
||||
@@ -65,6 +73,7 @@ interface AppState {
|
||||
setSelectedModel: (provider: ModelProvider, model: string) => void;
|
||||
setAvailableModels: (provider: ModelProvider, models: string[]) => void;
|
||||
setApiKey: (provider: ModelProvider, key: string) => void;
|
||||
setApiValidationStatus: (provider: ModelProvider, status: ApiValidationStatus) => void;
|
||||
setQwenTokens: (tokens?: { accessToken: string; refreshToken?: string; expiresAt?: number } | null) => void;
|
||||
setGithubToken: (token: string | null) => void;
|
||||
setProcessing: (processing: boolean) => void;
|
||||
@@ -110,6 +119,11 @@ const useStore = create<AppState>((set) => ({
|
||||
zai: "",
|
||||
},
|
||||
githubToken: null,
|
||||
apiValidationStatus: {
|
||||
qwen: { valid: false },
|
||||
ollama: { valid: false },
|
||||
zai: { valid: false },
|
||||
},
|
||||
isProcessing: false,
|
||||
error: null,
|
||||
history: [],
|
||||
@@ -176,6 +190,13 @@ const useStore = create<AppState>((set) => ({
|
||||
set((state) => ({
|
||||
apiKeys: { ...state.apiKeys, [provider]: key },
|
||||
})),
|
||||
setApiValidationStatus: (provider, status) =>
|
||||
set((state) => ({
|
||||
apiValidationStatus: {
|
||||
...state.apiValidationStatus,
|
||||
[provider]: status,
|
||||
},
|
||||
})),
|
||||
setQwenTokens: (tokens) => set({ qwenTokens: tokens }),
|
||||
setGithubToken: (token) => set({ githubToken: token }),
|
||||
setProcessing: (processing) => set({ isProcessing: processing }),
|
||||
|
||||
Reference in New Issue
Block a user