Repository navigation
refactor(shared): bring constants.ts back under the max-lines limit - #23923
Conversation
… defaults out of constants.ts
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughDefault notification, onboarding, and terminal platform implementations move from Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The sparse folder picker may show an untranslated label; rename the catalog key before merging. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 3 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 29 files. (1 skipped: 1 unsupported.)
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 ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
|
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Split out onboarding defaults —
ONBOARDING_FINAL_STEP,ONBOARDING_FLOW_VERSION, andgetDefaultOnboardingStatemoved verbatim tosrc/shared/onboarding-defaults.ts; all importers updated. - Split out notification defaults —
getDefaultNotificationSettingsmoved tosrc/shared/notification-settings-defaults.ts. - Split out terminal platform defaults —
defaultTerminalFontFamily(newly exported),getDefaultPrimarySelectionMiddleClickPaste, andgetDefaultTerminalRightClickToPastemoved tosrc/shared/terminal-platform-defaults.ts;constants.tsimports and still calls them fromgetDefaultSettings. - Import-site updates — 29 touched files re-point to the new modules with no re-exports, keeping
src/shared/constants.tsat 294 lines (under the 300-linemax-lineslimit).
Verified that no other import ... from '*/constants' block anywhere in the repo still pulls a moved symbol, that no barrel re-exports them, and that the new modules import only *-types so there is no cycle back to constants.ts. The moved code is byte-identical apart from the added export on defaultTerminalFontFamily, and src/shared/constants.test.ts (31 tests) passes locally.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Moved the anti-slop
shapedSidebarnaming exemption from**/src/shared/constants.tsto**/src/shared/onboarding-defaults.tsinconfig/oxlint-anti-slop.json, following the field to its new module. The remaining import-site re-points in this delta are unchanged from the prior review.
Verified the exemption relocation is needed and sufficient: shapedSidebar now appears as a symbol only in onboarding-defaults.ts and the already-exempted onboarding-state-types.ts, while the telemetry-schema occurrence is a string literal the no-shape-in-symbol-names rule never inspects. constants.ts retains no shape identifier, so dropping its exemption is safe, and the anti-slop single-file check over the four touched shared files passes with 0 warnings and 0 errors.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Merged
maininto the branch — the merge itself introduces no regression: a repo-wide scan forimport ... from '*/constants'blocks that still reference a moved symbol (getDefaultOnboardingState,getDefaultNotificationSettings,ONBOARDING_*,defaultTerminalFontFamily,getDefault*Paste) returns 0 hits, so no call site added onmainre-imports a moved symbol from its old location. - Regenerated the runtime-required English catalog —
src/renderer/src/i18n/en-runtime-required.jsonnow adds the previously-missingsparsePreset.findPathentry and restores the generator's canonical key ordering. Running the CI path (verify:localization-catalogs→generate-runtime-required-english-catalog.mjs) at head exits 0 with no missing, contradicting, or superfluous entries, and the file parses as valid JSON. This clears the "Verify localization catalogs" red check.
src/shared/constants.ts remains at 294 lines (under the 300-line max-lines limit), and the moved default builders remain byte-identical to main's copies.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d0d77141-de58-497d-abff-cb25d59b2ed7
📒 Files selected for processing (1)
src/renderer/src/i18n/en-runtime-required.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| "sparsePreset": { | ||
| "description": "Choose the folders a new workspace checks out.", | ||
| "findPath": "Find a folder…", | ||
| "finishEditing": "Save or cancel the preset to continue creating your workspace.", | ||
| "pathHelp": "One repository-relative directory per line. Spaces within a path are preserved." |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use the lookup key expected by SparseDirectoryPicker.
SparseDirectoryPicker requests sparsePreset.findOrTypePath, but this catalog adds sparsePreset.findPath. The added entry is therefore not used, so the folder-search label can remain untranslated.
Suggested fix
- "findPath": "Find a folder…",
+ "findOrTypePath": "Find a folder…",📝 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.
| "sparsePreset": { | |
| "description": "Choose the folders a new workspace checks out.", | |
| "findPath": "Find a folder…", | |
| "finishEditing": "Save or cancel the preset to continue creating your workspace.", | |
| "pathHelp": "One repository-relative directory per line. Spaces within a path are preserved." | |
| "sparsePreset": { | |
| "description": "Choose the folders a new workspace checks out.", | |
| "findOrTypePath": "Find a folder…", | |
| "finishEditing": "Save or cancel the preset to continue creating your workspace.", | |
| "pathHelp": "One repository-relative directory per line. Spaces within a path are preserved." |

ELI5
One shared settings file grew past the size limit our lint enforces, and a translation catalog fell behind the app's own text; both turned every pull request's lint check red. This moves three self-contained groups of defaults into their own small files so it fits again. Nothing the app does changes.
What Changed
src/shared/constants.tswas 348 lines after feat(explorer): scope file trees to sparse checkout directories #18750, over the 300-linemax-lineslimit, so the full-file lint in "static analysis" failed on every PR that merged main. It is now 294 lines.src/shared/onboarding-defaults.ts:ONBOARDING_FINAL_STEP,ONBOARDING_FLOW_VERSION,getDefaultOnboardingState.src/shared/notification-settings-defaults.ts:getDefaultNotificationSettings.src/shared/terminal-platform-defaults.ts: the per-platform terminal font and paste defaults (defaultTerminalFontFamily,getDefaultPrimarySelectionMiddleClickPaste,getDefaultTerminalRightClickToPaste).defaultTerminalFontFamily, whichgetDefaultSettingsstill calls. Every import site now names the new file directly; nothing is re-exported throughconstants.ts.constants.tscan import them without a cycle.src/renderer/src/i18n/en-runtime-required.jsonis regenerated withpnpm run sync:localization-runtime-catalog. On main it no longer covered keys main already ships (sparsePreset.findPathfrom feat(explorer): scope file trees to sparse checkout directories #18750, andbrowser-pane.markup.*), which turned "Verify localization catalogs" red on every PR. This change adds only those keys and reorders a few existing ones.shapedSidebarchecklist field (config/oxlint-anti-slop.json) moves fromconstants.tstoonboarding-defaults.ts, which now holds that field.Why
These three groups each have their own domain and few users (about 30 import lines in total), so moving them is a small, mechanical change. Moving the larger persisted-state default builders instead would have rewritten imports in about 160 files, and moving only the UI-state defaults would have created an import cycle with
constants.ts. Raising the limit or disabling the rule for this file is not allowed in this repo.Linked Issue
None; this fixes a red check on main.
Visual Proof
N/A: no behaviour change; the moved code is byte-identical apart from one added
export.Testing
tc:node,tc:web,tc:cliand the mobiletsc --noEmitpass.Full-file
oxlint --deny-warnings(includingmax-lines) and the react-doctor config pass on every touched file;oxfmtis clean.Vitest over the changed test files,
src/main/persistenceandsrc/shared: 12,064 passed. The only failures were five SQLite backup/recovery tests timing out at 30 s under machine load. They time out the same way on current main without this change.I manually tested these changes locally
Automated tests added/updated, or explained why not below
No new tests: this only moves code, and the existing tests import the moved functions from their new files.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No runtime, platform, SSH, mobile or wire impact: only module boundaries moved.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)