fix(ui): dispatch queued messages when session is already idle (#1978)
Co-authored-by: bashrusakh <bashrusakh@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
bashrusakh
parent
01a52eccab
commit
002c7a70ad
@@ -35,13 +35,17 @@ import {
|
|||||||
|
|
||||||
describe('shouldDispatchQueuedAutoSend', () => {
|
describe('shouldDispatchQueuedAutoSend', () => {
|
||||||
test('dispatches only after an active session becomes idle', () => {
|
test('dispatches only after an active session becomes idle', () => {
|
||||||
expect(shouldDispatchQueuedAutoSend('busy', 'idle')).toBe(true);
|
expect(shouldDispatchQueuedAutoSend('busy', 'idle', false)).toBe(true);
|
||||||
expect(shouldDispatchQueuedAutoSend('retry', 'idle')).toBe(true);
|
expect(shouldDispatchQueuedAutoSend('retry', 'idle', false)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('does not dispatch when idle is only first seen or status is missing', () => {
|
test('does not dispatch when idle is only first seen or status is missing', () => {
|
||||||
expect(shouldDispatchQueuedAutoSend(undefined, 'idle')).toBe(false);
|
expect(shouldDispatchQueuedAutoSend(undefined, 'idle', false)).toBe(false);
|
||||||
expect(shouldDispatchQueuedAutoSend('idle', 'idle')).toBe(false);
|
expect(shouldDispatchQueuedAutoSend('idle', 'idle', false)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('dispatches when idle→idle and queue has items', () => {
|
||||||
|
expect(shouldDispatchQueuedAutoSend('idle', 'idle', true)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ const resolveSessionSendConfig = (sessionId: string) => {
|
|||||||
export const shouldDispatchQueuedAutoSend = (
|
export const shouldDispatchQueuedAutoSend = (
|
||||||
previousStatusType: SessionStatusType | undefined,
|
previousStatusType: SessionStatusType | undefined,
|
||||||
currentStatusType: SessionStatusType,
|
currentStatusType: SessionStatusType,
|
||||||
|
hasQueuedItems: boolean = false,
|
||||||
): boolean => {
|
): boolean => {
|
||||||
|
if (hasQueuedItems && currentStatusType === 'idle') return true;
|
||||||
return (previousStatusType === 'busy' || previousStatusType === 'retry')
|
return (previousStatusType === 'busy' || previousStatusType === 'retry')
|
||||||
&& currentStatusType === 'idle';
|
&& currentStatusType === 'idle';
|
||||||
};
|
};
|
||||||
@@ -202,7 +204,7 @@ export function useQueuedMessageAutoSend(enabledOrOptions?: boolean | { enabled?
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (queue.length > 0 && (
|
if (queue.length > 0 && (
|
||||||
shouldDispatchQueuedAutoSend(previousStatusType, currentStatusType)
|
shouldDispatchQueuedAutoSend(previousStatusType, currentStatusType, queue.length > 0)
|
||||||
|| (wasAutoReviewBlocked && !isAutoReviewRunning && currentStatusType === 'idle')
|
|| (wasAutoReviewBlocked && !isAutoReviewRunning && currentStatusType === 'idle')
|
||||||
)) {
|
)) {
|
||||||
void dispatchSessionQueue(sessionId, queue);
|
void dispatchSessionQueue(sessionId, queue);
|
||||||
|
|||||||
Reference in New Issue
Block a user