fix(chat): preserve user image message order
This commit is contained in:
@@ -49,6 +49,7 @@ import { WaveformTimelinePanel } from "@/components/ui/waveform-timeline";
|
||||
import { useCameraPreview, type CameraPreview } from "@/hooks/use-camera-preview";
|
||||
import { usePhotoCaptureTool } from "@/hooks/use-photo-capture-tool";
|
||||
import {
|
||||
createUserInputId,
|
||||
useVoicePreview,
|
||||
type ChatMessage,
|
||||
type ClientToolDefinition,
|
||||
@@ -799,6 +800,7 @@ function DebugVoicePanel({
|
||||
sendText,
|
||||
sendUserInput,
|
||||
appendUserImage,
|
||||
removeUserImage,
|
||||
connect,
|
||||
disconnect,
|
||||
audioRef,
|
||||
@@ -866,6 +868,7 @@ function DebugVoicePanel({
|
||||
setSendingInput(true);
|
||||
setInputError("");
|
||||
let assetToken = "";
|
||||
let inputId = "";
|
||||
try {
|
||||
const imageUrl = await fileToDataUrl(pendingImage.file);
|
||||
const asset = await inputAssetsApi.uploadImage(pendingImage.file);
|
||||
@@ -878,11 +881,13 @@ function DebugVoicePanel({
|
||||
});
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
const result = await sendUserInput(parts);
|
||||
appendUserImage(result.inputId, imageUrl, timestamp, text);
|
||||
inputId = createUserInputId();
|
||||
appendUserImage(inputId, imageUrl, timestamp, text);
|
||||
await sendUserInput(parts, { inputId });
|
||||
setTextDraft("");
|
||||
setPendingImage(null);
|
||||
} catch (sendError) {
|
||||
if (inputId) removeUserImage(inputId);
|
||||
if (assetToken) {
|
||||
void inputAssetsApi.remove(assetToken).catch(() => {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user