fix(FN-000): scope dashboard project flows

This commit is contained in:
gsxdsm
2026-04-02 17:51:04 -07:00
parent bf12c22efb
commit 05f2114743
63 changed files with 1332 additions and 904 deletions

View File

@@ -21,7 +21,7 @@ function capLogEntries(entries: AgentLogEntry[]): AgentLogEntry[] {
* When `enabled` becomes false or the component unmounts, the EventSource
* is closed to avoid unnecessary SSE connections.
*/
export function useAgentLogs(taskId: string | null, enabled: boolean) {
export function useAgentLogs(taskId: string | null, enabled: boolean, projectId?: string) {
const [entries, setEntries] = useState<AgentLogEntry[]>([]);
const [loading, setLoading] = useState(false);
const eventSourceRef = useRef<EventSource | null>(null);
@@ -45,7 +45,7 @@ export function useAgentLogs(taskId: string | null, enabled: boolean) {
setLoading(true);
try {
const historical = await fetchAgentLogs(currentTaskId);
const historical = await fetchAgentLogs(currentTaskId, projectId);
if (cancelled) return;
setEntries(capLogEntries(historical));
} catch {
@@ -56,7 +56,8 @@ export function useAgentLogs(taskId: string | null, enabled: boolean) {
}
// Open SSE connection for live updates
const es = new EventSource(`/api/tasks/${currentTaskId}/logs/stream`);
const query = projectId ? `?projectId=${encodeURIComponent(projectId)}` : "";
const es = new EventSource(`/api/tasks/${currentTaskId}/logs/stream${query}`);
eventSourceRef.current = es;
es.addEventListener("agent:log", (e) => {
@@ -79,7 +80,7 @@ export function useAgentLogs(taskId: string | null, enabled: boolean) {
eventSourceRef.current = null;
}
};
}, [taskId, enabled]);
}, [taskId, enabled, projectId]);
const clear = useCallback(() => setEntries([]), []);