Skip to content

Conversation

@BP602
Copy link
Owner

@BP602 BP602 commented Sep 23, 2025

Summary

  • Fix 7TV cosmetics (badges and paints) not appearing by using correct Kick user ID for WebSocket subscriptions
  • Change from streamerData.id to streamerData.user_id in connectionManager.js

Root Cause

The shared WebSocket connection manager was using chatroom.streamerData.id instead of chatroom.streamerData.user_id for 7TV cosmetic subscriptions. This caused cosmetic events (entitlement.create, entitlement.delete, cosmetic.create) to be sent to wrong channels, so they were never received by KickTalk.

The original non-shared STV implementation was correctly using user_id, but the migration to shared connections introduced this bug.

Changes

  • Updated utils/services/connectionManager.js lines 309 and 589 to use streamerData.user_id
  • This restores the original working behavior from the non-shared implementation

Test Plan

  • Verified 7TV cosmetics now appear correctly in chat
  • Confirmed WebSocket subscriptions use correct IDs
  • No breaking changes to existing functionality

Summary by CodeRabbit

  • New Features
    • Real-time handling of entitlement deletions so revoked user cosmetics (badges/paints) are removed.
    • Added support for explicit removal of a user’s cosmetic entries when entitlements are revoked.
  • Bug Fixes
    • Prevents stale badges/paints from lingering after revocation.
    • Ensures usernames are normalized across platforms for reliable cosmetics cleanup.
  • Chores
    • Aligned which streamer/user identifier is used when wiring chatrooms to external services.

- Change streamerData.id to streamerData.user_id for 7TV cosmetic subscriptions
- Handle both entitlement.create and entitlement.delete events
- Add removeUserStyle method for proper cosmetic removal
- This fixes 7TV badges and paints not appearing due to wrong subscription IDs
@coderabbitai
Copy link

coderabbitai bot commented Sep 23, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds handling for 7TV/Kick entitlement.delete events alongside entitlement.create, propagating deletes to remove user cosmetics via a new removeUserStyle method. Updates shared 7TV WS to forward actual entitlement event type. Changes wiring to use streamerData.user_id for chatroom registration.

Changes

Cohort / File(s) Summary of Changes
Entitlement event handling (7TV/Kick)
src/renderer/src/providers/ChatProvider.jsx, utils/services/seventv/sharedStvWebSocket.js
Support entitlement.delete in shared 7TV WS and ChatProvider; forward actual event type from sharedStvWebSocket; ChatProvider derives/normalizes Kick username and dispatches cosmetics removal.
Cosmetics store updates
src/renderer/src/providers/CosmeticsProvider.jsx
Add removeUserStyle(username, body) to remove matching badge/paint by ref_id/kind, prune empty user entries, and update timestamps; existing APIs unchanged.
Connection wiring IDs
utils/services/connectionManager.js
Use streamerData.user_id (instead of streamerData.id) when registering chatrooms with Kick Pusher and 7TV shared WS.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant STV as 7TV Shared WS
  participant CP as ChatProvider
  participant CS as CosmeticsStore

  Note over STV,CP: Entitlement event (kind 10)

  STV->>CP: message(detail.type = entitlement.create|entitlement.delete, body)
  alt entitlement.create
    CP->>CS: addUserStyle(username, body)
    CS-->>CP: style added/updated
  else entitlement.delete
    rect rgba(200,230,255,0.25)
    note right of CP: New handling: remove on delete
    CP->>CS: removeUserStyle(username, body)
    end
    CS-->>CP: style removed/updated
  end
Loading
sequenceDiagram
  autonumber
  participant Kick as Kick WS (shared)
  participant CP as ChatProvider
  participant CS as CosmeticsStore

  Kick->>CP: entitlement.delete (body with user.connections[KICK])
  CP->>CP: derive username (dashes→underscores, toLowerCase)
  CP->>CS: removeUserStyle(username, body)
  CS-->>CP: user entry updated or pruned
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my ears at deletes and creates,
Tidying badges like neat little plates.
A hop, a bop—user_id in sight,
Cosmetics cleaned in the moonlit night.
Whiskers twitch; the chat looks right. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely and accurately summarizes the primary fix: switching to the correct Kick user ID for 7TV cosmetic subscriptions. It directly maps to the changes in utils/services/connectionManager.js and the PR objectives, so it is fully related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/7tv-cosmetics-subscription-id

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b21c0f and 94e7852.

📒 Files selected for processing (1)
  • src/renderer/src/providers/CosmeticsProvider.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/providers/CosmeticsProvider.jsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-builds (windows-latest)

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines 38 to 40
removeUserStyle: (username, body) => {
const transformedUsername = username.toLowerCase();
const refId = body?.object?.ref_id;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Guard against missing usernames before lowercasing

The new removeUserStyle action assumes the username argument is always defined and immediately calls username.toLowerCase(). However, handleStvMessage derives the username from body.object.user.connections on entitlement.delete events, and those payloads are not guaranteed to include a Kick connection (for example, when the 7TV event only carries a user_id). When such an event arrives, the provider will throw Cannot read properties of undefined (reading 'toLowerCase'), breaking cosmetic updates for all chatrooms. Consider short‑circuiting when username is falsy before transforming it.

Useful? React with 👍 / 👎.

Add null check before calling toLowerCase() on username parameter to prevent
TypeError when 7TV entitlement.delete events lack Kick connection data.
@BP602 BP602 merged commit 91fca72 into main Sep 23, 2025
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

Development

Successfully merging this pull request may close these issues.

1 participant