misc: improve timeout handling and warnings in skills (#211)

This commit is contained in:
Felix
2026-02-28 10:16:36 +08:00
committed by GitHub
Unverified
parent 538d285c71
commit d4f77a442c
6 changed files with 79 additions and 13 deletions

View File

@@ -142,7 +142,13 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
set({ skills: combinedSkills, loading: false });
} catch (error) {
console.error('Failed to fetch skills:', error);
set({ loading: false });
let errorMsg = error instanceof Error ? error.message : String(error);
if (errorMsg.includes('Timeout')) {
errorMsg = 'timeoutError';
} else if (errorMsg.toLowerCase().includes('rate limit')) {
errorMsg = 'rateLimitError';
}
set({ loading: false, error: errorMsg });
}
},
@@ -153,6 +159,12 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
if (result.success) {
set({ searchResults: result.results || [] });
} else {
if (result.error?.includes('Timeout')) {
throw new Error('searchTimeoutError');
}
if (result.error?.toLowerCase().includes('rate limit')) {
throw new Error('searchRateLimitError');
}
throw new Error(result.error || 'Search failed');
}
} catch (error) {
@@ -167,6 +179,12 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
try {
const result = await window.electron.ipcRenderer.invoke('clawhub:install', { slug, version }) as { success: boolean; error?: string };
if (!result.success) {
if (result.error?.includes('Timeout')) {
throw new Error('installTimeoutError');
}
if (result.error?.toLowerCase().includes('rate limit')) {
throw new Error('installRateLimitError');
}
throw new Error(result.error || 'Install failed');
}
// Refresh skills after install