From 76c28142ebfa1f76830846997ec1043fa101e610 Mon Sep 17 00:00:00 2001 From: Mahima Shanware Date: Tue, 7 Apr 2026 02:59:30 +0000 Subject: [PATCH] fix(cli): remove /plan extension context hacks and fix dropped queue messages --- packages/cli/src/ui/AppContainer.tsx | 2 +- .../cli/src/ui/commands/planCommand.test.ts | 3 +- packages/cli/src/ui/commands/planCommand.ts | 2 +- .../ui/hooks/slashCommandProcessor.test.tsx | 53 ------------------- .../cli/src/ui/hooks/slashCommandProcessor.ts | 2 - 5 files changed, 4 insertions(+), 58 deletions(-) diff --git a/packages/cli/src/ui/AppContainer.tsx b/packages/cli/src/ui/AppContainer.tsx index ccf6b58fb1..3aed6c700e 100644 --- a/packages/cli/src/ui/AppContainer.tsx +++ b/packages/cli/src/ui/AppContainer.tsx @@ -1366,7 +1366,7 @@ Logging in with Google... Restarting Gemini CLI to continue. } const isMcpOrConfigReady = isConfigInitialized && isMcpReady; - if ((isSlash && isConfigInitialized) || (isIdle && isMcpOrConfigReady)) { + if (isIdle && ((isSlash && isConfigInitialized) || isMcpOrConfigReady)) { if (!isSlash) { const permissions = await checkPermissions(submittedValue, config); if (permissions.length > 0) { diff --git a/packages/cli/src/ui/commands/planCommand.test.ts b/packages/cli/src/ui/commands/planCommand.test.ts index 56b6949750..ea51411794 100644 --- a/packages/cli/src/ui/commands/planCommand.test.ts +++ b/packages/cli/src/ui/commands/planCommand.test.ts @@ -56,8 +56,9 @@ describe('planCommand', () => { config: { isPlanEnabled: vi.fn(), setApprovalMode: vi.fn(), - getApprovedPlanPath: vi.fn(), getApprovalMode: vi.fn(), + getApprovedPlanPath: vi.fn(), + getPlansDir: vi.fn(), getFileSystemService: vi.fn(), storage: { getPlansDir: vi.fn().mockReturnValue('/mock/plans/dir'), diff --git a/packages/cli/src/ui/commands/planCommand.ts b/packages/cli/src/ui/commands/planCommand.ts index b90c74323c..b0d48d107a 100644 --- a/packages/cli/src/ui/commands/planCommand.ts +++ b/packages/cli/src/ui/commands/planCommand.ts @@ -82,7 +82,7 @@ export const planCommand: SlashCommand = { try { const content = await processSingleFileContent( approvedPlanPath, - config.storage.getPlansDir(), + config.getPlansDir(), config.getFileSystemService(), ); const fileName = path.basename(approvedPlanPath); diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.tsx b/packages/cli/src/ui/hooks/slashCommandProcessor.test.tsx index c909c6d7f8..34d6f4759a 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.tsx +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.tsx @@ -1046,53 +1046,6 @@ describe('useSlashCommandProcessor', () => { expect(spySetContext).toHaveBeenCalledWith(undefined); }); - it('clears active extension context when the canonical /plan command is executed', async () => { - const planCommand = createTestCommand({ - name: 'plan', - action: vi.fn(), - }); - - const spySetContext = vi.spyOn(mockConfig, 'setActiveExtensionContext'); - - const hook = await setupProcessorHook({ - builtinCommands: [planCommand], - }); - - await waitFor(() => expect(hook.current.slashCommands!.length).toBe(1)); - - await act(async () => { - await hook.current.handleSlashCommand('/plan my task'); - }); - - expect(spySetContext).toHaveBeenCalledWith(undefined); - }); - - it('clears active extension context when a /plan alias or subcommand is executed', async () => { - const planCommand = createTestCommand({ - name: 'plan', - subCommands: [ - createTestCommand({ - name: 'create', - }), - ], - action: vi.fn(), - }); - - const spySetContext = vi.spyOn(mockConfig, 'setActiveExtensionContext'); - - const hook = await setupProcessorHook({ - builtinCommands: [planCommand], - }); - - await waitFor(() => expect(hook.current.slashCommands!.length).toBe(1)); - - await act(async () => { - await hook.current.handleSlashCommand('/plan create'); - }); - - expect(spySetContext).toHaveBeenCalledWith(undefined); - }); - it('handles a sequence of context switches between extensions and default plan mode', async () => { const extA = createTestCommand({ name: 'extA', @@ -1137,12 +1090,6 @@ describe('useSlashCommandProcessor', () => { }); // A concurrent command should NOT modify the active extension context expect(spySetContext).not.toHaveBeenCalled(); - - // 4. Run /plan (Default) - await act(async () => { - await hook.current.handleSlashCommand('/plan my task'); - }); - expect(spySetContext).toHaveBeenLastCalledWith(undefined); }); }); }); diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index 035c65d7e7..5dac34542f 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -378,8 +378,6 @@ export const useSlashCommandProcessor = ( } else { config.setActiveExtensionContext(undefined); } - } else if (resolvedCommandPath?.[0] === 'plan') { - config.setActiveExtensionContext(undefined); } }