Files
fusion/packages/dashboard/app/hooks/useSessionFiles.ts
gsxdsm 753f2561cd feat(FN-947): show files-changed on done column task cards
- Extend useSessionFiles hook to fetch files for done column tasks
- Update TaskCard to display files-changed indicator on done column cards
- Add tests for useSessionFiles done column support
- Add tests for TaskCard files-changed display in done column
2026-04-04 18:54:13 -07:00

47 lines
1.1 KiB
TypeScript

import { useEffect, useState } from "react";
import { fetchSessionFiles } from "../api";
const ACTIVE_COLUMNS = new Set(["in-progress", "in-review", "done"]);
interface UseSessionFilesResult {
files: string[];
loading: boolean;
}
export function useSessionFiles(taskId: string, worktree: string | undefined, column: string, projectId?: string): UseSessionFilesResult {
const [files, setFiles] = useState<string[]>([]);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (!taskId || !worktree || !ACTIVE_COLUMNS.has(column)) {
setFiles([]);
setLoading(false);
return;
}
let cancelled = false;
async function load() {
setLoading(true);
try {
const result = await fetchSessionFiles(taskId, projectId);
if (!cancelled) {
setFiles(result);
}
} catch {
if (!cancelled) {
setFiles([]);
}
} finally {
if (!cancelled) {
setLoading(false);
}
}
}
void load();
}, [taskId, worktree, column, projectId]);
return { files, loading };
}