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
parent 555c8f5fa6
commit e36ca308b8
16 changed files with 686 additions and 94 deletions

View File

@@ -32,7 +32,7 @@ class UserInputParserTests(unittest.TestCase):
self.assertIsNotNone(value)
self.assertEqual(value.text, "帮我看看")
self.assertTrue(value.has_camera_frame)
self.assertEqual(value.transcript_text, "帮我看看")
self.assertEqual(value.transcript_text, "")
def test_rejects_legacy_and_unsupported_image_sources(self):
self.assertIsNone(parse_user_input({"type": "user-text", "text": "旧协议"}))
@@ -46,14 +46,40 @@ class UserInputParserTests(unittest.TestCase):
{
"type": "input_image",
"source": {
"type": "uploaded_asset",
"asset_id": "asset_1",
"type": "remote_url",
"url": "https://example.com/image.jpg",
},
}
],
}
)
def test_parses_uploaded_image_asset(self):
value = parse_user_input(
{
"type": "user-input",
"schema_version": 1,
"input_id": "input_upload",
"parts": [
{"type": "input_text", "text": "这是什么?"},
{
"type": "input_image",
"source": {
"type": "uploaded_asset",
"asset_token": "signed-token",
},
},
],
}
)
self.assertIsNotNone(value)
self.assertTrue(value.has_image)
self.assertFalse(value.has_camera_frame)
self.assertEqual(value.image_asset_token, "signed-token")
self.assertEqual(value.prompt_text, "这是什么?")
self.assertEqual(value.transcript_text, "")
def test_image_only_input_has_no_synthetic_chat_text(self):
value = parse_user_input(
{