Skip to content

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

feat(voiceNotes): attach voice notes by opaque id

Steven Enamakel3d9c5211a608
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index 6cc7c68d4b..77e64d3301 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -1317,7 +1317,6 @@ 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,
@@ -1352,7 +1351,6 @@ 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
@@ -1389,7 +1387,6 @@ 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) {
@@ -1439,28 +1436,12 @@ const Conversations = ({
const requestId = await chatSend({
threadId: sendingThreadId,
message: messageText,
- ...(opts?.voicePart
- ? { attachments: [...attachmentParts, opts.voicePart] }
- : attachmentParts.length
- ? { attachments: attachmentParts }
- : {}),
+ ...(opts?.voicePart ? { attachments: [opts.voicePart] } : {}),
...(modelOverride !== undefined ? { model: modelOverride } : {}),
locale: uiLocale,
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,
@@ -1527,7 +1508,12 @@ const Conversations = ({
if (!transcript) throw new Error(t('voiceNote.transcribeFailed'));
const noteId = `vn_${globalThis.crypto.randomUUID().replace(/-/g, '')}`;
const { mime } = await storeVoiceNote(noteId, draft.blob);
- const voicePart = await voiceNoteContentPart(draft.blob, draft.durationMs, draft.waveform);
+ const voicePart = await voiceNoteContentPart(
+ noteId,
+ draft.blob,
+ draft.durationMs,
+ draft.waveform
+ );
await handleSendMessage(transcript, {
voiceNote: { noteId, mime, durationMs: draft.durationMs, waveform: draft.waveform },
voicePart,
diff --git a/app/src/features/voiceNotes/voiceNoteApi.test.ts b/app/src/features/voiceNotes/voiceNoteApi.test.ts
index bfec13cba3..79dc069e17 100644
--- a/app/src/features/voiceNotes/voiceNoteApi.test.ts
+++ b/app/src/features/voiceNotes/voiceNoteApi.test.ts
@@ -25,6 +25,7 @@ describe('voiceNoteApi', () => {
it('keeps a recording as a typed voice-note part with its media and duration', async () => {
const part = await voiceNoteContentPart(
+ 'note-123',
new Blob([new Uint8Array([0, 1, 2])], { type: 'audio/wav' }),
5000,
[0.2, 0.8]
@@ -38,6 +39,7 @@ describe('voiceNoteApi', () => {
waveform: [0.2, 0.8],
pushToTalk: false,
media: {
+ opaqueId: 'note-123',
url: 'data:audio/wav;base64,AAEC',
kind: 'audio',
contentType: 'audio/wav',
diff --git a/app/src/features/voiceNotes/voiceNoteApi.ts b/app/src/features/voiceNotes/voiceNoteApi.ts
index 7249d835c2..8c2a381080 100644
--- a/app/src/features/voiceNotes/voiceNoteApi.ts
+++ b/app/src/features/voiceNotes/voiceNoteApi.ts
@@ -50,6 +50,7 @@ export function bytesToBase64(bytes: Uint8Array): string {
/** Keep the recorded media on the typed web-chat wire beside its transcript. */
export async function voiceNoteContentPart(
+ noteId: string,
blob: Blob,
durationMs: number,
waveform: number[]
@@ -64,6 +65,7 @@ export async function voiceNoteContentPart(
waveform,
pushToTalk: false,
media: {
+ opaqueId: noteId,
url: `data:${mime};base64,${bytesToBase64(bytes)}`,
kind: 'audio',
contentType: mime,