Skip to content

Commit 74eb2de

Browse files
committed
fix: address code review feedback on compress command
1 parent 87d252b commit 74eb2de

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

packages/cli/src/ui/AppContainer.test.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,7 @@ describe('AppContainer State Management', () => {
35783578
});
35793579

35803580
describe('Compression Queuing', () => {
3581-
it('queues messages during compression instead of handling as steering hints', async () => {
3581+
beforeEach(async () => {
35823582
const { checkPermissions } = await import(
35833583
'./hooks/atCommandProcessor.js'
35843584
);
@@ -3606,9 +3606,14 @@ describe('AppContainer State Management', () => {
36063606
},
36073607
],
36083608
}));
3609+
});
36093610

3611+
it('queues messages during compression instead of handling as steering hints', async () => {
36103612
const { unmount } = await act(async () => renderAppContainer());
36113613

3614+
// Verify state isolation
3615+
expect(capturedUIState.streamingState).toBe(StreamingState.Idle);
3616+
36123617
// Submit a message
36133618
await act(async () =>
36143619
capturedUIActions.handleFinalSubmit('follow up message'),
@@ -3619,5 +3624,17 @@ describe('AppContainer State Management', () => {
36193624

36203625
unmount();
36213626
});
3627+
3628+
it('executes slash commands immediately during compression', async () => {
3629+
const { unmount } = await act(async () => renderAppContainer());
3630+
3631+
// Submit a slash command
3632+
await act(async () => capturedUIActions.handleFinalSubmit('/help'));
3633+
3634+
// Verify it was NOT queued
3635+
expect(capturedUIState.messageQueue).not.toContain('/help');
3636+
3637+
unmount();
3638+
});
36223639
});
36233640
});

packages/cli/src/ui/AppContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
14271427
const isMcpOrConfigReady = isConfigInitialized && isMcpReady;
14281428
if (
14291429
(isSlash && isConfigInitialized) ||
1430-
(isIdle && !isCompressing && isMcpOrConfigReady)
1430+
(!isCompressing && isIdle && isMcpOrConfigReady)
14311431
) {
14321432
if (!isSlash) {
14331433
const permissions = await checkPermissions(submittedValue, config);

packages/cli/src/ui/commands/compressCommand.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('compressCommand', () => {
4242
},
4343
};
4444
await compressCommand.action!(context, '');
45+
await new Promise((r) => setTimeout(r, 0));
4546
expect(context.ui.addItem).toHaveBeenCalledWith(
4647
expect.objectContaining({
4748
type: MessageType.ERROR,
@@ -62,6 +63,7 @@ describe('compressCommand', () => {
6263
mockTryCompressChat.mockResolvedValue(compressedResult);
6364

6465
await compressCommand.action!(context, '');
66+
await new Promise((r) => setTimeout(r, 0));
6567

6668
expect(context.ui.setPendingItem).toHaveBeenNthCalledWith(1, {
6769
type: MessageType.COMPRESSION,
@@ -98,6 +100,7 @@ describe('compressCommand', () => {
98100
mockTryCompressChat.mockResolvedValue(null);
99101

100102
await compressCommand.action!(context, '');
103+
await new Promise((r) => setTimeout(r, 0));
101104

102105
expect(context.ui.addItem).toHaveBeenCalledWith(
103106
expect.objectContaining({
@@ -114,6 +117,7 @@ describe('compressCommand', () => {
114117
mockTryCompressChat.mockRejectedValue(error);
115118

116119
await compressCommand.action!(context, '');
120+
await new Promise((r) => setTimeout(r, 0));
117121

118122
expect(context.ui.addItem).toHaveBeenCalledWith(
119123
expect.objectContaining({
@@ -128,6 +132,7 @@ describe('compressCommand', () => {
128132
it('should clear the pending item in a finally block', async () => {
129133
mockTryCompressChat.mockRejectedValue(new Error('some error'));
130134
await compressCommand.action!(context, '');
135+
await new Promise((r) => setTimeout(r, 0));
131136
expect(context.ui.setPendingItem).toHaveBeenCalledWith(null);
132137
});
133138

0 commit comments

Comments
 (0)