Skip to content

Conversation

@Kasper24
Copy link
Owner

@Kasper24 Kasper24 commented Aug 5, 2025

This pull request introduces a fundamental architectural change to the theme generation and settings management systems, significantly improving application performance, user experience, and code maintainability.

Major Changes

1. Theme Generation Rearchitecture

The theme generation logic has been moved from the renderer process to a dedicated worker thread.

  • Performance: This prevents the UI from freezing when processing images or videos, resulting in a much more responsive user experience.
  • Backend Processing: The new theme TRPC router now uses the canvas library for server-side image processing. The client-side theme library has been entirely removed.
  • Enhanced Configuration: Users can now select between 'Material' and 'quantize' libraries for color extraction and have access to numerous new settings to fine-tune Base16 theme generation, such as saturation and luminance levels.

2. Complete Settings System Overhaul

The settings system has been migrated from electron-store to conf and completely rebuilt.

  • Strict Schema: A comprehensive, strictly-typed SettingsSchema is introduced, organizing all settings into logical groups (app, themeGeneration, themeOutput, wallpaperSources, etc.) for improved clarity and type safety.
  • Revamped UI: The settings UI has been rebuilt to support the new nested structure, adding new controls like sliders and dropdowns for more granular configuration.

3. Debounced Autosave & Improved UX in Settings

The user experience on the settings page has been significantly improved.

  • Automatic Saving: Input fields now automatically save 500ms after the user stops typing, using useDebouncedCallback. This replaces the previous onBlur save mechanism.
  • Visual Feedback: A loading spinner is now displayed directly inside an input field during the save operation, providing immediate visual feedback to the user. If an error occurs, the input reverts to its last saved state.

4. Code and Route Reorganization

  • TRPC Routes: The original theme router has been split into a wallpaper router (for searching/applying wallpapers) and a new theme router (for generation/application) for a clearer separation of concerns.
  • Dependencies:
    • Replaced electron-store with conf.
    • Added canvas and uuid.
    • Updated use-debounce.

- Use absolute imports for provider hooks/providers instead of relative
paths
- Standardize export pattern in trpc client (const + export instead of
export const)
- Improve consistency across import organization in App.tsx
…cture

This commit introduces a major refactoring of the theme generation and
settings management systems to improve performance, configurability, and
code structure.

### Theme Generation Overhaul

- **Performance:** Theme generation has been moved from the renderer
process to a dedicated worker thread in the main process. This prevents
the UI from freezing when generating themes from images or videos.
- **Backend Logic:** A new `theme` TRPC router now handles generation.
It utilizes the `canvas` library for server-side image processing. The
client-side theme library (`src/renderer/lib/theme`) has been removed.
- **Configurability:** Users can now select between "Material" and
"quantize" as the color extraction library. New settings have been added
to fine-tune the Base16 generation, including saturation, luminance, and
brightness controls.

### Settings System Refactor

- **Migration to `conf`:** The settings store has been migrated from
`electron-store` to `conf`.
- **Strict Schema:** A comprehensive, strictly-typed `SettingsSchema`
has been implemented, organizing all settings into logical groups:
`app`, `themeGeneration`, `themeOutput`, `wallpaperSources`, and
`internal`.
- **Revamped UI:** The settings UI has been completely rebuilt to
support the new nested schema, introducing new components like sliders
and dropdowns for more granular control over theme generation.

### Code and Route Reorganization

- **TRPC Routes:** The original `theme` router has been split for better
separation of concerns:
    - `wallpaper` router: Manages searching for and applying wallpapers.
    - `theme` router: Handles theme generation and template rendering.
- **Frontend Components:** React components have been updated to use the
new routes and a more generic type system (`<T extends BaseWallpaper>`)
for better reusability.
This commit enhances the user experience on the settings page by
replacing the `onBlur` save mechanism with a debounced, automatic save
for text inputs.

- Input fields now automatically save 500ms after the user stops typing,
using `useDebouncedCallback`.
- A loading spinner is displayed inside the input field during the save
operation for immediate visual feedback.
- If a save operation fails, the input's value reverts to the last known
valid state to prevent UI discrepancies.
- Mutation handlers in settings components are renamed to
`setValueMutation` for consistency.
- Added `use-debounce` dependency at `10.0.5`.
- Exported `SettingsSchema` and `SecretsSchema` from the settings route
- Replaced local `Base16Settings` interface with type reference to
`SettingsSchema["themeGeneration"]["base16"]`
- Ensures consistency between settings schema and theme generation logic
- Removed conditional check that prevented the configuration screen from
rendering when `configValue` was undefined or errored.
- Updated `ConfigurationScreen` to always render setup instructions and
quick actions when required, regardless of loading state.
- Added an additional check to `WallpapersGrid` to show the
configuration screen when `configValue` is an empty array.
- Updated `requiresConfiguration.setting.key` in image, video, and
wallpaper engine tabs
  to reflect the new settings structure under `wallpaperSources`.
- Fixes missing configuration screens due to outdated keys.
- Added `themeToChroma` function to recursively convert all theme values
to chroma color instances.
- Ensures consistent chroma color behavior (e.g., `.hex()`,
`.luminance()`, etc.) in template rendering.
- Applied `themeToChroma` to all template rendering and post-hook
invocations in the theme router.
- Replaced static `<span>` displaying slider value with an `<Input>`
field.
- Allows users to type precise values manually in addition to using the
slider.
- Input respects `min`, `max`, and `step` constraints and debounces
value updates.
- Add generics for sorting and configuration keys in WallpapersGridProps
- Introduce ApiWallpaper to replace DownloadableWallpaper with stricter
typing
- Enforce required fields in DynamicControlDefinition
- Remove SecretsSchema and exclude secrets from SettingKey
- Add "type" field to BaseWallpaper for better discrimination
- Rename getImageBytesFromSrc to getBytesFromImageSrc
- Update @trpc/server to 11.4.4 and lock via overrides
- Remove continue-on-error from CI lint/type/format steps
- Created a reusable `useSettings` hook to manage query and mutation
logic for settings
- Replaced repeated logic in `InputSetting`, `BooleanSetting`,
`DropdownSetting`, `SliderSetting`,
  `FolderListSetting`, and `TemplateListSetting` with the new hook
- Renamed `encrypt` prop to `encrypted` for clarity and consistency
- Updated all usages and components to use the new `useSettings` hook
- Reduced code duplication and improved maintainability of settings
components
- Renamed `lint:types` script to `ts:check` in package.json
- Updated CI workflow to use the new `ts:check` script
…e imports

- Moved TRPC route files into directories with `index.ts` for improved
modularity and readability
- Updated all imports to point to new index-based paths
- Renamed `base.ts` to `index.ts` to better reflect its role as the root
router
- Replaced `total` with `totalItems` and `numberOfPages` with
`totalPages` for consistency in pagination responses
- Previously checked the `lastWallpaperCmd` object, which was always
truthy
- Now correctly checks the `command` string to determine if a wallpaper
should be reapplied
@Kasper24 Kasper24 merged commit 82c4b9d into main Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants