fix: image gen result persistence with fallback for temp message IDs, bump v0.17.3
Root cause: assistant messages use temporary IDs (temp-assistant-{timestamp})
in the frontend, which don't match real DB message IDs. The PUT update by
message_id always found 0 rows, so results were never persisted.
Fix — fallback search by session + prompt:
- db.ts: updateMessageContent now returns changes count; new
updateMessageBySessionAndHint() finds the latest assistant message
containing image-gen-request with matching prompt text and updates it
- /api/chat/messages PUT: tries message_id first, falls back to
session_id + prompt_hint search; returns 404 if neither finds a match;
response includes updated_message_id and fallback_used for debugging
- ImageGenConfirmation: always sends session_id and prompt_hint in PUT
request, regardless of whether messageId is a real or temp ID
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
20a5934cfc
commit
40a78ea0fc
5 files changed
+68
-13
No files matched your search
@@ -143,7 +143,7 @@ export function ImageGenConfirmation({
|
||||
}
|
||||
|
||||
// Persist result to DB by replacing image-gen-request with image-gen-result
|
||||
if (messageId) {
|
||||
{
|
||||
const resultBlock = JSON.stringify({
|
||||
status: 'completed',
|
||||
prompt,
|
||||
@@ -158,8 +158,10 @@ export function ImageGenConfirmation({
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
message_id: messageId,
|
||||
message_id: messageId || '',
|
||||
content: '```image-gen-result\n' + resultBlock + '\n```',
|
||||
session_id: sessionId,
|
||||
prompt_hint: initialPrompt,
|
||||
}),
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user