@@ -16,6 +16,7 @@ import { sessionFormRequest, sessionPermissionRequest, sessionTreeIDs } from "@/
1616import { notifySessionTabsRemoved } from "./session-events"
1717import { errorMessage } from "@/shell/layout/helpers"
1818import { showToast } from "@/shell/notifications/toast"
19+ import { createSessionRenamer } from "@/session/commands/rename-session"
1920import { workingSince } from "./inbox-working"
2021import {
2122 INITIAL_INBOX_BRANCH_STATE ,
@@ -67,6 +68,8 @@ export function createSessionInbox(options: { archived?: boolean } = {}) {
6768 const language = useLanguage ( )
6869 const queryClient = useQueryClient ( )
6970
71+ const rename = createSessionRenamer ( )
72+
7073 const [ clock , setClock ] = createStore ( { second : Date . now ( ) , minute : Date . now ( ) } )
7174 const timer = setInterval ( ( ) => setClock ( "minute" , Date . now ( ) ) , 60_000 )
7275 onCleanup ( ( ) => clearInterval ( timer ) )
@@ -456,15 +459,7 @@ export function createSessionInbox(options: { archived?: boolean } = {}) {
456459 if ( ! entry . ctx . data . session . get ( entry . session . id ) ) entry . ctx . data . session . remember ( entry . session )
457460 entry . ctx . notification . session . markRead ( entry . session . id )
458461 } ,
459- rename : async ( entry : InboxEntry , title : string ) => {
460- await entry . ctx . sdk . api . session . update ( { sessionID : entry . session . id , title } )
461- entry . ctx . data . session . remember ( { ...( entry . ctx . data . session . get ( entry . session . id ) ?? entry . session ) , title } )
462- entry . ctx . data . session . invalidate ( entry . session . id )
463- void entry . ctx . data . session . sync ( entry . session . id ) . catch ( ( ) => undefined )
464- void queryClient . invalidateQueries ( { queryKey : [ "home-sessions" , entry . conn ] , exact : true } )
465- void queryClient . invalidateQueries ( { queryKey : [ "inbox-sessions" , entry . conn ] , exact : true } )
466- void queryClient . invalidateQueries ( { queryKey : [ "inbox-archived-sessions" , entry . conn ] , exact : true } )
467- } ,
462+ rename : ( entry : InboxEntry , title : string ) => rename ( entry . server , entry . session , title ) ,
468463 archive : ( entry : InboxEntry ) =>
469464 entry . ctx . sdk . api . session
470465 . update ( { sessionID : entry . session . id , archived : true } )
0 commit comments