Skip to content

Commit aebbca4

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

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

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

Lines changed: 22 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,21 @@ describe('AppContainer State Management', () => {
36193624

36203625
unmount();
36213626
});
3627+
3628+
it('queues slash commands 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 queued
3635+
expect(capturedUIState.messageQueue).toContain('/help');
3636+
// Verify handleSlashCommand was NOT called immediately
3637+
expect(
3638+
mockedUseSlashCommandProcessor().handleSlashCommand,
3639+
).not.toHaveBeenCalled();
3640+
3641+
unmount();
3642+
});
36223643
});
36233644
});

packages/cli/src/ui/AppContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,8 +1426,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
14261426

14271427
const isMcpOrConfigReady = isConfigInitialized && isMcpReady;
14281428
if (
1429-
(isSlash && isConfigInitialized) ||
1430-
(isIdle && !isCompressing && isMcpOrConfigReady)
1429+
!isCompressing &&
1430+
((isSlash && isConfigInitialized) || (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)