refactor: extract vault and frontmatter services#1204
Conversation
📝 WalkthroughWalkthroughThis PR extracts file/vault operations and frontmatter post-processing logic from ChangesService Extraction and Engine Refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
Deploying quickadd with
|
| Latest commit: |
afe98b4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://553bcec4.quickadd.pages.dev |
| Branch Preview URL: | https://engine-flat-01-vault-frontma.quickadd.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@src/engine/CaptureChoiceEngine.ts`:
- Around line 634-635: The local variable `file` is annotated as non-nullable
TFile but `vaultFileService.getFileByPath` can return null/undefined (you
immediately check `if (!file)`), so update the declaration to reflect the
nullable return: change the `file` type to `TFile | null` (or `TFile |
undefined`) or remove the explicit type and let TypeScript infer it from
`this.vaultFileService.getFileByPath`; ensure references to `file` (and the null
check) remain valid in the `CaptureChoiceEngine` method.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2102e3df-7901-47db-b831-33376a6f2111
📒 Files selected for processing (11)
src/engine/CaptureChoiceEngine.selection.test.tssrc/engine/CaptureChoiceEngine.tssrc/engine/QuickAddEngine.test.tssrc/engine/QuickAddEngine.tssrc/engine/QuickAddEngine.validation.test.tssrc/engine/TemplateChoiceEngine.tssrc/engine/TemplateEngine.tssrc/services/FrontmatterPropertyService.test.tssrc/services/FrontmatterPropertyService.tssrc/services/VaultFileService.test.tssrc/services/VaultFileService.ts
| const file: TFile = this.vaultFileService.getFileByPath(filePath); | ||
| if (!file) throw new Error("File not found"); |
There was a problem hiding this comment.
Fix type annotation to match nullable return type.
The type annotation declares file as non-nullable TFile, but line 635 immediately checks if (!file), indicating the method can return null or undefined. The type should be TFile | null or omit the explicit annotation to let TypeScript infer it.
🔧 Proposed fix
- const file: TFile = this.vaultFileService.getFileByPath(filePath);
+ const file = this.vaultFileService.getFileByPath(filePath);
if (!file) throw new Error("File not found");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const file: TFile = this.vaultFileService.getFileByPath(filePath); | |
| if (!file) throw new Error("File not found"); | |
| const file = this.vaultFileService.getFileByPath(filePath); | |
| if (!file) throw new Error("File not found"); |
🤖 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 `@src/engine/CaptureChoiceEngine.ts` around lines 634 - 635, The local variable
`file` is annotated as non-nullable TFile but `vaultFileService.getFileByPath`
can return null/undefined (you immediately check `if (!file)`), so update the
declaration to reflect the nullable return: change the `file` type to `TFile |
null` (or `TFile | undefined`) or remove the explicit type and let TypeScript
infer it from `this.vaultFileService.getFileByPath`; ensure references to `file`
(and the null check) remain valid in the `CaptureChoiceEngine` method.
Summary
VaultFileService.FrontmatterPropertyService.Stack
engine-flat/02-formatter-template-servicesengine-flat/03-template-choiceengine-flat/04-capture-choiceengine-flat/05-macro-cutoverValidation
bun run lintbun run testbun run buildSummary by CodeRabbit
Release Notes
Refactor
@date:prefix coercion for automatic date value handling.Tests