fix(chat): avoid implicit stream reuse
This commit is contained in:
+20
-6
@@ -193,6 +193,21 @@ const pipeUiChunk = (
|
||||
}
|
||||
};
|
||||
|
||||
export const resolveRequestedStreamSessionId = (input: {
|
||||
sessionId?: string;
|
||||
promptText: string;
|
||||
createClientSessionId: () => string;
|
||||
}) => {
|
||||
const sessionId = input.sessionId?.trim();
|
||||
if (sessionId) {
|
||||
return sessionId;
|
||||
}
|
||||
if (isPressureTrendDemoPrompt(input.promptText)) {
|
||||
return input.createClientSessionId();
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const buildChatRouter = (
|
||||
sessionBridge: ChatSessionBridge,
|
||||
runtime: OpencodeRuntimeAdapter,
|
||||
@@ -617,12 +632,11 @@ export const buildChatRouter = (
|
||||
});
|
||||
return;
|
||||
}
|
||||
const requestedSessionId =
|
||||
parsed.data.session_id?.trim() ||
|
||||
parsed.data.id?.trim() ||
|
||||
(isPressureTrendDemoPrompt(promptText)
|
||||
? sessionBridge.createClientSessionId()
|
||||
: undefined);
|
||||
const requestedSessionId = resolveRequestedStreamSessionId({
|
||||
sessionId: parsed.data.session_id,
|
||||
promptText,
|
||||
createClientSessionId: () => sessionBridge.createClientSessionId(),
|
||||
});
|
||||
const existingSessionRecord = requestedSessionId
|
||||
? await sessionMetadataStore.get(
|
||||
{ actorKey, projectId, projectKey, userId },
|
||||
|
||||
Reference in New Issue
Block a user