fix(web): "Thread completed" alerts arrive with the thread, not 2 seconds before it #38318
main fromrefs/pull/38318/head·opened View on GitHubProblem#
"Thread completed" (toast, sound, desktop notification) fires about 2 seconds before the thread shows up in the sidebar. Until then the thread is still tucked under Working, so the alert names something you can't see yet. A thread that starts working again right away still announces as done.
The sidebar holds a finished thread in Working for 2 s (#24760). Alerts used to wait the same 2 s, and #29146 removed the wait from alerts only.
Change#
- Completion alerts wait the same hold as the sidebar, so both land together.
- The hold drops from 2 s to 0.7 s. Mobile shares the constant, so its list gets the shorter hold too.
- A thread that continues or asks for input inside the hold no longer announces as done.
Scope#
#29146 dropped the alert wait on purpose, because a 2 s late sound felt slow. This keeps most of that speed (0.7 s instead of 2 s) and makes the alert match what the sidebar shows. Two source files change; the rest is tests.
Verification#
Real web client, Replay provider, 5 runs before and 6 after:
| Toast after the run ends | Thread in the inbox after the run ends | Gap | |
|---|---|---|---|
| Before | ~0.5 s | ~2.5 s | 2.01 s (2,009 to 2,013 ms) |
| After | ~1.3 s | ~1.3 s | 0.03 s (26 to 39 ms) |
https://github.com/user-attachments/assets/06d365dd-ec7b-493a-9768-4853a74f2730
Why 0.7 s. In my own history, 94 of 9,756 completed runs (1%) were followed by a new run within 2 s. All 94 were started by an agent or the server, none typed by a person.
| Hold | Follow-ups it still catches | Wait on every other finish |
|---|---|---|
| 0.5 s | 45 of 94 | 0.5 s |
| 0.7 s | 54 of 94 | 0.7 s |
| 1.0 s | 66 of 94 | 1.0 s |
| 2.0 s (main) | 94 of 94 | 2.0 s |
The 40 runs that 0.7 s no longer catches (0.4%) show in the inbox briefly and hop back to Working. On main those same runs already sent a wrong "Thread completed".
Happy to keep the hold at 2 s instead if you prefer. That is a one-line change to WORKING_EXIT_GRACE_MS, and alerts would still land with the sidebar.
Tests. The new gate tests fail on main and pass here: a run that continues inside the hold, a request inside the hold, and a held alert that survives a reconnect. vp run check:changed passes.
Not checked. How long server auto-settle takes after a run ends (the stored settle time is back-dated to the run's finish). A run's end queues that thread's settle check right away, and a PR merged from the thread is already synced by then. A settle that needs a fresh host lookup could still land after 0.7 s, and that thread would show in the inbox first. Not run on a native mobile client.
Council review#
Rounds: 2
| Delegate | Round 1 | Round 2 |
|---|---|---|
| Claude Opus 5.5 | 8/10 | 9/10 |
| GPT-6.1 Sol | 9/10 | 9/10 |
Unavailable: GLM-5.3 Flash and DeepSeek V4.1 Flash (OpenCode's free models did not respond in either round).
Created with Claude Fable 5.2 in Claude Code through T3 Code.
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -289,3 +291,4 @@289291 latestTurn: { turnId: "turn", state: "completed", completedAt: "2026-09-13T07:00:01.000Z" },290292 }),291293 );294+ expect(TestNotification.sent).toEqual([]);
components/ThreadNotificationCoordinator.badge.browser.test.ts:294The gate unit test already checks that completion is withheld during the grace, so this repeats the timing case in the browser wrapper. Could you keep that check at the unit layer?
Suggested change294- expect(TestNotification.sent).toEqual([]);No longer relevant as of 60f2fa2e79a7c9d2d008edf42a78c828af5663ca
Note
🤖 Claude Opus 5.5 responding on behalf of notkainoa
Fixed in 60f2fa2e79. The "nothing sent before the grace" check now lives only in the gate unit tests. The browser test still advances the grace and checks that the notification and sound arrive.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — Completion alerts now wait for the Working-shelf transition, whose built-in delay drops from 2 seconds to 700 ms. Human review is required to accept this change to default user-visible timing.
Notes:
- No code objects were reviewed. Approvability was decided on eligibility alone.
No actionable comments were generated in the recent review.
Walkthrough
-
The Working-shelf grace period changes from 2,000 ms to 700 ms. Ordinary completion notifications now wait for that grace period. The notification gate preserves pending durations across pauses and suppresses a pending completion if a request arrives during the grace period.
Changes: Working-exit grace and completion alerts
Layer / File(s) Summary Set the shared Working-exit grace
packages/client-runtime/src/state/threadInbox.ts,packages/client-runtime/src/state/threadInbox.test.ts,apps/mobile/src/features/threads/threadListV2.test.tsWORKING_EXIT_GRACE_MSis exported and reduced to 700 ms. Inbox and mobile tests use the constant for grace boundaries and return timestamps.Apply grace periods in the notification gate
apps/web/src/components/ThreadNotificationCoordinator.logic.tsOrdinary completion alerts use the Working-exit grace. Wake completions retain their separate grace. The gate preserves pending durations across pauses and marks pending completions handled when a request arrives during the grace. Verify completion-alert timing and suppression
apps/web/src/components/ThreadNotificationCoordinator.logic.test.ts,apps/web/src/components/ThreadNotificationCoordinator.badge.browser.test.tsTests cover delayed alerts, resumed runs, attention, snoozes, pauses, and browser notification timing across reconnect and offline scenarios. Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant ThreadNotificationCoordinator participant CompletionGate participant GraceTimer participant Notification ThreadNotificationCoordinator->>CompletionGate: Observe completed run CompletionGate->>GraceTimer: Schedule Working-exit grace alt Run resumes during grace ThreadNotificationCoordinator->>CompletionGate: Observe request CompletionGate->>CompletionGate: Mark pending completion handled GraceTimer-->>CompletionGate: Grace expires else Run stays completed GraceTimer-->>CompletionGate: Grace expires CompletionGate->>Notification: Emit completion alert endPossibly related issues
- pingdotgg/t3code#25585: The changes address the shared completion-alert gate, but do not cover the issue’s long background-command waits.
- pingdotgg/t3code#31087: The delay and suppression during the grace period address the reported alert gap between a delegate finishing and a parent run starting.
- pingdotgg/t3code#31346: The suppression applies to the same completion-alert path, but the specific wake-handoff fix is not part of these changes.
Suggested reviewers:
juliusmarminge,t3dotgg,yash-singh1
Merge Risk:
Minimal · up to60f2f-
Completion alerts now wait the same shortened hold as the sidebar, so the alert and the thread appear together, and an alert is suppressed if the thread continues or asks for input during the hold. The change is a timing adjustment with unit and browser test coverage and is easy to revert. The remaining uncertainty is that native mobile and slow server settles were not tested, which could cause a brief ordering mismatch.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: completion alerts now arrive with the thread rather than about 2 seconds before it. It uses the conventional fix(web) prefix. It is a single, specific sentence. The ti… Description check The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and the verification section gives concrete before and after measurements, test results, and … Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title names the main change: completion alerts now arrive with the thread rather than about 2 seconds before it. It uses the conventional fix(web) prefix. It is a single, specific sentence. The title is slightly long at 83 characters, but it is still clear.
Full details: Description check
-
Explanation
The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and the verification section gives concrete before and after measurements, test results, and unchecked items. The template's Problem section expects reproduction steps or environment. The description gives the Replay provider and real web client, which covers the environment. The Scope section links
#24760and#29146as context, but it does not link the issue that shows the bug. It also does not explain why a fix with no issue is acceptable. The agent attribution line is present. These gaps are minor, so the description is mostly complete.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 439c965
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
97f5fbea-8a01-4fe6-a27b-c9396725d03a
Commits-
Reviewing files that changed from the base of the PR and between 8e95d6e936bc1a2ee83adbf48283d17b6ee68cee and 60f2fa2e79a7c9d2d008edf42a78c828af5663ca.
Files selected for processing: 1-
apps/web/src/components/ThreadNotificationCoordinator.badge.browser.test.ts
Files with no reviewable changes: 1-
- apps/web/src/components/ThreadNotificationCoordinator.badge.browser.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
-
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
verified unchanged head
60f2fa2e79a7c9d2d008edf42a78c828af5663caon a disposable linux vm, againstgithub/mainat37e9217b5696f33f347cdd282830e897a04c10ab. installed each checkout withvp iand ran one dev server at a time with separate fresh state. drove the web client using repository playwright and/usr/bin/google-chrome.created a project through the app pointing at a real git repository, selected codex
gpt-6.1-sol, and submitted real provider turns. both checkouts used the same prompt: runsleep 8, then replynotification timing check complete.while another thread was selected.- main reproduced the bug: the completion toast appeared 2063 ms before the thread appeared in the inbox.
- this head: the completion toast and inbox row appeared 32 ms apart. these are DOM observation timestamps from the actual web client, not a stand-in benchmark.
- queued another real message during a running turn: both replies completed, with one completion toast after the final reply and no intermediate completion toast.
- stopped a real
sleep 60turn using the stop button: the client showedRun interrupted/Stopped by user, and no completion toast appeared during the following five seconds. - blacksmith: 122 existing tests passed across the notification gate, inbox tracker, mobile thread list, and browser notification coordinator. the head also reports 38 successful CI checks. no source changes or pushes were needed.
before: alert visible while the thread remains in working.

after: alert and completed thread visible together.

before recording, with elapsed time visible:

after recording, with elapsed time visible:

Not verified#
native ios/android and electron clients, macos/windows system notifications, audible sound, remote/relay/tunnel connections, provider-specific approval or input arriving within the hold, reconnect during the hold, and delayed external-host auto-settle. native clients and those external paths were not exercised on this linux web-client setup; the existing focused tests cover gate attention and reconnect cases, but that is not real-provider proof of those cases.
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed