Add DebugView component to show raw lore status data for visual verification that the data pipeline works end-to-end: - Frontend -> Tauri IPC -> Rust backend -> lore CLI -> parsed data New files: - src/components/DebugView.tsx - Debug component with health indicator - src/hooks/useLoreData.ts - TanStack Query hook for lore status - tests/components/DebugView.test.tsx - Component tests - tests/hooks/useLoreData.test.ts - Hook tests Modified: - src/App.tsx - Add QueryClientProvider wrapper - src/stores/nav-store.ts - Add 'debug' ViewId - src/components/AppShell.tsx - Add Debug nav tab and view routing - tests/components/AppShell.test.tsx - Update tests for new nav
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
/**
|
|
* Hook for fetching lore status data via Tauri IPC.
|
|
*
|
|
* Uses TanStack Query for caching and state management.
|
|
* The data can be refreshed via query invalidation when
|
|
* lore-data-changed events are received.
|
|
*/
|
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { getLoreStatus } from "@/lib/tauri";
|
|
import type { LoreStatus } from "@/lib/bindings";
|
|
|
|
export interface UseLoreDataResult {
|
|
data: LoreStatus | undefined;
|
|
isLoading: boolean;
|
|
error: Error | null;
|
|
refetch: () => void;
|
|
}
|
|
|
|
/**
|
|
* Fetch lore status data from the Tauri backend.
|
|
*
|
|
* Returns the current lore status including health, last sync time,
|
|
* and summary counts (open issues, authored MRs, reviewing MRs).
|
|
*/
|
|
export function useLoreData(): UseLoreDataResult {
|
|
const query = useQuery({
|
|
queryKey: ["lore-status"],
|
|
queryFn: async (): Promise<LoreStatus> => {
|
|
const result = await getLoreStatus();
|
|
|
|
if (result.status === "error") {
|
|
throw new Error(result.error.message);
|
|
}
|
|
|
|
return result.data;
|
|
},
|
|
refetchInterval: false, // Manual refetch on lore-data-changed
|
|
staleTime: 30_000, // Consider data fresh for 30 seconds
|
|
});
|
|
|
|
return {
|
|
data: query.data,
|
|
isLoading: query.isLoading,
|
|
error: query.error,
|
|
refetch: query.refetch,
|
|
};
|
|
}
|