Skip to content

Commit 27c9cd0

Browse files
authored
🤖 fix: enable image paste/drop for first prompt (#817)
The paste/drop handlers and ImageAttachments display were only wired up for the workspace variant, preventing users from pasting images in the first prompt (creation variant). ## Changes - Enable `onPaste`, `onDragOver`, `onDrop` handlers for both variants - Show `ImageAttachments` component for both variants - Update `useCreationWorkspace` to accept and pass `imageParts` to `sendMessage` - Clear image attachments on successful workspace creation _Generated with `mux`_
1 parent 19b5492 commit 27c9cd0

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/browser/components/ChatInput/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,13 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
563563
// Handle standard message sending based on variant
564564
if (variant === "creation") {
565565
setIsSending(true);
566-
const ok = await creationState.handleSend(messageText);
566+
const ok = await creationState.handleSend(
567+
messageText,
568+
imageParts.length > 0 ? imageParts : undefined
569+
);
567570
if (ok) {
568571
setInput("");
572+
setImageAttachments([]);
569573
if (inputRef.current) {
570574
inputRef.current.style.height = "36px";
571575
}
@@ -882,9 +886,9 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
882886
mode={mode}
883887
onChange={setInput}
884888
onKeyDown={handleKeyDown}
885-
onPaste={variant === "workspace" ? handlePaste : undefined}
886-
onDragOver={variant === "workspace" ? handleDragOver : undefined}
887-
onDrop={variant === "workspace" ? handleDrop : undefined}
889+
onPaste={handlePaste}
890+
onDragOver={handleDragOver}
891+
onDrop={handleDrop}
888892
suppressKeys={showCommandSuggestions ? COMMAND_SUGGESTION_KEYS : undefined}
889893
placeholder={placeholder}
890894
disabled={!editingMessage && (disabled || isSending)}
@@ -897,10 +901,8 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
897901
/>
898902
</div>
899903

900-
{/* Image attachments - workspace only */}
901-
{variant === "workspace" && (
902-
<ImageAttachments images={imageAttachments} onRemove={handleRemoveImage} />
903-
)}
904+
{/* Image attachments */}
905+
<ImageAttachments images={imageAttachments} onRemove={handleRemoveImage} />
904906

905907
<div className="flex flex-col gap-1" data-component="ChatModeToggles">
906908
{/* Editing indicator - workspace only */}

src/browser/components/ChatInput/useCreationWorkspace.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from "@/common/constants/storage";
1717
import type { Toast } from "@/browser/components/ChatInputToast";
1818
import { createErrorToast } from "@/browser/components/ChatInputToasts";
19+
import type { ImagePart } from "@/common/types/ipc";
1920

2021
interface UseCreationWorkspaceOptions {
2122
projectPath: string;
@@ -49,7 +50,7 @@ interface UseCreationWorkspaceReturn {
4950
toast: Toast | null;
5051
setToast: (toast: Toast | null) => void;
5152
isSending: boolean;
52-
handleSend: (message: string) => Promise<boolean>;
53+
handleSend: (message: string, imageParts?: ImagePart[]) => Promise<boolean>;
5354
}
5455

5556
/**
@@ -95,7 +96,7 @@ export function useCreationWorkspace({
9596
}, [projectPath]);
9697

9798
const handleSend = useCallback(
98-
async (message: string): Promise<boolean> => {
99+
async (message: string, imageParts?: ImagePart[]): Promise<boolean> => {
99100
if (!message.trim() || isSending) return false;
100101

101102
setIsSending(true);
@@ -114,6 +115,7 @@ export function useCreationWorkspace({
114115
runtimeConfig,
115116
projectPath, // Pass projectPath when workspaceId is null
116117
trunkBranch: settings.trunkBranch, // Pass selected trunk branch from settings
118+
imageParts: imageParts && imageParts.length > 0 ? imageParts : undefined,
117119
});
118120

119121
if (!result.success) {

0 commit comments

Comments
 (0)