@@ -33,6 +33,7 @@ import { createSessionMessageHandoffs } from "@/session/handoff"
3333import { createServerNotificationState } from "@/shell/notifications/notification"
3434import { createNotificationCoordinator } from "@/shell/notifications/coordinator"
3535import { useCurrentRoute } from "@/shell/state/layout"
36+ import { createSessionPreferences } from "@/shell/state/session-preferences"
3637import { useTabs } from "@/shell/tabs/tabs"
3738import { Persist , persisted } from "@/runtime/persistence/storage"
3839import { createDesktopData } from "./data"
@@ -52,6 +53,7 @@ export const { use: useGlobal, provider: GlobalProvider } = createSimpleContext(
5253 init : ( ) => {
5354 const server = useServers ( )
5455 const models = createGlobalModels ( )
56+ const sessionPreferences = createSessionPreferences ( )
5557 const notificationCoordinator = createNotificationCoordinator ( )
5658 const owner = getOwner ( )
5759
@@ -79,6 +81,7 @@ export const { use: useGlobal, provider: GlobalProvider } = createSimpleContext(
7981 ( ) => server . local ( effect . conn ) ,
8082 server . projects . forServer ( effect . key ) ,
8183 notificationCoordinator ,
84+ sessionPreferences ,
8285 ) ,
8386 dispose,
8487 } ) ,
@@ -124,6 +127,7 @@ export const { use: useGlobal, provider: GlobalProvider } = createSimpleContext(
124127 retry : serverHealth . retry ,
125128 } ,
126129 models,
130+ sessionPreferences,
127131 /** Runs each keyed sound and system notification once across windows; notifications only while none has focus. */
128132 notifications : notificationCoordinator ,
129133 /** The live controller of a server, or undefined while it is unlisted or rejects our credentials. Reactive. */
@@ -198,6 +202,7 @@ function createServerController(
198202 isLocal : Accessor < boolean > ,
199203 projects : ReturnType < typeof createServerProjects > ,
200204 notificationCoordinator : ReturnType < typeof createNotificationCoordinator > ,
205+ sessionPreferences : ReturnType < typeof createSessionPreferences > ,
201206) {
202207 const language = useLanguage ( )
203208 const settings = useSettings ( )
@@ -254,7 +259,17 @@ function createServerController(
254259
255260 const sync = createServerSyncContext ( sdk , data )
256261 const autoApprove = createPermissionAutoApprover ( { sdk, data } )
257- const notification = createServerNotificationState ( { sdk, data, key : connKey , coordinator : notificationCoordinator } )
262+ onCleanup ( data . on ( "session.deleted" , ( event ) => sessionPreferences . forget ( connKey , event . data . sessionID ) ) )
263+
264+ const notification = createServerNotificationState ( {
265+ sdk,
266+ data,
267+ key : connKey ,
268+ coordinator : notificationCoordinator ,
269+ muted : ( id ) => sessionPreferences . muted ( connKey , id ) ,
270+ preferencesLoaded : sessionPreferences . ready . promise ,
271+ } )
272+
258273 // Owned by the server, so a first prompt's handoff outlives the draft that sent it.
259274 const handoff = createSessionMessageHandoffs ( { sdk, data } )
260275
0 commit comments