diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions.ts index 62d685fc7..e1e13b9d4 100644 --- a/apps/desktop/src/app/session/hooks/use-prompt-actions.ts +++ b/apps/desktop/src/app/session/hooks/use-prompt-actions.ts @@ -65,7 +65,7 @@ interface PromptActionsOptions { activeSessionIdRef: MutableRefObject busyRef: MutableRefObject branchCurrentSession: () => Promise - createBackendSessionForSend: () => Promise + createBackendSessionForSend: (preview?: string | null) => Promise handleSkinCommand: (arg: string) => string requestGateway: (method: string, params?: Record) => Promise selectedStoredSessionIdRef: MutableRefObject @@ -296,7 +296,7 @@ export function usePromptActions({ if (!sessionId) { try { - sessionId = await createBackendSessionForSend() + sessionId = await createBackendSessionForSend(visibleText) } catch (err) { dropOptimistic(null) releaseBusy() diff --git a/apps/desktop/src/app/session/hooks/use-session-actions.ts b/apps/desktop/src/app/session/hooks/use-session-actions.ts index 7b301f7f3..a07bfdb64 100644 --- a/apps/desktop/src/app/session/hooks/use-session-actions.ts +++ b/apps/desktop/src/app/session/hooks/use-session-actions.ts @@ -303,7 +303,7 @@ export function useSessionActions({ [activeSessionIdRef, busyRef, navigate, selectedStoredSessionIdRef] ) - const createBackendSessionForSend = useCallback(async (): Promise => { + const createBackendSessionForSend = useCallback(async (preview: string | null = null): Promise => { const startingActiveSessionId = activeSessionIdRef.current const startingStoredSessionId = selectedStoredSessionIdRef.current const startingRouteToken = getRouteToken() @@ -330,7 +330,11 @@ export function useSessionActions({ ensureSessionState(created.session_id, stored) if (stored) { - upsertOptimisticSession(created, stored) + // Seed the sidebar preview with the user's first message so the row + // reads meaningfully while the turn is in flight, instead of flashing + // "Untitled session" until the turn persists and auto-title runs. The + // server later returns its own preview/title and supersedes this. + upsertOptimisticSession(created, stored, null, preview?.trim() || null) navigate(sessionRoute(stored), { replace: true }) }