Introduce optional Discord activity updates across config, runtime, tests, and docs so playback context appears in Discord without destabilizing app lifecycle. Tune default refresh cadence to reduce pause/resume lag during real sessions.
4.3 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, priority
| id | title | status | assignee | created_date | updated_date | labels | dependencies | priority | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TASK-109 | Add Discord Rich Presence integration with polished activity card | In Progress |
|
2026-02-22 19:40 | 2026-02-23 01:15 |
|
medium |
Description
Add optional Discord Rich Presence support so SubMiner can publish current activity (show/file context, study/mining status, elapsed session) with a polished, readable Discord activity card.
Action Steps
- Choose and add a Discord RPC client strategy compatible with Electron + launcher runtime.
- Add config toggle and safe defaults so Discord presence is opt-in.
- Define presence payload model (state/details/timestamps/assets/buttons) from existing runtime session metadata.
- Wire lifecycle updates for start, pause/resume, episode/file changes, and stop/quit.
- Design assets/text for a clean, branded activity box that is informative without noisy updates.
- Add debounce/rate-limit handling and fallback behavior when Discord is unavailable.
- Add focused tests for payload mapping and lifecycle transitions; document setup in user docs.
Acceptance Criteria
- #1 Discord Rich Presence can be enabled via config and remains disabled by default.
- #2 Activity card shows clear state/details and updates correctly across playback/session transitions.
- #3 Activity card visuals (assets/text) are polished and consistent with project branding.
- #4 Runtime handles Discord closed/not installed/disconnected without crashes or noisy logs.
- #5 Docs include setup steps (app/client id), config keys, and troubleshooting notes.
Implementation Plan
- Validate existing TASK-109 implementation in working tree against AC #1-#5 (config default-off, activity mapping/transitions, polished visuals, resilient error handling, docs coverage).
- Run parallel audit passes (config/docs and runtime/lifecycle) and apply minimal fixes only for confirmed gaps.
- Execute focused Discord/config tests, then full gates (
bun run build,bun run test:fast,bun run docs:build) and record outcomes. - Capture manual Discord-session verification status/evidence.
- Finalize TASK-109 in Backlog with checked AC/DoD, final summary, and status Done (no commit).
Implementation Notes
Implemented opt-in discordPresence config surface in types/defaults/resolver/option-registry/template sections with clamped timing fields and focused config tests.
Added src/core/services/discord-presence.ts with payload mapping, debounce+interval update throttling, duplicate suppression, and resilient login/set/clear error handling.
Wired MPV/runtime lifecycle hooks to refresh Discord presence on subtitle/media/path/time/pause/connection transitions and added cleanup stop hook in app lifecycle cleanup path + focused tests.
Updated docs and generated config examples with Discord Rich Presence setup/config/troubleshooting guidance.
Validation status: focused config/runtime/discord tests pass and docs build passes. Full bun run build currently blocked by pre-existing src/main.ts duplicate imports/symbol errors unrelated to TASK-109 scope (existing in working tree).
User validation feedback: Discord activity resumed to Playing but with noticeable delay after pause/resume transitions.
Adjusted default discordPresence.updateIntervalMs from 15000 to 3000 to reduce perceived status refresh lag while keeping debounce/duplicate suppression behavior unchanged.
Updated docs/config examples (docs/configuration.md, config.example.jsonc, docs/public/config.example.jsonc) and config default assertions; reran focused tests: bun test src/config/config.test.ts src/config/resolve/jellyfin.test.ts and bun test src/core/services/discord-presence.test.ts (all pass).
Definition of Done
- #1 Focused tests cover presence payload mapping and lifecycle update behavior.
- #2 Manual validation confirms Discord card appearance/updates for at least one real playback session.
- #3 Build/test/docs gates pass with no regressions.