This commit is contained in:
2025-08-31 17:01:07 -04:00
parent 66b114f374
commit e3e6a4460b
11 changed files with 600 additions and 101 deletions

View File

@ -156,17 +156,24 @@ export const ExecutionModal: React.FC<ExecutionModalProps> = ({
const loadLogs = async (executionId: string) => {
try {
console.debug(`[ExecutionModal] Loading logs for execution ${executionId}`);
setLoadingLogs(true);
const response = await executionApi.getLogs(executionId);
console.debug(`[ExecutionModal] Loaded logs for execution ${executionId}:`, {
logCount: response.data.logs?.length || 0,
logs: response.data.logs
});
setLogs(response.data.logs || []);
} catch (error) {
console.error('Error loading logs:', error);
console.error(`[ExecutionModal] Error loading logs for execution ${executionId}:`, error);
} finally {
setLoadingLogs(false);
}
};
const startLogsAutoRefresh = (executionId: string) => {
console.debug(`[ExecutionModal] Starting auto-refresh for execution ${executionId}`);
// Clear any existing interval
if (logsPollIntervalRef.current) {
clearInterval(logsPollIntervalRef.current);
@ -180,10 +187,15 @@ export const ExecutionModal: React.FC<ExecutionModalProps> = ({
// Set up auto-refresh every 2 seconds
logsPollIntervalRef.current = setInterval(async () => {
try {
console.debug(`[ExecutionModal] Auto-refreshing logs for execution ${executionId}`);
const response = await executionApi.getLogs(executionId);
console.debug(`[ExecutionModal] Auto-refresh got logs for execution ${executionId}:`, {
logCount: response.data.logs?.length || 0,
logs: response.data.logs
});
setLogs(response.data.logs || []);
} catch (error) {
console.error('Error auto-refreshing logs:', error);
console.error(`[ExecutionModal] Error auto-refreshing logs for execution ${executionId}:`, error);
}
}, 2000);
};

View File

@ -75,8 +75,21 @@ export const executionApi = {
cancel: (id: string) =>
api.delete(`/executions/${id}`),
getLogs: (id: string) =>
api.get<{ logs: string[] }>(`/executions/${id}/logs`),
getLogs: (id: string) => {
console.debug(`[API] Fetching logs for execution ${id}`);
return api.get<{ logs: string[] }>(`/executions/${id}/logs`)
.then(response => {
console.debug(`[API] Successfully fetched logs for execution ${id}:`, {
logCount: response.data.logs?.length || 0,
logs: response.data.logs
});
return response;
})
.catch(error => {
console.error(`[API] Failed to fetch logs for execution ${id}:`, error);
throw error;
});
},
getRunning: () =>
api.get<{ executions: FunctionExecution[]; count: number }>('/executions/running'),