|
1 | 1 | import { AgentMonitorService } from './monitor.js'; |
| 2 | +import { AgentLoggerService } from './logger.js'; |
2 | 3 | import type { AgentStatus } from './types.js'; |
3 | 4 | import type { WorkflowEventEmitter } from '../../workflows/events/emitter.js'; |
4 | 5 | import type { ParsedTelemetry } from '../../shared/telemetry/index.js'; |
@@ -62,22 +63,27 @@ export class StatusService { |
62 | 63 | // Mark skipped by monitoring ID (for cleanup coordination) |
63 | 64 | async markSkipped(monitoringId: number): Promise<void> { |
64 | 65 | this.skippedIds.add(monitoringId); |
| 66 | + await AgentLoggerService.getInstance().flush(monitoringId); |
65 | 67 | await this.monitor.markSkipped(monitoringId); |
66 | 68 | this.emitStatus(monitoringId, 'skipped'); |
67 | 69 | } |
68 | 70 |
|
69 | 71 | // Status updates (DB + UI) |
| 72 | + // All status changes flush the log first to ensure data is readable |
70 | 73 | async complete(id: number, telemetry?: ParsedTelemetry): Promise<void> { |
| 74 | + await AgentLoggerService.getInstance().flush(id); |
71 | 75 | await this.monitor.complete(id, telemetry); |
72 | 76 | this.emitStatus(id, 'completed'); |
73 | 77 | } |
74 | 78 |
|
75 | 79 | async fail(id: number, error: Error | string): Promise<void> { |
| 80 | + await AgentLoggerService.getInstance().flush(id); |
76 | 81 | await this.monitor.fail(id, error); |
77 | 82 | this.emitStatus(id, 'failed'); |
78 | 83 | } |
79 | 84 |
|
80 | 85 | async pause(id: number): Promise<void> { |
| 86 | + await AgentLoggerService.getInstance().flush(id); |
81 | 87 | await this.monitor.markPaused(id); |
82 | 88 | this.emitStatus(id, 'paused'); |
83 | 89 | } |
|
0 commit comments