@@ -9,7 +9,6 @@ import { createSerializer, useQueryStates } from 'nuqs'
99import { requestJson } from '@/lib/api/client/request'
1010import type { WorkspaceSearchFilters } from '@/lib/api/contracts/knowledge'
1111import { getWorkspaceHostContextContract } from '@/lib/api/contracts/workspaces'
12- import { useSession } from '@/lib/auth/client'
1312import { BrowserStorage } from '@/lib/core/utils/browser-storage'
1413import {
1514 getMothershipAttachmentPreviewUrl ,
@@ -125,21 +124,19 @@ interface UseConversationGateOptions {
125124
126125/** Whether the surface may mount, and for which identity. Its key remounts on any change to one. */
127126export function useConversationGate ( { chatId, requestMode } : UseConversationGateOptions ) {
128- const { organization, searchAccess, canBuild, mothershipAvailable } = useOrganization ( )
129- const { data : session } = useSession ( )
127+ const { organization, viewer, searchAccess, canBuild, mothershipAvailable } = useOrganization ( )
130128 const isClient = useHydrated ( )
131129 const isRestoredChatEntry = useRestoredChatEntry ( { chatId } )
132- const userId = session ?. user ?. id
133130 if (
134131 ! mothershipAvailable ||
135132 ( requestMode === 'assistant' ? ! searchAccess . memberScoped : ! canBuild )
136133 )
137134 return { status : 'denied' } as const
138135 if ( isRestoredChatEntry ) return { status : 'restoring' } as const
139- if ( ! isClient || ! userId ) return { status : 'waiting' } as const
136+ if ( ! isClient ) return { status : 'waiting' } as const
140137 return {
141138 status : 'ready' ,
142- instanceKey : `${ userId } :${ organization . id } :${ chatId ?? 'new' } ` ,
139+ instanceKey : `${ viewer . userId } :${ organization . id } :${ chatId ?? 'new' } ` ,
143140 } as const
144141}
145142
@@ -165,10 +162,9 @@ export function useOrganizationConversation({
165162 summaryRequest,
166163 onSummaryConsumed,
167164} : UseOrganizationConversationOptions ) {
168- const { organization, canBuild } = useOrganization ( )
165+ const { organization, viewer , canBuild } = useOrganization ( )
169166 const panelSurface = surface . kind === 'panel' ? surface : null
170- const { data : session } = useSession ( )
171- const userId = session ?. user ?. id
167+ const userId = viewer . userId
172168 const planEnabled = useFeatureFlag ( 'mothership-plan-mode' )
173169 const [ planning , setPlanning ] = useState ( false )
174170 const requestMode =
0 commit comments