Skip to content

TP-F1 — File watcher for user themes folder #160

Description

@ZhuchkaTriplesix

Epic: #159
Depends on: TP-22 (Refresh themes), shipped in 0.4.2

Source: docs/planned-0.4.3.md

Goal

Auto-refresh the theme registry when the user adds, removes, or renames files under {appSupport}/themes/ without requiring Refresh themes in Preferences.

Files

  • lib/core/theme/theme_registry_service.dart
  • lib/core/theme/theme_controller.dart
  • lib/core/theme/theme_paths.dart
  • new watcher helper (e.g. lib/core/theme/theme_folder_watcher.dart)
  • lib/features/settings/... (only if UI feedback is needed)
  • tests under test/core/theme/

Implementation

  • Watch ThemePaths.userThemesDirectory() with a platform-appropriate Directory.watch / recursive watcher.
  • Debounce events (e.g. 300–500 ms) and call existing ThemeController.loadAvailableThemes() / registry rescan.
  • Handle lifecycle: start watcher after app init; cancel on dispose / app pause where needed to avoid duplicate watchers or leaks.
  • Ignore transient write patterns (import copies temp files) — coalesce events before rescan.
  • If the currently selected theme file is removed, reuse 0.4.2 startup fallback behavior (do not crash; surface Preferences error).
  • Do not watch imported/ separately if it is a subpath of themes/; avoid double refresh.

Acceptance Criteria

  • Dropping a valid .json / .jsonc into the themes folder updates the picker within a few seconds without manual refresh.
  • Deleting the active theme file triggers safe fallback (same as TP-27).
  • Renaming a theme file updates list metadata (id may change — document behavior).
  • No duplicate registry scans on rapid file events.
  • Watcher is cancelled cleanly on app shutdown (no leaked isolates/subscriptions in tests).

Tests

  • Unit/integration test with a temp directory: add/remove file → debounced rescan updates definition count.
  • Test watcher cancellation / idempotent start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfilesystemTheme parser epic label: filesystemfrontendTheme parser epic label: frontendregistryTheme parser epic label: registrythemeTheming, colors, VS Code themes

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions