refactor: Ctrl service-locator → app/Container DI (Phase 2, #234) - #236
Merged
Conversation
Phase 2 of #234. Introduce src/app/ composition root: Container (implements JournalController, single-pass ctor with a logger factory — removes two-phase initServices/!), register.ts (command/provider wiring), startup.ts (lifecycle, moved from vscode/). Consumers now depend on the JournalController interface, not the concrete controller class. Expand IConfiguration with the methods consumers actually call (getNavigationMode, getScopeDefinitions, getWeek*PatternRaw, *ForLocalOpen, getWeeklySyncConfig, getTimeStringTemplate, get*LinkInlineTemplate). Move WeeklySyncConfig type to model. paths.ts now types config as IConfiguration. Delete src/util/controller.ts and src/vscode/startup.ts. Refs #234. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7 tasks
Owner
Author
Brooks-Lint PR Review: ApprovedHealth Score: 92/100 Phase 2 of #234 is successfully implemented. This PR replaces the \Ctrl\ service-locator with a dedicated composition root in \�pp/container.ts, significantly improving the system's modularity and testability. Key Findings:
Recommendation: Merge immediately to unblock Phase 3 (Split Configuration). |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of #234 — replace the
Ctrlservice-locator with a real composition root + dependency injection.Depends on #235 (Phase 1) being merged.
Changes
src/app/new composition root:container.ts—Container implements JournalController. Single-pass constructor(configSource, loggerFactory)builds the whole service graph in one go. Removes the two-phaseinitServices+!non-null fields.register.ts— command / code-action / cache-invalidation registration.startup.ts— extension lifecycle (moved fromvscode/startup.ts),.then()chain rewritten toasync/await.JournalControllerinterface, never the concrete controller class.IConfigurationwith the 11 methods consumers actually call (getNavigationMode,getScopeDefinitions,getWeeksPathPatternRaw,getWeeksFilePatternRaw,getWeeklySyncConfig,getTimeStringTemplate,getFileLinkInlineTemplate,getDailyLinkInlineTemplate,getBasePathForLocalOpen,getResolvedEntryPathForLocalOpen,getWeekPathPatternForLocalOpen).WeeklySyncConfigtype tomodel/.journal/paths.tsnow types its config param asIConfiguration(drops ajournal → vscodecoupling).src/util/controller.tsandsrc/vscode/startup.ts.new Container(cfg, () => logger)instead ofnew Ctrl(cfg); ctrl.initServices(logger).Lifecycle decision (per #234 review)
Container is the single owner; all services are singletons (one instance per activation), matching the old single-
Ctrlmodel. No separate state module.Verification
npm run compile-tests(tsc) ✔npm run compile(esbuild) ✔npm run lint✔Acceptance (#234)
Ctrl/Container— all takeJournalController.app/container.ts.Refs #234.
🤖 Generated with Claude Code