summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/chatCommand.ts
diff options
context:
space:
mode:
authorHiroaki Mitsuyoshi <[email protected]>2025-08-09 15:59:22 +0900
committerGitHub <[email protected]>2025-08-09 06:59:22 +0000
commit6487cc16895976ef6c983f8beca08a64addb6688 (patch)
treee2d4d06bc37331d0c36a1c27442457d42f81d385 /packages/cli/src/ui/commands/chatCommand.ts
parent191cc01bf5833a4c7636f8fc4d9b4c5066982822 (diff)
feat(chat): Add overwrite confirmation dialog to `/chat save` (#5686)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/commands/chatCommand.ts')
-rw-r--r--packages/cli/src/ui/commands/chatCommand.ts26
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/cli/src/ui/commands/chatCommand.ts b/packages/cli/src/ui/commands/chatCommand.ts
index a5fa13da..56eebe1a 100644
--- a/packages/cli/src/ui/commands/chatCommand.ts
+++ b/packages/cli/src/ui/commands/chatCommand.ts
@@ -5,11 +5,15 @@
*/
import * as fsPromises from 'fs/promises';
+import React from 'react';
+import { Text } from 'ink';
+import { Colors } from '../colors.js';
import {
CommandContext,
SlashCommand,
MessageActionReturn,
CommandKind,
+ SlashCommandActionReturn,
} from './types.js';
import path from 'path';
import { HistoryItemWithoutId, MessageType } from '../types.js';
@@ -96,7 +100,7 @@ const saveCommand: SlashCommand = {
description:
'Save the current conversation as a checkpoint. Usage: /chat save <tag>',
kind: CommandKind.BUILT_IN,
- action: async (context, args): Promise<MessageActionReturn> => {
+ action: async (context, args): Promise<SlashCommandActionReturn | void> => {
const tag = args.trim();
if (!tag) {
return {
@@ -108,6 +112,26 @@ const saveCommand: SlashCommand = {
const { logger, config } = context.services;
await logger.initialize();
+
+ if (!context.overwriteConfirmed) {
+ const exists = await logger.checkpointExists(tag);
+ if (exists) {
+ return {
+ type: 'confirm_action',
+ prompt: React.createElement(
+ Text,
+ null,
+ 'A checkpoint with the tag ',
+ React.createElement(Text, { color: Colors.AccentPurple }, tag),
+ ' already exists. Do you want to overwrite it?',
+ ),
+ originalInvocation: {
+ raw: context.invocation?.raw || `/chat save ${tag}`,
+ },
+ };
+ }
+ }
+
const chat = await config?.getGeminiClient()?.getChat();
if (!chat) {
return {