Skip to content

fix(chat,mux): atomic message insert, fix mislabeled health field, real recording toggle - #1663

Merged
davedumto merged 1 commit into
StreamFi-x:devfrom
aniokedianne:fix/755-759-764-765
Oct 17, 2026
Merged

davedumto merged 1 commit into
StreamFi-x:devfrom
aniokedianne:fix/755-759-764-765

Conversation

@aniokedianne

Copy link
Copy Markdown
Contributor

Closes #755
Closes #759
Closes #764
Closes #765

Atomic chat message insert + counter update (#764)

app/api/streams/chat/route.ts — the POST handler ran a bare INSERT INTO chat_messages followed by a separate UPDATE stream_sessions SET total_messages = total_messages + 1. A crash or connection drop between them left total_messages permanently one short with no recovery path. Replaced both statements with a single writable CTE (WITH new_msg AS (INSERT ...) _counter AS (UPDATE ...)), which runs inside one implicit Postgres transaction.

Stream health field mislabeled as a timestamp (#759)

lib/mux/server.ts — getMuxStreamHealth returned lastSeen: liveStream.recent_asset_ids?.[0], but recent_asset_ids contains Mux asset UUID strings, not timestamps. new Date(uuid) produces Invalid Date. Renamed the field to recentAssetId so callers cannot mistake it for a Date, and added createdAt: liveStream.created_at as a genuine time-based field for recency display.

Recording toggle was a silent no-op (#755)

lib/mux/server.ts — updateMuxStreamRecording returned { success: true } without contacting Mux, meaning the creator-facing "Enable Recording" toggle had no effect on the actual stream. Replaced with a real mux.video.liveStreams.update() call that sets new_asset_settings to a public-playback policy when enabling, or clears it when disabling. Added structured logging matching the other helpers in the file. The function now throws on Mux errors (the caller in updates/[wallet]/route.ts already swallows these and logs without failing the settings save). A comment notes that Mux applies recording changes to the next broadcast segment, not one already in progress.

Tags table comma (#765)

The reported missing comma between visibility and created_at in the tags table definition is not present in the current dev branch — schema.sql line 185 already reads visibility BOOLEAN DEFAULT true, with the comma. No change needed; including Closes #765 to track that the issue has been verified against current code.

…al recording toggle

Atomic chat insert (StreamFi-x#764): replaces the separate INSERT + UPDATE stream_sessions
pair in the chat POST handler with a single writable CTE. Both operations now
run in one implicit transaction so a crash between them can never leave
total_messages permanently out of sync with the actual row count.

Stream health field (StreamFi-x#759): renames getMuxStreamHealth's lastSeen field to
recentAssetId and adds a createdAt field. recent_asset_ids[0] is a Mux asset
UUID string, not a timestamp — calling new Date() on it produces Invalid Date.
The rename makes the type of the value explicit; createdAt supplies a genuine
time reference for recency display.

Recording toggle (StreamFi-x#755): replaces the documented no-op updateMuxStreamRecording
with a real mux.video.liveStreams.update() call that sets new_asset_settings to
enable or clear the recording policy. Adds structured logging consistent with
the other helpers in this file. A comment notes that Mux applies the change to
the next broadcast segment, not the one already in progress.

Closes StreamFi-x#755
Closes StreamFi-x#759
Closes StreamFi-x#764
Closes StreamFi-x#765
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@aniokedianne Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@aniokedianne is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@davedumto
davedumto merged commit 48f21e0 into StreamFi-x:dev Oct 17, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants