feat: support uploaded images in debug voice preview

Allow paste/drag temporary image assets so vision turns work without a live camera frame.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Xin Wang
2026-08-05 19:52:37 +08:00
co-authored by Cursor
parent 555c8f5fa6
commit e36ca308b8
16 changed files with 686 additions and 94 deletions
+11 -4
View File
@@ -61,7 +61,9 @@ export type UserInputPart =
| { type: "input_text"; text: string }
| {
type: "input_image";
source: { type: "camera_frame"; frame: "current" };
source:
| { type: "camera_frame"; frame: "current" }
| { type: "uploaded_asset"; asset_token: string };
};
export type UserInputResult = {
inputId: string;
@@ -880,7 +882,12 @@ export function useVoicePreview(
);
const appendUserImage = useCallback(
(inputId: string, imageUrl: string, timestamp: string) => {
(
inputId: string,
imageUrl: string,
timestamp: string,
content = "",
) => {
messageSeqRef.current += 1;
const sequence = messageSeqRef.current;
setMessages((previous) =>
@@ -889,7 +896,7 @@ export function useVoicePreview(
{
id: `user-image-${inputId}`,
role: "user",
content: "",
content: content.trim(),
timestamp,
sequence,
attachments: [
@@ -897,7 +904,7 @@ export function useVoicePreview(
id: `image-${inputId}`,
type: "image",
url: imageUrl,
alt: "用户拍摄的照片",
alt: "用户提交的图片",
},
],
},