sync gemini-cli 0.1.17

Co-Authored-By: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Yiheng Xu
2025-08-05 16:44:06 +08:00
235 changed files with 16997 additions and 3736 deletions

View File

@@ -13,6 +13,8 @@ import {
Config,
GitService,
Logger,
logSlashCommand,
SlashCommandEvent,
ToolConfirmationOutcome,
} from '@qwen-code/qwen-code-core';
import { useSessionStats } from '../contexts/SessionContext.js';
@@ -40,7 +42,6 @@ export const useSlashCommandProcessor = (
clearItems: UseHistoryManagerReturn['clearItems'],
loadHistory: UseHistoryManagerReturn['loadHistory'],
refreshStatic: () => void,
setShowHelp: React.Dispatch<React.SetStateAction<boolean>>,
onDebugMessage: (message: string) => void,
openThemeDialog: () => void,
openAuthDialog: () => void,
@@ -103,6 +104,11 @@ export const useSlashCommandProcessor = (
selectedAuthType: message.selectedAuthType,
gcpProject: message.gcpProject,
};
} else if (message.type === MessageType.HELP) {
historyItemContent = {
type: 'help',
timestamp: message.timestamp,
};
} else if (message.type === MessageType.STATS) {
historyItemContent = {
type: 'stats',
@@ -136,7 +142,6 @@ export const useSlashCommandProcessor = (
},
[addItem],
);
const commandContext = useMemo(
(): CommandContext => ({
services: {
@@ -185,6 +190,8 @@ export const useSlashCommandProcessor = (
],
);
const ideMode = config?.getIdeMode();
useEffect(() => {
const controller = new AbortController();
const load = async () => {
@@ -205,7 +212,7 @@ export const useSlashCommandProcessor = (
return () => {
controller.abort();
};
}, [config]);
}, [config, ideMode]);
const handleSlashCommand = useCallback(
async (
@@ -235,6 +242,7 @@ export const useSlashCommandProcessor = (
let currentCommands = commands;
let commandToExecute: SlashCommand | undefined;
let pathIndex = 0;
const canonicalPath: string[] = [];
for (const part of commandPath) {
// TODO: For better performance and architectural clarity, this two-pass
@@ -255,6 +263,7 @@ export const useSlashCommandProcessor = (
if (foundCommand) {
commandToExecute = foundCommand;
canonicalPath.push(foundCommand.name);
pathIndex++;
if (foundCommand.subCommands) {
currentCommands = foundCommand.subCommands;
@@ -270,6 +279,17 @@ export const useSlashCommandProcessor = (
const args = parts.slice(pathIndex).join(' ');
if (commandToExecute.action) {
if (config) {
const resolvedCommandPath = canonicalPath;
const event = new SlashCommandEvent(
resolvedCommandPath[0],
resolvedCommandPath.length > 1
? resolvedCommandPath.slice(1).join(' ')
: undefined,
);
logSlashCommand(config, event);
}
const fullCommandContext: CommandContext = {
...commandContext,
invocation: {
@@ -318,9 +338,6 @@ export const useSlashCommandProcessor = (
return { type: 'handled' };
case 'dialog':
switch (result.dialog) {
case 'help':
setShowHelp(true);
return { type: 'handled' };
case 'auth':
openAuthDialog();
return { type: 'handled' };
@@ -447,7 +464,6 @@ export const useSlashCommandProcessor = (
[
config,
addItem,
setShowHelp,
openAuthDialog,
commands,
commandContext,