From 68cca767b4aa10c50a123e8595dacddbe1601b34 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Sep 2025 22:26:33 +0000 Subject: [PATCH 1/2] Initial plan From fa284f3928ab4b0d82796f4a03a8f35ced9ffc4f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Sep 2025 22:33:51 +0000 Subject: [PATCH 2/2] Fix validation error when pausing broadcast during live streaming - Store session ID locally to prevent race conditions during async operations - Prevents null session_id being passed to incrementHostSessionStats when broadcast is paused/stopped Co-authored-by: acdc-digital <127530566+acdc-digital@users.noreply.github.com> --- smnb/lib/services/host/hostAgentService.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/smnb/lib/services/host/hostAgentService.ts b/smnb/lib/services/host/hostAgentService.ts index a6adaee..791433f 100644 --- a/smnb/lib/services/host/hostAgentService.ts +++ b/smnb/lib/services/host/hostAgentService.ts @@ -1274,6 +1274,8 @@ Focus on: What's new, why it matters, and how it advances the story. return; } + // Store session ID locally to prevent race conditions if session ends during async operations + const sessionId = this.currentSessionId; const convex = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!); // Append narration to session content with timestamp and metadata @@ -1284,7 +1286,7 @@ Focus on: What's new, why it matters, and how it advances the story. // Update the session content in the database await convex.mutation(api.redditFeed.updateHostSessionContent, { - session_id: this.currentSessionId, + session_id: sessionId, content_text: this.sessionContent, current_narration_id: narration.id, narration_type: this.mapToneToNarrationType(narration.tone), @@ -1307,16 +1309,16 @@ Focus on: What's new, why it matters, and how it advances the story. }) }); - // Update session stats + // Update session stats using the locally stored session ID const wordCount = content.split(/\s+/).filter(word => word.length > 0).length; await convex.mutation(api.redditFeed.incrementHostSessionStats, { - session_id: this.currentSessionId, + session_id: sessionId, narrations_increment: 1, words_increment: wordCount, items_increment: 1, }); - console.log(`💾 Appended narration to session ${this.currentSessionId}: ${content.substring(0, 50)}...`); + console.log(`💾 Appended narration to session ${sessionId}: ${content.substring(0, 50)}...`); } catch (error) { console.error('❌ Failed to save host narration to session:', error);