Skip to content

Migrate hierarchical preferences storage#489

Merged
DropSnorz merged 1 commit into
v2from
chore/preferences-hierarchy
Jun 26, 2026
Merged

Migrate hierarchical preferences storage#489
DropSnorz merged 1 commit into
v2from
chore/preferences-hierarchy

Conversation

@DropSnorz

Copy link
Copy Markdown
Owner

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR refactors preference storage to a namespaced ApplicationDefaults.Prefs structure, adds migration from legacy flat keys, and updates services, controllers, and tests to read and write the new keys across startup, telemetry, plugin discovery, display, and project settings.

Changes

Preference namespace migration

Layer / File(s) Summary
Keys and migration
owlplug-client/src/main/java/com/owlplug/core/components/ApplicationDefaults.java, owlplug-client/src/main/java/com/owlplug/core/components/ApplicationPreferences.java, owlplug-client/src/main/java/com/owlplug/core/components/PreferencesMigration.java, owlplug-client/src/main/java/com/owlplug/core/services/OptionsService.java
The preference key tree is renamed to nested Prefs.* constants, ApplicationPreferences adds integer and removal helpers, PreferencesMigration maps legacy keys to new keys at startup, and OptionsService depends on the migration before seeding defaults.
App state and startup
owlplug-client/src/main/java/com/owlplug/auth/services/AuthenticationService.java, owlplug-client/src/main/java/com/owlplug/core/components/ApplicationMonitor.java, owlplug-client/src/main/java/com/owlplug/core/controllers/HomeController.java, owlplug-client/src/main/java/com/owlplug/core/controllers/MainController.java
Authentication, application state, account selection, first-launch, auto-sync, and last-scan lookups now read and write the namespaced auth and app keys.
Telemetry settings
owlplug-client/src/main/java/com/owlplug/core/controllers/options/ApplicationOptionsController.java, owlplug-client/src/main/java/com/owlplug/core/services/TelemetryService.java
Telemetry service and the application options checkbox now use the namespaced telemetry keys for the user id and enabled flag.
Discovery settings UI
owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/WelcomeDialogController.java, owlplug-client/src/main/java/com/owlplug/core/controllers/options/InstallationOptionsController.java, owlplug-client/src/main/java/com/owlplug/core/controllers/options/PluginScanOptionsController.java, owlplug-client/src/main/java/com/owlplug/explore/controllers/dialogs/InstallStepDialogController.java, owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/NewLinkController.java
Welcome, installation, plugin-scan, install-step, and new-link dialogs use the namespaced plugin and explore keys for discovery toggles, path previews, and suggestion population.
Discovery runtime and services
owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/CrashRecoveryDialogController.java, owlplug-client/src/main/java/com/owlplug/plugin/services/NativeHostService.java, owlplug-client/src/main/java/com/owlplug/plugin/services/PluginService.java, owlplug-client/src/main/java/com/owlplug/plugin/components/PluginTaskFactory.java
Crash recovery, native-host service, plugin scan orchestration, and plugin-service lookups now read and persist loader, timeout, scan-date, and discovery settings from the namespaced plugin keys.
Display and disable prompts
owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginsController.java, owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/DisablePluginDialogController.java, owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java, owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTableController.java
Plugin display mode is stored under the new plugins key, and the disable-plugin dialog, info view, and table action use the new app-level confirmation flag.
Project directories and test stubs
owlplug-client/src/main/java/com/owlplug/project/components/ProjectTaskFactory.java, owlplug-client/src/main/java/com/owlplug/project/services/ProjectService.java, owlplug-client/src/main/java/com/owlplug/core/controllers/options/ProjectsOptionsController.java, owlplug-client/src/test/java/com/owlplug/AppTestContext.java
Project directory options, project sync lookup, and the test context switch to the namespaced project key and matching plugin and app stubs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • DropSnorz/OwlPlug#280: Introduces the old plugins display preference constant that this PR replaces with ApplicationDefaults.Prefs.Plugins.PREFERRED_DISPLAY.
  • DropSnorz/OwlPlug#356: Adds the telemetry preference keys that this PR renames under ApplicationDefaults.Prefs.Telemetry.*.
  • DropSnorz/OwlPlug#478: Touches the native loader timeout preference flow that this PR moves under ApplicationDefaults.Prefs.Plugins.NativeHost.LOADER_TIMEOUT.

Suggested labels

Status: In Progress

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No substantive description was provided, so the change cannot be assessed from the PR body. Add a brief PR description summarizing the key preference migration and any behavior changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: converting preferences to a hierarchical structure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/preferences-hierarchy

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.23.0)
owlplug-client/src/main/java/com/owlplug/core/controllers/options/InstallationOptionsController.java

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.30][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

owlplug-client/src/main/java/com/owlplug/core/controllers/options/PluginScanOptionsController.java

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.30][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

owlplug-client/src/main/java/com/owlplug/core/controllers/options/ProjectsOptionsController.java

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.15][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

  • 14 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DropSnorz

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
owlplug-client/src/main/java/com/owlplug/plugin/services/PluginService.java (1)

217-217: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Confirm the default-format fallback is intentional. When format matches none of the branches, the method falls back to the VST2 directory rather than an empty/neutral path. This preserves prior behavior, but worth confirming it's still desired post-migration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@owlplug-client/src/main/java/com/owlplug/plugin/services/PluginService.java`
at line 217, The fallback in PluginService#getPluginDirectory currently returns
the VST2 preference when format does not match any branch, so confirm this
legacy default is still intended after migration. If not, update the method’s
default path to a neutral/empty result or a format-appropriate fallback, and
keep the behavior aligned with the other format-specific branches in
PluginService.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@owlplug-client/src/main/java/com/owlplug/core/controllers/MainController.java`:
- Line 149: `Prefs.Auth.SELECTED_ACCOUNT` is being used as a long account id in
`MainController` and must not be initialized as a boolean anywhere else. Update
the `OptionsService` seeding path so the same preference key is stored as a long
sentinel value (for example an unset account id) or left unset until selection,
and keep the `MainController` read/write logic consistent with
`getLong()`/`putLong()` semantics.

In
`@owlplug-client/src/main/java/com/owlplug/core/controllers/options/PluginScanOptionsController.java`:
- Line 135: The `LOADER_TIMEOUT` default is inconsistent between
`PluginScanOptionsController` and `NativeHostService.init()`, so unify the
fallback value used when reading `Prefs.Plugins.NativeHost.LOADER_TIMEOUT`.
Update the timeout read in `PluginScanOptionsController` to use the same
centralized default as the runtime path, or extract a shared constant/helper for
the default so both the UI and `NativeHostService` always show and apply the
same value.

In `@owlplug-client/src/main/java/com/owlplug/core/services/OptionsService.java`:
- Around line 93-95: The auth.selected_account preference in OptionsService is
being seeded with the wrong type, which breaks the long-based contract used by
AuthenticationService and MainController. Update the null-initialization logic
in OptionsService so it writes a long-compatible sentinel instead of a boolean,
or remove the seed if it is unnecessary, and keep the key consistent with the
putLong/getLong callers such as MainController.refreshAccounts().
- Around line 43-44: The startup dependency is only added on OptionsService, but
ApplicationMonitor, TelemetryService, and NativeHostService also read migrated
Prefs values during `@PostConstruct` and can still run too early. Update those
beans to depend on preferencesMigration as well, or move the migration earlier
in startup so all migrated-pref readers initialize after the copy; use the
existing preferencesMigration symbol and the bean class names to apply the fix
consistently.

In
`@owlplug-client/src/main/java/com/owlplug/core/services/TelemetryService.java`:
- Around line 61-62: Telemetry ID initialization in TelemetryService should wait
for PreferencesMigration so existing installs keep their migrated user ID
instead of generating a new one. Update the TelemetryService bean initialization
to depend explicitly on the migration bean (for example with
`@DependsOn`("preferencesMigration")), and keep the Prefs.Telemetry.USER_ID
read/write in the `@PostConstruct` path after that dependency is enforced.

---

Nitpick comments:
In `@owlplug-client/src/main/java/com/owlplug/plugin/services/PluginService.java`:
- Line 217: The fallback in PluginService#getPluginDirectory currently returns
the VST2 preference when format does not match any branch, so confirm this
legacy default is still intended after migration. If not, update the method’s
default path to a neutral/empty result or a format-appropriate fallback, and
keep the behavior aligned with the other format-specific branches in
PluginService.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4a27dd89-a814-45f4-82ae-728013c042ce

📥 Commits

Reviewing files that changed from the base of the PR and between 63c0921 and 2362bff.

📒 Files selected for processing (27)
  • owlplug-client/src/main/java/com/owlplug/auth/services/AuthenticationService.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationDefaults.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationMonitor.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationPreferences.java
  • owlplug-client/src/main/java/com/owlplug/core/components/PreferencesMigration.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/HomeController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/MainController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/CrashRecoveryDialogController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/WelcomeDialogController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/ApplicationOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/InstallationOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/PluginScanOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/ProjectsOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/services/OptionsService.java
  • owlplug-client/src/main/java/com/owlplug/core/services/TelemetryService.java
  • owlplug-client/src/main/java/com/owlplug/explore/controllers/dialogs/InstallStepDialogController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/components/PluginTaskFactory.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTableController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginsController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/DisablePluginDialogController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/NewLinkController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/services/NativeHostService.java
  • owlplug-client/src/main/java/com/owlplug/plugin/services/PluginService.java
  • owlplug-client/src/main/java/com/owlplug/project/components/ProjectTaskFactory.java
  • owlplug-client/src/main/java/com/owlplug/project/services/ProjectService.java
  • owlplug-client/src/test/java/com/owlplug/AppTestContext.java

Comment thread owlplug-client/src/main/java/com/owlplug/core/services/OptionsService.java Outdated
@DropSnorz DropSnorz force-pushed the chore/preferences-hierarchy branch from 2362bff to 6629f1a Compare June 26, 2026 19:50
@DropSnorz

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@DropSnorz DropSnorz self-assigned this Jun 26, 2026
@DropSnorz DropSnorz added this to the 2.0.0 milestone Jun 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@owlplug-client/src/main/java/com/owlplug/core/components/PreferencesMigration.java`:
- Around line 75-94: PreferencesMigration should not access
Preferences.userRoot() directly; it needs to use the injected
ApplicationPreferences abstraction instead. Update migrate() in
PreferencesMigration to read, write, and remove values through
ApplicationPreferences helpers (get, put, remove, getInt, putInt) so the
migration stays aligned with the rest of the app and any test/stub backing
store.

In
`@owlplug-client/src/main/java/com/owlplug/explore/controllers/dialogs/InstallStepDialogController.java`:
- Around line 349-365: Sanitize the STORE_DIRECTORY preference before appending
it in InstallStepDialogController so it cannot escape the intended install root.
Update the logic around shouldStoreInDirectory to validate or normalize the
value returned from getPreferences().get(Prefs.Explore.STORE_DIRECTORY, "")
before passing it to new File(selectedDirectory, relativeDirectoryPath), and
ensure only a safe relative child path is accepted. Keep the existing creator
subfolder handling unchanged, but apply the same path-safety rules consistently
in the directory-building flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 59366a99-aac7-4a97-8b9b-7e5d36e0ea8e

📥 Commits

Reviewing files that changed from the base of the PR and between 2362bff and 6629f1a.

📒 Files selected for processing (27)
  • owlplug-client/src/main/java/com/owlplug/auth/services/AuthenticationService.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationDefaults.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationMonitor.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationPreferences.java
  • owlplug-client/src/main/java/com/owlplug/core/components/PreferencesMigration.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/HomeController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/MainController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/CrashRecoveryDialogController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/WelcomeDialogController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/ApplicationOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/InstallationOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/PluginScanOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/ProjectsOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/services/OptionsService.java
  • owlplug-client/src/main/java/com/owlplug/core/services/TelemetryService.java
  • owlplug-client/src/main/java/com/owlplug/explore/controllers/dialogs/InstallStepDialogController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/components/PluginTaskFactory.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTableController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginsController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/DisablePluginDialogController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/NewLinkController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/services/NativeHostService.java
  • owlplug-client/src/main/java/com/owlplug/plugin/services/PluginService.java
  • owlplug-client/src/main/java/com/owlplug/project/components/ProjectTaskFactory.java
  • owlplug-client/src/main/java/com/owlplug/project/services/ProjectService.java
  • owlplug-client/src/test/java/com/owlplug/AppTestContext.java
✅ Files skipped from review due to trivial changes (1)
  • owlplug-client/src/test/java/com/owlplug/AppTestContext.java
🚧 Files skipped from review as they are similar to previous changes (24)
  • owlplug-client/src/main/java/com/owlplug/core/services/TelemetryService.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/WelcomeDialogController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/ApplicationOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/MainController.java
  • owlplug-client/src/main/java/com/owlplug/core/services/OptionsService.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/HomeController.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationPreferences.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginsController.java
  • owlplug-client/src/main/java/com/owlplug/project/components/ProjectTaskFactory.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTableController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/ProjectsOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/services/NativeHostService.java
  • owlplug-client/src/main/java/com/owlplug/project/services/ProjectService.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationDefaults.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/CrashRecoveryDialogController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/services/PluginService.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/DisablePluginDialogController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/components/PluginTaskFactory.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/InstallationOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/core/controllers/options/PluginScanOptionsController.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/dialogs/NewLinkController.java
  • owlplug-client/src/main/java/com/owlplug/auth/services/AuthenticationService.java
  • owlplug-client/src/main/java/com/owlplug/core/components/ApplicationMonitor.java

@DropSnorz DropSnorz merged commit 0ca9fde into v2 Jun 26, 2026
3 of 4 checks passed
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.

1 participant