Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(settings): reflect settings state in URL (#4522)
Aidan Holloway-Bidwellb4bd890ea70d
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsxindex 46bad0524d..d270fe95ba 100644--- a/js/app/packages/app/component/GlobalHotkeys.tsx+++ b/js/app/packages/app/component/GlobalHotkeys.tsx@@ -128,7 +128,7 @@ export default function GlobalShortcuts() {useHotkeyAnalytics();- const { openSettings, settingsOpen, setActiveTabId, toggleSettings } =+ const { openSettings, settingsOpen, selectTab, toggleSettings } =useSettingsState();const logout = useLogout();@@ -274,11 +274,11 @@ export default function GlobalShortcuts() {keyDownHandler: createNewSplit,});- // Settings open in a modal by default; tab selection is applied even when- // settings are already open.- const openSettingsModal = (tab?: SettingsTab) => {+ // Open settings to a specific tab, switching the page in place if settings+ // are already open.+ const openSettingsAt = (tab?: SettingsTab) => {if (settingsOpen()) {- if (tab) setActiveTabId(tab);+ if (tab) selectTab(tab);return;}openSettings(tab);@@ -301,7 +301,7 @@ export default function GlobalShortcuts() {description: 'Account',icon: UserIcon,keyDownHandler: () => {- openSettingsModal('Account');+ openSettingsAt('Account');return true;},runWithInputFocused: true,diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsxindex 657b4f4863..5207041cc3 100644--- a/js/app/packages/app/component/Layout.tsx+++ b/js/app/packages/app/component/Layout.tsx@@ -11,6 +11,7 @@ import { mountGlobalFocusListener } from '@app/signal/focus';import { AutomationComposer } from '@block-automation/component';import { useIsAuthenticated } from '@core/auth';import { usePaywallState } from '@core/constant/PaywallState';+import { isSettingsPath } from '@core/constant/SettingsState';import { isMobile } from '@core/mobile/isMobile';import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';import { updateCookie } from '@core/util/cookies';@@ -49,7 +50,6 @@ import { MobileSearchOuter } from './mobile/MobileSearch';import { SwipeDownDismissKeyboard } from './mobile/SwipeDownDismissKeyboard';import { Paywall } from './paywall/Paywall';import { PropertyEditorModal } from './property-edit-modal/PropertyEditorModal';-import { SettingsModal } from './settings/SettingsModal';import { useAppSquishHandlers } from './useAppSquishHandlers';const AUTH_URLS = [@@ -77,7 +77,9 @@ export function Layout(props: RouteSectionProps) {() =>!isMobile() &&isAuthenticated() === true &&- !AUTH_URLS.includes(location.pathname)+ !AUTH_URLS.includes(location.pathname) &&+ // Settings is a full-cover route with its own tab nav — hide app chrome.+ !isSettingsPath(location.pathname));createEffect(() => {console.log('VIZ', sidebarVisible());@@ -151,7 +153,6 @@ function LayoutInner(props: RouteSectionProps) {<GlobalShareModal /><IosShareSheet /><MacroMcpSetupModal />- <SettingsModal /></Show><Showwhen={diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsxindex 1c499d6904..5f11e76e02 100644--- a/js/app/packages/app/component/Root.tsx+++ b/js/app/packages/app/component/Root.tsx@@ -106,6 +106,7 @@ import { Layout } from './Layout';import { SearchProvider } from './next-soup/search-context';import { usePendingNotificationNavigationEffect } from './PendingNotificationNavigationEffect';import { ReactiveFavicon } from './ReactiveFavicon';+import { SettingsRoute } from './settings/SettingsRoute';import { LAYOUT_ROUTE } from './split-layout/SplitLayoutRoute';import { TeamInviteAcceptance } from './TeamInviteAcceptance';@@ -264,6 +265,13 @@ const { EmailCallback, CALLBACK_PATH, EmailLinkCallback, LINK_CALLBACK_PATH } =const ROUTES: RouteDefinition[] = [LAYOUT_ROUTE,+ // Settings is its own place (`/settings/:tab`) rather than a layout split, so+ // it's linkable without dragging the workspace layout into the URL. The static+ // prefix outranks the `/*splits` splat.+ {+ path: '/settings/:tab?',+ component: SettingsRoute,+ },/** BEGIN - APP ROUTES */{path: '/inbox',diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsxindex 922a450aaf..a1c39c8e0f 100644--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx@@ -704,7 +704,7 @@ const PROMOTED_SETTINGS_TABS: SettingsTab[] = [export const AppSidebar = (props: AppSidebarProps) => {const layout = useSplitLayout();- const { openSettings, setActiveTabId, settingsOpen } = useSettingsState();+ const { openSettings, selectTab, settingsOpen } = useSettingsState();const isTabAvailable = useSettingsTabAvailable();const callCtx = useCallContextOptional();@@ -768,7 +768,7 @@ export const AppSidebar = (props: AppSidebarProps) => {const openSettingsTab = (tab: SettingsTab) => {if (!isTabAvailable(tab)) return;if (settingsOpen()) {- setActiveTabId(tab);+ selectTab(tab);return;}openSettings(tab);diff --git a/js/app/packages/app/component/settings/Settings.tsx b/js/app/packages/app/component/settings/Settings.tsxindex a0af97b2e2..1091d1771b 100644--- a/js/app/packages/app/component/settings/Settings.tsx+++ b/js/app/packages/app/component/settings/Settings.tsx@@ -1,13 +1,21 @@import {+ createRenderEffect,createSignal,For,onCleanup,onMount,Show,Suspense,+ untrack,} from 'solid-js';-import { type SettingsTab, useSettingsState } from '@core/constant/SettingsState';+import { useLocation } from '@solidjs/router';+import {+ type SettingsTab,+ settingsTabFromSplitPath,+ useSettingsState,+} from '@core/constant/SettingsState';import { useSettingsTabs } from '@core/constant/settingsTabsConfig';+import { activeTabId, setActiveTabId } from '@core/signal/settingsTab';import { useLogout } from '@core/auth/logout';import { isMobile } from '@core/mobile/isMobile';import { MobileApp } from './MobileApp';@@ -36,9 +44,9 @@ import {import { Billing } from '@app/component/settings/Billing';/** Where the settings panel is mounted, which determines its header chrome. */-export type SettingsVariant = 'split' | 'modal';+export type SettingsVariant = 'split' | 'fullscreen';-// Panel-width breakpoints (the panel can be a full-screen modal or a resizable+// Panel-width breakpoints (the panel can be a full-screen page or a resizable// split, so we measure the panel itself rather than the viewport). Below// `COMPACT` the sidebar collapses into a horizontal tab bar; between `COMPACT`// and `NARROW` the gutter around the content card tightens.@@ -46,9 +54,20 @@ const COMPACT_WIDTH = 660;const NARROW_WIDTH = 820;export function SettingsPanelComponentWrapper() {- return (- <SettingsPanel />- )+ const location = useLocation();+ // Sync the active page from the docked split's URL (`settings/<slug>`). Read+ // the live URL reactively — not static mount props — so browser back/forward+ // and direct navigation stay in sync: reconcile reuses this component on+ // same-key changes, so it never remounts to pick up a new tab. Using+ // createRenderEffect (runs during render) matches the previous synchronous set+ // so the layout URL-sync never observes a stale tab on first paint, and the+ // activeTabId read is untracked so a tab click (which sets it, then updates+ // the URL) isn't reverted by this effect firing before the URL catches up.+ createRenderEffect(() => {+ const tab = settingsTabFromSplitPath(location.pathname);+ if (tab && untrack(activeTabId) !== tab) setActiveTabId(tab);+ });+ return <SettingsPanel />;}type SettingsPanelProps = {@@ -61,9 +80,9 @@ export function SettingsPanel(props: SettingsPanelProps) {const {closeSettings,moveSettingsToSplit,- moveSettingsToModal,+ moveSettingsToFullscreen,activeTabId,- setActiveTabId,+ selectTab,} = useSettingsState();const { groups, flatTabs, isAvailable } = useSettingsTabs();const logout = useLogout();@@ -116,7 +135,7 @@ export function SettingsPanel(props: SettingsPanelProps) {if (index >= 0 && index < tabs.length) {const tab = tabs[index];if (tab) {- setActiveTabId(tab.tab);+ selectTab(tab.tab);return true;}}@@ -174,7 +193,7 @@ export function SettingsPanel(props: SettingsPanelProps) {const handleTabChange = (value: string) => {if (flatTabs().some((tab) => tab.tab === value)) {- setActiveTabId(value as SettingsTab);+ selectTab(value as SettingsTab);}};@@ -196,7 +215,7 @@ export function SettingsPanel(props: SettingsPanelProps) {);}- // "Back to app" — the modal's only close affordance. Laid out like a nav row.+ // "Back to app" — the full-page route's only close affordance. Laid out like a nav row.const backToApp = () => (<buttontype="button"@@ -249,13 +268,13 @@ export function SettingsPanel(props: SettingsPanelProps) {</div></Show></SplitHeaderLeft>- {/* Pop the split back out into the modal (desktop only). */}+ {/* Pop the split back out into the full-page settings route (desktop only). */}<Show when={!isMobile()}><SplitHeaderRight><Buttonclass="p-1 rounded-lg"- label="Open in modal"- onClick={() => moveSettingsToModal()}+ label="Open fullscreen"+ onClick={() => moveSettingsToFullscreen()}><ArrowsOut class="size-4" /></Button>@@ -272,9 +291,9 @@ export function SettingsPanel(props: SettingsPanelProps) {narrow() ? 'pr-1' : 'pr-2')}>- {/* The full-screen modal has no surrounding chrome, so the sidebar+ {/* The full-screen page has no surrounding chrome, so the sidebarcarries the "back" and "move to split" affordances itself. */}- <Show when={variant() === 'modal'}>+ <Show when={variant() === 'fullscreen'}><div class="flex items-center justify-between gap-1">{backToApp()}{moveToSplitButton()}@@ -324,11 +343,11 @@ export function SettingsPanel(props: SettingsPanelProps) {><Layer depth={1}><div class="relative flex size-full flex-col overflow-hidden rounded-xl border border-ink/[0.06] bg-surface shadow-menu mobile:rounded-none mobile:border-0 mobile:bg-transparent">- {/* Compact modal chrome: no split header to host the tabs, so- the sidebar collapses into a top bar here — back / tab+ {/* Compact full-screen chrome: no split header to host the tabs,+ so the sidebar collapses into a top bar here — back / tabdropdown / move-to-split. (Split mode puts the tabs in itsheader.) */}- <Show when={variant() === 'modal' && compact()}>+ <Show when={variant() === 'fullscreen' && compact()}><div class="flex shrink-0 items-center gap-2 h-13 px-2 border-b border-ink/[0.05]">{backToApp()}<TabsInsetDropdowndiff --git a/js/app/packages/app/component/settings/SettingsModal.tsx b/js/app/packages/app/component/settings/SettingsModal.tsxdeleted file mode 100644index 1bba8a0f44..0000000000--- a/js/app/packages/app/component/settings/SettingsModal.tsx+++ /dev/null@@ -1,27 +0,0 @@-import { useSettingsState } from '@core/constant/SettingsState';-import { Dialog, Layer } from '@ui';-import { SettingsPanel } from './Settings';--/**- * Settings rendered as a scrim-backed modal overlay (the default activation).- * Use the "Open in split" control in its header to dock it into the split- * layout instead — see {@link SettingsPanelComponentWrapper}.- */-export function SettingsModal() {- const { settingsModalOpen, closeModal } = useSettingsState();-- return (- <Dialog- open={settingsModalOpen()}- onOpenChange={(open) => {- if (!open) closeModal();- }}- fullscreen- class="bg-surface"- >- <Layer depth={0}>- <SettingsPanel variant="modal" />- </Layer>- </Dialog>- );-}diff --git a/js/app/packages/app/component/settings/SettingsRoute.tsx b/js/app/packages/app/component/settings/SettingsRoute.tsxnew file mode 100644index 0000000000..6c0c57f1bd--- /dev/null+++ b/js/app/packages/app/component/settings/SettingsRoute.tsx@@ -0,0 +1,43 @@+import { settingsSlugToTab } from '@core/constant/settingsTabsConfig';+import { useSettingsState } from '@core/constant/SettingsState';+import { Navigate, useParams } from '@solidjs/router';+import { Layer } from '@ui';+import { createEffect, Show } from 'solid-js';+import { SettingsPanel } from './Settings';++/**+ * Settings as a full-page route (`/settings/:tab`). This replaces the old+ * signal-driven fullscreen overlay: the URL is now the source of truth for+ * whether settings is open and which page is showing, so it's linkable and+ * survives reload — without leaking the workspace layout that a query param on+ * the split path would have carried.+ *+ * The app sidebar is hidden on this route (see Layout's `sidebarVisible`), so+ * the panel fills the window. "Move to split" still docks settings into the+ * layout as a `settings/<tab>` split.+ */+export function SettingsRoute() {+ const params = useParams<{ tab?: string }>();+ const { setActiveTabId } = useSettingsState();++ const tab = () => settingsSlugToTab(params.tab);++ // Route → state: keep the shared panel's active tab in sync with the URL.+ // Known-but-unavailable tabs (gated behind a flag/permission) still set the+ // tab; the panel renders it blank until the gate resolves, which preserves+ // deep links rather than bouncing legitimate users off mid-load.+ createEffect(() => {+ const current = tab();+ if (current) setActiveTabId(current);+ });++ return (+ <Show when={tab()} fallback={<Navigate href="/settings/account" />}>+ <div class="h-full w-full bg-surface">+ <Layer depth={0}>+ <SettingsPanel variant="fullscreen" />+ </Layer>+ </div>+ </Show>+ );+}diff --git a/js/app/packages/app/component/settings/SignatureSection.tsx b/js/app/packages/app/component/settings/SignatureSection.tsxindex bb84d3e668..d61c6f55f3 100644--- a/js/app/packages/app/component/settings/SignatureSection.tsx+++ b/js/app/packages/app/component/settings/SignatureSection.tsx@@ -13,7 +13,7 @@ import { createSignal, lazy, Show, Suspense } from 'solid-js';const SignatureEditor = lazy(() => import('./SignatureEditor'));// Unsaved signature drafts and per-inbox expanded state, keyed by link id and-// held at module scope. The settings modal unmounts the Connected Accounts tab+// held at module scope. The settings panel unmounts the Connected Accounts tab// when you switch away (and the links query can recreate an inbox row on// refetch); keeping this outside that subtree means tabbing away and back no// longer closes the editor or discards unsaved edits.diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.tsindex affdbf9ac7..2838c169af 100644--- a/js/app/packages/app/component/split-layout/layoutManager.ts+++ b/js/app/packages/app/component/split-layout/layoutManager.ts@@ -7,10 +7,12 @@ import type {} from '@core/block';import type { ResizeZoneCtx } from '@core/component/Resize/types';import { isBlockAlias, resolveBlockAlias } from '@core/constant/allBlocks';+import { settingsTabToSlug } from '@core/constant/settingsTabsConfig';import type {BlockInstanceHandle,BlockOrchestrator,} from '@core/orchestrator';+import { activeTabId } from '@core/signal/settingsTab';import { useFocusLock } from '@core/util/createControlledOpenSignal';import {type Accessor,@@ -83,6 +85,20 @@ function getAliasOrType(content: SplitContent): string {: content.aliasContext?.alias || content.type;}+/**+ * The `type/id` URL pair for a split's content. The docked settings panel is+ * stored internally as the `component/settings` content, but it serializes as+ * `settings/<active-tab-slug>` so the URL reflects (and can restore) which+ * settings page is open — matching the full-page `/settings/:tab` route. Reads+ * the active-tab signal, so the URL updates reactively as the tab changes.+ */+function contentUrlSegments(content: SplitContent): string[] {+ if (content.type === 'component' && content.id === 'settings') {+ return ['settings', settingsTabToSlug(activeTabId())];+ }+ return [getAliasOrType(content), content.id].map(String);+}+function keyOfSplitContent(s: SplitContent): SplitKey {return `${s.type}:${s.id}`;}@@ -809,8 +825,7 @@ export function createSplitLayout(const getUrlSegments = () => {return state.splits.filter((s) => !isExcluded(s))- .flatMap((s) => [getAliasOrType(s.content), s.content.id])- .map(String);+ .flatMap((s) => contentUrlSegments(s.content));};const getUrl = () => {@@ -925,9 +940,8 @@ export function createSplitLayout(removeSplit(currentSplit.id);},- getUrlSegments: () =>- [getAliasOrType(content()), content().id].map(String),- getUrl: () => getAliasOrType(content()) + '/' + content().id,+ getUrlSegments: () => contentUrlSegments(content()),+ getUrl: () => contentUrlSegments(content()).join('/'),isFirst: () => state.splits.at(0)?.id === id,isLast: () => state.splits.at(-1)?.id === id,isActive: () => currentSplit.id === state.activeSplitId,diff --git a/js/app/packages/app/component/split-layout/layoutUtils.ts b/js/app/packages/app/component/split-layout/layoutUtils.tsindex cb51d94596..3368e30263 100644--- a/js/app/packages/app/component/split-layout/layoutUtils.ts+++ b/js/app/packages/app/component/split-layout/layoutUtils.ts@@ -29,7 +29,14 @@ export function decodePairs(segments: string[]): SplitContent[] {const id = segments[i + 1];if (!type || !id) break;- if (type === 'component') {+ if (type === 'settings') {+ // `settings/<tab>` is the URL form of the docked settings panel; it maps+ // to the internal `component/settings` content. The active tab is read+ // reactively from the URL by SettingsPanelComponentWrapper, so it isn't+ // threaded through content params. See `contentUrlSegments` in+ // layoutManager for the matching encode.+ pairs.push({ type: 'component', id: 'settings' });+ } else if (type === 'component') {pairs.push({ type: 'component', id });} else {const resolvedType = resolveBlockAlias(type as BlockName | BlockAlias);diff --git a/js/app/packages/core/constant/SettingsState.tsx b/js/app/packages/core/constant/SettingsState.tsxindex 7eba2668c2..7d9088d9a5 100644--- a/js/app/packages/core/constant/SettingsState.tsx+++ b/js/app/packages/core/constant/SettingsState.tsx@@ -1,9 +1,12 @@import { useSplitLayout } from '@app/component/split-layout/layout';+import { DEFAULT_ROUTE } from '@app/constants/defaultRoute';+import { ROUTER_BASE } from '@app/constants/routerBase';import { globalSplitManager } from '@app/signal/splitLayout';-import { isMobile } from '@core/mobile/isMobile';import { isTouchDevice } from '@core/mobile/isTouchDevice';-import { createControlledOpenSignal } from '@core/util/createControlledOpenSignal';+import { activeTabId, setActiveTabId } from '@core/signal/settingsTab';+import { useLocation, useNavigate } from '@solidjs/router';import { createMemo, createSignal } from 'solid-js';+import { settingsSlugToTab, settingsTabToSlug } from './settingsTabsConfig';export type SettingsTab =| 'Account'@@ -23,16 +26,79 @@ export type SettingsTab =| 'GitHub'| 'Admin';-const [activeTabId, setActiveTabId] = createSignal<SettingsTab>('Account');+// Where "Back to app" (and move-to-split) should return to: the layout the user+// was on when they opened settings. Undefined when settings was deep-linked, in+// which case we fall back to DEFAULT_ROUTE.+const [settingsReturnTo, setSettingsReturnTo] = createSignal<string>();++const SETTINGS_PATH = '/settings';++const settingsPathFor = (tab: SettingsTab) =>+ `${SETTINGS_PATH}/${settingsTabToSlug(tab)}`;++/**+ * Strip the router base from a `location.pathname` (which includes it, e.g.+ * `/app/settings`) so it can be compared to — and reused with — the+ * base-relative paths that `navigate()` and route definitions use.+ */+const toBaseRelative = (pathname: string) => {+ if (ROUTER_BASE === '/') return pathname;+ if (pathname === ROUTER_BASE) return '/';+ if (pathname.startsWith(`${ROUTER_BASE}/`)) {+ return pathname.slice(ROUTER_BASE.length);+ }+ return pathname;+};++/** Whether a `location.pathname` (base included) is the settings route. */+export const isSettingsPath = (pathname: string) => {+ const path = toBaseRelative(pathname);+ return path === SETTINGS_PATH || path.startsWith(`${SETTINGS_PATH}/`);+};-// Settings open in a scrim-backed modal by default. The focus-lock signal keeps-// modal focus return consistent with the command menu / launcher.-const [modalOpen, setModalOpen] = createControlledOpenSignal(false, {- id: 'settings',-});+/**+ * Drop a settings split from a split-layout path, if present. Handles both the+ * URL encoding (`settings/<tab>`) and the legacy internal form+ * (`component/settings`). Only type positions (even indices) are inspected so a+ * block id that happens to be "settings" isn't mistaken for one.+ */+const stripSettingsSplit = (pathname: string) => {+ const segments = pathname.split('/').filter(Boolean);+ for (let i = 0; i + 1 < segments.length; i += 2) {+ const type = segments[i];+ if (+ type === 'settings' ||+ (type === 'component' && segments[i + 1] === 'settings')+ ) {+ segments.splice(i, 2);+ break;+ }+ }+ return segments.length ? `/${segments.join('/')}` : DEFAULT_ROUTE;+};++/**+ * Extract the active settings tab from a docked-split path+ * (`.../settings/<slug>`), or undefined if the path has no settings split.+ * Scans type positions (even indices, base stripped) so a block id that happens+ * to be "settings" isn't mistaken for one — mirrors {@link stripSettingsSplit}.+ */+export const settingsTabFromSplitPath = (+ pathname: string+): SettingsTab | undefined => {+ const segments = toBaseRelative(pathname).split('/').filter(Boolean);+ for (let i = 0; i + 1 < segments.length; i += 2) {+ if (segments[i] === 'settings') return settingsSlugToTab(segments[i + 1]);+ }+ return undefined;+};export const useSettingsState = () => {const { openWithSplit } = useSplitLayout();+ const navigate = useNavigate();+ const location = useLocation();++ const isOnSettingsRoute = () => isSettingsPath(location.pathname);const getSettingsSplit = () => {const splitManager = globalSplitManager();@@ -45,8 +111,9 @@ export const useSettingsState = () => {const splitOpen = createMemo(() => getSettingsSplit() !== undefined);- // Settings are considered open whether shown as a modal or docked in a split.- const isOpen = createMemo(() => modalOpen() || splitOpen());+ // Settings are considered open whether shown as the full-page route or docked+ // in a split.+ const isOpen = createMemo(() => isOnSettingsRoute() || splitOpen());const focusSettingsPanel = () => {if (isTouchDevice()) return;@@ -60,18 +127,28 @@ export const useSettingsState = () => {}, 10);};- // Default activation: open settings in a modal overlay. Mobile keeps the- // full-screen split behavior since the modal is sized for desktop.- const openSettings = (activeTabId?: SettingsTab) => {- if (isMobile()) {- openSettingsInSplit(activeTabId);- return;+ // Default activation: navigate to the settings route (both desktop and+ // mobile). Remember where we came from so "Back to app" can return there.+ // Opening without a specific tab always lands on Account rather than the+ // last-viewed page — a fresh open shouldn't resume a prior session's tab.+ const openSettings = (tab?: SettingsTab) => {+ if (!isOnSettingsRoute()) {+ setSettingsReturnTo(toBaseRelative(location.pathname));}- if (activeTabId) setActiveTabId(activeTabId);- setModalOpen(true);+ navigate(settingsPathFor(tab ?? 'Account'));};- // Opt-in: dock settings into the split layout (the pre-modal behavior).+ // Switch the active settings page. On the route this is a URL change (so the+ // page is reflected/shareable); in a split it's just the in-memory signal.+ const selectTab = (tab: SettingsTab) => {+ if (isOnSettingsRoute()) {+ navigate(settingsPathFor(tab), { replace: true });+ } else {+ setActiveTabId(tab);+ }+ };++ // Opt-in: dock settings into the split layout (the pre-route behavior).const openSettingsInSplit = (activeTabId?: SettingsTab) => {if (activeTabId) setActiveTabId(activeTabId);openWithSplit(@@ -88,8 +165,6 @@ export const useSettingsState = () => {focusSettingsPanel();};- const closeModal = () => setModalOpen(false);-const removeSettingsSplit = () => {const settingsSplit = getSettingsSplit();if (settingsSplit) {@@ -98,30 +173,41 @@ export const useSettingsState = () => {};const closeSettings = () => {- if (modalOpen()) setModalOpen(false);+ if (isOnSettingsRoute()) {+ navigate(settingsReturnTo() ?? DEFAULT_ROUTE, { replace: true });+ return;+ }removeSettingsSplit();};- // Promote the modal into the split layout: close the overlay and dock it.- const moveSettingsToSplit = (activeTabId?: SettingsTab) => {- setModalOpen(false);- openSettingsInSplit(activeTabId);+ // Promote the route into the split layout: rebuild the layout we came from and+ // dock settings into it as a `settings/<tab>` pair. Navigating straight to the+ // composed path avoids racing the split manager's mount.+ const moveSettingsToSplit = (tab?: SettingsTab) => {+ if (tab) setActiveTabId(tab);+ // Strip any settings split already in the target layout before re-adding+ // one, so repeatedly toggling fullscreen ⇄ split reuses a single settings+ // split (on the current tab) instead of stacking a new one each cycle.+ const base = stripSettingsSplit(+ settingsReturnTo() ?? DEFAULT_ROUTE+ ).replace(/\/$/, '');+ navigate(`${base}/settings/${settingsTabToSlug(activeTabId())}`);};- // Pop the docked split back out into the modal. The split is removed so it- // doesn't keep occupying layout space — the inverse of moveSettingsToSplit.- const moveSettingsToModal = (activeTabId?: SettingsTab) => {- if (activeTabId) setActiveTabId(activeTabId);- removeSettingsSplit();- setModalOpen(true);+ // Pop the docked split back out into the full-page route. The return layout is+ // the current path minus the settings split, so "Back to app" lands correctly.+ const moveSettingsToFullscreen = (tab?: SettingsTab) => {+ if (tab) setActiveTabId(tab);+ setSettingsReturnTo(stripSettingsSplit(toBaseRelative(location.pathname)));+ navigate(settingsPathFor(tab ?? activeTabId()));};// Focus-aware toggle: bring settings to the user rather than destroying it,// and only close when settings is what they're actually looking at.const toggleSettings = () => {- // Modal takes priority: if it's open, close it.- if (modalOpen()) {- setModalOpen(false);+ // Route takes priority: if it's the current page, leave it.+ if (isOnSettingsRoute()) {+ closeSettings();return;}@@ -139,20 +225,19 @@ export const useSettingsState = () => {return;}- // Nothing open → open the modal (mobile falls back to split internally).+ // Nothing open → open the route.openSettings();};return {settingsOpen: isOpen,- settingsModalOpen: modalOpen,settingsSplitOpen: splitOpen,openSettings,openSettingsInSplit,+ selectTab,closeSettings,- closeModal,moveSettingsToSplit,- moveSettingsToModal,+ moveSettingsToFullscreen,activeTabId,setActiveTabId,toggleSettings,diff --git a/js/app/packages/core/constant/settingsTabsConfig.tsx b/js/app/packages/core/constant/settingsTabsConfig.tsxindex cfd5375e49..30cdefae0b 100644--- a/js/app/packages/core/constant/settingsTabsConfig.tsx+++ b/js/app/packages/core/constant/settingsTabsConfig.tsx@@ -71,6 +71,47 @@ export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [/** Flattened view of {@link SETTINGS_TAB_GROUPS} for direct tab lookups. */const SETTINGS_TAB_ITEMS = SETTINGS_TAB_GROUPS.flatMap((group) => group.items);+/**+ * URL slugs for each settings tab, used to build the settings page path+ * (`/settings/<slug>`, and the `settings/<slug>` pair when docked in a split).+ * Kept separate from labels so we can rename a tab's UI label without breaking+ * existing/bookmarked URLs.+ */+const SETTINGS_TAB_SLUGS: Record<SettingsTab, string> = {+ Account: 'account',+ Billing: 'billing',+ Subscription: 'subscription',+ Organization: 'organization',+ Appearance: 'appearance',+ Mobile: 'mobile',+ 'AI Memory': 'ai-memory',+ Inbox: 'inbox',+ Shortcuts: 'shortcuts',+ 'Mobile App': 'mobile-app',+ Agent: 'mcp-server',+ Team: 'team',+ Connected: 'connections',+ Email: 'email',+ GitHub: 'github',+ Admin: 'admin',+};++const SETTINGS_SLUG_TO_TAB = new Map<string, SettingsTab>(+ (Object.entries(SETTINGS_TAB_SLUGS) as [SettingsTab, string][]).map(+ ([tab, slug]) => [slug, tab]+ )+);++/** The URL slug for a settings tab (e.g. `Connected` → `connections`). */+export const settingsTabToSlug = (tab: SettingsTab): string =>+ SETTINGS_TAB_SLUGS[tab];++/** Resolve a URL slug back to its settings tab, or `undefined` if unknown. */+export const settingsSlugToTab = (+ slug: string | null | undefined+): SettingsTab | undefined =>+ slug ? SETTINGS_SLUG_TO_TAB.get(slug) : undefined;+/*** Look up a single tab's presentation (label + icon). Lets consumers that* surface individual tabs (e.g. the sidebar's quick links) reuse the config'sdiff --git a/js/app/packages/core/signal/settingsTab.ts b/js/app/packages/core/signal/settingsTab.tsnew file mode 100644index 0000000000..9fb72eab26--- /dev/null+++ b/js/app/packages/core/signal/settingsTab.ts@@ -0,0 +1,14 @@+import type { SettingsTab } from '@core/constant/SettingsState';+import { createSignal } from 'solid-js';++/**+ * The active settings page. Lives in its own leaf module (rather than in+ * SettingsState) so the split-layout URL serializer can read it to encode a+ * docked settings split as `settings/<tab>` without creating an import cycle:+ * SettingsState → split-layout → layoutManager → activeTabId.+ *+ * The `SettingsTab` import above is type-only, so it's erased at runtime and+ * doesn't reintroduce the cycle.+ */+export const [activeTabId, setActiveTabId] =+ createSignal<SettingsTab>('Account');