feat(notifications): name the session a notification is about - #834
Merged
xintaofei merged 2 commits intoSep 28, 2026
Merged
Conversation
An OS notification was titled with the window's active folder, not the
folder of the session that raised it, and its body named only the agent.
With several sessions running there was no telling which one had
finished, failed, asked a question or was waiting on a permission, and
the folder in the title could be the wrong one.
Every notification raised from an ACP event (turn finished or failed,
session error, permission request, question, background task settled)
now resolves its session from the connection's context key, which is its
tab id. The tab leads to the persisted conversation: its title becomes
the notification title and its own folder leads the body
("<folder> · <message>"). A draft with no conversation row yet uses its
tab label. A context key no tab owns (a canvas card, a delegated
sub-agent's connection) keeps the previous "<folder> - Codeg" title.
With "hide notification contents" on, the notification reads as before,
"<folder> - Codeg" over the message alone, but names the session's own
folder: a session title is the user's own words, which that setting
exists to keep out of the notification centre. NotifyPayload gains an
optional redactedTitle for this, applied like redactedBody.
dawNotPoi
approved these changes
Sep 25, 2026
dawNotPoi
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the session lookup, notification call sites, and redacted title/body behavior at 09d74bc. Focused notification tests passed 29/29 locally; TypeScript and ESLint on the changed files passed. No blocking findings for this PR scope. Notification-click navigation remains tracked separately in #808.
Closing a tab whose agent is still busy keeps its connection alive (see `shouldDisconnectOnUnmount`), so the turn that finishes in the background arrives under a tab id that no longer exists. The tab-only lookup then fell back to the window's active folder — the wrong-folder title this change set out to fix, in exactly the case where the notification is the only way the user learns the turn finished. When no tab owns the key, resolve the conversation the connection serves instead: the row id `connect()` was given, or the one a first send linked (`conversation_linked`), both already remembered per context key past the surface itself. Not the agent's session id — a Claude `/clear` re-points the row's `external_id` while the ACP session keeps its own, and Gemini / Cline rows are renormalized to the parser's id. A tab still wins when there is one. This also names the session behind a canvas card. A connection with no known conversation (a delegated sub-agent's own) keeps the active-folder title. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
|
codeg work task |
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.
Summary
OS notifications raised by agent sessions (turn finished or failed, session error, permission request, question, background task settled) were titled
<folder> - Codegwith the window's active folder, not the folder of the session that raised them, and the body named only the agent. With several sessions running there was no way to tell which one needed you, and the folder in the title could be the wrong one.Each of these notifications now names its session: the session's title as the notification title, and the session's own folder at the start of the body.
Behavior
<folder> · <message>, where the folder is the session's own (its alias when one is set). A chat-mode conversation names its hidden "Chat" folder; a chat draft that has no folder yet names none rather than the active one.<folder> - Codegover the message alone, but names the session's folder. A session title is the user's own words (often the first line of their prompt), which that setting exists to keep out of the notification centre.<active folder> - Codegtitle.Implementation:
src/lib/notification-session.ts(new):sessionNotificationPayload(contextKey, activeFolderName, { body, redactedBody }). The connection's context key is its tab id; from the tab it finds the persisted conversation (through the runtime session's row id for a draft whose first send has not bound the tab yet) and the folder inallFolders.src/lib/desktop-notification.ts:NotifyPayloadgains an optionalredactedTitle, used when contents are hidden, the same way asredactedBody.src/contexts/acp-connections-context.tsx: the sixnotifyDesktopcall sites wrap their existing payloads insessionNotificationPayload. What they notify and when (failure-aware turn completion,acpErrorNotifiesDesktop,quiet) is unchanged.Verification
src/lib/notification-session.test.ts(new, 7 tests): the session title and the session's own folder win over a different active folder; folder alias and reference-link folding; draft tab label; a draft reached through its runtime session; a chat-mode conversation's hidden folder; a folderless chat draft names no folder; an unknown context key keeps the old title.src/lib/desktop-notification.test.ts: the redacted title replaces the title only when contents are hidden.pnpm lint .,pnpm test,pnpm build) and every Rust desktop/server cell on Ubuntu, macOS and Windows. There are no Rust changes.