Skip to content

feat: add support for theme override #1591

Merged
rohanchkrabrty merged 1 commit intomainfrom
fix-preferences-theme
May 7, 2026
Merged

feat: add support for theme override #1591
rohanchkrabrty merged 1 commit intomainfrom
fix-preferences-theme

Conversation

@rohanchkrabrty
Copy link
Copy Markdown
Contributor

@rohanchkrabrty rohanchkrabrty commented May 6, 2026

Summary

  • Fixes a bug where the theme switch in preferences did not work when the consuming app does not render the SDK's ThemeProvideruseTheme's setTheme was a no-op without it.
  • Add optional theme and onThemeChange props to OrganizationProfile so consumers can control the preferences theme select externally instead of relying solely on the SDK's ThemeProvider.
  • Thread these props through the router context and into both PreferencesPage and PreferencesView; when not provided, behavior falls back to useTheme from Apsara.
  • Memoize the memory router and pass dynamic context via RouterProvider's context prop so prop updates no longer recreate the router and reset navigation state.
  • Refactor the theme Select in views-new/preferences to render from a single THEME_OPTIONS map.

@rohanchkrabrty rohanchkrabrty self-assigned this May 6, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment May 6, 2026 10:36am

@rohanchkrabrty rohanchkrabrty changed the title feat: add support for theme override in OrganizationProfile feat: add support for theme override May 6, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Theme customization now available in organization preferences with light, dark, and system theme options
    • Theme selection integrated throughout the preferences interface with visual indicators and icons
    • Theme preferences automatically propagate across the organization interface
  • Refactor

    • Improved component initialization performance through optimized internal rendering logic

Walkthrough

This PR adds theme selection capability to the organization profile and preferences system. It introduces a Theme type, extends routing and component interfaces to propagate theme and onThemeChange props, updates the router context to include theme fields, and modifies preference pages to render theme selection UI.

Changes

Theme Support Integration

Layer / File(s) Summary
Type Definitions & Interfaces
web/sdk/react/components/organization/routes.tsx
Introduces Theme type ('light' | 'dark' | 'system'), extends OrganizationProfileProps with theme? and onThemeChange?, and exports updated RouterContext to include theme fields.
Router Context & Profile Component
web/sdk/react/components/organization/profile.tsx
Adds useMemo hook to memoize router creation; extends OrganizationProfile signature with theme and onThemeChange props; passes theme data into RouterProvider context alongside router configuration.
Route-to-Component Wiring
web/sdk/react/components/organization/preferences/index.tsx
Updates UserPreferences component to extract theme and onThemeChange from routing context via useRouteContext and forward them as props to PreferencesPage.
Preference Page & View Implementation
web/sdk/react/views/preferences/preferences-page.tsx, web/sdk/react/views-new/preferences/preferences-view.tsx
Both components now accept theme and onThemeChange props; compute effective theme and route changes either through callback or ThemeProvider; add dynamic theme selection UI using THEME_OPTIONS map with labels and icons.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • raystack/frontier#1407: Modifies route/outlet context handling for organization/preferences by switching to typed Router/route context for theme propagation.
  • raystack/frontier#1493: Updates preferences UI code (PreferencesView/PreferencesPage) to change component props and rendering behavior.

Suggested reviewers

  • rohilsurana
  • rsbh
  • paanSinghCoder
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25430271924

Coverage remained the same at 41.963%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 37254
Covered Lines: 15633
Line Coverage: 41.96%
Coverage Strength: 11.88 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/sdk/react/views-new/preferences/preferences-view.tsx (1)

62-64: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Wrong ViewHeader description — stale copy-paste

"Manage members for this domain." is clearly copied from the members view. This is user-visible text on the Preferences page.

🐛 Proposed fix
-        description="Manage members for this domain."
+        description="Customize your workspace preferences and settings."
🧹 Nitpick comments (3)
web/sdk/react/views/preferences/preferences-page.tsx (1)

75-75: 💤 Low value

Theme type is duplicated — import from routes.tsx instead

Theme is already exported from web/sdk/react/components/organization/routes.tsx. Defining it again here means any future change (e.g., adding a new theme value) must be updated in multiple places.

♻️ Proposed fix

Remove the local type alias and import from the canonical location:

+import type { Theme } from '~/react/components/organization/routes';
-type Theme = 'light' | 'dark' | 'system';
web/sdk/react/views-new/preferences/preferences-view.tsx (1)

27-27: 💤 Low value

Theme type should be imported from routes.tsx rather than re-derived locally

type Theme = keyof typeof THEME_OPTIONS produces the same union as routes.tsx's exported Theme, but the two definitions will silently diverge if THEME_OPTIONS gains a new key that isn't added to routes.tsx (or vice versa). Since both PreferencesView and the router context (RouterContext) need compatible Theme types, a single source of truth avoids this risk.

♻️ Proposed fix
+import type { Theme } from '~/react/components/organization/routes';
-type Theme = keyof typeof THEME_OPTIONS;
web/sdk/react/components/organization/profile.tsx (1)

38-68: ⚡ Quick win

memoryHistory and routeTree are recalculated on every render but only consumed on the first

useMemo(..., []) captures both values at mount and never reads the re-computed versions produced on subsequent renders. The calls to createMemoryHistory and getRootTree on lines 38–44 are pure waste after the first render. Move them inside the useMemo to make the intent explicit and eliminate the overhead.

customRoutes must remain outside (it's also consumed by RouterProvider's context prop for live updates) — only memoryHistory and routeTree need to move.

♻️ Proposed refactor
-  const memoryHistory = createMemoryHistory({
-    initialEntries: [defaultRoute]
-  });
-
-  const customRoutes = getCustomRoutes(customScreens);
-
-  const routeTree = getRootTree({ customScreens });
-
+  const customRoutes = getCustomRoutes(customScreens);
+
   const memoryRouter = useMemo(
     () =>
       createRouter({
-        routeTree,
-        history: memoryHistory,
+        routeTree: getRootTree({ customScreens }),
+        history: createMemoryHistory({ initialEntries: [defaultRoute] }),
         context: {
           organizationId,
           ...

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 390621db-7bd8-434e-88ad-e529a0d166f3

📥 Commits

Reviewing files that changed from the base of the PR and between cb27b57 and 0739e9b.

📒 Files selected for processing (5)
  • web/sdk/react/components/organization/preferences/index.tsx
  • web/sdk/react/components/organization/profile.tsx
  • web/sdk/react/components/organization/routes.tsx
  • web/sdk/react/views-new/preferences/preferences-view.tsx
  • web/sdk/react/views/preferences/preferences-page.tsx

Comment thread web/sdk/react/views-new/preferences/preferences-view.tsx
Comment thread web/sdk/react/views/preferences/preferences-page.tsx
@rohanchkrabrty rohanchkrabrty enabled auto-merge (squash) May 7, 2026 07:33
@rohanchkrabrty rohanchkrabrty merged commit 67dc76c into main May 7, 2026
8 checks passed
@rohanchkrabrty rohanchkrabrty deleted the fix-preferences-theme branch May 7, 2026 07:36
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.

3 participants