|
1 | 1 | import { useAuthStore } from "@features/auth/stores/authStore"; |
2 | 2 | import { usePanelLayoutStore } from "@features/panels/store/panelLayoutStore"; |
3 | 3 | import { useSettingsStore } from "@features/settings/stores/settingsStore"; |
4 | | -import { type AgentEvent, parseAgentEvents } from "@posthog/agent"; |
| 4 | +import type { AgentEvent } from "@posthog/agent"; |
5 | 5 | import { track } from "@renderer/lib/analytics"; |
6 | 6 | import { logger } from "@renderer/lib/logger"; |
7 | 7 | import { queryClient } from "@renderer/lib/queryClient"; |
@@ -83,30 +83,12 @@ const toClarifyingQuestions = ( |
83 | 83 | }; |
84 | 84 |
|
85 | 85 | /** |
86 | | - * Fetch logs from S3 log URL via main process to avoid CORS issues |
87 | | - * S3 stores AgentEvent objects as newline-delimited JSON |
| 86 | + * Fetch logs from S3 log URL via main process |
| 87 | + * Main process handles parsing and validation |
88 | 88 | */ |
89 | 89 | async function fetchLogsFromS3Url(logUrl: string): Promise<AgentEvent[]> { |
90 | 90 | try { |
91 | | - const content = await window.electronAPI?.fetchS3Logs(logUrl); |
92 | | - |
93 | | - if (!content || !content.trim()) { |
94 | | - return []; |
95 | | - } |
96 | | - |
97 | | - const rawEntries = content |
98 | | - .trim() |
99 | | - .split("\n") |
100 | | - .map((line: string) => { |
101 | | - try { |
102 | | - return JSON.parse(line); |
103 | | - } catch { |
104 | | - return null; |
105 | | - } |
106 | | - }) |
107 | | - .filter(Boolean); |
108 | | - |
109 | | - return parseAgentEvents(rawEntries); |
| 91 | + return (await window.electronAPI?.fetchS3Logs(logUrl)) ?? []; |
110 | 92 | } catch (err) { |
111 | 93 | log.warn("Failed to fetch task logs from S3", err); |
112 | 94 | return []; |
@@ -385,9 +367,9 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()( |
385 | 367 | } |
386 | 368 | }; |
387 | 369 |
|
388 | | - // Poll immediately, then every 2 seconds |
| 370 | + // Poll immediately, then every 500ms |
389 | 371 | void poll(); |
390 | | - const poller = setInterval(() => void poll(), 2000); |
| 372 | + const poller = setInterval(() => void poll(), 500); |
391 | 373 | store.updateTaskState(taskId, { logPoller: poller }); |
392 | 374 | }, |
393 | 375 |
|
|
0 commit comments