mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-11 05:41:08 -07:00
fix: positional arguments for MCP prompts (#8034)
This commit is contained in:
@@ -549,7 +549,13 @@ describe('useSlashCompletion', () => {
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockCompletionFn).toHaveBeenCalledWith(
|
||||
mockCommandContext,
|
||||
expect.objectContaining({
|
||||
invocation: {
|
||||
raw: '/chat resume my-ch',
|
||||
name: 'resume',
|
||||
args: 'my-ch',
|
||||
},
|
||||
}),
|
||||
'my-ch',
|
||||
);
|
||||
});
|
||||
@@ -591,7 +597,16 @@ describe('useSlashCompletion', () => {
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockCompletionFn).toHaveBeenCalledWith(mockCommandContext, '');
|
||||
expect(mockCompletionFn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
invocation: {
|
||||
raw: '/chat resume',
|
||||
name: 'resume',
|
||||
args: '',
|
||||
},
|
||||
}),
|
||||
'',
|
||||
);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { AsyncFzf } from 'fzf';
|
||||
import type { Suggestion } from '../components/SuggestionsDisplay.js';
|
||||
import type { CommandContext, SlashCommand } from '../commands/types.js';
|
||||
import {
|
||||
CommandKind,
|
||||
type CommandContext,
|
||||
type SlashCommand,
|
||||
} from '../commands/types.js';
|
||||
|
||||
// Type alias for improved type safety based on actual fzf result structure
|
||||
type FzfCommandResult = {
|
||||
@@ -93,9 +97,13 @@ function useCommandParser(
|
||||
const found: SlashCommand | undefined = currentLevel.find((cmd) =>
|
||||
matchesCommand(cmd, part),
|
||||
);
|
||||
|
||||
if (found) {
|
||||
leafCommand = found;
|
||||
currentLevel = found.subCommands as readonly SlashCommand[] | undefined;
|
||||
if (found.kind === CommandKind.MCP_PROMPT) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
leafCommand = null;
|
||||
currentLevel = [];
|
||||
@@ -194,7 +202,17 @@ function useCommandSuggestions(
|
||||
const depth = commandPathParts.length;
|
||||
const argString = rawParts.slice(depth).join(' ');
|
||||
const results =
|
||||
(await leafCommand.completion(commandContext, argString)) || [];
|
||||
(await leafCommand.completion(
|
||||
{
|
||||
...commandContext,
|
||||
invocation: {
|
||||
raw: `/${rawParts.join(' ')}`,
|
||||
name: leafCommand.name,
|
||||
args: argString,
|
||||
},
|
||||
},
|
||||
argString,
|
||||
)) || [];
|
||||
|
||||
if (!signal.aborted) {
|
||||
const finalSuggestions = results.map((s) => ({
|
||||
|
||||
Reference in New Issue
Block a user