Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8260 feat(web): fit the mobile web app to iPhone Duo (#9558)

Jiayuan Zhanga097f592be73
diff --git a/apps/desktop/src/renderer/src/components/desktop-layout.test.tsx b/apps/desktop/src/renderer/src/components/desktop-layout.test.tsx
index d678cf5e46..20ec58eb66 100644
--- a/apps/desktop/src/renderer/src/components/desktop-layout.test.tsx
+++ b/apps/desktop/src/renderer/src/components/desktop-layout.test.tsx
@@ -168,7 +168,7 @@ describe("DesktopShell sidebar trigger", () => {
it("keeps full clearance for compact layouts in either sidebar state", () => {
Object.defineProperty(window, "innerWidth", {
configurable: true,
- value: 800,
+ value: 700,
});
const { container, getByRole, getByTestId } = renderShell();
diff --git a/packages/ui/components/ui/sidebar.tsx b/packages/ui/components/ui/sidebar.tsx
index 34821a6282..43c17d03c8 100644
--- a/packages/ui/components/ui/sidebar.tsx
+++ b/packages/ui/components/ui/sidebar.tsx
@@ -33,10 +33,10 @@ const SIDEBAR_WIDTH_STORAGE_KEY = "sidebar_width"
const SIDEBAR_WIDTH_MOBILE = "18rem"
const SIDEBAR_WIDTH_ICON = "3rem"
const SIDEBAR_DRAG_THRESHOLD = 2
-// Tailwind `lg`–`xl`: wide enough to keep a two-pane list/detail surface, too
-// narrow to also spend 256px on the nav. The nav starts collapsed here and the
-// header's trigger brings it back.
-const SIDEBAR_AUTO_COLLAPSE_QUERY = "(min-width: 1024px) and (max-width: 1279px)"
+// Tailwind `md`–`xl`: wide enough to keep a two-pane list/detail surface, too
+// narrow to also spend 256px on the nav by default. The nav starts collapsed
+// here and the header's trigger docks it back.
+const SIDEBAR_AUTO_COLLAPSE_QUERY = "(min-width: 768px) and (max-width: 1279px)"
/**
* Paints an element with whatever the sidebar wrapper is currently filled with.
@@ -66,8 +66,7 @@ type SidebarContextProps = {
setOpenMobile: (open: boolean) => void
/**
* The sidebar is an overlay sheet rather than a column in the main flow.
- * True below the compact breakpoint, which covers tablets and folded inner
- * screens as well as phones, not phones alone.
+ * True below the compact breakpoint (`md`).
*/
isCompact: boolean
toggleSidebar: () => void
@@ -166,7 +165,7 @@ function SidebarProvider({
// because nothing ever read it, and restoring the pair would be a bug rather
// than a feature: the auto-collapse below drives `setOpen(false)` from the
// viewport, so persisting its result would carry a collapse the user never
- // asked for out of the `lg`–`xl` band and into their next session on a wider
+ // asked for out of the `md`–`xl` band and into their next session on a wider
// display. Persisting this needs a source that distinguishes a user toggle
// from an automated one — not a cookie on this callback.
const [_open, _setOpen] = React.useState(defaultOpen)
@@ -183,7 +182,7 @@ function SidebarProvider({
[setOpenProp, open]
)
- // Auto-collapse across the `lg`–`xl` band. Only the two crossings are
+ // Auto-collapse across the `md`–`xl` band. Only the two crossings are
// automated: entering it parks the state we came in with and closes the nav,
// leaving it restores that state. Anything the user does in between — most
// of all re-opening the nav — is left alone until the next crossing.
@@ -335,19 +334,26 @@ function Sidebar({
<SheetTitle>Sidebar</SheetTitle>
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
</SheetHeader>
- <div className="flex h-full w-full flex-col">{children}</div>
+ {/*
+ On a short screen (phone landscape, a foldable's outer display) a
+ pinned header and footer leave the nav list only a few rows, so
+ the whole sheet scrolls as one column instead.
+ */}
+ <div className="flex h-full w-full flex-col [@media(max-height:640px)]:overflow-y-auto [@media(max-height:640px)]:[&>[data-slot=sidebar-content]]:flex-none">
+ {children}
+ </div>
</SheetContent>
</Sheet>
)
}
- // `lg`, not `md`: this CSS gate has to agree with the `useIsCompact()` gate
- // that chose the in-flow branch over the sheet above. While they disagreed,
+ // `md`: this CSS gate has to agree with the `useIsCompact()` gate that
+ // chose the in-flow branch over the sheet above. While they disagreed,
// every load between the two breakpoints painted a 256px sidebar for one
// frame before the hook resolved and collapsed it into a sheet.
return (
<div
- className="group peer hidden text-sidebar-foreground lg:block"
+ className="group peer hidden text-sidebar-foreground md:block"
data-state={state}
data-collapsible={state === "collapsed" ? collapsible : ""}
data-variant={variant}
@@ -370,7 +376,7 @@ function Sidebar({
data-slot="sidebar-container"
data-side={side}
className={cn(
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-out motion-reduce:transition-none lg:flex",
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-out motion-reduce:transition-none md:flex",
"data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
// Adjust the padding for floating and inset variants.
variant === "floating" || variant === "inset"
@@ -587,7 +593,7 @@ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
<main
data-slot="sidebar-inset"
className={cn(
- "relative flex w-full flex-1 flex-col bg-page-canvas lg:peer-data-[variant=inset]:m-2 lg:peer-data-[variant=inset]:ml-0 lg:peer-data-[variant=inset]:rounded-xl lg:peer-data-[variant=inset]:ring-1 lg:peer-data-[variant=inset]:ring-surface-border lg:peer-data-[variant=inset]:shadow-[var(--surface-shadow)] lg:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
+ "relative flex w-full flex-1 flex-col bg-page-canvas md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:ring-1 md:peer-data-[variant=inset]:ring-surface-border md:peer-data-[variant=inset]:shadow-[var(--surface-shadow)] md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
className
)}
{...props}
diff --git a/packages/ui/hooks/use-mobile.ts b/packages/ui/hooks/use-mobile.ts
index 6107c04390..4e0675c95e 100644
--- a/packages/ui/hooks/use-mobile.ts
+++ b/packages/ui/hooks/use-mobile.ts
@@ -1,10 +1,11 @@
import * as React from "react"
const MOBILE_BREAKPOINT = 768
-// Tailwind `lg`. Below it a 256px nav plus a 320px list column leave a
-// list/detail surface only a couple hundred pixels of reading width, so those
-// surfaces fold to the single column phones already get.
-const COMPACT_BREAKPOINT = 1024
+// Tailwind `md`. Below it the nav is a sheet and list/detail surfaces fold to
+// one column. From here up to `xl` the nav stays a docked column but starts
+// collapsed (see SIDEBAR_AUTO_COLLAPSE_QUERY), which leaves a foldable's inner
+// screen or a tablet enough reading width for both panes.
+const COMPACT_BREAKPOINT = 768
function useIsBelow(breakpoint: number) {
const [isBelow, setIsBelow] = React.useState<boolean | undefined>(undefined)
diff --git a/packages/views/chat/chat-page.test.tsx b/packages/views/chat/chat-page.test.tsx
index 25f9f3a941..568f38ef82 100644
--- a/packages/views/chat/chat-page.test.tsx
+++ b/packages/views/chat/chat-page.test.tsx
@@ -74,13 +74,15 @@ vi.mock("@multica/ui/components/ui/resizable", () => ({
// Same width-driven layout mock the inbox page tests use: the deep-link tests
// all want the desktop two-pane layout, the breakpoint tests at the bottom set
// their own width.
-const FOLD_INNER = 851;
-const TABLET = 1024;
+// iPhone Duo's inner screen: 669px wide held upright, 951px held sideways.
+const FOLD_INNER_PORTRAIT = 669;
+const FOLD_INNER_LANDSCAPE = 951;
+const TABLET = 768;
const DESKTOP = 1440;
const layout = vi.hoisted(() => ({ width: 1440 }));
vi.mock("@multica/ui/hooks/use-mobile", () => ({
useIsMobile: () => layout.width < 768,
- useIsCompact: () => layout.width < 1024,
+ useIsCompact: () => layout.width < 768,
}));
vi.mock("@multica/core/paths", () => ({
useRequiredWorkspaceSlug: () => "acme",
@@ -453,11 +455,10 @@ describe("ChatPage ?agent= deep link", () => {
describe("ChatPage responsive layout", () => {
const SELECT_PROMPT = "Pick a conversation, or start a new one with +";
- it("folds to a single column on a folded inner screen", () => {
- // 851px — the reported Pixel Fold inner screen. Too narrow for nav + thread
- // list + conversation, so with nothing open it spends the whole width on
- // the list instead of an empty conversation pane.
- layout.width = FOLD_INNER;
+ it("folds to a single column on a foldable's inner screen held upright", () => {
+ // Below the compact breakpoint, with nothing open, the page spends the
+ // whole width on the thread list instead of an empty conversation pane.
+ layout.width = FOLD_INNER_PORTRAIT;
renderPage("");
expect(
@@ -466,10 +467,10 @@ describe("ChatPage responsive layout", () => {
expect(screen.queryByText(SELECT_PROMPT)).not.toBeInTheDocument();
});
- it("gives the open conversation the whole folded inner screen", () => {
+ it("gives the open conversation the whole upright inner screen", () => {
// Opening a thread replaces the list, so the way back has to travel with
// the conversation — same trip the phone layout already had.
- layout.width = FOLD_INNER;
+ layout.width = FOLD_INNER_PORTRAIT;
// The page reconciles the store against `?session=`, so the open thread has
// to be in the URL too — otherwise the sync effect closes it.
storeRef.current = { activeSessionId: "session-1" };
@@ -482,11 +483,11 @@ describe("ChatPage responsive layout", () => {
expect(screen.getByRole("button", { name: "Chat" })).toBeInTheDocument();
});
- it("keeps both panes at the compact breakpoint", () => {
- // 1024px is the first width that keeps two panes. The nav auto-collapses
+ it.each([TABLET, FOLD_INNER_LANDSCAPE])("keeps both panes at %spx", (width) => {
+ // 768px is the first width that keeps two panes. The nav auto-collapses
// there instead (see the sidebar), so the thread list stays on screen next
// to an open conversation.
- layout.width = TABLET;
+ layout.width = width;
storeRef.current = { activeSessionId: "session-1" };
renderPage("session=session-1");
diff --git a/packages/views/inbox/components/inbox-page.test.tsx b/packages/views/inbox/components/inbox-page.test.tsx
index 97c07f552c..3cfc530573 100644
--- a/packages/views/inbox/components/inbox-page.test.tsx
+++ b/packages/views/inbox/components/inbox-page.test.tsx
@@ -147,13 +147,15 @@ vi.mock("../../navigation", () => ({
// about actioning a row WHILE it is open need the two-panel desktop layout,
// since a single column swaps the list out for the detail on selection.
const PHONE = 390;
-const FOLD_INNER = 851;
-const TABLET = 1024;
+// iPhone Duo's inner screen: 669px wide held upright, 951px held sideways.
+const FOLD_INNER_PORTRAIT = 669;
+const FOLD_INNER_LANDSCAPE = 951;
+const TABLET = 768;
const DESKTOP = 1440;
const layout = { width: PHONE };
vi.mock("@multica/ui/hooks/use-mobile", () => ({
useIsMobile: () => layout.width < 768,
- useIsCompact: () => layout.width < 1024,
+ useIsCompact: () => layout.width < 768,
}));
vi.mock("@multica/ui/components/ui/resizable", () => ({
ResizablePanelGroup: ({ children }: { children: React.ReactNode }) => (
@@ -878,12 +880,11 @@ describe("InboxPage", () => {
expect(markReadMutate).toHaveBeenCalledWith("inbox-a", expect.anything());
});
- it("folds to a single column on a folded inner screen", () => {
- // 851px — the reported Pixel Fold inner screen. Above the phone breakpoint
- // but far too narrow for nav + list + detail, so it takes the same single
- // column: opening a row replaces the list rather than sharing the width.
+ it("folds to a single column on a foldable's inner screen held upright", () => {
+ // Below the compact breakpoint the list and detail cannot share the
+ // width: opening a row replaces the list.
reset();
- layout.width = FOLD_INNER;
+ layout.width = FOLD_INNER_PORTRAIT;
listData.active = [item({ id: "inbox-a", issue_id: "issue-a" })];
render(<InboxPage />);
@@ -894,12 +895,13 @@ describe("InboxPage", () => {
expect(screen.queryByTestId("list")).toBeNull();
});
- it("keeps both panes at the compact breakpoint", () => {
- // 1024px is the first width that keeps the two-pane layout. The nav
+ it.each([TABLET, FOLD_INNER_LANDSCAPE])("keeps both panes at %spx", (width) => {
+ // 768px is the first width that keeps the two-pane layout. The nav
// auto-collapses there instead (see the sidebar), so the list has to stay
- // on screen next to an open item.
+ // on screen next to an open item — on a foldable's inner screen held
+ // sideways as much as on a tablet.
reset();
- layout.width = TABLET;
+ layout.width = width;
listData.active = [item({ id: "inbox-a", issue_id: "issue-a" })];
render(<InboxPage />);
diff --git a/packages/views/layout/sidebar-auto-collapse.test.tsx b/packages/views/layout/sidebar-auto-collapse.test.tsx
index ee9fa73257..fec1c353a1 100644
--- a/packages/views/layout/sidebar-auto-collapse.test.tsx
+++ b/packages/views/layout/sidebar-auto-collapse.test.tsx
@@ -4,8 +4,8 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { SidebarProvider, useSidebar } from "@multica/ui/components/ui/sidebar";
import { renderWithI18n } from "../test/i18n";
-// A width-driven `matchMedia`: the provider watches the `lg`–`xl` band and
-// `useIsCompact` watches `max-width: 1023px`, so both have to answer against
+// A width-driven `matchMedia`: the provider watches the `md`–`xl` band and
+// `useIsCompact` watches `max-width: 767px`, so both have to answer against
// the same viewport and both have to be notified when it changes.
type Listener = (e: MediaQueryListEvent) => void;
@@ -37,9 +37,9 @@ function setWidth(next: number) {
}
function Probe() {
- const { state, toggleSidebar } = useSidebar();
+ const { state, isCompact, toggleSidebar } = useSidebar();
return (
- <button type="button" data-testid="state" onClick={toggleSidebar}>
+ <button type="button" data-testid="state" data-compact={isCompact} onClick={toggleSidebar}>
{state}
</button>
);
@@ -49,7 +49,7 @@ function state() {
return screen.getByTestId("state").textContent;
}
-describe("sidebar auto-collapse between lg and xl", () => {
+describe("sidebar auto-collapse between md and xl", () => {
beforeEach(() => {
queries.clear();
window.matchMedia = ((query: string) => {
@@ -130,8 +130,25 @@ describe("sidebar auto-collapse between lg and xl", () => {
expect(state()).toBe("expanded");
});
+ it("docks the nav on a foldable's inner screen held sideways", () => {
+ // 951px, iPhone Duo's inner screen in landscape: the nav is a column in
+ // the page rather than a sheet, starts collapsed, and the trigger docks it.
+ setWidth(951);
+ renderWithI18n(
+ <SidebarProvider>
+ <Probe />
+ </SidebarProvider>,
+ );
+
+ expect(screen.getByTestId("state")).toHaveAttribute("data-compact", "false");
+ expect(state()).toBe("collapsed");
+
+ fireEvent.click(screen.getByTestId("state"));
+ expect(state()).toBe("expanded");
+ });
+
it("does not touch the collapsed state below the band", () => {
- // Under 1024 the nav is a sheet, which has its own open state — the
+ // Under 768 the nav is a sheet, which has its own open state — the
// in-flow state must be left where the user last put it.
renderWithI18n(
<SidebarProvider>
@@ -139,8 +156,9 @@ describe("sidebar auto-collapse between lg and xl", () => {
</SidebarProvider>,
);
- setWidth(851);
+ setWidth(669);
+ expect(screen.getByTestId("state")).toHaveAttribute("data-compact", "true");
expect(state()).toBe("expanded");
});