Skip to content

refactor(services): expose six more singletons via AppServices and convert callers#1152

Merged
datlechin merged 1 commit into
mainfrom
refactor/expand-appservices-and-convert-callers
May 9, 2026
Merged

refactor(services): expose six more singletons via AppServices and convert callers#1152
datlechin merged 1 commit into
mainfrom
refactor/expand-appservices-and-convert-callers

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Expose six additional singletons via AppServices and convert every raw .shared read in services-aware files:

Added to AppServices: appSettingsStorage, schemaProviderRegistry, aiKeyStorage, groupStorage, favoritesExpansionState, linkedFolderWatcher.

Converted call sites (15 total):

  • AIChatViewModelaiKeyStorage (1 site)
  • FavoritesSidebarViewModelfavoritesExpansionState (3 sites)
  • WelcomeViewModelgroupStorage, appSettingsStorage, linkedFolderWatcher (4 sites)
  • MainContentCoordinatorschemaProviderRegistry (7 sites)

WelcomeViewModel.showOnboarding had to move from a default-value property initializer to the explicit init body so it could read services.appSettingsStorage (default initializers can't reference self).

Why this matters

This is the second tranche of the AppServices DI completion (audit findings 3.1 + arch 5.1). After PR #1151 closed the gap on AppEvents use inside the four already-converted files, this PR widens the container so every other singleton those files read can also flow through services. The remaining ~510 raw .shared reads will land in domain-scoped follow-up PRs (Storage, Database, MCP, etc.).

Test plan

  • Open the welcome window; the onboarding card appears the first time and not on subsequent launches.
  • AI Chat connects to a provider that uses an API key (e.g. Anthropic) and returns a response.
  • Create / expand / collapse a SQL favorites folder; expansion state persists across window reopens.
  • Connect and disconnect a database; MainContentCoordinator retains/releases the schema provider as before (no leak, no missing schema).
  • swiftlint --strict clean on changed files.

@datlechin datlechin merged commit a6fdabb into main May 9, 2026
2 checks passed
@datlechin datlechin deleted the refactor/expand-appservices-and-convert-callers branch May 9, 2026 17:01
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