Skip to content

Add missing fields recursively to settings on startup#389

Merged
bl-ue merged 3 commits intomainfrom
add-missing-fields-to-settings
Jan 19, 2026
Merged

Add missing fields recursively to settings on startup#389
bl-ue merged 3 commits intomainfrom
add-missing-fields-to-settings

Conversation

@bl-ue
Copy link
Copy Markdown
Member

@bl-ue bl-ue commented Jan 19, 2026

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed issue where missing configuration fields weren't properly initialized on startup. All required settings are now automatically populated with defaults.
    • Configuration changes are now persisted to disk after initialization.
  • Tests

    • Added comprehensive test coverage for configuration merging logic.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

This PR introduces a recursive deep merge utility function to handle configuration defaults, exports three new default templates for configuration objects, refactors the config loading logic to use the new utility instead of manual property checks, and includes a comprehensive test suite validating the merge behavior across various scenarios.

Changes

Cohort / File(s) Summary
Core Implementation
src/utils.ts, src/config.ts, src/defaultSettings.ts
Added deepMergeWithDefaults() utility for recursive merging of partial configs with defaults. Refactored config.ts to replace manual default-filling logic with this utility, removing explicit checks for top-level properties. Introduced three new exported defaults: DEFAULT_INPUT_PATTERN_HIGHLIGHTER, DEFAULT_TOOLSET, and DEFAULT_THEME tied to existing template structures.
Test Suite
src/tests/deepMergeWithDefaults.test.ts
Comprehensive test suite with 388 lines covering basic merging, nested objects, arrays, settings structures, highlighter objects, and edge cases including null handling, immutability, and recursion behavior.
Documentation
CHANGELOG.md
Updated patch reference for CC 2.1.9 and added new entry for missing fields feature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A deep merge hops through nested trees,
Filling gaps with gentle ease,
Defaults sprout where data's shy,
No missing fields left high and dry!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the pull request: adding a new deepMergeWithDefaults utility function to recursively merge missing fields from defaults into loaded settings during startup.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

🔧 markdownlint-cli2 (0.18.1)
CHANGELOG.md

markdownlint-cli2 v0.18.1 (markdownlint v0.38.0)
Finding: CHANGELOG.md
Linting: 1 file(s)
Summary: 1 error(s)
Error: EACCES: permission denied, open '/markdownlint-cli2-results.json'
at async open (node:internal/fs/promises:640:25)
at async Object.writeFile (node:internal/fs/promises:1214:14)
at async Promise.all (index 0)
at async outputSummary (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:877:5)
at async main (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:1053:25)
at async file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs:12:22 {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/markdownlint-cli2-results.json'
}


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 and usage tips.

@bl-ue bl-ue marked this pull request as ready for review January 19, 2026 04:42
@bl-ue bl-ue merged commit 8b984d5 into main Jan 19, 2026
2 checks passed
@bl-ue bl-ue deleted the add-missing-fields-to-settings branch January 19, 2026 04:45
@bl-ue bl-ue restored the add-missing-fields-to-settings branch January 24, 2026 17:10
@bl-ue bl-ue deleted the add-missing-fields-to-settings branch January 24, 2026 17:10
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