feat: implement app preferences and window listeners hooks#139
Conversation
feat: add hotkeys management for file navigation and quick look refactor: streamline App component by splitting into hooks
There was a problem hiding this comment.
Pull request overview
This PR refactors the App component by extracting logic into four custom hooks, improving code organization, maintainability, and testability. The refactoring preserves all existing functionality while making the codebase more modular.
Changes:
- Created
useFilesTabState,useAppWindowListeners,useAppPreferences, anduseAppHotkeyshooks to encapsulate related concerns - Reduced App.tsx from 514 lines to ~400 lines by moving logic into specialized hooks
- Added comprehensive unit tests for all new hooks with good coverage
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cardinal/src/hooks/useFilesTabState.ts | Manages active tab and search focus state with callbacks |
| cardinal/src/hooks/useAppWindowListeners.ts | Handles window focus/blur events, Tauri event listeners (status updates, lifecycle, quick launch), and drag-drop functionality |
| cardinal/src/hooks/useAppPreferences.ts | Manages preferences state, watch configuration, tray icon settings, and theme/language reset |
| cardinal/src/hooks/useAppHotkeys.ts | Handles keyboard shortcuts (Meta+F/R/O/C, arrow keys, space for Quick Look) and Quick Look native events |
| cardinal/src/hooks/tests/useFilesTabState.test.ts | Tests tab switching and search focus state management |
| cardinal/src/hooks/tests/useAppWindowListeners.test.ts | Tests event listeners, drag-drop routing, and window focus synchronization |
| cardinal/src/hooks/tests/useAppPreferences.test.ts | Tests preferences lifecycle, watch config updates, and reset functionality |
| cardinal/src/hooks/tests/useAppHotkeys.test.ts | Tests keyboard shortcuts and Quick Look event handling |
| cardinal/src/App.tsx | Refactored to use new hooks, removed ~200 lines of code, improved readability with better separation of concerns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
feat: add hotkeys management for file navigation and quick look
refactor: streamline App component by splitting into hooks