feat: add React SettingsContext with useSettings and useTheme hooks#168
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
feat: add React SettingsContext with useSettings and useTheme hooks#168devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
Migrate Angular SettingsService to React Context as part of Phase 1 of the Angular-to-React migration. - SettingsProvider with localStorage persistence - System dark mode detection via matchMedia - useSettings() hook for full settings access - useTheme() hook for theme-specific state Co-Authored-By: Eashan Sinha <eashan.sinha@codeium.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Phase 1 of the Angular-to-React migration: converts the Angular
SettingsService(src/app/shared/services/settings.service.ts) into a React Context (src/context/SettingsContext.tsx).Adds:
Settingsinterface andSettingsContextValuetypeSettingsProvidercomponent withlocalStoragepersistence foropenLinkInNewTab,theme,titleFontSize,listSpacingwindow.matchMedia('(prefers-color-scheme: dark)')with achangeevent listeneruseSettings()hook — exposes all settings state +toggleSettings,toggleOpenLinksInNewTab,setTheme,setFont,setSpacinguseTheme()hook — narrow accessor fortheme+setThemeSingle file added, no existing files modified.
Local Testing
The existing Angular app compiles and runs successfully (
ng serve) with the new file in place — no regressions to the current app.Review & Testing Checklist for Human
initTheme()logic (lines 59–68 in new file) against the Angular version. When no saved theme exists, the React version readsmatchMedia.matchessynchronously rather than dispatching a synthetic event like Angular does — confirm this is acceptable.changelistener (lines 71–80) callssetThemeunconditionally, which will overwrite a manually chosen theme if the OS preference flips. This matches the Angular behavior but may be undesirable long-term.toggleSettingsandtoggleOpenLinksInNewTabreadsettings.showSettings/settings.openLinkInNewTabfrom closure rather than using a functional updater withprev. Dependency arrays look correct so it should work, but worth a second look for potential stale-closure edge cases under rapid toggling.@types/react@17but there are no unit tests and no consumers yet (Phase 1). Plan to add tests and wire up the provider in a subsequent phase.Suggested test plan: Once a later phase wires up
SettingsProvider, manually toggle each setting in the UI, refresh the page, and confirm values persist vialocalStorage. Also toggle OS dark mode and verify the theme updates automatically.Notes