fix: subagent title extraction race condition

- Add 100ms debounce for new file detection to allow content to be written
- Add subagent:updated event for retroactive description updates
- Extract description in processEntry when first user message is processed
- Add extractDescriptionFromFile helper with retry in file change handler
- Update SubagentTranscriptEntry.content type to support string | array
- Add test coverage for subagent:updated event

Fixes 43% failure rate where subagents displayed raw IDs instead of descriptions
due to race condition when files were discovered before first line was written.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-25 19:49:58 +01:00
co-authored by Claude Opus 4.5
parent 87bdd9376c
commit c6b16bf815
6 changed files with 1928 additions and 59 deletions
+17
View File
@@ -1308,6 +1308,23 @@ class ClaudemanApp {
}
});
this.eventSource.addEventListener('subagent:updated', (e) => {
const data = JSON.parse(e.data);
const existing = this.subagents.get(data.agentId);
if (existing) {
// Merge updated fields (especially description)
Object.assign(existing, data);
this.subagents.set(data.agentId, existing);
} else {
this.subagents.set(data.agentId, data);
}
this.renderSubagentPanel();
// Update floating window if open
if (this.subagentWindows.has(data.agentId)) {
this.renderSubagentWindowContent(data.agentId);
}
});
this.eventSource.addEventListener('subagent:tool_call', (e) => {
const data = JSON.parse(e.data);
const activity = this.subagentActivity.get(data.agentId) || [];
+4
View File
@@ -303,6 +303,10 @@ export class WebServer extends EventEmitter {
this.broadcast('subagent:discovered', info);
});
subagentWatcher.on('subagent:updated', (info: SubagentInfo) => {
this.broadcast('subagent:updated', info);
});
subagentWatcher.on('subagent:tool_call', (data: SubagentToolCall) => {
this.broadcast('subagent:tool_call', data);
});