mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 12:39:42 +02:00
perf: fix memory leaks — strip task outputs from SSE broadcasts, use light state everywhere
- TaskTracker.getTaskTreeLight(): strips large `output` strings from tasks in SSE broadcasts (was serializing 5-10MB every 500ms with many subagents) - session:created broadcasts now use toLightDetailedState() (consistent with session:updated which already did) - GET /api/sessions/:id returns light state (no 2-3MB terminal+text buffers) - Ralph wizard polls /terminal?tail=2048 instead of full session endpoint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -547,6 +547,27 @@ export class TaskTracker extends EventEmitter {
|
||||
return rootTasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lightweight task tree for SSE broadcasts — strips large `output` strings
|
||||
* to avoid serializing 5-10MB of task results every 500ms.
|
||||
* Full task details available via getTaskTree().
|
||||
*
|
||||
* @returns Array of root tasks with output truncated to 200 chars
|
||||
*/
|
||||
getTaskTreeLight(): Omit<BackgroundTask, 'output'>[] {
|
||||
const rootTasks: Omit<BackgroundTask, 'output'>[] = [];
|
||||
|
||||
for (const task of this.tasks.values()) {
|
||||
if (!task.parentId) {
|
||||
// Strip output to avoid serializing large strings on every broadcast
|
||||
const { output: _output, ...lightTask } = task;
|
||||
rootTasks.push(lightTask);
|
||||
}
|
||||
}
|
||||
|
||||
return rootTasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all tasks as a flat Map.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user