refactor: centralize app settings via typed RPC and shared provider (4)#1230
Merged
arnestrickmann merged 3 commits intogeneralaction:mainfrom Mar 2, 2026
Merged
Conversation
|
@Davidknp is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile SummaryThis PR successfully centralizes app settings management by introducing a typed RPC layer and React context provider. The refactor eliminates 1,132 lines of duplicated state management logic and replaces it with a single source of truth backed by TanStack Query. Key improvements
Issues found
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| src/renderer/components/NotificationSettingsCard.tsx | Critical logic bug - sub-settings disabled when notifications are enabled instead of disabled |
| src/renderer/contexts/AppSettingsProvider.tsx | New provider created but lacks optimistic updates despite PR claiming to fix this |
| src/main/ipc/settingsIpc.ts | Successfully migrated from manual IPC handlers to typed RPC controller |
| src/main/settings.ts | Added DeepPartial type and AppSettingsUpdate, duplicated deepMerge in renderer utils |
| src/renderer/types/electron-api.d.ts | Removed 272 lines of duplicate type definitions, now sourced from settings.ts |
| src/renderer/lib/utils.ts | Added deepMerge utility but duplicates logic from main/settings.ts |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Settings Components] -->|useAppSettings| B[AppSettingsProvider]
B -->|TanStack Query| C[Query Cache]
B -->|rpc.appSettings.get| D[RPC Client]
B -->|rpc.appSettings.update| D
D -->|IPC invoke| E[Main Process]
E -->|appSettings.get| F[appSettingsController]
E -->|appSettings.update| F
F -->|getAppSettings| G[settings.ts]
F -->|updateAppSettings| G
G -->|Read/Write| H[settings.json]
B -->|invalidateQueries| C
subgraph Renderer Process
A
B
C
D
end
subgraph Main Process
E
F
G
H
end
Last reviewed commit: 5cc2b73
Contributor
|
sick refactor |
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
settings:get/settings:updateIPC channels with acreateRPCControllerhandler (appSettings.get/appSettings.update) whose return types flow end-to-end fromsettings.tsthrough to the renderer with noanycasts.AppSettingsProvider— a single React context backed by TanStack Query that owns fetching, caching, optimistic updates, and rollback for app settings. All 15+ settings components now calluseAppSettings()instead of each managing their ownuseState+useEffect+rpccall.DeepPartial<AppSettings>/AppSettingsUpdate— typed deep-partial update shape so callers only pass the fields they're changing; the server-sidedeepMergedoes the rest, eliminating the bug where components spread stale cached values on every save.electron-api.d.ts— the hand-maintainedgetSettings/updateSettingsdeclarations and their duplicated types (ProviderCustomConfig, etc.) are deleted; the ground truth lives insettings.tsnow.Why this was necessary
Every settings component had its own copy of the same pattern:
This caused several concrete problems:
settings:get/settings:updateerrors — several components called the oldwindow.electronAPI.getSettings()API that no longer had a registered handler after a prior IPC refactor, causing visible console errors on load.ProviderCustomConfig,AppSettingssub-types, and related shapes were declared in bothsettings.tsandelectron-api.d.ts, drifting out of sync.anyreturn types — the@/shared/ipc/rpcimport insettingsIpc.tsused the@/*alias which resolves differently under the renderer'stsconfig.json, causing the entireRpcRoutertype to collapse toanyin the renderer.