Skip to content

Split the settings view model by tab and keep view models out of its orchestrator - #179

Merged
vesnicancz merged 1 commit into
masterfrom
refactor/split-settings-view-model
Nov 5, 2026
Merged

vesnicancz merged 1 commit into
masterfrom
refactor/split-settings-view-model

Conversation

@vesnicancz

@vesnicancz vesnicancz commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

SettingsViewModel had 806 lines and held every tab of the dialog in one class: theme and language previews, the favorites form, the Pomodoro values and the plugin list with its connection test. ISettingsOrchestrator also took and returned PluginViewModel, so filling in the form and refreshing its fields happened in the orchestrator.

What changes

  • AppearanceSettingsViewModel has the theme and language with their previews and the revert.
  • FavoritesSettingsViewModel has the list and its edit form.
  • PomodoroSettingsViewModel has the values, and ToSettings() builds what gets saved.
  • PluginSettingsViewModel has the plugin list, the selection and the connection test.
  • SettingsViewModel keeps the General tab, the About tab, and saving or dismissing the whole dialog, in 216 lines. Its constructor and its registration don't change, and it creates the sections itself.
  • PluginSettingsEntry is what ISettingsOrchestrator now takes and returns: a descriptor, the enabled state and the configuration. PluginViewModel turns one into form fields and back, and the orchestrator no longer refers to it.
  • The members drop their repeated prefixes (Favorites.EditingName, Pomodoro.WorkMinutes), and SettingsWindow.axaml only changes its binding paths. Compiled bindings check those paths at build time.

Behavior to check

  • ApplicationSettings and the settings file don't change, and neither does the order of steps in SaveSettingsAsync.
  • Save now takes one copy of the plugin configurations and uses it for both validation and saving. It used to read the live form twice, so an edit made during the validation could have been saved without being validated.

Testing

  • All 1453 tests pass on Windows, with four new ones: the version line follows a language switch, stored values go over a plugin's defaults and keys without a field are kept, Save sends what is in the form, and the connection test uses the unsaved values.
  • I opened the dialog in the Debug GUI with the real settings through UI Automation and went through all five tabs. General, Pomodoro, Plugins and About showed the stored values, and Favorites showed its list with the stored items, though another window covered its right half in the capture. I left through Cancel, and settings.json kept its timestamp.
  • Not tried in the running app: pressing Save, because it would write to the real settings, and editing a favorite or running a connection test there. Tests cover those.

@vesnicancz
vesnicancz merged commit ff82e74 into master Nov 5, 2026
6 checks passed
@vesnicancz
vesnicancz deleted the refactor/split-settings-view-model branch November 5, 2026 11:34
vesnicancz added a commit that referenced this pull request Nov 5, 2026
… the architecture test (#181)

The last small items from the architecture review: members nothing
reads, a comment that stopped being true, and two architecture checks
for what #178 and #179 cleaned up.

## What changes

- **`IWorklogStateService.RefreshFromDatabaseAsync`** goes, since only
its tests called it. The two tests now run through
`NotifyWorkEntriesModifiedAsync`, so the refresh keeps its coverage.
- **`IStatusIndicatorPlugin.IsDeviceAvailable`** goes from the contract,
the base class and the Luxafor plugin. The application always called
`SetStateAsync` regardless, because that is what opens the device. One
Luxafor test relied on the property to see that a failed device gets
closed, and now checks that the next call opens it again.
- **`PluginWorklogEntry.Category`, `PluginWorklogEntry.ProjectName` and
`PluginMetadata.MinimumAppVersion`** go. Nothing set or read them.
- **The comment on `RemoteControlHost`** blamed events raised on the
caller's thread, which `WorklogStateService` no longer does.
- **`ProjectDependencyTests`** gets two checks: orchestrators don't use
types named `*ViewModel`, and only `App` and `MainWindowAccessor` touch
`ApplicationLifetime`. `WorklogPreviewItem` still passes through its
orchestrator, and the first check doesn't cover it.
- `docs/plugins/luxafor.md` and `docs/plugin-development.md` follow.

Removing members from `WorkTracker.Plugin.Abstractions` changes the
contract, and a plugin outside this repository that overrides
`IsDeviceAvailable` would stop compiling. All the plugins I know of are
in this repository.

## Left as it is

`WorkEntry.Reconstitute` and `PluginManager.LoadEmbeddedPlugin` are used
only by tests, as the review noted, but both are `internal` and dozens
of tests build on them. Replacing them would make those tests go through
the database and assembly loading without anyone gaining anything.

## Testing

- All 1456 tests pass on Windows: two Luxafor tests of the property are
gone and the two architecture checks are new.
- I ran the Debug GUI with the real development settings: all six
plugins loaded and initialized, including Luxafor with the changed
contract. The only warnings were the hotkey and the Stream Deck pipe,
with the installed app running at the same time.
- Not tried: a real Luxafor changing color on this build.
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