fix: address critical review issues in voice overlay

- Clean up voice sessions on WebSocket disconnect (prevents timer leak)
- Guard against missing LLM config in voice_stop send path
- Return overlay to idle on goal_failed (prevents stuck UI)
This commit is contained in:
Sanju Sivalingam
2026-02-20 02:16:39 +05:30
parent 1f47a990cc
commit a42b5b08f4
2 changed files with 9 additions and 1 deletions

View File

@@ -79,6 +79,7 @@ class CommandRouter(
} }
"goal_failed" -> { "goal_failed" -> {
currentGoalStatus.value = GoalStatus.Failed currentGoalStatus.value = GoalStatus.Failed
ConnectionService.instance?.overlay?.returnToIdle()
Log.i(TAG, "Goal failed: ${msg.message}") Log.i(TAG, "Goal failed: ${msg.message}")
} }

View File

@@ -410,7 +410,13 @@ export async function handleDeviceMessage(
.where(eq(llmConfig.userId, userId)) .where(eq(llmConfig.userId, userId))
.limit(1); .limit(1);
const groqKey = configs[0]?.apiKey ?? ""; if (configs.length === 0 || !configs[0].apiKey) {
handleVoiceCancel(deviceId);
sendToDevice(ws, { type: "transcript_final", text: "" });
break;
}
const groqKey = configs[0].apiKey;
const transcript = await handleVoiceSend(ws, deviceId, groqKey); const transcript = await handleVoiceSend(ws, deviceId, groqKey);
if (transcript) { if (transcript) {
@@ -488,6 +494,7 @@ export function handleDeviceClose(
active.abort.abort(); active.abort.abort();
activeSessions.delete(deviceId); activeSessions.delete(deviceId);
} }
handleVoiceCancel(deviceId);
sessions.removeDevice(deviceId); sessions.removeDevice(deviceId);
// Update device status in DB // Update device status in DB