Do not attribute surface-less desktop notifications to the active workspace
Summary
App-target (surface-less) OSC 9/777 desktop notifications were recorded against tabManager.selectedTabId (the active workspace). A raw terminal notification's body is written to the per-workspace notification store, and the sidebar subtitle is latestNotificationSubtitle ?? conversationMessageSubtitle, so this stamped an unrelated notification onto whichever workspace was focused and hid that row's real conversation subtitle. A surface-less notification has no originating surface, so its emitting workspace is unknown; it must not fall back to the active workspace.
Root cause
handleAction has two GHOSTTY_ACTION_DESKTOP_NOTIFICATION paths. The surface-target branch attributes by surfaceView.tabId (correct); the app-target branch (target.tag != GHOSTTY_TARGET_SURFACE) used tabManager.selectedTabId. The two have diverged since the original implementation.
Fix
Add GhosttyApp.rawNotificationRecordingTabId(surfaceTabId:) as the single attribution rule — a notification is recorded against its emitting surface's workspace, or nowhere when the surface is unknown — and route both paths through it. The app-target path passes surfaceTabId: nil, so it records nothing instead of stamping the active workspace; the surface-target path is unchanged.
Verification
Added cmuxTests/GhosttyRawNotificationAttributionTests.swift (wired into the cmuxTests target):
rawNotificationRecordingTabId(surfaceTabId: nil) == nil
rawNotificationRecordingTabId(surfaceTabId: origin) == origin
xcodebuild test -scheme cmux-unit -only-testing:cmuxTests/GhosttyRawNotificationAttributionTests
** TEST SUCCEEDED **
Note
Surface-targeted notifications (the normal path, including Claude Code) are unaffected. A surface-less notification is now dropped rather than mis-homed; delivering an OS banner for that rare, unattributable case without recording it to a workspace would be a follow-up.
Related
Found while investigating #7132 (sidebar conversation subtitle attributed to the wrong workspace), which is a separate, upstream cause.
Summary by CodeRabbit
- Bug Fixes
- Improved desktop notification tab attribution so notifications are tied to the originating workspace when available.
- Prevented notifications from being attributed to the currently selected tab when no source tab is available.
- Added automated tests to verify correct behavior for both attributed and non-attributed notification scenarios.