Skip to content

Commit 8d93c93

Browse files
committed
fix(cli): exit image mode when adding image via paste
- Add exitImageModeIfActive() helper in add-pending-image.ts - Call it from validateAndAddImage() and addPendingImageFromFile() - Fixes bug where /image mode wasn't exited after pasting an image
1 parent c8051cb commit 8d93c93

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cli/src/utils/add-pending-image.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import path from 'node:path'
44
import { processImageFile, resolveFilePath, isImageFile } from './image-handler'
55
import { useChatStore, type PendingImage } from '../state/chat-store'
66

7+
/**
8+
* Exit image input mode if currently active.
9+
* Called after successfully adding an image via paste or path.
10+
*/
11+
function exitImageModeIfActive(): void {
12+
if (useChatStore.getState().inputMode === 'image') {
13+
useChatStore.getState().setInputMode('default')
14+
}
15+
}
16+
717
/**
818
* Process an image file and add it to the pending images state.
919
* This handles compression/resizing and caches the result so we don't
@@ -67,6 +77,11 @@ export async function addPendingImageFromFile(
6777
}
6878
}),
6979
}))
80+
81+
// Exit image mode after successfully adding an image
82+
if (result.success) {
83+
exitImageModeIfActive()
84+
}
7085
}
7186

7287
/**
@@ -164,7 +179,7 @@ export async function validateAndAddImage(
164179
return { success: false, error }
165180
}
166181

167-
// Process and add the image
182+
// Process and add the image (addPendingImageFromFile handles exiting image mode on success)
168183
await addPendingImageFromFile(resolvedPath, cwd)
169184
return { success: true }
170185
}

0 commit comments

Comments
 (0)