feat(core): add Discord presence service and extract Jellyfin runtime composition

Introduce Discord presence runtime support and continue composition-root decomposition by moving Jellyfin wiring into dedicated composer modules. This keeps main runtime orchestration thinner while preserving behavior and test coverage across config, runtime, and docs updates.
This commit is contained in:
2026-02-22 14:53:10 -08:00
parent 43a8a37f5b
commit edfe6640ac
52 changed files with 2222 additions and 317 deletions

View File

@@ -0,0 +1,28 @@
# Agent: `codex-discord-presence-task-20260222T194048Z-d7k2`
- alias: `codex-discord-presence-task`
- mission: `Add backlog task for Discord Rich Presence integration with polished activity card`
- status: `done`
- branch: `main`
- started_at: `2026-02-22T19:40:48Z`
- heartbeat_minutes: `5`
## Current Work (newest first)
- [2026-02-22T19:41:00Z] handoff: added `TASK-109` backlog ticket for Discord Rich Presence integration + polished activity card scope.
- [2026-02-22T19:40:56Z] progress: verified no existing Discord presence backlog ticket via search across backlog directories.
- [2026-02-22T19:40:48Z] intent: create ticket only; no runtime code implementation.
## Files Touched
- `backlog/tasks/task-109 - Add-Discord-Rich-Presence-integration-with-polished-activity-card.md`
- `docs/subagents/INDEX.md`
- `docs/subagents/agents/codex-discord-presence-task-20260222T194048Z-d7k2.md`
## Assumptions
- User request means backlog task creation, not immediate implementation.
- Existing markdown task format in `backlog/tasks` remains canonical.
## Open Questions / Blockers
- None.
## Next Step
- Wait for user follow-up (implement `TASK-109` when requested).

View File

@@ -0,0 +1,52 @@
# codex-field-grouping-autoupdate-race-20260222T193915Z-m8p4
- alias: `codex-field-grouping-autoupdate-race`
- mission: Fix Kiku field-grouping merge race with auto-update so note enrichment completes before duplicate merge.
- status: `handoff`
- last_update_utc: `2026-02-22T19:41:20Z`
- backlog_ticket: `TASK-94` (`backlog/tasks/task-94 - Fix-Kiku-duplicate-detection-for-Yomitan-marked-duplicates.md`) for duplicate/grouping workflow scope.
## Intent
- Reproduce reported ordering bug in `NoteUpdateWorkflow`.
- Add regression test first (TDD): update fields before field-grouping merge.
- Patch workflow ordering with minimal behavior change.
## Planned Files
- `src/anki-integration/note-update-workflow.test.ts`
- `src/anki-integration/note-update-workflow.ts`
## Assumptions
- Bug path: auto-update flow enters duplicate merge before sentence/audio/image enrichment completes.
- Existing field-grouping handlers remain source of merge/delete behavior; only invocation timing changes.
## Progress Log
- 2026-02-22T19:39:15Z: session start; read subagent index/collaboration; identified target workflow and tests.
- 2026-02-22T19:40:15Z: added failing TDD regression in `src/anki-integration/note-update-workflow.test.ts` asserting update-before-auto-merge order.
- 2026-02-22T19:40:45Z: patched `src/anki-integration/note-update-workflow.ts` to defer field-grouping execution until after enrichment/update; refresh note info before merge.
- 2026-02-22T19:41:20Z: verification green:
- `bun test src/anki-integration/note-update-workflow.test.ts`
- `bun test src/anki-integration/field-grouping-workflow.test.ts src/anki-integration.test.ts`
## Files Touched
- `src/anki-integration/note-update-workflow.ts`
- `src/anki-integration/note-update-workflow.test.ts`
- `docs/subagents/INDEX.md`
- `docs/subagents/agents/codex-field-grouping-autoupdate-race-20260222T193915Z-m8p4.md`
## Decisions
- Keep duplicate detection early (single lookup), but run merge/manual handlers only after card update path completes.
- Refresh `noteInfo` after update so grouping handlers operate on enriched fields.
## Blockers
- None.
## Next Step
- Optional: add an integration-level test for keep-both (`kikuDeleteDuplicateInAuto=false`) flow to assert both notes retain enriched data.

View File

@@ -0,0 +1,30 @@
# Agent: `codex-kiku-modal-overlay-20260222T220502Z-r4m1`
- alias: `codex-kiku-modal-overlay`
- mission: `Fix Kiku field-grouping modal overlay visibility restore when modal closes`
- status: `handoff`
- branch: `main`
- started_at: `2026-02-22T22:05:02Z`
- heartbeat_minutes: `5`
## Current Work (newest first)
- [2026-02-22T22:07:38Z] handoff: added failing regression test for hidden->modal->close restore path; patched `field-grouping-overlay` to sync visible overlay state for external senders; focused tests green.
- [2026-02-22T22:05:02Z] intent: investigate Kiku modal + overlay visibility restore regression; add failing test first, then minimal fix.
- [2026-02-22T22:06:10Z] progress: traced leak to `createFieldGroupingOverlayRuntime` path using `sendToActiveOverlayWindow` without syncing `visibleOverlayVisible` state.
## Files Touched
- `docs/subagents/INDEX.md`
- `docs/subagents/collaboration.md`
- `docs/subagents/agents/codex-kiku-modal-overlay-20260222T220502Z-r4m1.md`
- `src/core/services/field-grouping-overlay.ts`
- `src/core/services/field-grouping-overlay.test.ts`
## Assumptions
- Bug reproduces when visible overlay is initially hidden and Kiku modal auto-opens overlay.
- Existing callback restore path should remain source of truth (hide on resolve/cancel).
## Open Questions / Blockers
- none
## Next Step
- User validation in real overlay flow (hidden visible overlay -> Kiku modal open/close -> hidden restored).

View File

@@ -0,0 +1,40 @@
# Agent Session: codex-task103-jellyfin-main-composer-20260222T220441Z-m8p1
- alias: `codex-task103-jellyfin-main-composer`
- mission: `Execute TASK-103 Jellyfin runtime wiring extraction from src/main.ts composition root without commit.`
- status: `done`
- last_update_utc: `2026-02-22T22:49:30Z`
## Intent
- Load TASK-103 from Backlog MCP.
- Produce plan artifact via writing-plans skill.
- Execute plan end-to-end with tests (no commit).
## Planned Files (initial)
- `src/main.ts`
- `src/main/runtime/composers/*jellyfin*`
- `src/main/runtime/*jellyfin*`
- `src/main/runtime/composers/*.test.ts`
- `docs/architecture.md` (if ownership docs required)
- `docs/plans/2026-02-22-task-103-jellyfin-runtime-wiring.md`
## Assumptions
- Existing runtime composer patterns from TASK-94/TASK-97 remain canonical.
- No behavior changes expected; extraction/refactor only.
- User requested no commit in this run.
## Progress Log
- `2026-02-22T22:04:41Z` session created; backlog overview + task guides loaded; TASK-103 context loaded.
- `2026-02-22T22:10:20Z` wrote plan artifact `docs/plans/2026-02-22-task-103-jellyfin-runtime-wiring.md`; saved plan to TASK-103.
- `2026-02-22T22:36:15Z` implemented `src/main/runtime/composers/jellyfin-runtime-composer.ts` and `src/main/runtime/composers/jellyfin-runtime-composer.test.ts`; rewired Jellyfin block in `src/main.ts` to `composeJellyfinRuntimeHandlers(...)`; updated `docs/architecture.md` composer ownership.
- `2026-02-22T22:38:58Z` validations: focused composer tests PASS, `check:main-fanin` PASS, `test:core:src` PASS; `build` blocked by pre-existing duplicate/invalid imports in `src/main.ts`.
- `2026-02-22T22:49:05Z` user-reported build fix validated; reran required gates (`build`, `test:core:src`, `check:main-fanin`) all PASS; TASK-103 finalized Done in Backlog.
## Handoff Notes
- TASK-103 complete: AC1-4 and DoD1-3 checked; status Done.
- New files: `src/main/runtime/composers/jellyfin-runtime-composer.ts`, `src/main/runtime/composers/jellyfin-runtime-composer.test.ts`.

View File

@@ -0,0 +1,46 @@
# Agent: `codex-task104-launcher-config-20260222T194708Z-z9x1`
- alias: `codex-task104-launcher-config`
- mission: `Execute TASK-104 end-to-end with plan-first workflow and no commit`
- status: `done`
- branch: `main`
- started_at: `2026-02-22T19:47:08Z`
- heartbeat_minutes: `5`
## Current Work (newest first)
- [2026-02-22T19:47:08Z] intent: load backlog context, write execution plan with writing-plans skill, execute with executing-plans skill, and validate launcher test lanes.
- [2026-02-22T19:56:26Z] progress: extracted launcher config domain modules (`shared-config-reader`, `youtube-subgen-config`, `jellyfin-config`, `plugin-runtime-config`, `cli-parser-builder`, `args-normalizer`) and reduced `launcher/config.ts` to orchestration facade.
- [2026-02-22T19:56:26Z] test: `bun test launcher/config-domain-parsers.test.ts launcher/parse-args.test.ts`, `bun run test:launcher`, and `bun run test:fast` all passed.
- [2026-02-22T19:56:26Z] handoff: TASK-104 finalized Done in Backlog MCP with AC/DoD checks complete and final summary recorded.
## Files Touched
- `docs/subagents/agents/codex-task104-launcher-config-20260222T194708Z-z9x1.md`
- `docs/subagents/INDEX.md`
- `docs/subagents/collaboration.md`
- `docs/plans/2026-02-22-task-104-launcher-config-domain-parsers-cli-builder.md`
- `launcher/config.ts`
- `launcher/config/shared-config-reader.ts`
- `launcher/config/youtube-subgen-config.ts`
- `launcher/config/jellyfin-config.ts`
- `launcher/config/plugin-runtime-config.ts`
- `launcher/config/cli-parser-builder.ts`
- `launcher/config/args-normalizer.ts`
- `launcher/config-domain-parsers.test.ts`
- `launcher/parse-args.test.ts`
- `launcher/jellyfin.ts`
- `launcher/types.ts`
- `package.json`
## Assumptions
- Existing launcher CLI behavior can be preserved with modular extraction plus regression tests.
## Open Questions / Blockers
- none
## Next Step
- await user follow-up (optional: commit, docs wording update, or additional jellyfin session-source hardening).

View File

@@ -0,0 +1,57 @@
# Agent Session: codex-task105-sliceb-20260222T195423Z-w8n3
- alias: `codex-task105-sliceb`
- mission: `Implement TASK-105 slice B runtime cast removal in targeted main/runtime modules without commit.`
- status: `done`
- started_utc: `2026-02-22T19:54:23Z`
- last_update_utc: `2026-02-22T20:02:06Z`
## Intent
- Remove unsafe non-test casts in requested runtime modules using strict shared contracts.
- Keep behavior unchanged; limit scope to type-safety and minimal fallout tests.
- Run targeted tests for changed modules and report outputs.
## Planned Files
- `src/main/runtime/app-runtime-main-deps.ts`
- `src/main/runtime/cli-command-context-main-deps.ts`
- `src/main/runtime/subtitle-tokenization-main-deps.ts`
- `src/main/runtime/overlay-runtime-options-main-deps.ts`
- `src/main/runtime/dictionary-runtime-main-deps.ts`
- `src/main/runtime/mpv-jellyfin-defaults.ts`
- `src/main/runtime/jellyfin-playback-launch.ts`
- `src/main/runtime/cli-command-context-main-deps.test.ts`
- `src/main/runtime/subtitle-tokenization-main-deps.test.ts`
- `src/main/runtime/mpv-jellyfin-defaults.test.ts`
- `src/main/runtime/mpv-jellyfin-defaults-main-deps.test.ts`
- `src/main/runtime/jellyfin-playback-launch.test.ts`
- `src/main/runtime/jellyfin-playback-launch-main-deps.test.ts`
- `src/main/runtime/**/*.test.ts`
## Files Touched
- `docs/subagents/INDEX.md`
- `docs/subagents/agents/codex-task105-sliceb-20260222T195423Z-w8n3.md`
- `docs/subagents/collaboration.md`
- `src/main/runtime/app-runtime-main-deps.ts`
- `src/main/runtime/cli-command-context-main-deps.ts`
- `src/main/runtime/subtitle-tokenization-main-deps.ts`
- `src/main/runtime/overlay-runtime-options-main-deps.ts`
- `src/main/runtime/mpv-jellyfin-defaults.ts`
- `src/main/runtime/jellyfin-playback-launch.ts`
## Assumptions
- Existing runtime contract types already cover needed dependency boundaries.
- Requested slice B is limited to listed files plus minimal typing-test fallout.
## Phase Log
- `2026-02-22T19:54:23Z` Session started; loaded backlog workflow + task context + subagent docs; preparing cast hotspot edits.
- `2026-02-22T19:59:42Z` Completed slice B edits: removed unsafe casts in targeted runtime modules, tightened contracts to shared runtime types, and ran targeted runtime tests (16 pass / 0 fail).
- `2026-02-22T20:02:06Z` Updated focused tests for stricter contracts (typed stubs/status snapshots) and re-ran targeted suite (16 pass / 0 fail).
## Next Step
- Handoff ready.

View File

@@ -0,0 +1,80 @@
# Agent Log: codex-task109-discord-presence-20260222T220537Z-lkfv
- alias: `codex-task109-discord-presence`
- mission: `Execute TASK-109 Discord Rich Presence integration end-to-end with plan-first workflow (no commit).`
- status: `in_progress`
- started_utc: `2026-02-22T22:05:37Z`
- backlog_task: `TASK-109`
## Intent
- Load TASK-109 context from Backlog MCP.
- Write execution plan via `writing-plans` skill.
- Execute approved plan via `executing-plans` skill.
- Prefer parallel subagents for independent slices.
## Planned Files (initial)
- `src/config/definitions.ts`
- `src/config/service.ts`
- `src/main.ts`
- `src/main/runtime/*discord*`
- `src/core/services/*discord*`
- `docs/configuration.md`
## Assumptions
- Discord integration optional, default off.
- Existing logging standards: avoid noisy transient errors.
- Rich Presence client id/config wired via existing config loading.
## Progress
- `2026-02-22T22:06:00Z`: Loaded backlog workflow overview + TASK-109 details.
- `2026-02-22T22:18:00Z`: Wrote plan at `docs/plans/2026-02-22-task-109-discord-rich-presence.md` and started execution.
- `2026-02-22T22:25:00Z`: Completed config surface for `discordPresence` (types/defaults/resolve/option registry/template + config tests).
- `2026-02-22T22:32:00Z`: Added `src/core/services/discord-presence.ts` with lifecycle + payload mapping + debounce/interval throttling + focused tests.
- `2026-02-22T22:35:00Z`: Wired MPV event handlers + app cleanup hooks for presence updates/stop; focused runtime tests green.
- `2026-02-22T22:36:00Z`: Updated docs/config examples; docs build green; backlog TASK-109 set In Progress with implementation notes.
## Blockers
- Full gate `bun run build` blocked by pre-existing `src/main.ts` duplicate imports/symbol errors unrelated to TASK-109 scope in current dirty workspace.
## Handoff Notes
- Implemented files:
- `src/core/services/discord-presence.ts`
- `src/core/services/discord-presence.test.ts`
- `src/config/definitions/defaults-integrations.ts`
- `src/config/definitions/options-integrations.ts`
- `src/config/definitions/template-sections.ts`
- `src/config/resolve/integrations.ts`
- `src/config/resolve/jellyfin.test.ts`
- `src/config/config.test.ts`
- `src/types.ts`
- `src/main/state.ts`
- `src/main/runtime/mpv-main-event-actions.ts`
- `src/main/runtime/mpv-main-event-actions.test.ts`
- `src/main/runtime/mpv-client-event-bindings.ts`
- `src/main/runtime/mpv-client-event-bindings.test.ts`
- `src/main/runtime/mpv-main-event-bindings.ts`
- `src/main/runtime/mpv-main-event-bindings.test.ts`
- `src/main/runtime/mpv-main-event-main-deps.ts`
- `src/main/runtime/mpv-main-event-main-deps.test.ts`
- `src/main/runtime/app-lifecycle-actions.ts`
- `src/main/runtime/app-lifecycle-actions.test.ts`
- `src/main/runtime/app-lifecycle-main-cleanup.ts`
- `src/main/runtime/app-lifecycle-main-cleanup.test.ts`
- `src/main/runtime/composers/startup-lifecycle-composer.test.ts`
- `src/main/runtime/composers/mpv-runtime-composer.test.ts`
- `src/core/services/field-grouping-overlay.test.ts`
- `src/main.ts`
- `docs/configuration.md`
- `config.example.jsonc`
- `docs/public/config.example.jsonc`
- `package.json`
- `bun.lock`
- Remaining work:
- Resolve unrelated `src/main.ts` duplicate import/symbol breakage in workspace to unblock full build/test gate.
- Manual Discord desktop validation still pending (DoD #2).

View File

@@ -0,0 +1,50 @@
# Agent Log: codex-ts-build-errors-20260222T215411Z-h3k7
- alias: `codex-ts-build-errors`
- mission: `Fix current TypeScript build failures in anki/runtime tests and deps typing contracts; keep behavior unchanged.`
- backlog: `TASK-105 (runtime cast/type tightening fallout) + current build-break triage`
- status: `in_progress`
- last_update_utc: `2026-02-22T21:54:29Z`
## Intent
- Triage all listed TS2322/TS2741/TS2353 errors.
- Prefer test stub/type fixes; minimal production changes only if contract mismatch in runtime composer wiring.
- Re-run `bun run tsc --noEmit` (or project build target) to confirm green.
## Planned Files
- `src/anki-integration/note-update-workflow.test.ts`
- `src/main/runtime/cli-command-context-factory.test.ts`
- `src/main/runtime/composers/app-ready-composer.test.ts`
- `src/main/runtime/composers/mpv-runtime-composer.test.ts`
- `src/main/runtime/composers/mpv-runtime-composer.ts`
- `src/main/runtime/overlay-runtime-bootstrap-handlers.test.ts`
- `src/main/runtime/overlay-runtime-options-main-deps.test.ts`
## Assumptions
- Failures are strict typing drift after recent runtime contract hardening.
- No functional behavior change intended.
## Activity
- `2026-02-22T21:54:29Z` started; reading failing files and applying minimal type-aligned fixes.
## Result
- status: `done`
- last_update_utc: `2026-02-22T21:55:54Z`
- files_touched:
- `src/anki-integration/note-update-workflow.test.ts`
- `docs/subagents/agents/codex-ts-build-errors-20260222T215411Z-h3k7.md`
- `docs/subagents/INDEX.md`
- `docs/subagents/collaboration.md`
- key_decisions:
- Typed harness deps as `NoteUpdateWorkflowDeps` to avoid literal over-narrowing in test overrides.
- Kept fixes test-only; no runtime behavior changes.
- verification:
- `bun run tsc --noEmit` passed.
- `make build` passed.
- blockers: none.
- next_step: optional commit/changelog by user preference.