diff --git a/apps/rowboat/components/common/compose-box-playground.tsx b/apps/rowboat/components/common/compose-box-playground.tsx index e0c941bd..e6fa2abe 100644 --- a/apps/rowboat/components/common/compose-box-playground.tsx +++ b/apps/rowboat/components/common/compose-box-playground.tsx @@ -23,6 +23,7 @@ export function ComposeBoxPlayground({ }: ComposeBoxPlaygroundProps) { const [input, setInput] = useState(''); const [uploading, setUploading] = useState(false); + const [pendingImage, setPendingImage] = useState<{ url: string; mimeType?: string } | null>(null); const [isFocused, setIsFocused] = useState(false); const textareaRef = useRef(null); const previousMessagesLength = useRef(messages.length); @@ -36,11 +37,18 @@ export function ComposeBoxPlayground({ }, [messages.length, shouldAutoFocus]); function handleInput() { - const prompt = input.trim(); - if (!prompt) { + const text = input.trim(); + if (!text && !pendingImage) { return; } + const parts: string[] = []; + if (text) parts.push(text); + if (pendingImage?.url) { + parts.push(`The user uploaded an image. URL: ${pendingImage.url}`); + } + const prompt = parts.join('\n\n'); setInput(''); + setPendingImage(null); handleUserMessage(prompt); } @@ -72,7 +80,7 @@ export function ComposeBoxPlayground({ const data = await res.json(); const url: string | undefined = data?.url; if (!url) throw new Error('No URL returned'); - handleUserMessage(`The user uploaded an image. URL: ${url}`); + setPendingImage({ url, mimeType: data?.mimeType }); } catch (e) { console.error('Image upload failed', e); alert('Image upload failed. Please try again.'); @@ -113,6 +121,22 @@ export function ComposeBoxPlayground({ {/* Textarea */}
+ {pendingImage && ( +
+ Uploaded image preview + +
+ )}