Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(settings): restore missing settings modal overlay

Steven Enamakelc29ad7126afb
diff --git a/app/src/components/settings/modal/SettingsModal.tsx b/app/src/components/settings/modal/SettingsModal.tsx
deleted file mode 100644
index f7a2d7171e..0000000000
--- a/app/src/components/settings/modal/SettingsModal.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import { SettingsModalFrame } from './SettingsModalFrame';
-import SettingsModalLayout from './SettingsModalLayout';
-import { useCloseSettings } from './useCloseSettings';
-
-/**
- * Desktop Settings, presented as a centered full-app-size modal floating over
- * the page it was opened from (the "background location"). Composes the
- * presentational {@link SettingsModalFrame} (backdrop / Esc / focus / close)
- * around the routed two-column {@link SettingsModalLayout}.
- *
- * Mounted by `AppShellDesktop` whenever the current path is a settings path; the
- * shell renders the background page underneath. iOS keeps the full-page
- * `pages/Settings.tsx` and never mounts this.
- */
-export default function SettingsModal() {
- const close = useCloseSettings();
- return (
- <SettingsModalFrame onClose={close}>
- <SettingsModalLayout />
- </SettingsModalFrame>
- );
-}
diff --git a/app/src/components/settings/modal/SettingsModalFrame.test.tsx b/app/src/components/settings/modal/SettingsModalFrame.test.tsx
deleted file mode 100644
index ba2c9d7fa5..0000000000
--- a/app/src/components/settings/modal/SettingsModalFrame.test.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import { fireEvent, render, screen } from '@testing-library/react';
-import { describe, expect, it, vi } from 'vitest';
-
-import { SettingsModalFrame } from './SettingsModalFrame';
-
-// Identity translator so we can assert on stable i18n keys.
-vi.mock('../../../lib/i18n/I18nContext', () => ({ useT: () => ({ t: (key: string) => key }) }));
-
-/**
- * The frame is backed by Radix `Dialog` now (see ui/ModalShell.test.tsx for
- * the same pattern). Radix registers its outside-pointer listener in a
- * macrotask, so a click synchronous with render is not observed — flush first.
- */
-async function flushDeferredWork(): Promise<void> {
- await new Promise(resolve => setTimeout(resolve, 0));
-}
-
-/**
- * Radix treats an outside interaction as pointerdown *followed by* a click, so
- * dragging out of the dialog doesn't dismiss it. Fire both against the same
- * target to trigger a real dismiss.
- */
-function dismissByOutsideClick(target: HTMLElement): void {
- fireEvent.pointerDown(target);
- fireEvent.click(target);
-}
-
-describe('SettingsModalFrame', () => {
- it('renders its children', () => {
- render(
- <SettingsModalFrame onClose={vi.fn()}>
- <div data-testid="child">hello</div>
- </SettingsModalFrame>
- );
- expect(screen.getByTestId('child')).toHaveTextContent('hello');
- });
-
- it('calls onClose when the X button is clicked', () => {
- const onClose = vi.fn();
- render(
- <SettingsModalFrame onClose={onClose}>
- <div>body</div>
- </SettingsModalFrame>
- );
- fireEvent.click(screen.getByTestId('settings-modal-close'));
- expect(onClose).toHaveBeenCalledTimes(1);
- });
-
- it('calls onClose when Escape is pressed', () => {
- const onClose = vi.fn();
- render(
- <SettingsModalFrame onClose={onClose}>
- <div>body</div>
- </SettingsModalFrame>
- );
- fireEvent.keyDown(document, { key: 'Escape' });
- expect(onClose).toHaveBeenCalledTimes(1);
- });
-
- it('calls onClose when the backdrop is clicked', async () => {
- const onClose = vi.fn();
- render(
- <SettingsModalFrame onClose={onClose}>
- <div>body</div>
- </SettingsModalFrame>
- );
- await flushDeferredWork();
- dismissByOutsideClick(screen.getByTestId('settings-modal-backdrop'));
- expect(onClose).toHaveBeenCalledTimes(1);
- });
-
- it('does not call onClose when the card body is clicked', async () => {
- const onClose = vi.fn();
- render(
- <SettingsModalFrame onClose={onClose}>
- <div data-testid="child">body</div>
- </SettingsModalFrame>
- );
- await flushDeferredWork();
- dismissByOutsideClick(screen.getByTestId('child'));
- expect(onClose).not.toHaveBeenCalled();
- });
-
- // The card is sized by fixed CSS (80vh tall, capped at max-w-5xl), never by its
- // content — this is what keeps the modal from resizing when switching tabs.
- // Render with deliberately different-sized children and assert the size classes
- // are identical and content-independent.
- it('sizes the card with fixed, content-independent dimensions', () => {
- const tiny = render(
- <SettingsModalFrame onClose={vi.fn()}>
- <div>x</div>
- </SettingsModalFrame>
- );
- const tinyCard = tiny.getByTestId('settings-modal-card');
- expect(tinyCard.className).toContain('h-full');
- expect(tinyCard.className).toContain('w-full');
- // The card's positioning wrapper carries the fixed height + max width.
- const tinyWrapper = tinyCard.parentElement as HTMLElement;
- expect(tinyWrapper.className).toContain('h-[80vh]');
- expect(tinyWrapper.className).toContain('max-w-5xl');
- expect(tinyWrapper.className).toContain('w-full');
- tiny.unmount();
-
- const big = render(
- <SettingsModalFrame onClose={vi.fn()}>
- <div style={{ height: 4000, width: 4000 }}>huge</div>
- </SettingsModalFrame>
- );
- const bigWrapper = big.getByTestId('settings-modal-card').parentElement as HTMLElement;
- // Same size classes regardless of how large the panel content is.
- expect(bigWrapper.className).toBe(tinyWrapper.className);
- });
-});
diff --git a/app/src/components/settings/modal/SettingsModalFrame.tsx b/app/src/components/settings/modal/SettingsModalFrame.tsx
deleted file mode 100644
index 3ee2dbeed7..0000000000
--- a/app/src/components/settings/modal/SettingsModalFrame.tsx
+++ /dev/null
@@ -1,93 +0,0 @@
-import { Dialog as DialogPrimitive } from 'radix-ui';
-import { type ReactNode } from 'react';
-
-import { useT } from '../../../lib/i18n/I18nContext';
-import Button from '../../ui/Button';
-import { DialogOverlay, DialogRoot } from '../../ui/Dialog';
-import { CloseIcon } from '../../ui/icons';
-import VisuallyHidden from '../../ui/VisuallyHidden';
-
-interface SettingsModalFrameProps {
- /** Invoked on X click, Esc, or backdrop click. */
- onClose: () => void;
- children: ReactNode;
- /** id of the element labelling the dialog, if any. */
- labelledBy?: string;
-}
-
-/**
- * Presentational chrome for the desktop Settings modal: a portalled, dimmed
- * backdrop and a centered, full-app-size card with a floating close button.
- *
- * Backed by Radix `Dialog` (see `ui/ModalShell.tsx` for the rationale — real
- * focus trap, scroll lock, `aria-hidden` on the rest of the tree, and focus
- * restore on unmount). This frame does not reuse `ModalShell` itself: it needs
- * no title bar, a two-column body instead of a single content slot, and a
- * close affordance floated *above* the card rather than inside a header row —
- * so it composes the lower-level `DialogRoot`/`DialogOverlay`/
- * `DialogPrimitive.Content` pieces directly.
- */
-export function SettingsModalFrame({ onClose, children, labelledBy }: SettingsModalFrameProps) {
- const { t } = useT();
-
- // Portal into #root (not document.body) so the modal stays inside the app's
- // tested subtree — `#root`-scoped checks (and E2E specs reading
- // `#root.innerText()`) see the routed panel. Falls back to body if absent.
- const portalTarget = document.getElementById('root') ?? document.body;
-
- return (
- <DialogRoot
- open
- onOpenChange={next => {
- if (!next) onClose();
- }}>
- <DialogPrimitive.Portal container={portalTarget}>
- <DialogOverlay
- data-testid="settings-modal-backdrop"
- className="flex items-center justify-center"
- />
- {/* Positioning wrapper sized to the card, rendered as a sibling of the
- overlay so it sits above the scrim without needing its own click
- handler — Radix's dismissable layer already treats a click on the
- overlay as an outside interaction. The close button is a sibling of
- the card so it can float just above the top-right corner — outside
- the card surface — and never overlap panel content. No overflow
- clip here. */}
- <div className="pointer-events-none fixed inset-0 z-50 flex items-center justify-center">
- <div className="pointer-events-auto relative mx-4 flex h-[80vh] w-full max-w-5xl">
- <Button
- variant="secondary"
- iconOnly
- size="sm"
- aria-label={t('common.close')}
- data-testid="settings-modal-close"
- onClick={onClose}
- className="absolute bottom-full right-0 mb-2 h-8 w-8 rounded-full text-content-muted shadow-md hover:text-content-secondary">
- <CloseIcon className="h-4 w-4" />
- </Button>
- <DialogPrimitive.Content
- aria-labelledby={labelledBy}
- aria-label={labelledBy ? undefined : t('nav.settings')}
- data-testid="settings-modal-card"
- // Radius matches the shell's ContentSurface so the modal reads as the
- // app's one content card lifted forward. It keeps `shadow-xl` rather
- // than the shell's `shadow-content-edge` hairline: this card floats on
- // a dimmed scrim with no adjacent chrome to seam against, and the two
- // utilities would collide on `box-shadow` anyway.
- className="flex h-full w-full overflow-hidden rounded-2xl bg-surface shadow-xl animate-fade-up focus:outline-hidden">
- {/* Radix requires a Title in the tree for the dialog to be
- accessible. When the caller supplies its own visible heading
- via `labelledBy`, that id still wins as the accessible name
- (set above); this hidden node only satisfies Radix's a11y
- check and gives screen readers a fallback name otherwise. */}
- <VisuallyHidden>
- <DialogPrimitive.Title>{t('nav.settings')}</DialogPrimitive.Title>
- </VisuallyHidden>
- {children}
- </DialogPrimitive.Content>
- </div>
- </div>
- </DialogPrimitive.Portal>
- </DialogRoot>
- );
-}
diff --git a/app/src/components/settings/modal/SettingsModalLayout.tsx b/app/src/components/settings/modal/SettingsModalLayout.tsx
deleted file mode 100644
index 2a0d74b4db..0000000000
--- a/app/src/components/settings/modal/SettingsModalLayout.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Outlet, Route, Routes } from 'react-router-dom';
-
-import { SettingsLayoutProvider } from '../layout/SettingsLayoutContext';
-import SettingsSidebar from '../layout/SettingsSidebar';
-import { settingsRouteElements } from '../settingsRouteElements';
-
-/**
- * Two-column body of the desktop Settings modal: the grouped nav + search on the
- * left and the routed panel on the right, both inside the modal card.
- *
- * Unlike {@link SettingsLayout} (the iOS full-page host, which projects the
- * sidebar into the app shell via `SidebarContent`), this renders the sidebar
- * inline. It still advertises `inTwoPaneShell: true` so shared chrome
- * (SettingsHeader / SettingsBackButton) behaves exactly as in the full-page
- * shell — top-level panels hide their back button and rely on the sidebar.
- *
- * The shared {@link settingsRouteElements} use paths relative to `/settings`
- * (e.g. `account`). On iOS they are nested under the `/settings/*` route in
- * `AppRoutesIOS`; here there is no such ancestor (the modal is mounted directly
- * by the shell), so we scope them under an explicit `/settings` parent route
- * whose `<Outlet/>` renders the matched panel into the right column.
- */
-export default function SettingsModalLayout() {
- return (
- <SettingsLayoutProvider value={{ inTwoPaneShell: true }}>
- <div className="flex h-full w-full min-h-0">
- <div className="h-full w-64 shrink-0 overflow-hidden border-r border-line">
- <SettingsSidebar />
- </div>
- {/* Right column: the routed panel. The sibling sub-nav pill row now
- lives inside each panel's header (via SettingsPanel), so the title
- always sits above the pills and the content top never shifts. */}
- <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
- <div className="min-h-0 flex-1 overflow-hidden">
- <Routes>
- <Route path="/settings" element={<Outlet />}>
- {settingsRouteElements()}
- </Route>
- </Routes>
- </div>
- </div>
- </div>
- </SettingsLayoutProvider>
- );
-}
diff --git a/app/src/components/settings/modal/settingsOverlay.test.ts b/app/src/components/settings/modal/settingsOverlay.test.ts
deleted file mode 100644
index d8e4ca0dc4..0000000000
--- a/app/src/components/settings/modal/settingsOverlay.test.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import type { Location } from 'react-router-dom';
-import { describe, expect, it } from 'vitest';
-
-import {
- isSettingsPath,
- resolveBackgroundLocation,
- resolveSettingsOverlay,
- SETTINGS_FALLBACK_PATH,
- settingsNavState,
-} from './settingsOverlay';
-
-/** Build a minimal Location for tests (cast avoids coupling to router internals). */
-const loc = (pathname: string, state: unknown = null): Location =>
- ({ pathname, search: '', hash: '', state, key: 'test' }) as unknown as Location;
-
-describe('isSettingsPath', () => {
- it('matches the settings index and sub-paths', () => {
- expect(isSettingsPath('/settings')).toBe(true);
- expect(isSettingsPath('/settings/account')).toBe(true);
- expect(isSettingsPath('/settings/team/manage/1')).toBe(true);
- });
-
- it('does not match other paths', () => {
- expect(isSettingsPath('/chat')).toBe(false);
- expect(isSettingsPath('/settings-foo')).toBe(false);
- expect(isSettingsPath('/')).toBe(false);
- });
-});
-
-describe('resolveBackgroundLocation', () => {
- it('captures the current location when opening from a non-settings page', () => {
- const here = loc('/brain');
- expect(resolveBackgroundLocation(here)).toBe(here);
- });
-
- it('preserves the stored background when already on a settings path', () => {
- const background = loc('/brain');
- expect(
- resolveBackgroundLocation(loc('/settings/billing', { backgroundLocation: background }))
- ).toBe(background);
- });
-
- it('returns undefined on a settings path with no stored background (deep link)', () => {
- expect(resolveBackgroundLocation(loc('/settings/voice'))).toBeUndefined();
- });
-});
-
-describe('settingsNavState', () => {
- it('wraps the resolved background in navigate options', () => {
- const here = loc('/rewards');
- expect(settingsNavState(here)).toEqual({ state: { backgroundLocation: here } });
- });
-
- it('preserves background across in-modal navigation', () => {
- const background = loc('/human');
- expect(settingsNavState(loc('/settings/account', { backgroundLocation: background }))).toEqual({
- state: { backgroundLocation: background },
- });
- });
-});
-
-describe('resolveSettingsOverlay', () => {
- it('reports closed and passes the current location through off settings', () => {
- const here = loc('/chat');
- expect(resolveSettingsOverlay(here)).toEqual({ settingsOpen: false, baseLocation: here });
- });
-
- it('reports open and renders the stored background behind', () => {
- const background = loc('/brain');
- expect(
- resolveSettingsOverlay(loc('/settings/account', { backgroundLocation: background }))
- ).toEqual({ settingsOpen: true, baseLocation: background });
- });
-
- it('falls back to /chat behind a deep-linked settings path', () => {
- expect(resolveSettingsOverlay(loc('/settings/voice'))).toEqual({
- settingsOpen: true,
- baseLocation: SETTINGS_FALLBACK_PATH,
- });
- });
-});
diff --git a/app/src/components/settings/modal/settingsOverlay.ts b/app/src/components/settings/modal/settingsOverlay.ts
deleted file mode 100644
index 1ccc45281a..0000000000
--- a/app/src/components/settings/modal/settingsOverlay.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-// [settings:modal] Pure routing helpers for the desktop Settings modal overlay.
-//
-// Desktop Settings is presented as a centered modal floating over the page the
-// user was on. We use react-router's "background location" pattern: opening
-// Settings stashes the current location in `history.state.backgroundLocation`,
-// the shell renders that page underneath, and the `/settings/*` route renders
-// inside the modal on top. The URL still becomes `/settings/account` etc. so
-// deep links, settings search, and legacy redirects keep working.
-//
-// This module is pure (no JSX/React) so the branching logic is unit-testable in
-// isolation without mounting the app or importing the panel barrel.
-import debugFactory from 'debug';
-import type { Location } from 'react-router-dom';
-
-const debug = debugFactory('settings:modal');
-
-/**
- * Page rendered behind the modal when Settings is reached via a deep link or a
- * redirect that carries no `backgroundLocation` (e.g. `/activity` →
- * `/settings/notifications`). Guarantees the overlay always has a sane backdrop.
- */
-export const SETTINGS_FALLBACK_PATH = '/chat';
-
-/** Shape of the nav state we thread through history to remember the backdrop. */
-interface SettingsLocationState {
- backgroundLocation?: Location;
-}
-
-/** True when a pathname targets the settings route tree. */
-export function isSettingsPath(pathname: string): boolean {
- return pathname === '/settings' || pathname.startsWith('/settings/');
-}
-
-/**
- * Resolve the location that should render *behind* the modal for a navigation.
- *
- * - Already on a settings path (switching panels inside the modal): preserve the
- * existing `backgroundLocation` so the backdrop never changes.
- * - Anywhere else (opening Settings): the current location *is* the backdrop.
- *
- * Returns `undefined` only when we're on a settings path with no stored
- * background (deep link / redirect) — callers fall back to {@link
- * SETTINGS_FALLBACK_PATH}.
- */
-export function resolveBackgroundLocation(location: Location): Location | undefined {
- if (isSettingsPath(location.pathname)) {
- return (location.state as SettingsLocationState | null)?.backgroundLocation;
- }
- return location;
-}
-
-/**
- * `navigate(...)` options that carry the resolved backdrop. Spread into any
- * navigation that opens or moves within Settings:
- * navigate('/settings/billing', settingsNavState(location))
- */
-export function settingsNavState(location: Location): { state: { backgroundLocation?: Location } } {
- return { state: { backgroundLocation: resolveBackgroundLocation(location) } };
-}
-
-/**
- * Drive the desktop shell: whether the Settings modal is open and which
- * location the page *behind* it should render.
- */
-export function resolveSettingsOverlay(location: Location): {
- settingsOpen: boolean;
- baseLocation: Location | string;
-} {
- const settingsOpen = isSettingsPath(location.pathname);
- const background = (location.state as SettingsLocationState | null)?.backgroundLocation;
- const baseLocation = background ?? (settingsOpen ? SETTINGS_FALLBACK_PATH : location);
- debug(
- 'resolveSettingsOverlay: path=%s open=%s base=%o',
- location.pathname,
- settingsOpen,
- background ?? (settingsOpen ? SETTINGS_FALLBACK_PATH : location.pathname)
- );
- return { settingsOpen, baseLocation };
-}
diff --git a/app/src/components/settings/modal/useCloseSettings.test.tsx b/app/src/components/settings/modal/useCloseSettings.test.tsx
deleted file mode 100644
index a36a273d11..0000000000
--- a/app/src/components/settings/modal/useCloseSettings.test.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import { fireEvent, render, screen } from '@testing-library/react';
-import { MemoryRouter, useLocation } from 'react-router-dom';
-import { describe, expect, it } from 'vitest';
-
-import { useCloseSettings } from './useCloseSettings';
-
-/** Probe that closes on click and echoes the current path. */
-function Probe() {
- const close = useCloseSettings();
- const location = useLocation();
- return (
- <button type="button" data-testid="probe" data-path={location.pathname} onClick={close}>
- close
- </button>
- );
-}
-
-const currentPath = () => screen.getByTestId('probe').getAttribute('data-path');
-
-describe('useCloseSettings', () => {
- it('navigates to the stored backgroundLocation when present', () => {
- render(
- <MemoryRouter
- initialEntries={[
- { pathname: '/settings/account', state: { backgroundLocation: { pathname: '/brain' } } },
- ]}>
- <Probe />
- </MemoryRouter>
- );
- expect(currentPath()).toBe('/settings/account');
- fireEvent.click(screen.getByTestId('probe'));
- expect(currentPath()).toBe('/brain');
- });
-
- it('falls back to /chat when there is no backgroundLocation', () => {
- render(
- <MemoryRouter initialEntries={[{ pathname: '/settings/voice' }]}>
- <Probe />
- </MemoryRouter>
- );
- fireEvent.click(screen.getByTestId('probe'));
- expect(currentPath()).toBe('/chat');
- });
-});
diff --git a/app/src/components/settings/modal/useCloseSettings.ts b/app/src/components/settings/modal/useCloseSettings.ts
deleted file mode 100644
index 5a233b7b50..0000000000
--- a/app/src/components/settings/modal/useCloseSettings.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import debugFactory from 'debug';
-import { useCallback } from 'react';
-import { type Location, useLocation, useNavigate } from 'react-router-dom';
-
-import { SETTINGS_FALLBACK_PATH } from './settingsOverlay';
-
-const debug = debugFactory('settings:modal');
-
-interface SettingsLocationState {
- backgroundLocation?: Location;
-}
-
-/**
- * Returns a callback that closes the Settings modal by navigating back to the
- * page it was opened over (`history.state.backgroundLocation`), falling back to
- * {@link SETTINGS_FALLBACK_PATH} for deep links / redirects that carry no
- * background. Shared by the X button, Esc, and backdrop click.
- */
-export function useCloseSettings(): () => void {
- const navigate = useNavigate();
- const location = useLocation();
-
- return useCallback(() => {
- const background = (location.state as SettingsLocationState | null)?.backgroundLocation;
- debug('closeSettings: background=%o', background ?? SETTINGS_FALLBACK_PATH);
- // replace so pressing Back after closing doesn't reopen the Settings modal.
- navigate(background ?? SETTINGS_FALLBACK_PATH, { replace: true });
- }, [navigate, location.state]);
-}