fix: correct notification session id

This commit is contained in:
Haileyesus
2026-06-11 19:31:13 +03:00
parent f5eac2ec12
commit 881e72d4a0
9 changed files with 254 additions and 22 deletions

View File

@@ -46,6 +46,7 @@ function AppContentInner() {
setShowSettings,
openSettings,
refreshProjectsSilently,
registerOptimisticSession,
sidebarSharedProps,
handleNewSession,
} = useProjectsState({
@@ -172,6 +173,9 @@ function AppContentInner() {
onNavigateToSession={(targetSessionId: string, options) =>
navigate(`/session/${targetSessionId}`, { replace: Boolean(options?.replace) })
}
onSessionEstablished={(targetSessionId, context) =>
registerOptimisticSession({ sessionId: targetSessionId, ...context })
}
onShowSettings={() => setShowSettings(true)}
externalMessageUpdate={externalMessageUpdate}
newSessionTrigger={newSessionTrigger}

View File

@@ -19,6 +19,7 @@ import type {
ChatMessage,
PendingPermissionRequest,
PermissionMode,
SessionEstablishedContext,
} from '../types/types';
import type { Project, ProjectSession, LLMProvider, ProviderModelsCacheInfo } from '../../../types/app';
import { escapeRegExp } from '../utils/chatFormatting';
@@ -51,7 +52,7 @@ interface UseChatComposerStateArgs {
* stable for the conversation's whole lifetime — the consumer navigates to
* /session/:id and records it as the current session.
*/
onSessionEstablished?: (sessionId: string) => void;
onSessionEstablished?: (sessionId: string, context: SessionEstablishedContext) => void;
onInputFocusChange?: (focused: boolean) => void;
onFileOpen?: (filePath: string, diffInfo?: unknown) => void;
onShowSettings?: () => void;
@@ -606,6 +607,7 @@ export function useChatComposerState({
}
const resolvedProjectPath = selectedProject.fullPath || selectedProject.path || '';
const sessionSummary = getNotificationSessionSummary(selectedSession, currentInput);
// The conversation always has a stable backend-allocated session id
// BEFORE the first websocket send: brand-new chats allocate one here
@@ -646,7 +648,11 @@ export function useChatComposerState({
return;
}
onSessionEstablished?.(targetSessionId);
onSessionEstablished?.(targetSessionId, {
provider,
project: selectedProject,
summary: sessionSummary,
});
}
const userMessage: ChatMessage = {
@@ -696,8 +702,6 @@ export function useChatComposerState({
};
const toolsSettings = getToolsSettings();
const sessionSummary = getNotificationSessionSummary(selectedSession, currentInput);
const model =
provider === 'cursor'
? cursorModel

View File

@@ -107,6 +107,12 @@ export type SessionNavigationOptions = {
replace?: boolean;
};
export type SessionEstablishedContext = {
provider: LLMProvider;
project: Project;
summary?: string | null;
};
export interface ChatInterfaceProps {
selectedProject: Project | null;
selectedSession: ProjectSession | null;
@@ -118,6 +124,7 @@ export interface ChatInterfaceProps {
onSessionIdle?: MarkSessionIdle;
processingSessions?: SessionActivityMap;
onNavigateToSession?: (targetSessionId: string, options?: SessionNavigationOptions) => void;
onSessionEstablished?: (sessionId: string, context: SessionEstablishedContext) => void;
onShowSettings?: () => void;
autoExpandTools?: boolean;
showRawParameters?: boolean;

View File

@@ -29,6 +29,7 @@ function ChatInterface({
onSessionIdle,
processingSessions,
onNavigateToSession,
onSessionEstablished,
onShowSettings,
autoExpandTools,
showRawParameters,
@@ -138,10 +139,11 @@ function ChatInterface({
// Brand-new conversation: the composer allocated a stable session id via
// the session gateway before the first send. Record it locally and put it
// in the URL — this id never changes again, so there is no later handoff.
const handleSessionEstablished = useCallback((sessionId: string) => {
const handleSessionEstablished = useCallback<NonNullable<ChatInterfaceProps['onSessionEstablished']>>((sessionId, context) => {
setCurrentSessionId(sessionId);
onSessionEstablished?.(sessionId, context);
onNavigateToSession?.(sessionId);
}, [setCurrentSessionId, onNavigateToSession]);
}, [setCurrentSessionId, onSessionEstablished, onNavigateToSession]);
const {
input,

View File

@@ -6,7 +6,7 @@ import type {
MarkSessionProcessing,
SessionActivityMap,
} from '../../../hooks/useSessionProtection';
import type { SessionNavigationOptions } from '../../chat/types/types';
import type { SessionEstablishedContext, SessionNavigationOptions } from '../../chat/types/types';
export type TaskMasterTask = {
id: string | number;
@@ -52,6 +52,7 @@ export type MainContentProps = {
onSessionIdle: MarkSessionIdle;
processingSessions: SessionActivityMap;
onNavigateToSession: (targetSessionId: string, options?: SessionNavigationOptions) => void;
onSessionEstablished: (sessionId: string, context: SessionEstablishedContext) => void;
onShowSettings: () => void;
externalMessageUpdate: number;
newSessionTrigger: number;

View File

@@ -45,6 +45,7 @@ function MainContent({
onSessionIdle,
processingSessions,
onNavigateToSession,
onSessionEstablished,
onShowSettings,
externalMessageUpdate,
newSessionTrigger,
@@ -131,6 +132,7 @@ function MainContent({
onSessionIdle={onSessionIdle}
processingSessions={processingSessions}
onNavigateToSession={onNavigateToSession}
onSessionEstablished={onSessionEstablished}
onShowSettings={onShowSettings}
autoExpandTools={autoExpandTools}
showRawParameters={showRawParameters}