chore: sync gemini-cli v0.1.19

This commit is contained in:
tanzhenxin
2025-08-18 19:55:46 +08:00
244 changed files with 19407 additions and 5030 deletions

View File

@@ -18,6 +18,7 @@ import {
ToolConfirmationOutcome,
} from '@qwen-code/qwen-code-core';
import { useSessionStats } from '../contexts/SessionContext.js';
import { runExitCleanup } from '../../utils/cleanup.js';
import {
Message,
MessageType,
@@ -49,6 +50,7 @@ export const useSlashCommandProcessor = (
toggleCorgiMode: () => void,
setQuittingMessages: (message: HistoryItem[]) => void,
openPrivacyNotice: () => void,
openSettingsDialog: () => void,
toggleVimEnabled: () => Promise<boolean>,
setIsProcessing: (isProcessing: boolean) => void,
setGeminiMdFileCount: (count: number) => void,
@@ -63,6 +65,11 @@ export const useSlashCommandProcessor = (
approvedCommands?: string[],
) => void;
}>(null);
const [confirmationRequest, setConfirmationRequest] = useState<null | {
prompt: React.ReactNode;
onConfirm: (confirmed: boolean) => void;
}>(null);
const [sessionShellAllowlist, setSessionShellAllowlist] = useState(
new Set<string>(),
);
@@ -221,6 +228,7 @@ export const useSlashCommandProcessor = (
async (
rawQuery: PartListUnion,
oneTimeShellAllowlist?: Set<string>,
overwriteConfirmed?: boolean,
): Promise<SlashCommandProcessorResult | false> => {
setIsProcessing(true);
try {
@@ -300,6 +308,7 @@ export const useSlashCommandProcessor = (
name: commandToExecute.name,
args,
},
overwriteConfirmed,
};
// If a one-time list is provided for a "Proceed" action, temporarily
@@ -353,6 +362,11 @@ export const useSlashCommandProcessor = (
case 'privacy':
openPrivacyNotice();
return { type: 'handled' };
case 'settings':
openSettingsDialog();
return { type: 'handled' };
case 'help':
return { type: 'handled' };
default: {
const unhandled: never = result.dialog;
throw new Error(
@@ -372,7 +386,8 @@ export const useSlashCommandProcessor = (
}
case 'quit':
setQuittingMessages(result.messages);
setTimeout(() => {
setTimeout(async () => {
await runExitCleanup();
process.exit(0);
}, 100);
return { type: 'handled' };
@@ -422,6 +437,36 @@ export const useSlashCommandProcessor = (
new Set(approvedCommands),
);
}
case 'confirm_action': {
const { confirmed } = await new Promise<{
confirmed: boolean;
}>((resolve) => {
setConfirmationRequest({
prompt: result.prompt,
onConfirm: (resolvedConfirmed) => {
setConfirmationRequest(null);
resolve({ confirmed: resolvedConfirmed });
},
});
});
if (!confirmed) {
addItem(
{
type: MessageType.INFO,
text: 'Operation cancelled.',
},
Date.now(),
);
return { type: 'handled' };
}
return await handleSlashCommand(
result.originalInvocation.raw,
undefined,
true,
);
}
default: {
const unhandled: never = result;
throw new Error(
@@ -475,9 +520,11 @@ export const useSlashCommandProcessor = (
openPrivacyNotice,
openEditorDialog,
setQuittingMessages,
openSettingsDialog,
setShellConfirmationRequest,
setSessionShellAllowlist,
setIsProcessing,
setConfirmationRequest,
],
);
@@ -487,5 +534,6 @@ export const useSlashCommandProcessor = (
pendingHistoryItems,
commandContext,
shellConfirmationRequest,
confirmationRequest,
};
};