feat: improve background startup and launcher control

Detach --background launches from terminals with quieter runtime output, make wrapper/plugin overlay start explicit, and allow trailing commas in JSONC configs for safer hot-reload edits. Includes pending Anki/docs/backlog updates in this unreleased batch.
This commit is contained in:
2026-02-18 02:22:01 -08:00
parent 4703b995da
commit ebaed49f76
34 changed files with 515 additions and 48 deletions

View File

@@ -0,0 +1,45 @@
---
id: TASK-66
title: Add AnkiConnect tagging for mined and updated cards
status: Done
assignee: []
created_date: '2026-02-18 09:23'
updated_date: '2026-02-18 09:24'
labels:
- anki
- config
- enhancement
dependencies: []
references:
- src/anki-connect.ts
- src/anki-integration.ts
- src/anki-integration/card-creation.ts
- src/config/definitions.ts
- src/config/service.ts
- src/config/config.test.ts
- docs/configuration.md
- config.example.jsonc
- docs/public/config.example.jsonc
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Support configuring tags applied to cards created or updated through SubMiner's AnkiConnect workflow. Default behavior should add the `SubMiner` tag to all mined/updated cards, while allowing users to override or disable automatic tagging via config.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 AnkiConnect note creation supports passing tags.
- [x] #2 Existing-card update flows add configured tags via AnkiConnect after updates.
- [x] #3 Default config includes `ankiConnect.tags: ["SubMiner"]`.
- [x] #4 Config parsing validates `ankiConnect.tags` and falls back safely on invalid values.
- [x] #5 User-facing docs/config examples mention the new tags option and default behavior.
<!-- AC:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Implemented configurable AnkiConnect tagging across SubMiner card creation and update workflows. Added `ankiConnect.tags` config (default `['SubMiner']`), validation/fallback in config parsing, AnkiConnect client support for `addNote` tags + `addTags`, and integration hooks so created/updated/merged cards receive configured tags. Updated docs and regenerated config examples; config test suite passes.
<!-- SECTION:FINAL_SUMMARY:END -->

View File

@@ -0,0 +1,67 @@
---
id: TASK-65
title: Run Electron app as background tray service with IPC startup
status: Done
assignee: []
created_date: '2026-02-18 08:48'
updated_date: '2026-02-18 10:17'
labels:
- electron
- tray
- ipc
- desktop-entry
dependencies: []
priority: high
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Allow launching the app from desktop/application entry so it starts in background with minimal logging, waits for IPC connection, and exposes tray icon for settings/configuration.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Launching via app/desktop file starts app without foreground window by default
- [x] #2 Process runs in background with minimal startup logging
- [x] #3 Main process initializes IPC server/client wait loop for incoming connection
- [x] #4 Tray icon is visible and provides menu actions for settings/configuration and quit
- [x] #5 Behavior documented for desktop launch usage
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Implemented `--background` CLI mode to keep app running without overlay windows, default to quieter logging, and preserve IPC client startup.
Added persistent tray runtime (icon + menu actions for overlay, Yomitan settings, runtime options, Jellyfin setup, AniList setup, quit).
Disabled window-all-closed auto-quit while in background mode; desktop Linux launcher now passes `--background` by default via electron-builder desktop Exec.
Updated usage/installation docs and CLI help; validated with `bun run build && bun run test:fast`.
Follow-up packaging fix: replaced invalid `build.linux.desktop.Exec` override with supported electron-builder `build.linux.executableArgs: ["--background"]` after AppImage schema validation failure on electron-builder 26.7.0.
Re-verified Linux packaging with `bun run build:appimage`; background launcher argument is now applied without config validation errors.
Correction: any earlier mention of `desktop Exec` is obsolete; final shipped config uses `build.linux.executableArgs` only.
Background launch now detaches from terminal via new `src/main-entry.ts` bootstrap: `--background` parent process spawns detached child and exits, so Ctrl+C no longer stops the running tray process.
Background detached child now suppresses Node runtime warnings (`NODE_NO_WARNINGS=1`) and strips `VK_INSTANCE_LAYERS` when it contains `lsfg` to reduce non-actionable startup noise in background mode.
Updated package entrypoint to `dist/main-entry.js` and docs usage note for detached background behavior.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Added an always-on background startup mode for desktop launches by introducing `--background`, wiring startup/lifecycle state to keep the process alive without windows, and defaulting this mode to quieter logging unless explicitly overridden. Added a tray icon/menu for settings and runtime configuration entry points and updated Linux desktop packaging so launcher executions use background mode by default, with docs and tests updated accordingly.
Added detached background bootstrap behavior for `--background` launches so terminal invocations return immediately while the tray process continues independently, and reduced background startup noise by suppressing Node warnings and removing problematic lsfg Vulkan layer env in detached child startups.
<!-- SECTION:FINAL_SUMMARY:END -->
## Definition of Done
<!-- DOD:BEGIN -->
- [x] #1 Implementation verified locally with launch command or desktop entry simulation
<!-- DOD:END -->

View File

@@ -0,0 +1,53 @@
---
id: TASK-67
title: Make wrapper stop auto-sending --start by default
status: Done
assignee: []
created_date: '2026-02-18 09:47'
updated_date: '2026-02-18 10:02'
labels:
- launcher
- wrapper
- cli
- background-mode
dependencies: []
priority: high
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Update the subminer wrapper flow so it no longer appends --start automatically when launching the app, requiring explicit start semantics and allowing background AppImage workflow to be primary.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Wrapper launch path does not append --start unless explicitly requested
- [x] #2 Existing explicit startup commands still work and are documented
- [x] #3 Tests updated for new wrapper behavior
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Launcher wrapper no longer auto-starts overlay from mpv plugin `auto_start` setting; only explicit `--start`/`--start-overlay` trigger wrapper-managed startup.
Simplified plugin runtime config parsing in launcher to consume `socket_path` only for wrapper behavior.
Updated docs examples and descriptions to make explicit startup flow clear (`subminer --start video.mkv`), and rebuilt bundled `subminer` script.
Validated with `bun run build && make build-launcher && bun run test:fast`.
Follow-up: updated mpv plugin command builder (`plugin/subminer.lua`) to stop forcing `--start` for toggle/show/hide actions; only explicit `start` action now sends start context. This avoids second-instance command failures when app is already running in background mode.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Updated the `subminer` wrapper to stop implicitly issuing app `--start` based on plugin auto-start settings, so background AppImage usage is the default and overlay startup happens only on explicit wrapper flags (`--start`/`--start-overlay`) or manual plugin commands. Also updated launcher docs/examples to reflect explicit startup semantics and regenerated the bundled `subminer` script.
<!-- SECTION:FINAL_SUMMARY:END -->
## Definition of Done
<!-- DOD:BEGIN -->
- [x] #1 Validated with launcher-related tests or command simulation
<!-- DOD:END -->

View File

@@ -0,0 +1,49 @@
---
id: TASK-68
title: Allow trailing commas in JSONC config parsing
status: Done
assignee: []
created_date: '2026-02-18 10:13'
updated_date: '2026-02-18 10:13'
labels:
- config
- jsonc
dependencies: []
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Permit trailing commas in `config.jsonc` parsing so normal JSONC edits do not fail strict reload/watcher startup.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Config parser accepts trailing commas in JSONC objects/arrays
- [x] #2 Invalid malformed JSONC still fails strict reload
- [x] #3 Coverage added to prevent regression
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Enabled `allowTrailingComma: true` in `src/config/service.ts` JSONC parse options while preserving strict parse error handling.
Added regression test `accepts trailing commas in jsonc` in `src/config/config.test.ts`.
Updated docs note in `docs/configuration.md` that JSONC config supports comments and trailing commas.
Validated with `bun run build && bun run test:config:dist`.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
SubMiner now accepts trailing commas in `config.jsonc` by enabling JSONC parser trailing-comma support in the strict config load path. Strict reload behavior remains intact for malformed JSON/JSONC, and a regression test now covers trailing-comma acceptance. Documentation was updated accordingly.
<!-- SECTION:FINAL_SUMMARY:END -->
## Definition of Done
<!-- DOD:BEGIN -->
- [x] #1 Config test suite passes after parser change
<!-- DOD:END -->