fix: auto-send queue to check session status before sending (#447)
This commit is contained in:
committed by
GitHub
parent
34c8ff3962
commit
135b2c89be
@@ -666,9 +666,18 @@ export const ChatInput: React.FC<ChatInputProps> = ({ onOpenSettings, scrollToBo
|
|||||||
// Prevent double-triggering
|
// Prevent double-triggering
|
||||||
autoSendTriggeredRef.current = true;
|
autoSendTriggeredRef.current = true;
|
||||||
|
|
||||||
|
const targetSessionId = currentSessionId;
|
||||||
|
|
||||||
// Use setTimeout to avoid calling during render
|
// Use setTimeout to avoid calling during render
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (currentSessionId && currentProviderId && currentModelId) {
|
const activeSessionId = useSessionStore.getState().currentSessionId;
|
||||||
|
const currentStatus = targetSessionId
|
||||||
|
? useSessionStore.getState().sessionStatus?.get(targetSessionId)
|
||||||
|
: null;
|
||||||
|
const stillIdle = currentStatus?.type === 'idle';
|
||||||
|
const sessionUnchanged = Boolean(targetSessionId) && activeSessionId === targetSessionId;
|
||||||
|
|
||||||
|
if (sessionUnchanged && stillIdle && targetSessionId && currentProviderId && currentModelId) {
|
||||||
void handleSubmitRef.current({ queuedOnly: true });
|
void handleSubmitRef.current({ queuedOnly: true });
|
||||||
}
|
}
|
||||||
autoSendTriggeredRef.current = false;
|
autoSendTriggeredRef.current = false;
|
||||||
|
|||||||
@@ -1382,7 +1382,6 @@ export const useEventStream = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
completeStreamingMessage(sessionId, messageId);
|
completeStreamingMessage(sessionId, messageId);
|
||||||
updateSessionStatus(sessionId, { type: 'idle' }, 'sse:message.updated.completed');
|
|
||||||
// Removed: void refreshSessionStatus();
|
// Removed: void refreshSessionStatus();
|
||||||
|
|
||||||
const rawMessageSessionId = (message as { sessionID?: string }).sessionID;
|
const rawMessageSessionId = (message as { sessionID?: string }).sessionID;
|
||||||
|
|||||||
Reference in New Issue
Block a user