Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(settings): dock settings into a split on mobile (#4544)

Peter Chinman6091ac052696
diff --git a/js/app/packages/app/component/settings/SettingsRoute.tsx b/js/app/packages/app/component/settings/SettingsRoute.tsx
index f38be2e75f..b00f8e4082 100644
--- a/js/app/packages/app/component/settings/SettingsRoute.tsx
+++ b/js/app/packages/app/component/settings/SettingsRoute.tsx
@@ -1,5 +1,6 @@
import { useSettingsState } from '@core/constant/SettingsState';
import { settingsSlugToTab } from '@core/constant/settingsTabsConfig';
+import { isMobile } from '@core/mobile/isMobile';
import { Navigate, useParams } from '@solidjs/router';
import { Layer } from '@ui';
import { createEffect, Show } from 'solid-js';
@@ -15,6 +16,8 @@ import { SettingsPanel } from './Settings';
* 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.
+ *
+ * Desktop-only: on mobile this route redirects into the docked-split form.
*/
export function SettingsRoute() {
const params = useParams<{ tab?: string }>();
@@ -31,13 +34,31 @@ export function SettingsRoute() {
if (current) setActiveTabId(current);
});
+ // Mobile never shows the full-page route: its exit affordances ("Back to
+ // app", "Move to split") all live in desktop-only chrome, so rendering it
+ // would trap the user. Bounce into the docked-split form instead — the way
+ // settings opens on mobile (see SettingsState.openSettings). Reached by deep
+ // links, URLs persisted before mobile went back to split-docked settings,
+ // and width changes (e.g. phone rotation) while on the route.
+ const MobileSettingsRedirect = () => {
+ // Carry the requested tab into the docked panel via the shared signal —
+ // the docked form's URL (`component/settings`) doesn't encode it. Set
+ // synchronously (not via the effect above) since navigation can unmount
+ // this route before effects run.
+ const initialTab = tab();
+ if (initialTab) setActiveTabId(initialTab);
+ return <Navigate href="/component/settings" />;
+ };
+
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 when={!isMobile()} fallback={<MobileSettingsRedirect />}>
+ <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>
</Show>
);
}
diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.ts
index 2838c169af..0a28b4d1a7 100644
--- a/js/app/packages/app/component/split-layout/layoutManager.ts
+++ b/js/app/packages/app/component/split-layout/layoutManager.ts
@@ -8,6 +8,7 @@ import type {
import type { ResizeZoneCtx } from '@core/component/Resize/types';
import { isBlockAlias, resolveBlockAlias } from '@core/constant/allBlocks';
import { settingsTabToSlug } from '@core/constant/settingsTabsConfig';
+import { isMobile } from '@core/mobile/isMobile';
import type {
BlockInstanceHandle,
BlockOrchestrator,
@@ -91,9 +92,16 @@ function getAliasOrType(content: SplitContent): string {
* `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.
+ *
+ * On mobile the panel keeps its internal `component/settings` form instead:
+ * mobile serializes only the foreground split, and a bare `settings/<tab>`
+ * path would be claimed by the full-page `/settings/:tab` route — unmounting
+ * the split layout whose back button / swipe-back gesture are the reason
+ * settings docks into a split on mobile in the first place.
*/
function contentUrlSegments(content: SplitContent): string[] {
if (content.type === 'component' && content.id === 'settings') {
+ if (isMobile()) return ['component', 'settings'];
return ['settings', settingsTabToSlug(activeTabId())];
}
return [getAliasOrType(content), content.id].map(String);
diff --git a/js/app/packages/core/constant/SettingsState.tsx b/js/app/packages/core/constant/SettingsState.tsx
index 7d9088d9a5..3699f56aff 100644
--- a/js/app/packages/core/constant/SettingsState.tsx
+++ b/js/app/packages/core/constant/SettingsState.tsx
@@ -2,6 +2,7 @@ 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 { activeTabId, setActiveTabId } from '@core/signal/settingsTab';
import { useLocation, useNavigate } from '@solidjs/router';
@@ -127,11 +128,18 @@ export const useSettingsState = () => {
}, 10);
};
- // 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.
+ // Default activation. On mobile, dock settings into the split layout so it
+ // inherits the split navigation chrome (back button, swipe-back gesture) —
+ // the full-page route's exit affordances all live in desktop-only UI. On
+ // desktop, navigate to the settings route, remembering 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 (isMobile()) {
+ openSettingsInSplit(tab ?? 'Account');
+ return;
+ }
if (!isOnSettingsRoute()) {
setSettingsReturnTo(toBaseRelative(location.pathname));
}
@@ -225,7 +233,7 @@ export const useSettingsState = () => {
return;
}
- // Nothing open → open the route.
+ // Nothing open → open settings (route on desktop, docked split on mobile).
openSettings();
};