Skip to content

feat: send chat messages via helix#84

Merged
ImpulseB23 merged 4 commits intomainfrom
feat/twitch-send-message
Apr 19, 2026
Merged

feat: send chat messages via helix#84
ImpulseB23 merged 4 commits intomainfrom
feat/twitch-send-message

Conversation

@ImpulseB23
Copy link
Copy Markdown
Owner

Adds the ability to send chat messages from the app via Helix POST /chat/messages.

Backend (Go sidecar)

  • New SendChatMessage on HelixClient with a 500-byte cap (MaxChatMessageBytes) and structured drop-reason handling.
  • send_chat_message control command dispatched from stdin; result emitted as a send_chat_result notification.
  • Tests cover success, drop reason (msg_duplicate), empty/oversize validation, and 401 unauthorized.

Host (Rust / Tauri)

  • New twitch_send_message Tauri command and SidecarCommandSender (Arc<Mutex<Option<CommandChild>>>) shared between the supervisor (publish on connect, clear on terminate/heartbeat-timeout) and the command (writes a control line to sidecar stdin).
  • Per-call load_or_refresh so token rotations work over a long sidecar lifetime.
  • Adds user:write:chat to the requested OAuth scopes (alongside the existing user:read:chat).
  • Single-account model (ADR 30): broadcaster_id == user_id.

Frontend (Solid)

  • MessageInput component pinned below the chat feed: Enter to send, Shift+Enter newline, char/byte validation, inline error status.
  • Pure helpers (normalize, byte-limit check, error formatting) extracted to lib/messageInput.ts with unit tests.

Verification

  • cargo clippy --all-targets clean
  • cargo test --lib 148 passed
  • go test ./... all green
  • bun run typecheck && bun run lint && bun run test 50/50 passed

wires a Tauri command through the sidecar control

plane to POST /helix/chat/messages, with a bottom

input bar for sending
Copilot AI review requested due to automatic review settings April 19, 2026 03:35
@github-actions github-actions bot added rust Rust/Tauri changes go Go sidecar changes typescript Frontend/TypeScript changes size/l 500-1000 lines changed labels Apr 19, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Copy link
Copy Markdown

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

Adds an end-to-end “send Twitch chat message” path by wiring a new Tauri command to a stdin control command consumed by the Go sidecar, plus a new frontend input UI and helper utilities.

Changes:

  • Frontend: adds MessageInput UI plus shared normalization/byte-limit/error-format helpers with unit tests.
  • Rust host: introduces twitch_send_message Tauri command and a shared SidecarCommandSender so commands can write control lines to the running sidecar’s stdin; expands Twitch OAuth scopes to include user:write:chat.
  • Go sidecar: adds Helix POST /chat/messages client + validation and a new send_chat_message control command handler.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
apps/desktop/src/lib/twitchAuth.ts Adds sendMessage() invoke wrapper, shared 500-byte constant, and TS error envelope type for UI handling.
apps/desktop/src/lib/messageInput.ts Pure helpers for normalizing outbound text, enforcing byte cap, and formatting structured errors.
apps/desktop/src/lib/messageInput.test.ts Unit tests for message input helpers (trim, byte counting, error formatting, coercion).
apps/desktop/src/components/MessageInput.tsx New UI component to compose and send chat messages via the Tauri command.
apps/desktop/src/App.tsx Renders the new MessageInput below the chat feed when logged in.
apps/desktop/src-tauri/src/sidecar_supervisor.rs Publishes/clears a shared child handle so commands can write to sidecar stdin across respawns/timeouts.
apps/desktop/src-tauri/src/sidecar_commands.rs New Tauri command (twitch_send_message) + shared sender handle + structured frontend error enum.
apps/desktop/src-tauri/src/lib.rs Registers the new command, manages sender state, and adds required OAuth scopes.
apps/desktop/src-tauri/src/host.rs Adds encoder for send_chat_message control command line (JSON + newline).
apps/desktop/src-sidecar/internal/twitch/helix.go Implements Helix SendChatMessage with 500-byte cap validation.
apps/desktop/src-sidecar/internal/twitch/helix_test.go Tests Helix send success, drop reason, empty/oversize validation, and 401 mapping.
apps/desktop/src-sidecar/internal/sidecar/sidecar.go Dispatches send_chat_message command and emits a send_chat_result notification payload.
apps/desktop/src-sidecar/internal/control/control.go Extends control Command schema to carry message bodies for send.

Comment thread apps/desktop/src/components/MessageInput.tsx Outdated
Comment thread apps/desktop/src/components/MessageInput.tsx
Comment thread apps/desktop/src/lib/messageInput.ts Outdated
Comment thread apps/desktop/src-tauri/src/sidecar_commands.rs Outdated
Comment thread apps/desktop/src-sidecar/internal/sidecar/sidecar.go Outdated
- MessageInput: aria-label for a11y; treat input as single-line (no Shift+Enter handling)

- messageInput: strict per-variant guards in toSendError; add helix variant formatter

- sidecar (Go): add request_id to control.Command; echo it on send_chat_result

- sidecar_commands: recover from poisoned mutex instead of panicking

- correlate Helix drop_reason back to UI via request_id + oneshot completer map

- expand test coverage on Go (httptest) and Rust (oneshot/HashMap correlation)
@github-actions github-actions bot removed the size/l 500-1000 lines changed label Apr 19, 2026
@github-actions
Copy link
Copy Markdown

This PR has 1343 lines changed. Consider splitting it into smaller PRs for easier review.

@github-actions github-actions bot added the size/xl > 1000 lines, needs splitting label Apr 19, 2026
…ants

- extract validate_message + advance_request_id helpers from twitch_send_message

- cover SendCommandError serde tagging across all variants

- add sendMessage frontend test mocking @tauri-apps/api/core
@github-actions
Copy link
Copy Markdown

This PR has 1486 lines changed. Consider splitting it into smaller PRs for easier review.

- carve out Pending struct (allocate/cancel/complete/clear) so id

  allocation and completer routing are testable without IPC

- send_with_pending rolls back registration on json/io failure

- exhaustively cover toSendError variants on the frontend
@github-actions
Copy link
Copy Markdown

This PR has 1644 lines changed. Consider splitting it into smaller PRs for easier review.

@ImpulseB23 ImpulseB23 merged commit 4bb8911 into main Apr 19, 2026
13 checks passed
@ImpulseB23 ImpulseB23 deleted the feat/twitch-send-message branch April 19, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Go sidecar changes rust Rust/Tauri changes size/xl > 1000 lines, needs splitting typescript Frontend/TypeScript changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants