Repository navigation
fix(web): notify when delegated work settles, and name the asking subagent - #18
Merged
Merged
Conversation
…agent A coordinator that hands work to delegated tasks got "Thread completed" each time a task finished: the task's result commits before the parent's wake run exists, and in that gap the parent reads as done. When a completion was held by background work and that work ends, the notification gate now waits out the same grace a monitor wake gets (5 s, matching the push relay's completion confirmation). The wake run cancels it; if no wake follows, it notifies. A subagent's approval request now names the subagent and opens it, in web and desktop notifications and toasts and in mobile push. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A coordinator thread that hands work to
delegate_taskchildren got "Thread completed" (sound, desktop notification, toast) each time a child finished. A child's result commits before the parent's wake run exists. For that gap, usually tens of milliseconds, the parent has a completed run and nothing held, so the notification gate fires at once. The real completion comes after the wake run. Upstream reports the same gap in pingdotgg#31087, pingdotgg#31346 and pingdotgg#25585 (the case of an awaited command that wakes its agent).A subagent's approval request also notified with only the parent's title, and clicking it opened the parent.
What already worked, unchanged
subagenttask holds the parent's completion (backgroundWorkHoldsCompletion), so ending a turn with delegates still running does not notify.isShownUnderParent, and push skips them withisListedThreadLineage.Change
Completion after held work ends (web and desktop). The gate now records when the latest run's completion was being held. If the thread later becomes settled with that same completion, so held work ended and no new run started, the gate waits out the existing
RELEASED_COMPLETION_GRACE_MS(5 s) before notifying. Monitor wakes already use this grace. The wake run cancels it, and the wake's own completion then notifies right away as a fresh completion. If no wake follows, for example when a task is cancelled, the completion is announced 5 s late. Mobile push already holds every completion for 5 s (AgentAwarenessRelayconfirmation), so web/desktop and phones now use the same window.This is a client-side grace, not a server-side fact. The fork's shell has no "wake pending" field. The upstream server-side fixes are both still open: pingdotgg#31130 (L, changes every shell path in
ProjectionStore) and pingdotgg#31357 (one SQL branch that misses the memory shell path). The grace is cheaper and also covers awaited commands and other held work, which pingdotgg#31130 and pingdotgg#31357 don't. If one of them lands upstream, this rule still holds and simply fires less often.Subagent approvals. When the parent's attention comes from a descendant's approval or a side chat's question, the notification text is
<child title> (in <parent title>). Clicking the toast or desktop notification opens the child, which is where the parent's own "Open approval" button already goes. The child comes from the existingchildThreadInputsAtom, which also covers tasks delegated to linked environments. Mobile push carries the same thing:SubagentRequestAwarenessnow includes the asking child's id and title, and the parent's card says " needs approval." and deep-links to the child.The request text isn't included. The thread shell carries only the request kind, and fetching details for each notification would add a thread-detail subscription.
User docs (
thread-sidebar.md,mobile-notifications.md) now describe both behaviors.Checks
vp test run --project unit src/components/ThreadNotificationCoordinator.logic.test.ts(apps/web)vp test run src/relay/AgentAwarenessRelay.test.ts(apps/server)vp test run src/agentAwareness.test.ts(packages/shared)vp test run src/provider/AgentContextBudget.test.ts(apps/server)vp run typecheck(packages/shared, apps/web, apps/server)vp run check:changed greaber/grant/main: format, graphql, lint, knip, typecheck (35 packages)check:changedtest step /ThreadNotificationCoordinator.badge.browser.test.ts933dee7784. Other browser test files run. The new browser case (subagent approval named and opened) still needs a run🤖 Generated with Claude Code