Skip to content

chat: show one OS notification when a session has no more work - #333038

Merged
Connor Peet (connor4312) merged 3 commits into
mainfrom
agents/fix-agent-session-notifications
Aug 27, 2026
Merged

chat: show one OS notification when a session has no more work#333038
Connor Peet (connor4312) merged 3 commits into
mainfrom
agents/fix-agent-session-notifications

Conversation

@connor4312

Copy link
Copy Markdown
Member

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.

  • 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
    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

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>
Copilot AI balanced review requested due to automatic review settings August 27, 2026 21:01
@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) August 27, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

Review tier: Balanced
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity 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…
Medium severity 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 truefalse transition, 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.

Comment thread src/vs/sessions/contrib/sessions/browser/sessionsWindowNotifier.ts
Comment thread src/vs/workbench/contrib/chat/browser/chatWindowNotifier.ts Outdated
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>
@connor4312
Connor Peet (connor4312) merged commit 44617f8 into main Aug 27, 2026
37 checks passed
@connor4312
Connor Peet (connor4312) deleted the agents/fix-agent-session-notifications branch August 27, 2026 21:41
@vs-code-engineering vs-code-engineering Bot added this to the 1.136.0 milestone Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants