Skip to content

feat: add React SettingsContext with useSettings and useTheme hooks#168

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1771014537-settings-context
Open

feat: add React SettingsContext with useSettings and useTheme hooks#168
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1771014537-settings-context

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Feb 13, 2026

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:

  • Settings interface and SettingsContextValue type
  • SettingsProvider component with localStorage persistence for openLinkInNewTab, theme, titleFontSize, listSpacing
  • System dark mode detection via window.matchMedia('(prefers-color-scheme: dark)') with a change event listener
  • useSettings() hook — exposes all settings state + toggleSettings, toggleOpenLinksInNewTab, setTheme, setFont, setSpacing
  • useTheme() hook — narrow accessor for theme + setTheme

Single 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.

App feed with settings panel open

Review & Testing Checklist for Human

  • Verify behavioral parity with Angular service — compare initTheme() logic (lines 59–68 in new file) against the Angular version. When no saved theme exists, the React version reads matchMedia.matches synchronously rather than dispatching a synthetic event like Angular does — confirm this is acceptable.
  • System dark mode listener overrides user-saved theme — the change listener (lines 71–80) calls setTheme unconditionally, which will overwrite a manually chosen theme if the OS preference flips. This matches the Angular behavior but may be undesirable long-term.
  • Toggle callbacks use direct state readstoggleSettings and toggleOpenLinksInNewTab read settings.showSettings / settings.openLinkInNewTab from closure rather than using a functional updater with prev. Dependency arrays look correct so it should work, but worth a second look for potential stale-closure edge cases under rapid toggling.
  • No runtime tests — this was type-checked against @types/react@17 but 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 via localStorage. Also toggle OS dark mode and verify the theme updates automatically.

Notes

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>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants