Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(conversations): persist request id on user message

Steven Enamakelc796e76282a6
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index f6ce0c54c8..934dd1af34 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -1317,6 +1317,7 @@ const Conversations = ({
// Originals ride beside the text as typed parts; the core stages them.
const attachmentParts = attachmentsToParts(pendingAttachments);
let messageText = trimmed;
+ let persistedUserMessage: ThreadMessage | null = null;
const userMessage: ThreadMessage = {
id: `msg_${globalThis.crypto.randomUUID()}`,
content: messageText,
@@ -1351,6 +1352,7 @@ const Conversations = ({
if (retryingUnchangedMessage) {
// The core already has this exact prompt from the failed attempt.
messageText = previousFailedMessage.content;
+ persistedUserMessage = previousFailedMessage;
} else if (previousFailedMessage) {
// A corrected retry must replace the already-persisted failed prompt;
// appending it would leave both prompts in the transcript. The edit
@@ -1387,6 +1389,7 @@ const Conversations = ({
).unwrap();
// The core saved the originals before returning this durable reference.
messageText = persisted.message.content;
+ persistedUserMessage = persisted.message;
persistedFailedMessageByThreadRef.current.set(sendingThreadId, persisted.message);
}
} catch (error) {
@@ -1433,7 +1436,7 @@ const Conversations = ({
// routed provider (managed cloud, BYOK, or a user-run local endpoint such
// as Ollama configured under Connections → LLM).
try {
- await chatSend({
+ const requestId = await chatSend({
threadId: sendingThreadId,
message: messageText,
...(opts?.voicePart
@@ -1446,6 +1449,18 @@ const Conversations = ({
reasoningEffort: composerReasoningEffort,
...(opts?.voiceNote ? { source: VOICE_NOTE_SOURCE } : {}),
});
+ if (requestId && persistedUserMessage) {
+ try {
+ await threadApi.updateMessage(sendingThreadId, persistedUserMessage.id, {
+ ...persistedUserMessage.extraMetadata,
+ requestId,
+ });
+ } catch (error) {
+ // Keep the accepted turn alive if the UI-only correlation stamp
+ // cannot be persisted; legacy projection remains conservative.
+ console.warn('[voice-note] could not persist user-turn correlation', error);
+ }
+ }
trackAnalyticsEvent('chat_message_sent', {
send_mode: opts?.voiceNote ? 'voice_note' : 'standard',
has_attachments: pendingAttachments.length > 0,