fix(cli): remove /plan extension context hacks and fix dropped queue messages

This commit is contained in:
Mahima Shanware
2026-04-07 02:59:30 +00:00
parent 7ab4c3d61f
commit 76c28142eb
5 changed files with 4 additions and 58 deletions
+1 -1
View File
@@ -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) {
@@ -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'),
+1 -1
View File
@@ -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);
@@ -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);
});
});
});
@@ -378,8 +378,6 @@ export const useSlashCommandProcessor = (
} else {
config.setActiveExtensionContext(undefined);
}
} else if (resolvedCommandPath?.[0] === 'plan') {
config.setActiveExtensionContext(undefined);
}
}