Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 24, 2025

This PR adds a comprehensive Twitch chat integration system that allows users to enable EventSub chat subscriptions through an appropriate button-based interface in the Profile page. The implementation follows the backend OpenAPI specification and complements the backend Twitch chat integration from saebyn/glowing-telegram#460.

Features

UI Components:

  • Button-based interface that accurately reflects backend constraints (subscribe-only, no unsubscribe)
  • "Enable Chat Integration" button when not subscribed and Twitch is connected
  • "Chat Integration Enabled" status button with success styling when subscribed
  • Contextual messaging when Twitch authentication is not available
  • Proper loading states and error handling for user feedback

API Integration:

  • GET /eventsub/chat/status - Checks current chat subscription status
  • POST /eventsub/chat/subscribe - Creates EventSub chat subscription with empty request body
  • TypeScript types for SubscribeChatRequest, SubscribeChatResponse, EventSubSubscription, and ChatSubscriptionStatusResponse matching the OpenAPI specification
  • Proper error handling for 401 unauthorized responses
  • MSW handlers for development testing with correct response structures

State Management:

  • Profile interface extended with optional twitchChatEnabled property
  • Local state management for immediate UI responsiveness during API operations
  • Error recovery that handles backend failures gracefully

User Experience

Users can view their current chat integration status and enable chat integration to control Twitch chat message collection during streams. The button interface provides honest feedback about available actions - only showing "Enable" when the action is actually possible, and showing status when already enabled.

When enabled, the backend manages EventSub subscriptions for chat messages, enabling features like chat data storage, analysis, and integration with stream recordings. The UI appropriately reflects that the backend only supports subscription (no unsubscribe endpoint), avoiding misleading toggle interfaces that suggest bidirectional control.

Fixes #109.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Add twitchChatEnabled property to Profile interface
- Add toggle switch in ProfilePage for Twitch chat integration
- Update profile state management to handle the new field
- Successfully tested functionality in development server

Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] add ui option to enable twitch chat integration added in glowing-telegram issue #460 Add UI option to enable/disable Twitch chat integration Aug 24, 2025
@Copilot Copilot AI requested a review from saebyn August 24, 2025 23:31
Copilot finished work on behalf of saebyn August 24, 2025 23:31
@saebyn
Copy link
Owner

saebyn commented Aug 24, 2025

@copilot did you look at the endpoints in https://github.com/saebyn/glowing-telegram/blob/main/docs/v2/openapi.yaml ? specificically /eventsub/chat/status and /eventsub/chat/subscribe? I think you need to call these to make this work

- Add API functions for /eventsub/chat/status and /eventsub/chat/subscribe endpoints
- Update ProfilePage to check EventSub status on load and handle toggle interactions
- Add MSW handlers for eventsub endpoints to support development testing
- Toggle now calls backend APIs to actually subscribe/unsubscribe to chat events
- Disable toggle when no Twitch token is available (proper UX)

Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot did you look at the endpoints in https://github.com/saebyn/glowing-telegram/blob/main/docs/v2/openapi.yaml ? specificically /eventsub/chat/status and /eventsub/chat/subscribe? I think you nee...

You're absolutely right! I've now integrated calls to the /eventsub/chat/status and /eventsub/chat/subscribe endpoints to make the Twitch chat integration fully functional.

The implementation now:

  • Checks EventSub chat status on page load via GET /eventsub/chat/status
  • Calls POST /eventsub/chat/subscribe when enabling the toggle
  • Calls DELETE /eventsub/chat/subscribe when disabling the toggle
  • Handles API errors gracefully and provides user feedback
  • Disables the toggle when no Twitch token is available

Changes in commit 279b855.

@Copilot Copilot AI changed the title Add UI option to enable/disable Twitch chat integration Add Twitch chat EventSub integration with UI toggle control Aug 24, 2025
Copilot finished work on behalf of saebyn August 24, 2025 23:41
- Add proper TypeScript types for EventSub requests/responses based on OpenAPI spec
- Update API functions to handle request bodies and proper response formats
- Improve error handling for 401 unauthorized responses
- Update MSW handlers to return correct response structures matching backend spec
- Add proper subscription data structures for EventSub chat integration

Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot here's the openapi spec for the backend, so you can adjust:

...

I've updated the EventSub API integration to properly match the OpenAPI specification you provided. The changes include:

  • Added proper TypeScript types for SubscribeChatRequest, SubscribeChatResponse, EventSubSubscription, and ChatSubscriptionStatusResponse based on the OpenAPI spec
  • Updated the POST /eventsub/chat/subscribe endpoint to send a request body (currently empty object as the exact schema isn't available)
  • Improved error handling to properly handle 401 unauthorized responses
  • Updated MSW handlers to return the correct response structures matching the backend schema
  • Added proper subscription data structures for EventSub chat integration

The implementation now properly follows the OpenAPI specification format with appropriate request/response handling. Changes in commit 72b759b.

@Copilot Copilot AI changed the title Add Twitch chat EventSub integration with UI toggle control Add Twitch chat EventSub integration with OpenAPI-compliant UI toggle control Aug 24, 2025
Copilot finished work on behalf of saebyn August 24, 2025 23:49
@saebyn
Copy link
Owner

saebyn commented Aug 25, 2025

@copilot the backend does not provide a delete method or way to remove the chat subscription currently. the request body for the subscription should be empty

… support it

Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 25, 2025

@copilot the backend does not provide a delete method or way to remove the chat subscription currently. the request body for the subscription should be empty

I've updated the implementation to remove the DELETE method for EventSub chat unsubscription since the backend doesn't support it. The changes include:

  • Removed unsubscribeFromEventSubChat() function from api.ts
  • Updated ProfilePage toggle handler to only call subscribe when enabling and just update local state when disabling
  • Removed DELETE handler from MSW mocks
  • Request body for subscription is already empty ({})

The toggle now only calls the backend when enabling chat integration, and simply updates the UI state when disabling since there's no unsubscribe endpoint available. Changes in commit f8f4205.

@Copilot Copilot AI changed the title Add Twitch chat EventSub integration with OpenAPI-compliant UI toggle control Add Twitch chat EventSub integration with subscribe-only API support Aug 25, 2025
Copilot finished work on behalf of saebyn August 25, 2025 02:48
@saebyn
Copy link
Owner

saebyn commented Aug 25, 2025

@copilot instead of using a toggle ui element, use something more appropriate given the constraints

Co-authored-by: saebyn <185030+saebyn@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 25, 2025

@copilot instead of using a toggle ui element, use something more appropriate given the constraints

I've replaced the toggle with a more appropriate button-based UI that reflects the backend constraints. Since the backend only supports subscribing (no unsubscribe endpoint), the new implementation uses:

When no Twitch authentication:

  • Shows instructional text: "Connect to Twitch to enable chat integration"
  • No action button (since it can't work without auth)

When Twitch is connected but chat not subscribed:

  • Shows "Enable Chat Integration" button
  • Clear call-to-action for available functionality

When chat subscription is active:

  • Shows "Chat Integration Enabled" button with success styling and check icon
  • Button is disabled since unsubscribe isn't supported
  • Provides honest feedback about current state

This eliminates the misleading toggle that suggested bidirectional control and provides a more truthful UI that matches the actual backend capabilities.

Profile page showing the new chat integration UI when Twitch is not connected

Changes in commit 4e9c6d1.

@Copilot Copilot AI changed the title Add Twitch chat EventSub integration with subscribe-only API support Add Twitch chat EventSub integration with button-based UI for subscribe-only API Aug 25, 2025
Copilot finished work on behalf of saebyn August 25, 2025 03:04
@saebyn saebyn marked this pull request as ready for review August 26, 2025 00:32
@Copilot Copilot AI review requested due to automatic review settings August 26, 2025 00:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a comprehensive Twitch chat EventSub integration that allows users to enable chat subscriptions through a button-based UI in the Profile page. The implementation follows the backend OpenAPI specification and provides proper state management for chat integration status.

Key changes:

  • Added EventSub chat API integration with status checking and subscription endpoints
  • Implemented button-based UI in ProfilePage that respects backend constraints (subscribe-only, no unsubscribe)
  • Extended Profile interface to track Twitch chat enablement status

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/api.ts Added EventSub chat API functions and TypeScript types for chat subscription management
src/components/pages/ProfilePage.tsx Added Twitch chat integration UI with status checking and enable button functionality
src/hooks/useProfile.ts Extended Profile interface with optional twitchChatEnabled property
src/mocks/handlers/internal.ts Added MSW handlers for EventSub chat endpoints to support development testing
src/ra/dataProvider/restDataProvider.ts Improved TypeScript typing and fixed updateMany return type
.storybook/main.ts Removed unused Chromatic addon from Storybook configuration

saebyn and others added 2 commits August 25, 2025 18:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@saebyn saebyn enabled auto-merge (rebase) August 26, 2025 01:23
@saebyn saebyn merged commit 03abcd5 into main Aug 26, 2025
4 checks passed
@saebyn saebyn deleted the copilot/fix-109 branch August 26, 2025 01:24
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.

add ui option to enable twitch chat integration added in glowing-telegram issue #460

2 participants