fix: return real message id from chat_send so editing fresh messages works
This commit is contained in:
+2
-1
@@ -188,7 +188,8 @@ export const api = {
|
||||
invoke<void>("deploy_model", { modelId, params }),
|
||||
engineStop: () => invoke<void>("engine_stop"),
|
||||
engineStatus: () => invoke<EngineStatus>("engine_status"),
|
||||
chatSend: (payload: ChatSendPayload) => invoke<string>("chat_send", { payload }),
|
||||
chatSend: (payload: ChatSendPayload) =>
|
||||
invoke<{ conversation_id: string; message_id: string }>("chat_send", { payload }),
|
||||
regenerateMessage: (
|
||||
conversationId: string,
|
||||
messageId: string,
|
||||
|
||||
@@ -219,21 +219,27 @@ export default function ChatPage() {
|
||||
await refreshConversations();
|
||||
}
|
||||
|
||||
const tempUserId = `user-${Date.now()}`;
|
||||
setMessages((prev) => [
|
||||
...prev,
|
||||
{ id: `user-${Date.now()}`, role: "user", content, images },
|
||||
{ id: tempUserId, role: "user", content, images },
|
||||
{ id: `assistant-${Date.now()}`, role: "assistant", content: "", streaming: true },
|
||||
]);
|
||||
setStreaming(true);
|
||||
|
||||
try {
|
||||
await api.chatSend({
|
||||
const result = await api.chatSend({
|
||||
conversation_id: convId,
|
||||
model_id: selectedModelId,
|
||||
content,
|
||||
params,
|
||||
images,
|
||||
});
|
||||
if (result?.message_id) {
|
||||
setMessages((prev) =>
|
||||
prev.map((m) => (m.id === tempUserId ? { ...m, id: result.message_id } : m)),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
setStreaming(false);
|
||||
setError(String(e));
|
||||
|
||||
Reference in New Issue
Block a user