mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(scheduler): prevent stale tool re-publication and fix stuck UI state (#17227)
This commit is contained in:
@@ -188,8 +188,13 @@ describe('SchedulerStateManager', () => {
|
||||
errorType: undefined,
|
||||
};
|
||||
|
||||
vi.mocked(onUpdate).mockClear();
|
||||
stateManager.updateStatus(call.request.callId, 'success', response);
|
||||
expect(onUpdate).toHaveBeenCalledTimes(1);
|
||||
|
||||
vi.mocked(onUpdate).mockClear();
|
||||
stateManager.finalizeCall(call.request.callId);
|
||||
expect(onUpdate).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(stateManager.isActive).toBe(false);
|
||||
expect(stateManager.completedBatch).toHaveLength(1);
|
||||
@@ -455,6 +460,7 @@ describe('SchedulerStateManager', () => {
|
||||
createValidatingCall('2'),
|
||||
]);
|
||||
|
||||
vi.mocked(onUpdate).mockClear();
|
||||
stateManager.cancelAllQueued('Batch cancel');
|
||||
|
||||
expect(stateManager.queueLength).toBe(0);
|
||||
@@ -462,6 +468,13 @@ describe('SchedulerStateManager', () => {
|
||||
expect(
|
||||
stateManager.completedBatch.every((c) => c.status === 'cancelled'),
|
||||
).toBe(true);
|
||||
expect(onUpdate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not notify if cancelAllQueued is called on an empty queue', () => {
|
||||
vi.mocked(onUpdate).mockClear();
|
||||
stateManager.cancelAllQueued('Batch cancel');
|
||||
expect(onUpdate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should clear batch and notify', () => {
|
||||
|
||||
@@ -130,6 +130,7 @@ export class SchedulerStateManager {
|
||||
if (this.isTerminalCall(call)) {
|
||||
this._completedBatch.push(call);
|
||||
this.activeCalls.delete(callId);
|
||||
this.emitUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +161,10 @@ export class SchedulerStateManager {
|
||||
}
|
||||
|
||||
cancelAllQueued(reason: string): void {
|
||||
if (this.queue.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (this.queue.length > 0) {
|
||||
const queuedCall = this.queue.shift()!;
|
||||
if (queuedCall.status === 'error') {
|
||||
|
||||
Reference in New Issue
Block a user