fix: list Claude background tasks from the snapshot instead of guessing (#2177)

* fix: list Claude background tasks from the snapshot instead of guessing

The status panel only had a count from `background_tasks_changed` and
reconstructed commands by regex-matching Bash results in loaded chat
history, so tasks whose start message was unloaded, auto-backgrounded
("moved to the background (ID: …)"), or non-Bash showed
"N running · exact command unavailable".

The hub now keeps the snapshot's tasks (id, type, description) on the
session alongside the count. The web panel lists them directly, using
the exact task ID to look up the Bash command when loaded and the
snapshot description otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(web): only attribute a Bash command from its background launch result

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(native): accept backgroundTasks in strict session patch decoders

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SSU-WEI HUANG
2026-10-28 12:12:41 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 40070a56db
commit fe2fbb881d
24 changed files with 160 additions and 195 deletions
+11
View File
@@ -336,6 +336,15 @@ export const DecryptedMessageSchema = z.object({
export type DecryptedMessage = z.infer<typeof DecryptedMessageSchema>
// One entry of Claude's `system/background_tasks_changed` snapshot.
export const BackgroundTaskSchema = z.object({
id: z.string(),
type: z.string(),
description: z.string()
})
export type BackgroundTask = z.infer<typeof BackgroundTaskSchema>
export const SessionSchema = z.object({
hasConversationContent: z.boolean().optional(),
id: z.string(),
@@ -356,6 +365,7 @@ export const SessionSchema = z.object({
thinkingAt: z.number(),
activeTurnStartedAt: z.number().nullable().optional(),
backgroundTaskCount: z.number().optional(),
backgroundTasks: z.array(BackgroundTaskSchema).optional(),
todos: TodosSchema.optional(),
teamState: TeamStateSchema.optional(),
// Watermarks for structured SSE patches (PR #897). Dual EventSource
@@ -430,6 +440,7 @@ export const SessionPatchSchema = z.object({
collaborationMode: CodexCollaborationModeSchema.optional(),
copilotAgentMode: CopilotAgentModeSchema.optional(),
backgroundTaskCount: z.number().optional(),
backgroundTasks: z.array(BackgroundTaskSchema).optional(),
// tiann/hapi#893 (scratchlist v2). Bumped whenever any entry on the
// session_scratchlist table mutates. Web client uses the change as a
// trigger to refetch the entries query - the timestamp itself is the
+1
View File
@@ -3,6 +3,7 @@ export type {
AgentStateCompletedRequest,
AgentStateRequest,
AttachmentMetadata,
BackgroundTask,
DecryptedMessage,
Metadata,
Machine,