fix(client): completed remote tasks stay grouped while their parent is offline #34237
main fromrefs/pull/34237/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- packages/client-runtime/src/state/threadShell.ts lines 684 to 686OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -670,10 +673,11 @@670673 for (const environmentId of environmentIds) {671674 for (const thread of get(environmentThreadsAtom(environmentId))) {672675 const parent = thread.delegatedFrom;673- if (674- parent !== undefined &&675- environmentIds.has(parent.environmentId) &&676- // An archived parent leaves navigation; its task there stays listed on its own.677- get(environmentThreadIndexAtom(parent.environmentId)).get(parent.threadId)?.archivedAt ===678- null679- ) {676+ if (parent === undefined || !environmentIds.has(parent.environmentId)) continue;677+ const parentThread = get(environmentThreadIndexAtom(parent.environmentId)).get(678+ parent.threadId,679+ );680+ // A missing parent in a cached shell does not prove its completed task is an orphan.681+ const awaitingParent =682+ parentThread === undefined &&683+ get(input.shellStatusAtom(parent.environmentId)) !== "live" &&
juliusmarminge added labelstakeover:in-progress
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -682,9 +688,14 @@682688 for (const thread of get(environmentThreadsAtom(environmentId))) {683689 const parent = thread.delegatedFrom;684- if (685- parent !== undefined &&686- environmentIds.has(parent.environmentId) &&687- // An archived parent leaves navigation; its task there stays listed on its own.688- get(environmentThreadIndexAtom(parent.environmentId)).get(parent.threadId)?.archivedAt ===689- null690- ) {690+ if (parent === undefined || !environmentIds.has(parent.environmentId)) continue;691+ const parentThread = get(environmentThreadIndexAtom(parent.environmentId)).get(692+ parent.threadId,693+ );694+ // A missing parent in a cached shell does not prove its completed task is an orphan.695+ const awaitingParent =696+ parentThread === undefined &&697+ get(input.shellStatusAtom(parent.environmentId)) !== "live" &&698+ !get(input.removedAtAtom(parent.environmentId)).has(parent.threadId) &&699+ thread.status === "completed" &&700+ thread.activeRunId === null &&701+ !isLiveSubagentShell(thread) &&
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelstakeover:needs-julius
juliusmarminge removed labelstakeover:in-progress
github-actions[bot](GitHub profile, opens in a new tab) added labelsneeds-rebase
github-actions[bot](GitHub profile, opens in a new tab) removed labelsneeds-rebase
Sign in to join this conversation.


No actionable comments were generated in the recent review.
Walkthrough
Shell state now records archive updates as thread removals. Delegated-task navigation grouping uses shell status and removal state to determine when a completed task with a missing parent appears.
Changes: Delegated Task Grouping
packages/client-runtime/src/state/shell.ts,packages/client-runtime/src/state/shell-sync.test.tspackages/client-runtime/src/state/threadShell.ts,packages/client-runtime/src/state/threadShell.test.tsapps/mobile/src/state/threads.ts,apps/web/src/state/threads.ts,apps/web/src/components/ThreadNotificationCoordinator.tsx,apps/web/src/components/ThreadNotificationCoordinator.badge.browser.test.ts,apps/mobile/src/state/use-composer-drafts.test.ts,apps/web/src/composerDraftStore.test.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers:
juliusmarmingeMerge Risk:
Minimal · up to
614d7Completed delegated tasks that still have running or busy child work stay visible while their parent is offline. Only quiet completed tasks are grouped under an unavailable parent. No concrete merge-blocking risk remains.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the main change: completed remote tasks stay grouped under their parent while the parent is offline. It follows the conventional commit form and matches the changeset, which adds a shared grouping rule for quiet completed tasks whose parent is missing from a non-live shell.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections, and each is filled in with specifics. The Problem section states the expected behavior and the reproduction context. The Change section explains the shared rule and the removal-marker handling. The Scope section links related issue
#30320and explains the obvious-bug exception. The Verification section gives commands, test counts, the tested head, and the limits of the testing, including what was not exercised (native mobile, packaged desktop). The description is long and includes some detail beyond the template, but it is complete. The template's Scope section asks for a link to the issue that shows the bug; the description links#30320as related rather than as the bug issue, which is a minor point.Finishing Touches
Generate unit tests (beta)
e463d511-9e43-4e91-8bc9-0d3734667207Reviewing files that changed from the base of the PR and between dd8a147dfaad6dde235c520133fb1b5bb413143b and 614d72ee165b9db90567e2246440bbdaf89febb1.
apps/web/src/components/ThreadNotificationCoordinator.badge.browser.test.tsapps/web/src/components/ThreadNotificationCoordinator.tsxpackages/client-runtime/src/state/threadShell.test.tspackages/client-runtime/src/state/threadShell.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.