diff --git a/assistant/src/daemon/handlers/misc.ts b/assistant/src/daemon/handlers/misc.ts index 61da49f02ba..09998d8f901 100644 --- a/assistant/src/daemon/handlers/misc.ts +++ b/assistant/src/daemon/handlers/misc.ts @@ -110,10 +110,19 @@ export async function handleTaskSubmit( ctx.send(socket, { type: 'task_routed', sessionId: conversation.id, interactionType: 'text_qa' }); ctx.send(socket, { type: 'assistant_text_delta', text: 'Starting screen recording.', sessionId: conversation.id }); } else { + // Recording was rejected (already active) — clean up the orphaned conversation ctx.send(socket, { type: 'task_routed', sessionId: conversation.id, interactionType: 'text_qa' }); ctx.send(socket, { type: 'assistant_text_delta', text: 'A recording is already active.', sessionId: conversation.id }); } ctx.send(socket, { type: 'message_complete', sessionId: conversation.id }); + + if (!recordingId) { + // Unbind the socket so the ephemeral rejection session doesn't block + // future task_submit routing, but keep the conversation in the DB so + // the client can still send follow-up messages to the routed sessionId. + ctx.socketToSession.delete(socket); + } + rlog.info({ sessionId: conversation.id }, 'Recording-only intent intercepted — routed to standalone recording'); return; }