chat: show one OS notification when a session has no more work - #333038
Merged
Connor Peet (connor4312) merged 3 commits intoAug 27, 2026
Conversation
Agent host sessions can be open in the editor window and the agents window at the same time. This caused two problems with the OS notifications. A "finished" toast came when a response ended, even if more requests were in the queue. A session that was open in two windows made one toast from each window. - Adds an idle observable in the chat window notifier. It combines the request state, the input state, and the count of queued requests. The notifier shows the toast only when the session has no more work. A 500ms delay prevents a toast in the short gap between two queued turns. - Makes the chat window notifier the only source of toasts in a window. It now shows the toast for needed input and for the idle state. The toast in the chat accessibility service is removed. That service keeps the accessibility signal and the ARIA announcement. - Limits the sessions window notifier to sessions that have no chat model in this window. Sessions with a model are the responsibility of the chat window notifier, which knows about the queue. - Adds a dedupe key to the toast options. The main process does not show a second toast while a toast with the same key is on the screen. This prevents duplicate toasts from two windows for one session. - Delays the toast 250ms in a window that does not show the session. The window that shows the session makes its toast first, so a click opens the window that the user worked in. - Delays the completed toast 1500ms in the sessions window notifier. A session with no chat model here gives no queue information, so the delay prevents a toast in the gap between two queued turns. See microsoft/agent-host-protocol#426 for the permanent fix. (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ion-notifications
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 2
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
src/vs/sessions/contrib/sessions/browser/sessionsWindowNotifier.ts — This no-model/no-widget path is exactly the notifier running in a window that only lists the… |
|
src/vs/workbench/contrib/chat/browser/chatWindowNotifier.ts — A nonzero pending count does not always mean runnable work remains. ChatService leaves queued… |
What changed in this PR
Centralizes chat OS notifications and suppresses duplicate session toasts across windows.
Changes:
- Adds idle/queued-work notification tracking.
- Coordinates chat and Sessions window notification ownership.
- Adds native toast deduplication and tests.
| File | Description |
|---|---|
src/vs/workbench/services/host/browser/host.ts |
Extends toast contracts. |
src/vs/platform/native/common/native.ts |
Extends native toast contracts. |
src/vs/platform/native/electron-main/nativeHostMainService.ts |
Deduplicates active native toasts. |
src/vs/workbench/contrib/chat/common/chatNotification.ts |
Defines shared notification keys. |
src/vs/workbench/contrib/chat/browser/chatWindowNotifier.ts |
Adds idle and input notifications. |
src/vs/workbench/contrib/chat/test/browser/chatWindowNotifier.test.ts |
Tests notifier behavior. |
src/vs/workbench/contrib/chat/browser/chat.ts |
Simplifies accessibility API. |
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts |
Updates accessibility call site. |
src/vs/workbench/contrib/chat/browser/accessibility/chatAccessibilityService.ts |
Removes duplicate OS notifications. |
src/vs/sessions/contrib/sessions/browser/sessionsWindowNotifier.ts |
Adds fallback notification coordination. |
src/vs/sessions/contrib/sessions/test/browser/sessionsWindowNotifier.test.ts |
Tests debounce and suppression. |
Suppressed comments (3)
src/vs/workbench/contrib/chat/browser/chatWindowNotifier.ts:91
- This only cancels a toast that has not fired. After an idle toast is already visible, starting or queueing another request leaves the stale “Session finished” notification on screen and keeps its dedupe key active while the session is busy. On the
true→falsetransition, also clear the session's active notification.
} else if (!newValue) {
idleScheduler.cancel();
src/vs/workbench/contrib/chat/browser/chatWindowNotifier.ts:173
- After the background-window delay, this only checks the detached model object. If the model is removed or replaced after the scheduler callback starts, disposing its tracker cannot cancel this async continuation, so a closed session can still produce a completion toast. Recheck that this exact model is still registered before notifying.
await this._delayForBackgroundWindow(widget?.visible === true);
if (!isIdle.get() || model.requestNeedsInput.get()) {
return;
src/vs/workbench/contrib/chat/browser/chatWindowNotifier.ts:199
- A previous idle notification can finish after a newer notification has replaced its entry in
_activeNotifications. This unconditional cleanup then disposes the newer notification's token, so rapid idle/busy/idle or idle/needs-input transitions can make the latest toast disappear. Keep the per-call disposable and clear the map only if it is still the current entry.
} finally {
this._clearNotification(model.sessionResource);
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Applies the Copilot review comments on PR #333038. - Treats a queue that cannot drain as no more work. The chat service and the agent host both stop the queue after an error or a cancellation. Before this change the session stayed busy forever in that state and the user got no notification, because the sessions window notifier is silent while a chat model is present. - Delays the toast from the sessions window notifier by 250ms. This notifier runs only for a session that the window does not show, so it must let a window that shows the session notify first. Without the delay it won the deduplication and the toast opened the wrong window. - Adds tests for a queue that an error or a cancellation stopped. (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 27, 2026
Connor Peet (connor4312)
deleted the
agents/fix-agent-session-notifications
branch
August 27, 2026 21:41
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.

chat: show one OS notification when a session has no more work
Agent host sessions can be open in the editor window and the agents window at the
same time. This caused two problems with the OS notifications. A "finished" toast
came when a response ended, even if more requests were in the queue. A session that
was open in two windows made one toast from each window.
state, the input state, and the count of queued requests. The notifier shows the
toast only when the session has no more work. A 500ms delay prevents a toast in
the short gap between two queued turns.
shows the toast for needed input and for the idle state. The toast in the chat
accessibility service is removed. That service keeps the accessibility signal and
the ARIA announcement.
window. Sessions with a model are the responsibility of the chat window notifier,
which knows about the queue.
toast while a toast with the same key is on the screen. This prevents duplicate
toasts from two windows for one session.
that shows the session makes its toast first, so a click opens the window that
the user worked in.
no chat model here gives no queue information, so the delay prevents a toast in
the gap between two queued turns. See
summaryStatus reports Idle while queued messages are pending, causing status flicker agent-host-protocol#426 for the permanent fix.
(Commit message generated by Copilot)
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com