Skip to content

Commit 8c2dd13

Browse files
committed
refactor(cli): replace dynamic imports with static imports in chat.tsx
1 parent 96775eb commit 8c2dd13

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

cli/src/chat.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
import { useShallow } from 'zustand/react/shallow'
1212

1313
import { routeUserPrompt, addBashMessageToHistory } from './commands/router'
14+
import { addPendingImageFromFile } from './utils/add-pending-image'
15+
import { getProjectRoot } from './project-files'
1416
import { AnnouncementBanner } from './components/announcement-banner'
1517
import { hasClipboardImage, readClipboardImage } from './utils/clipboard-image'
1618
import { showClipboardMessage } from './utils/clipboard'
@@ -1013,33 +1015,21 @@ export const Chat = ({
10131015
onBashHistoryUp: navigateUp,
10141016
onBashHistoryDown: navigateDown,
10151017
onPasteImage: () => {
1016-
// Check if clipboard has an image
10171018
if (!hasClipboardImage()) {
1018-
// No image in clipboard, let normal paste happen
10191019
return false
10201020
}
10211021

1022-
// Read image from clipboard
10231022
const result = readClipboardImage()
10241023
if (!result.success || !result.imagePath || !result.filename) {
10251024
showClipboardMessage(result.error || 'Failed to paste image', {
10261025
durationMs: 3000,
10271026
})
1028-
return true // We handled it (with an error), don't let default paste happen
1027+
return true
10291028
}
10301029

1031-
const imagePath = result.imagePath
1032-
if (!imagePath) return true
1033-
1034-
// Process and add image (handles compression and caching)
1035-
void (async () => {
1036-
const { addPendingImageFromFile } = await import('./utils/add-pending-image')
1037-
const { getProjectRoot } = await import('./project-files')
1038-
const cwd = getProjectRoot() ?? process.cwd()
1039-
await addPendingImageFromFile(imagePath, cwd)
1040-
})()
1041-
1042-
return true // Image was pasted successfully
1030+
const cwd = getProjectRoot() ?? process.cwd()
1031+
void addPendingImageFromFile(result.imagePath, cwd)
1032+
return true
10431033
},
10441034
}),
10451035
[

0 commit comments

Comments
 (0)