Retain native task identity across partial progress notifications

This commit is contained in:
2026-11-07 16:23:49 +00:00
parent b15597662f
commit f3a39a5e33
2 changed files with 16 additions and 1 deletions
+3 -1
View File
@@ -58,7 +58,9 @@ func (h *host) trackTasksLocked(line []byte) {
delete(h.taskOrigins, fallback)
}
}
h.tasks[id] = event.TaskID
if _, exists := h.tasks[id]; !exists || event.TaskID != "" {
h.tasks[id] = event.TaskID
}
origin := h.taskOrigins[id]
if event.ToolUseID != "" {
origin.ToolUseID = event.ToolUseID
+13
View File
@@ -31,6 +31,19 @@ func TestNativeTaskSnapshotOutlivesForegroundAndSpool(t *testing.T) {
}
}
func TestNativeTaskProgressWithoutIDRetainsCompletionAssociation(t *testing.T) {
h := &host{}
h.trackTasksLocked([]byte(`{"type":"system","subtype":"task_started","tool_use_id":"tool","task_id":"native"}`))
h.trackTasksLocked([]byte(`{"type":"system","subtype":"task_progress","tool_use_id":"tool"}`))
if h.tasks["tool"] != "native" {
t.Fatal("progress erased native identity")
}
h.trackTasksLocked([]byte(`{"type":"system","subtype":"task_notification","task_id":"native","status":"completed"}`))
if len(h.tasks) != 0 {
t.Fatal("native completion did not clear running membership")
}
}
func TestNativeTaskAliasesAndTextCompletion(t *testing.T) {
h := &host{}
h.trackTasksLocked([]byte(`{"type":"system","subtype":"task_progress","task_id":"native-agent"}`))