From 614b4d38608376a4e5c9d31aeddc2bd02ed0d3bb Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Mon, 30 Nov 2026 09:44:32 +0700 Subject: [PATCH] Open Profiles first and even out row heights in mobile Agent settings (#11371) * feat(app): open Profiles by default when configuring a new agent on mobile On a phone, picking a profile is the quickest way to set up a new agent, so the agent settings drawer now opens with the Profiles card expanded for a draft (New Chat, New Workspace) when profiles exist. A running agent keeps it collapsed, since there a profile overwrites settings the agent already runs with. A toggle holds until the drawer closes. * fix(app): give every Agent settings row on mobile the same height Model and switch rows used the settings-card row, sized for spacious settings pages (switch height plus 16pt padding, 58pt on touch), while the sheet's Profiles header and mode choices are 44pt list rows. A new list placement in the row-density context makes settings rows in a sheet of list rows one touch target tall, and Agent settings Home opts into it. --- docs/design.md | 2 +- .../e2e/browser/agent-profiles-picker.spec.ts | 39 +++++++++++++++++++ .../model-search-across-providers.spec.ts | 8 +++- .../internal/use-agent-profile-picker.ts | 6 ++- .../app/src/components/settings/index.tsx | 2 +- .../src/components/settings/row-density.tsx | 28 ++++++++++++- .../agent-controls/agent-settings-drawer.tsx | 12 ++++-- .../composer/agent-controls/sheet-home.tsx | 28 +++++++------ 8 files changed, 101 insertions(+), 24 deletions(-) diff --git a/docs/design.md b/docs/design.md index 5d9dd3b309..51b176a017 100644 --- a/docs/design.md +++ b/docs/design.md @@ -136,7 +136,7 @@ Cards inside a section sit closer than sections. Rows inside a card touch — on Rows have generous vertical padding: roughly 16px of content plus 16px of vertical padding for settings rows, 8–12px for sidebar list items where many rows must fit. Every row is at least as tall as one holding a switch, so text rows, switch rows and rows that open something (``, a collapsible row's header) line up. A row holding a button or a select is taller. Compressing rows below the established density to fit more on the screen is wrong. Too many rows means more cards or more sections, not smaller rows. -Rows revealed under a `` are nested rows, one step smaller than card rows: 8px of vertical padding, `fontSize.sm` text, `sm` controls, and one fixed height so rows with and without a trailing button line up. The collapsible row sets this for everything under it (`packages/app/src/components/settings/row-density.tsx`). Never pass a density to a row, and never pad or resize a nested row by hand. Settings rows that share a menu surface with menu rows, such as Usage's options, go inside ``, which puts their labels on the menu rows' label rail (`menuRowContentInset`). +Rows revealed under a `` are nested rows, one step smaller than card rows: 8px of vertical padding, `fontSize.sm` text, `sm` controls, and one fixed height so rows with and without a trailing button line up. The collapsible row sets this for everything under it (`packages/app/src/components/settings/row-density.tsx`). Never pass a density to a row, and never pad or resize a nested row by hand. Settings rows that share a menu surface with menu rows, such as Usage's options, go inside ``, which puts their labels on the menu rows' label rail (`menuRowContentInset`). Settings rows that share a sheet with list rows, such as Agent settings with its radio choices and section headers, go inside ``, which makes every row one touch target tall so Model, switch and radio rows line up. The whitespace is the design. diff --git a/packages/app/e2e/browser/agent-profiles-picker.spec.ts b/packages/app/e2e/browser/agent-profiles-picker.spec.ts index 799a4ed1ed..e47af5f20b 100644 --- a/packages/app/e2e/browser/agent-profiles-picker.spec.ts +++ b/packages/app/e2e/browser/agent-profiles-picker.spec.ts @@ -128,6 +128,45 @@ test.describe("Agent profiles in the model picker", () => { } }); + test("the compact drawer keeps a running agent's Profiles collapsed and its rows one height", async ({ + page, + }, testInfo) => { + const seed = await seedAgentProfiles([PROFILE]); + const workspace = await seedMockAgentWorkspace({ + repoPrefix: "agent-profiles-compact-running-", + title: "Agent profiles compact running", + model: "ten-second-stream", + modeId: "load-test", + }); + + try { + await page.setViewportSize({ width: 390, height: 800 }); + await openAgentRoute(page, workspace); + await expectComposerVisible(page); + await page.getByTestId("combined-model-selector").filter({ visible: true }).first().click(); + await expect(page.getByTestId("agent-controls-profiles")).toBeVisible(); + await expect(page.getByTestId("agent-controls-profiles-list")).toHaveCount(0); + + // Settings rows (Model, switches) sit in the same list as the Profiles header and mode rows. + const sheet = page.getByTestId("agent-controls-settings-list"); + const rows = [ + sheet.getByTestId("agent-controls-profiles"), + sheet.getByTestId("agent-controls-model"), + sheet.locator('[data-testid^="mode-option-"]').first(), + ]; + const heights = []; + for (const row of rows) { + await expect(row).toBeVisible(); + heights.push(Math.round((await row.boundingBox())!.height)); + } + await page.screenshot({ path: testInfo.outputPath("compact-agent-settings.png") }); + expect(new Set(heights).size, `row heights ${heights.join(", ")}`).toBe(1); + } finally { + await workspace.cleanup(); + await seed.restore(); + } + }); + test("a model row and its create-profile action are separate buttons", async ({ page }) => { const seed = await seedAgentProfiles([]); const workspace = await seedMockAgentWorkspace({ diff --git a/packages/app/e2e/browser/model-search-across-providers.spec.ts b/packages/app/e2e/browser/model-search-across-providers.spec.ts index ad78053c23..57fd847bbb 100644 --- a/packages/app/e2e/browser/model-search-across-providers.spec.ts +++ b/packages/app/e2e/browser/model-search-across-providers.spec.ts @@ -317,13 +317,16 @@ test.describe("Cross-provider model search", () => { await expectComposerFocused(page); }); - await test.step("the compact drawer surfaces collapsed Profiles above Model on Home and keeps provider headers stable on collapse", async () => { + await test.step("the compact drawer opens a new agent's Profiles above Model on Home and keeps provider headers stable on collapse", async () => { await page.setViewportSize({ width: 390, height: 800 }); await page.getByTestId("combined-model-selector").filter({ visible: true }).first().click(); const profilesToggle = page.getByTestId("agent-controls-profiles"); + const profilesList = page.getByTestId("agent-controls-profiles-list"); const modelRowButton = page.getByTestId("agent-controls-model"); await expect(profilesToggle).toBeVisible(); - await expect(page.getByTestId("agent-controls-profiles-list")).toHaveCount(0); + await expect(profilesList).toBeVisible(); + await profilesToggle.click(); + await expect(profilesList).toHaveCount(0); await waitForSettledPosition(profilesToggle); const profilesBox = await profilesToggle.boundingBox(); const modelBox = await modelRowButton.boundingBox(); @@ -361,6 +364,7 @@ test.describe("Cross-provider model search", () => { // Return Home, expand Profiles in place, and apply the profile. await page.getByTestId("sheet-header-back").click(); + await expect(profilesList).toHaveCount(0); await profilesToggle.click(); const sheetProfileRow = page.getByTestId("model-profile-row-agent_profile_e2e_arrows"); await expect(sheetProfileRow).toBeVisible(); diff --git a/packages/app/src/agent-profiles/internal/use-agent-profile-picker.ts b/packages/app/src/agent-profiles/internal/use-agent-profile-picker.ts index 4ff19ac874..d81de439ab 100644 --- a/packages/app/src/agent-profiles/internal/use-agent-profile-picker.ts +++ b/packages/app/src/agent-profiles/internal/use-agent-profile-picker.ts @@ -43,6 +43,8 @@ export interface AgentProfilePickerRow { export interface AgentProfilePicker { rows: AgentProfilePickerRow[]; applyProfile: (profileId: string) => void; + /** What a picked profile configures: a running agent, or the draft of a new one. */ + target: AgentProfileApplyTarget["kind"]; } export interface UseAgentProfilePickerInput { @@ -166,7 +168,7 @@ export function useAgentProfilePicker( ); return useMemo( - () => (isSupported && profiles !== null ? { rows, applyProfile } : null), - [applyProfile, isSupported, profiles, rows], + () => (isSupported && profiles !== null ? { rows, applyProfile, target: target.kind } : null), + [applyProfile, isSupported, profiles, rows, target.kind], ); } diff --git a/packages/app/src/components/settings/index.tsx b/packages/app/src/components/settings/index.tsx index 887e2f708c..323d535029 100644 --- a/packages/app/src/components/settings/index.tsx +++ b/packages/app/src/components/settings/index.tsx @@ -37,7 +37,7 @@ export type { SettingsRowHintStatus } from "./row-header"; export { SettingsAddRow } from "./add-row"; export { SettingsBackLink, SettingsDetailHeader } from "./detail-header"; export { SettingsInfoTip } from "./headings/settings-info-tip"; -export { MenuSettingsRows } from "./row-density"; +export { ListSettingsRows, MenuSettingsRows } from "./row-density"; /** * What app screens can add to a plugin-facing row: an accessory beside the label, such as an info diff --git a/packages/app/src/components/settings/row-density.tsx b/packages/app/src/components/settings/row-density.tsx index 25c360591d..6b92c23cb5 100644 --- a/packages/app/src/components/settings/row-density.tsx +++ b/packages/app/src/components/settings/row-density.tsx @@ -1,7 +1,12 @@ import { createContext, useContext, useMemo, type ReactNode } from "react"; import type { StyleProp, TextStyle, ViewStyle } from "react-native"; import { StyleSheet } from "react-native-unistyles"; -import { CONTROL_HEIGHTS, mapLayout, type ControlSize } from "@/components/ui/control-geometry"; +import { + CONTROL_HEIGHTS, + mapLayout, + TOUCH_TARGET, + type ControlSize, +} from "@/components/ui/control-geometry"; import { menuRowContentInset } from "@/components/ui/menu"; import { settingsStyles } from "@/styles/settings"; @@ -12,7 +17,9 @@ import { settingsStyles } from "@/styles/settings"; // - nested: rows revealed under a collapsible row belong to it, so they sit one step smaller than // the rows of the card: tighter padding, smaller text, smaller controls. // - menu: rows that share a menu surface with menu rows put their labels on the menu's label rail. -type RowPlacement = "card" | "nested" | "menu"; +// - list: rows that share a sheet with list rows, such as radio choices and section headers, take +// the list row's height so every row in the sheet lines up. +type RowPlacement = "card" | "nested" | "menu" | "list"; const RowPlacementContext = createContext("card"); @@ -25,6 +32,11 @@ export function MenuSettingsRows({ children }: { children: ReactNode }) { return {children}; } +/** Settings rows rendered in a sheet of list rows, such as Agent settings. */ +export function ListSettingsRows({ children }: { children: ReactNode }) { + return {children}; +} + export interface SettingsRowLayout { row: StyleProp; title: StyleProp; @@ -49,6 +61,13 @@ function layoutFor(placement: RowPlacement): SettingsRowLayout { hint: settingsStyles.rowHint, controlSize: "md", }; + case "list": + return { + row: [settingsStyles.row, styles.listRow], + title: settingsStyles.rowTitle, + hint: settingsStyles.rowHint, + controlSize: "md", + }; case "card": return { row: settingsStyles.row, @@ -72,6 +91,11 @@ const styles = StyleSheet.create((theme) => ({ paddingVertical: theme.spacing[2], minHeight: mapLayout(CONTROL_HEIGHTS.sm, (height) => height + theme.spacing[2] * 2), }, + // A list row is a touch target tall on every input; a switch still fits inside its padding. + listRow: { + paddingVertical: theme.spacing[2], + minHeight: TOUCH_TARGET, + }, nestedText: { fontSize: theme.fontSize.sm, }, diff --git a/packages/app/src/composer/agent-controls/agent-settings-drawer.tsx b/packages/app/src/composer/agent-controls/agent-settings-drawer.tsx index 994abb63c3..6ceab9522b 100644 --- a/packages/app/src/composer/agent-controls/agent-settings-drawer.tsx +++ b/packages/app/src/composer/agent-controls/agent-settings-drawer.tsx @@ -88,7 +88,11 @@ export function AgentSettingsDrawer({ }: AgentSettingsDrawerProps) { const { t } = useTranslation(); const [page, setPage] = useState(AGENT_SHEET_HOME); - const [profilesExpanded, setProfilesExpanded] = useState(false); + // Profiles open on Home for a new agent, where a profile is the quickest way to configure it. + // `null` until the user toggles the card in this opening. + const [profilesToggled, setProfilesToggled] = useState(null); + const profilesExpanded = + profilesToggled ?? (profiles?.target === "draft" && profiles.rows.length > 0); // Select pages search with this; the Model page keeps its own. const [pageQuery, setPageQuery] = useState(""); const [pageSearchKey, setPageSearchKey] = useState(0); @@ -103,8 +107,8 @@ export function AgentSettingsDrawer({ }); const toggleProfiles = useCallback(() => { - setProfilesExpanded((expanded) => !expanded); - }, []); + setProfilesToggled(!profilesExpanded); + }, [profilesExpanded]); const goTo = useCallback((next: AgentSheetPage) => { Keyboard.dismiss(); @@ -125,7 +129,7 @@ export function AgentSettingsDrawer({ const close = useCallback(() => { Keyboard.dismiss(); setPage(AGENT_SHEET_HOME); - setProfilesExpanded(false); + setProfilesToggled(null); setPageQuery(""); modelPage.reset(); onClose(); diff --git a/packages/app/src/composer/agent-controls/sheet-home.tsx b/packages/app/src/composer/agent-controls/sheet-home.tsx index 1e0eb6b231..b44459d2a3 100644 --- a/packages/app/src/composer/agent-controls/sheet-home.tsx +++ b/packages/app/src/composer/agent-controls/sheet-home.tsx @@ -8,6 +8,7 @@ import type { AgentMode } from "@getpaseo/protocol/agent-types"; import { getAgentModeOptionIcon } from "@/agent-controls/icons"; import { formatAgentModeLabel } from "@/agent-controls/labels"; import { + ListSettingsRows, SettingsCard, SettingsDetailRow, SettingsSection, @@ -19,6 +20,7 @@ import { PressHighlight } from "@/components/ui/press-highlight"; import { ScrollView as SheetScrollView } from "@/components/ui/scroll-view"; import { SegmentedControl, type SegmentedControlOption } from "@/components/ui/segmented-control"; import { SteppedSlider, type SteppedSliderOption } from "@/components/ui/stepped-slider"; +import { TOUCH_TARGET } from "@/components/ui/control-geometry"; import { isNative } from "@/constants/platform"; import { ICON_SIZE } from "@/styles/theme"; import { @@ -85,17 +87,19 @@ export function AgentSheetHome({ > {/* Themed insets sit on a View: the sheet scroller drops a themed contentContainerStyle on web. */} - {topCard} - {blocks.map((block) => ( - - ))} - {footer} + + {topCard} + {blocks.map((block) => ( + + ))} + {footer} + ); @@ -663,7 +667,7 @@ const styles = StyleSheet.create((theme) => ({ fontSize: theme.fontSize.base, }, radioRow: { - minHeight: 44, + minHeight: TOUCH_TARGET, flexDirection: "row", alignItems: "center", paddingHorizontal: theme.spacing[4],