refactor(settings): extract useProjectSettingsForm hook from SettingsDialog#4765
Merged
gregpriday merged 2 commits intodevelopfrom Apr 1, 2026
Merged
Conversation
…Dialog
- Extract 20+ useState hooks, auto-save debounce logic, and initialization effects
from SettingsDialog.tsx into src/hooks/useProjectSettingsForm.ts
- SettingsDialog now consumes projectForm = useProjectSettingsForm({...}) and
passes projectForm.* props to project tab components
- Reduce SettingsDialog from 1,985 to 1,649 lines (-336 lines)
- Add 11 tests for the new hook covering initialization, reset, debounced save,
flush, identity vs non-identity field changes, error handling, and env var filtering
- Export useProjectSettingsForm from hooks/index.ts
- All 181 existing Settings tests continue to pass unchanged
- Remove unused afterEach import from test file - Remove unused tick destructuring in test callback parameters
1e7b062 to
afe69e2
Compare
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.
Summary
SettingsDialog.tsxwas ~2,000 lines with all 50+ project settings state variables living at the dialog level, regardless of which tab owned them. This PR extracts all project-settings state and persistence logic into a dedicateduseProjectSettingsFormhook.SettingsDialognow just calls the hook and passes the returned values down.Resolves #4737
Changes
src/hooks/useProjectSettingsForm.ts(new): encapsulates all project-settings form state, auto-save orchestration, and dirty-trackingsrc/hooks/__tests__/useProjectSettingsForm.test.tsx(new): full unit test coverage for the hooksrc/components/Settings/SettingsDialog.tsx: ~400 lines removed; project-settings state replaced with the hooksrc/hooks/index.ts: exports the new hookTesting
Unit tests pass (
useProjectSettingsFormtest suite, 371 lines). Manual smoke-test confirmed settings load, auto-save fires, and dirty state tracks correctly across project switches. TypeScript and ESLint clean.