Feat/perf dashboard (#770)
This commit is contained in:
@@ -80,7 +80,7 @@ export const useChannelsStore = create<ChannelsState>((set, get) => ({
|
||||
} | null;
|
||||
}>>;
|
||||
channelDefaultAccountId?: Record<string, string>;
|
||||
}>('channels.status', { probe: true });
|
||||
}>('channels.status', { probe: false });
|
||||
if (data) {
|
||||
const channels: Channel[] = [];
|
||||
|
||||
|
||||
@@ -27,12 +27,19 @@ export const useCronStore = create<CronState>((set) => ({
|
||||
error: null,
|
||||
|
||||
fetchJobs: async () => {
|
||||
set({ loading: true, error: null });
|
||||
const currentJobs = useCronStore.getState().jobs;
|
||||
// Only show loading spinner when there's no data yet (stale-while-revalidate).
|
||||
if (currentJobs.length === 0) {
|
||||
set({ loading: true, error: null });
|
||||
} else {
|
||||
set({ error: null });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await hostApiFetch<CronJob[]>('/api/cron/jobs');
|
||||
set({ jobs: result, loading: false });
|
||||
} catch (error) {
|
||||
// Preserve previous jobs on error so the user sees stale data instead of nothing.
|
||||
set({ error: String(error), loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -171,7 +171,8 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch skills:', error);
|
||||
const appError = normalizeAppError(error, { module: 'skills', operation: 'fetch' });
|
||||
set({ loading: false, error: mapErrorCodeToSkillErrorKey(appError.code, 'fetch') });
|
||||
// Preserve previous skills on error (stale-while-revalidate).
|
||||
set((prev) => ({ loading: false, error: mapErrorCodeToSkillErrorKey(appError.code, 'fetch'), skills: prev.skills }));
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user