refactor: modularize App.tsx from 2400 to 563 lines with custom hooks and services #656
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.
Overview
This PR refactors the bloated 2400-line
App.tsxfile into a clean, modular architecture followingReact and TypeScript best practices.
Problem
Solution
Extracted functionality into specialized modules following single responsibility principle:
Custom Hooks (6 new hooks)
useModalState- Centralized modal state management (10+ modals)usePanelLayout- Complex sidebar/panel layout logicuseProjectManagement- Project CRUD, selection, and navigationuseTaskManagement- Task operations, deletion, renaminguseGithubIntegration- GitHub auth and device flowuseAppInitialization- App startup and first launch detectionServices (2 new services)
taskCreationService- Extracted 468-line task creation logicprojectService- Project creation and cloning helpersComponents (2 new components)
HomeView- Clean home screen UIMainContentArea- Content switching logicConstants
layout.ts- Layout constants and helpersproviders.ts- Terminal provider definitionsResults
Testing
npm run type-check)anytypes)Benefits
✅ Improved maintainability - Each module has single responsibility
✅ Better testability - Isolated hooks and pure functions
✅ Easier onboarding - Self-documenting module names
✅ Faster development - Easy to locate and modify specific features
✅ Performance ready - Better code splitting opportunities
File Structure
src/renderer/
├── components/
│ ├── HomeView.tsx (new)
│ └── MainContentArea.tsx (new)
├── constants/
│ ├── layout.ts (new)
│ └── providers.ts (new)
├── hooks/
│ ├── useModalState.ts (new)
│ ├── usePanelLayout.ts (new)
│ ├── useProjectManagement.ts (new)
│ ├── useTaskManagement.ts (new)
│ ├── useGithubIntegration.ts (new)
│ └── useAppInitialization.ts (new)
└── lib/
├── taskCreationService.ts (new)
└── projectService.ts (new)
Breaking Changes
None - This is a pure refactoring with no API or behavior changes.