summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useGeminiStream.ts
diff options
context:
space:
mode:
authorAbhi <[email protected]>2025-07-22 00:34:55 -0400
committerGitHub <[email protected]>2025-07-22 04:34:55 +0000
commit9daead63ddc4a0bddad05ec9f4bb7c0726da44f4 (patch)
treea756014f436f4cc356ca334a45494386027e7b4e /packages/cli/src/ui/hooks/useGeminiStream.ts
parent5f813ef51076177aadccc0046f2182310d6b0a1a (diff)
(feat): Initial Version of Custom Commands (#4572)
Diffstat (limited to 'packages/cli/src/ui/hooks/useGeminiStream.ts')
-rw-r--r--packages/cli/src/ui/hooks/useGeminiStream.ts42
1 files changed, 30 insertions, 12 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts
index 295b5650..456c0fb7 100644
--- a/packages/cli/src/ui/hooks/useGeminiStream.ts
+++ b/packages/cli/src/ui/hooks/useGeminiStream.ts
@@ -240,19 +240,37 @@ export const useGeminiStream = (
const slashCommandResult = await handleSlashCommand(trimmedQuery);
if (slashCommandResult) {
- if (slashCommandResult.type === 'schedule_tool') {
- const { toolName, toolArgs } = slashCommandResult;
- const toolCallRequest: ToolCallRequestInfo = {
- callId: `${toolName}-${Date.now()}-${Math.random().toString(16).slice(2)}`,
- name: toolName,
- args: toolArgs,
- isClientInitiated: true,
- prompt_id,
- };
- scheduleToolCalls([toolCallRequest], abortSignal);
- }
+ switch (slashCommandResult.type) {
+ case 'schedule_tool': {
+ const { toolName, toolArgs } = slashCommandResult;
+ const toolCallRequest: ToolCallRequestInfo = {
+ callId: `${toolName}-${Date.now()}-${Math.random().toString(16).slice(2)}`,
+ name: toolName,
+ args: toolArgs,
+ isClientInitiated: true,
+ prompt_id,
+ };
+ scheduleToolCalls([toolCallRequest], abortSignal);
+ return { queryToSend: null, shouldProceed: false };
+ }
+ case 'submit_prompt': {
+ localQueryToSendToGemini = slashCommandResult.content;
- return { queryToSend: null, shouldProceed: false };
+ return {
+ queryToSend: localQueryToSendToGemini,
+ shouldProceed: true,
+ };
+ }
+ case 'handled': {
+ return { queryToSend: null, shouldProceed: false };
+ }
+ default: {
+ const unreachable: never = slashCommandResult;
+ throw new Error(
+ `Unhandled slash command result type: ${unreachable}`,
+ );
+ }
+ }
}
if (shellModeActive && handleShellCommand(trimmedQuery, abortSignal)) {