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(web): mobile settings sheet survives menu dismissal, More models opens in place, no API Keys on mobile, Agents/Runtimes tabs keep scroll (#6975)

Wolf Mermelstein8af0b4f9f632
diff --git a/apps/web/src/components/app/mobile/MobileDrawer.tsx b/apps/web/src/components/app/mobile/MobileDrawer.tsx
index 13b150b818..d68fe1cc00 100644
--- a/apps/web/src/components/app/mobile/MobileDrawer.tsx
+++ b/apps/web/src/components/app/mobile/MobileDrawer.tsx
@@ -227,19 +227,39 @@ function MobileDrawerHandle<T extends ValidComponent = 'div'>(
);
}
+/**
+ * A Kobalte menu, select, or popover opened inside a drawer portals to
+ * `document.body` and, while modal, sets `pointer-events: none` there. A
+ * pointer aimed at the menu's backdrop therefore lands on `<html>`, which
+ * corvu reads as a pointer outside the drawer — so dismissing the menu would
+ * tear down the whole drawer with it. Leave those to the menu's own layer;
+ * the next pointer, with no menu open, reaches the overlay and closes the
+ * drawer as usual.
+ */
+function dismissesDrawer(event: PointerEvent) {
+ return event.target !== document.documentElement;
+}
+
/**
* Wrapper around Corvu's Drawer for mobile. Handles styling and input/virtual keyboard behaviour.
*/
export const MobileDrawer = Object.assign(
- (props: ComponentProps<typeof Drawer>) => (
- <Drawer
- breakPoints={[0.8]}
- closeOnOutsideFocus={false}
- noOutsidePointerEvents={false}
- restoreFocus={false}
- {...props}
- />
- ),
+ (props: ComponentProps<typeof Drawer>) => {
+ const [local, rest] = splitProps(props, ['onOutsidePointer']);
+ return (
+ <Drawer
+ breakPoints={[0.8]}
+ closeOnOutsideFocus={false}
+ noOutsidePointerEvents={false}
+ restoreFocus={false}
+ {...rest}
+ onOutsidePointer={(event) => {
+ if (!dismissesDrawer(event)) event.preventDefault();
+ local.onOutsidePointer?.(event);
+ }}
+ />
+ );
+ },
{
Trigger: Drawer.Trigger,
Portal: Drawer.Portal,
diff --git a/apps/web/src/features/settings/AgentSettings.test.tsx b/apps/web/src/features/settings/AgentSettings.test.tsx
new file mode 100644
index 0000000000..ad8cf2109a
--- /dev/null
+++ b/apps/web/src/features/settings/AgentSettings.test.tsx
@@ -0,0 +1,63 @@
+/**
+ * @vitest-environment jsdom
+ */
+
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import type { JSX } from 'solid-js';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { AgentSettings } from './AgentSettings';
+
+vi.mock('@solidjs/router', () => ({
+ useSearchParams: () => [{}],
+}));
+
+vi.mock('./components/bring-your-own-agent', () => ({
+ BringYourOwnAgent: () => <div>Bring your own agent</div>,
+}));
+
+// Each section owns a SettingsPage: the scroll container swaps with the tab.
+function FakePage(props: { title: string; navigation: JSX.Element }) {
+ return (
+ <div data-settings-page>
+ {props.navigation}
+ <h1>{props.title}</h1>
+ </div>
+ );
+}
+
+vi.mock('./Agents', () => ({
+ Agents: (props: { navigation: JSX.Element }) => (
+ <FakePage title="Team agents" navigation={props.navigation} />
+ ),
+}));
+
+vi.mock('./Harness', () => ({
+ Harness: (props: { navigation: JSX.Element }) => (
+ <FakePage title="Built-in runtimes" navigation={props.navigation} />
+ ),
+}));
+
+afterEach(() => {
+ cleanup();
+});
+
+describe('AgentSettings section tabs', () => {
+ it('keeps the scroll offset when the section swaps its page', () => {
+ render(() => <AgentSettings />);
+ const page = () =>
+ document.querySelector<HTMLElement>('[data-settings-page]');
+ const first = page();
+ if (!first) throw new Error('no settings page');
+ first.scrollTop = 260;
+
+ fireEvent.click(screen.getByRole('button', { name: 'Runtimes' }));
+ expect(screen.getByText('Built-in runtimes')).toBeTruthy();
+ const second = page();
+ expect(second).not.toBe(first);
+ expect(second?.scrollTop).toBe(260);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Agents' }));
+ expect(screen.getByText('Team agents')).toBeTruthy();
+ expect(page()?.scrollTop).toBe(260);
+ });
+});
diff --git a/apps/web/src/features/settings/AgentSettings.tsx b/apps/web/src/features/settings/AgentSettings.tsx
index 83feaa4b56..52551b336e 100644
--- a/apps/web/src/features/settings/AgentSettings.tsx
+++ b/apps/web/src/features/settings/AgentSettings.tsx
@@ -17,36 +17,52 @@ export function AgentSettings(props: {
searchParams.pair ? 'runtimes' : (props.initialSection ?? 'agents')
);
const [startPairing, setStartPairing] = createSignal(false);
+ let host: HTMLDivElement | undefined;
+ const scrollBody = () =>
+ host?.querySelector<HTMLElement>('[data-settings-page]') ?? null;
+
+ // Each section is its own SettingsPage, so switching mounts a fresh scroll
+ // container. Carry the offset across so the section tabs, which sit below
+ // the shared header, stay under the finger or pointer that chose them.
+ const showSection = (next: AgentManagementSection) => {
+ const scrollTop = scrollBody()?.scrollTop ?? 0;
+ setSection(next);
+ const body = scrollBody();
+ if (body) body.scrollTop = scrollTop;
+ };
+
const navigation = () => (
<AgentManagementNavigation
section={section()}
onChange={(section) => {
setStartPairing(false);
- setSection(section);
+ showSection(section);
}}
/>
);
return (
- <Show
- when={section() === 'agents'}
- fallback={
- <Harness navigation={navigation()} startPairing={startPairing()} />
- }
- >
- <Agents
- navigation={
- <>
- <BringYourOwnAgent
- onAddRuntime={() => {
- setStartPairing(true);
- setSection('runtimes');
- }}
- />
- {navigation()}
- </>
+ <div ref={host} class="contents">
+ <Show
+ when={section() === 'agents'}
+ fallback={
+ <Harness navigation={navigation()} startPairing={startPairing()} />
}
- />
- </Show>
+ >
+ <Agents
+ navigation={
+ <>
+ <BringYourOwnAgent
+ onAddRuntime={() => {
+ setStartPairing(true);
+ showSection('runtimes');
+ }}
+ />
+ {navigation()}
+ </>
+ }
+ />
+ </Show>
+ </div>
);
}
diff --git a/apps/web/src/features/settings/MobileSettingsSheet.test.tsx b/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
index e957937dd6..1fbaca8559 100644
--- a/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
+++ b/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
@@ -92,6 +92,19 @@ describe('unavailable mobile settings sections', () => {
}
);
+ it('survives the tap that dismisses a menu portaled over it', () => {
+ const { settings, onClose } = setup('Account');
+ // A modal Kobalte menu takes pointer events off the body, so the tap that
+ // dismisses it reaches `<html>` rather than anything on the page.
+ fireEvent.pointerDown(document.documentElement);
+ expect(onClose).not.toHaveBeenCalled();
+ expect(settings.open()).toBe(true);
+
+ fireEvent.pointerDown(document.body);
+ expect(onClose).toHaveBeenCalled();
+ expect(settings.open()).toBe(false);
+ });
+
it('renders available sections and reacts when availability changes', () => {
const { setAvailableGroups } = setup('Account');
expect(screen.getByText('Account form')).toBeTruthy();
diff --git a/apps/web/src/features/settings/primitives.tsx b/apps/web/src/features/settings/primitives.tsx
index 65ed3bc8af..5b3974aa76 100644
--- a/apps/web/src/features/settings/primitives.tsx
+++ b/apps/web/src/features/settings/primitives.tsx
@@ -37,6 +37,7 @@ export function SettingsPage(props: {
const inSheet = useContext(SettingsSheetContext);
return (
<div
+ data-settings-page
data-drawer-scroll-body={inSheet ? true : undefined}
class="@container/settings-page h-full min-h-0 overflow-y-auto [overflow-anchor:none] select-children"
>
@@ -234,7 +235,6 @@ export function ChoiceRow(props: {
class="flex min-w-0 items-start gap-3 rounded-lg border border-edge-muted p-3 has-checked:border-accent has-checked:bg-accent-bg"
classList={{
'cursor-not-allowed opacity-50': props.disabled,
- 'cursor-pointer': !props.disabled,
}}
>
<input
diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx
index bb50449af4..0e3f6f651a 100644
--- a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx
+++ b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx
@@ -14,6 +14,18 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
import { ModelCatalogPicker } from './ModelCatalogPicker';
import type { CatalogModelOption } from './modelCatalog';
+const { isMobileWidth, setMobileWidth } = vi.hoisted(() => {
+ let mobile = false;
+ return {
+ isMobileWidth: () => mobile,
+ setMobileWidth: (value: boolean) => {
+ mobile = value;
+ },
+ };
+});
+
+vi.mock('@core/mobile/mobileWidth', () => ({ isMobileWidth }));
+
vi.mock('@ui', () => {
const cn = (...args: unknown[]) =>
args.flat(Infinity).filter(Boolean).join(' ');
@@ -95,6 +107,7 @@ const OPTIONS: CatalogModelOption[] = [
afterEach(() => {
cleanup();
+ setMobileWidth(false);
});
function mountPicker() {
@@ -144,3 +157,21 @@ describe('ModelCatalogPicker search focus', () => {
});
});
});
+
+describe('ModelCatalogPicker more models at phone width', () => {
+ it('replaces the list in place and comes back', () => {
+ setMobileWidth(true);
+ mountPicker();
+ fireEvent.click(screen.getByRole('button', { name: 'Agent model' }));
+
+ expect(screen.queryByText('Gemini 3.8 Flash High')).toBeNull();
+
+ fireEvent.click(screen.getByText('More models'));
+ expect(screen.getByText('Gemini 3.8 Flash High')).toBeTruthy();
+ expect(screen.queryByText('Claude Opus 5 High')).toBeNull();
+
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Recommended' }));
+ expect(screen.getByText('Claude Opus 5 High')).toBeTruthy();
+ expect(screen.queryByText('Gemini 3.8 Flash High')).toBeNull();
+ });
+});
diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx
index d96a7904c1..9c22873cc7 100644
--- a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx
+++ b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx
@@ -1,3 +1,4 @@
+import { isMobileWidth } from '@core/mobile/mobileWidth';
import CaretDown from '@phosphor/caret-left.svg';
import CaretRight from '@phosphor/caret-right.svg';
import CheckIcon from '@phosphor/check.svg';
@@ -9,6 +10,7 @@ import {
buildModelCatalog,
type CatalogModelOption,
MAX_RECOMMENDED_MODELS,
+ type ModelFamily,
matchesModelQuery,
modelFamilyHint,
moreModelFamilies,
@@ -57,6 +59,34 @@ function ModelRow(props: {
);
}
+/** The remaining families, grouped, for the More models screen. */
+function FamilyList(props: {
+ families: ModelFamily[];
+ value: string | null;
+ onSelect: (id: string) => void;
+}) {
+ return (
+ <For each={props.families}>
+ {(family) => (
+ <>
+ <Show when={family.label}>
+ <Dropdown.GroupLabel>{family.label}</Dropdown.GroupLabel>
+ </Show>
+ <For each={family.options}>
+ {(option) => (
+ <ModelRow
+ option={option}
+ selected={option.id === props.value}
+ onSelect={() => props.onSelect(option.id)}
+ />
+ )}
+ </For>
+ </>
+ )}
+ </For>
+ );
+}
+
/**
* Kobalte menus still autofocus the collection on a deferred `setTimeout(0)`
* (`deferAutoFocus` in createSelectableList) after `onOpenAutoFocus` is
@@ -143,6 +173,9 @@ export function ModelCatalogMenu(
}
) {
const [query, setQuery] = createSignal('');
+ // A submenu needs a second menu's width beside the first, which a phone
+ // does not have: there, More models replaces the list in place instead.
+ const [showingMore, setShowingMore] = createSignal(false);
const normalizedQuery = () => query().trim().toLowerCase();
const filtered = createMemo(() => {
const currentQuery = normalizedQuery();
@@ -197,7 +230,28 @@ export function ModelCatalogMenu(
<Show
when={normalizedQuery().length > 0}
fallback={
- <>
+ <Show
+ when={!(isMobileWidth() && showingMore())}
+ fallback={
+ <Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
+ <Dropdown.Item
+ closeOnSelect={false}
+ class="h-8 gap-2 text-ink-muted"
+ onSelect={() => setShowingMore(false)}
+ >
+ <CaretRight class="size-3 shrink-0 rotate-180" />
+ <span class="min-w-0 flex-1 truncate text-sm">
+ Recommended
+ </span>
+ </Dropdown.Item>
+ <FamilyList
+ families={extraFamilies()}
+ value={props.value}
+ onSelect={props.onSelect}
+ />
+ </Dropdown.Group>
+ }
+ >
<Show when={catalog().recommended.length > 0}>
<Dropdown.Group>
<Dropdown.GroupLabel>Recommended</Dropdown.GroupLabel>
@@ -216,48 +270,52 @@ export function ModelCatalogMenu(
<Show when={extraCount() > 0}>
<Dropdown.Group>
- <Dropdown.Sub>
- <Dropdown.SubTrigger>
- <span class="truncate">More models</span>
- <span class="flex shrink-0 items-center gap-1 text-xs text-ink-extra-muted">
- {extraCount()}
- <CaretRight class="size-3" />
- </span>
- </Dropdown.SubTrigger>
- <Dropdown.SubContent
- onPointerDown={(event: PointerEvent) =>
- event.stopPropagation()
- }
- onMouseDown={(event: MouseEvent) => event.stopPropagation()}
- class="w-72 max-w-[calc(100vw-1rem)] max-h-[var(--kb-popper-content-available-height)] overflow-y-auto overscroll-contain"
- >
- <Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
- <For each={extraFamilies()}>
- {(family) => (
- <>
- <Show when={family.label}>
- <Dropdown.GroupLabel>
- {family.label}
- </Dropdown.GroupLabel>
- </Show>
- <For each={family.options}>
- {(option) => (
- <ModelRow
- option={option}
- selected={option.id === props.value}
- onSelect={() => props.onSelect(option.id)}
- />
- )}
- </For>
- </>
- )}
- </For>
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
+ <Show
+ when={!isMobileWidth()}
+ fallback={
+ <Dropdown.Item
+ closeOnSelect={false}
+ class="justify-between"
+ onSelect={() => setShowingMore(true)}
+ >
+ <span class="truncate">More models</span>
+ <span class="flex shrink-0 items-center gap-1 text-xs text-ink-extra-muted">
+ {extraCount()}
+ <CaretRight class="size-3" />
+ </span>
+ </Dropdown.Item>
+ }
+ >
+ <Dropdown.Sub>
+ <Dropdown.SubTrigger>
+ <span class="truncate">More models</span>
+ <span class="flex shrink-0 items-center gap-1 text-xs text-ink-extra-muted">
+ {extraCount()}
+ <CaretRight class="size-3" />
+ </span>
+ </Dropdown.SubTrigger>
+ <Dropdown.SubContent
+ onPointerDown={(event: PointerEvent) =>
+ event.stopPropagation()
+ }
+ onMouseDown={(event: MouseEvent) =>
+ event.stopPropagation()
+ }
+ class="w-72 max-w-[calc(100vw-1rem)] max-h-[var(--kb-popper-content-available-height)] overflow-y-auto overscroll-contain"
+ >
+ <Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
+ <FamilyList
+ families={extraFamilies()}
+ value={props.value}
+ onSelect={props.onSelect}
+ />
+ </Dropdown.Group>
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+ </Show>
</Dropdown.Group>
</Show>
- </>
+ </Show>
}
>
<Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
diff --git a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
index d85420ab58..990e902139 100644
--- a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
+++ b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
@@ -16,6 +16,7 @@ import UserIconPhosphor from '@phosphor/user.svg';
import UsersThreeIcon from '@phosphor/users-three.svg';
import { type Component, createMemo } from 'solid-js';
import { useHasPermission } from '../context/user';
+import { isMobile } from '../mobile/isMobile';
import { isNativeMobilePlatform } from '../mobile/isNativeMobilePlatform';
import { isTouchDevice } from '../mobile/isTouchDevice';
import {
@@ -166,9 +167,12 @@ export const useSettingsTabAvailable = () => {
switch (tab) {
case 'Appearance':
case 'Account':
- case 'API Keys':
case 'Billing':
return true;
+ // Issuing and copying a key is desk work, and the mobile sheet has no
+ // good place for a one-time secret.
+ case 'API Keys':
+ return !isMobile();
case 'Notifications':
return notificationSettingsFlag().enabled;
case 'Team':
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index 191627e146..013120175e 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -139,6 +139,8 @@ permission failures should display a failed tool call without a successful resul
Its trigger, model options, and session metadata use the same readable model names
as the new-conversation picker. The menu includes provider icons, search, a short
**Recommended** list, and a scrollable **More models** submenu shared with Settings.
+ At phone width there is no room beside the menu, so **More models** replaces the
+ list in place and a **Recommended** row at the top goes back.
- Chat agents' empty input cycles tips about connectors, skills, mentions, and
agents; coding agents show **Describe what you want to build**. Type `@` for
mentions and `/` for skills.
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index b9f00d6087..8bf5b583a2 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1149,8 +1149,10 @@ On phones, **More views → Settings** opens an inset glass sheet over the curre
page. The main page has a profile shortcut and grouped Account, Preferences,
Workspace, and enabled agent/admin sections. Tap a row to open that settings
page inside the sheet; **Back to settings** returns to the grouped list at its
-previous scroll position. **Close settings** at the top right, Escape, an
-outside tap, or a downward swipe dismisses the sheet. Opening Settings again
+previous scroll position. `API Keys` is desktop-only and has no row here.
+**Close settings** at the top right, Escape, an
+outside tap, or a downward swipe dismisses the sheet. A tap that dismisses a
+menu opened inside the sheet leaves the sheet itself open. Opening Settings again
starts at the main page; explicit links (for example Account) open their
section directly. Existing settings URLs open the requested section in the sheet
and restore the underlying app route. The header stays visible while forms