From ef611e494b471c7f1bfeaaa2a04cac93cd75df17 Mon Sep 17 00:00:00 2001 From: Dore Kleinstern Date: Mon, 23 Mar 2026 11:51:14 +0200 Subject: [PATCH] fix(example): properly disconnect realtime session and support env API key The disconnect button was not calling the SDK's disconnect method, leaving WebRTC, WebSocket, and audio streams active after clicking disconnect. Also pre-populate the API key input from VITE_DECART_API_KEY env variable. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/sdk/index.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/sdk/index.html b/packages/sdk/index.html index dcc9b62..2d5f948 100644 --- a/packages/sdk/index.html +++ b/packages/sdk/index.html @@ -418,6 +418,11 @@

Console Logs

processedVideo: document.getElementById('processed-video') }; + // Pre-populate API key from environment variable if available + if (import.meta.env.VITE_DECART_API_KEY) { + elements.apiKey.value = import.meta.env.VITE_DECART_API_KEY; + } + // Logging system function addLog(message, type = 'info') { const timestamp = new Date().toLocaleTimeString(); @@ -574,10 +579,10 @@

Console Logs

// Disconnect elements.disconnectBtn.addEventListener('click', () => { - if (decartClient) { + if (decartRealtime) { addLog('Disconnecting from Decart...', 'info'); - // Note: The SDK doesn't seem to have a disconnect method, - // so we'll just reset our state + decartRealtime.disconnect(); + decartRealtime = null; decartClient = null; }