Skip to content

fix(web): notify when delegated work settles, and name the asking subagent - #18

Merged
greaber merged 1 commit into
grant/mainfrom
grant/notify-when-work-settles
Nov 19, 2026
Merged

greaber merged 1 commit into
grant/mainfrom
grant/notify-when-work-settles

Conversation

@greaber

@greaber greaber commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Problem

A coordinator thread that hands work to delegate_task children 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

  • While a delegated child runs, its subagent task holds the parent's completion (backgroundWorkHoldsCompletion), so ending a turn with delegates still running does not notify.
  • Subagent threads never send their own notifications. Web skips them with isShownUnderParent, and push skips them with isListedThreadLineage.
  • A child's question goes to the parent agent, which answers it, so it doesn't notify the user (upstream fix(client-runtime): keep subagent questions off parent threads pingdotgg/t3code#26367). If the parent can't answer, it asks the user itself, and that request notifies.
  • A child's failure or usage limit goes back to the parent as its result, and the parent's wake run handles it. It stays quiet. If the parent then fails or stops on its own limit, that notifies.

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 (AgentAwarenessRelay confirmation), 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 existing childThreadInputsAtom, which also covers tasks delegated to linked environments. Mobile push carries the same thing: SubagentRequestAwareness now 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

Command SHA Result
vp test run --project unit src/components/ThreadNotificationCoordinator.logic.test.ts (apps/web) a682908 pass, 10/10. The new case fails without the gate change
vp test run src/relay/AgentAwarenessRelay.test.ts (apps/server) a682908 pass, 19/19. The new assertions fail without the change
vp test run src/agentAwareness.test.ts (packages/shared) a682908 pass, 26/26
vp test run src/provider/AgentContextBudget.test.ts (apps/server) a682908 pass
vp run typecheck (packages/shared, apps/web, apps/server) a682908 pass
vp run check:changed greaber/grant/main: format, graphql, lint, knip, typecheck (35 packages) a682908 pass
check:changed test step / ThreadNotificationCoordinator.badge.browser.test.ts a682908 did not finish: hangs on this machine and also hangs unchanged on 933dee7784. Other browser test files run. The new browser case (subagent approval named and opened) still needs a run

🤖 Generated with Claude Code

…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>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Nov 19, 2026
@greaber
greaber merged commit e3a4522 into grant/main Nov 19, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant