diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts
index 8cdf6f2e25..a75f9f06d1 100644
--- a/apps/mobile/app.config.ts
+++ b/apps/mobile/app.config.ts
@@ -64,7 +64,7 @@ const config: ExpoConfig = {
runtimeVersion: {
policy: process.env.MOBILE_VERSION_POLICY ?? "appVersion",
},
- orientation: "portrait",
+ orientation: "default",
icon: "./assets/icon.png",
userInterfaceStyle: "automatic",
updates: {
diff --git a/apps/mobile/src/app/_layout.tsx b/apps/mobile/src/app/_layout.tsx
index 968be6c14a..de7e3c784a 100644
--- a/apps/mobile/src/app/_layout.tsx
+++ b/apps/mobile/src/app/_layout.tsx
@@ -26,6 +26,7 @@ import {
useClerkSettingsSheetDetent,
} from "../features/cloud/ClerkSettingsSheetDetent";
import { useAgentNotificationNavigation } from "../features/agent-awareness/notificationNavigation";
+import { AdaptiveWorkspaceLayout } from "../features/layout/AdaptiveWorkspaceLayout";
import { useThemeColor } from "../lib/useThemeColor";
function AppNavigator() {
@@ -92,33 +93,35 @@ function AppNavigatorContent() {
backgroundColor={String(statusBarBg)}
translucent
/>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
>
);
}
diff --git a/apps/mobile/src/app/index.tsx b/apps/mobile/src/app/index.tsx
index 7f9962efc9..552becc170 100644
--- a/apps/mobile/src/app/index.tsx
+++ b/apps/mobile/src/app/index.tsx
@@ -10,7 +10,7 @@ import {
} from "@t3tools/contracts";
import * as Arr from "effect/Array";
import * as Order from "effect/Order";
-import { useRouter } from "expo-router";
+import { Stack, useRouter } from "expo-router";
import { useCallback, useMemo, useState } from "react";
import { useProjects, useThreadShells } from "../state/entities";
@@ -21,6 +21,8 @@ import { HomeScreen } from "../features/home/HomeScreen";
import { HomeHeader } from "../features/home/HomeHeader";
import type { HomeProjectSortOrder } from "../features/home/homeThreadList";
import { useThreadListActions } from "../features/home/useThreadListActions";
+import { useAdaptiveWorkspaceLayout } from "../features/layout/AdaptiveWorkspaceLayout";
+import { WorkspaceEmptyDetail } from "../features/layout/WorkspaceEmptyDetail";
interface HomeListOptions {
readonly selectedEnvironmentId: EnvironmentId | null;
@@ -32,6 +34,7 @@ interface HomeListOptions {
/* ─── Route screen ───────────────────────────────────────────────────── */
export default function HomeRouteScreen() {
+ const { layout } = useAdaptiveWorkspaceLayout();
const projects = useProjects();
const threads = useThreadShells();
const { state: catalogState } = useWorkspaceState();
@@ -80,6 +83,22 @@ export default function HomeRouteScreen() {
setListOptions((current) => ({ ...current, projectGroupingMode }));
}, []);
+ if (layout.usesSplitView) {
+ return (
+ <>
+
+
+ >
+ );
+ }
+
return (
<>
({
+ layout: compactLayout,
+});
+
+function firstRouteParam(value: string | string[] | undefined): string | null {
+ return Array.isArray(value) ? (value[0] ?? null) : (value ?? null);
+}
+
+export function useAdaptiveWorkspaceLayout(): AdaptiveWorkspaceContextValue {
+ return use(AdaptiveWorkspaceContext);
+}
+
+export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) {
+ const { width, height } = useWindowDimensions();
+ const router = useRouter();
+ const params = useGlobalSearchParams<{
+ environmentId?: string | string[];
+ threadId?: string | string[];
+ }>();
+ const layout = useMemo(() => deriveLayout({ width, height }), [height, width]);
+ const environmentId = firstRouteParam(params.environmentId);
+ const threadId = firstRouteParam(params.threadId);
+ const selectedThreadKey =
+ environmentId !== null && threadId !== null
+ ? scopedThreadKey(EnvironmentId.make(environmentId), ThreadId.make(threadId))
+ : null;
+ const contextValue = useMemo(() => ({ layout }), [layout]);
+
+ const handleSelectThread = (thread: EnvironmentThreadShell) => {
+ router.replace(buildThreadRoutePath(thread));
+ };
+
+ return (
+
+
+ {layout.usesSplitView && layout.listPaneWidth !== null ? (
+ router.push("/settings")}
+ onSelectThread={handleSelectThread}
+ onStartNewTask={() => router.push("/new")}
+ />
+ ) : null}
+ {props.children}
+
+
+ );
+}
diff --git a/apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx b/apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx
new file mode 100644
index 0000000000..9d052a89a2
--- /dev/null
+++ b/apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx
@@ -0,0 +1,21 @@
+import { SymbolView } from "expo-symbols";
+import { View } from "react-native";
+
+import { AppText as Text } from "../../components/AppText";
+import { useThemeColor } from "../../lib/useThemeColor";
+
+export function WorkspaceEmptyDetail() {
+ const iconColor = useThemeColor("--color-icon-subtle");
+
+ return (
+
+
+
+ Select a thread
+
+ Choose a thread from the sidebar or start a new task.
+
+
+
+ );
+}
diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx
index a82e7c49cc..4ba6fbed58 100644
--- a/apps/mobile/src/features/threads/ThreadFeed.tsx
+++ b/apps/mobile/src/features/threads/ThreadFeed.tsx
@@ -25,6 +25,7 @@ import {
ActivityIndicator,
Image,
Linking,
+ type LayoutChangeEvent,
Pressable,
ScrollView,
StyleSheet,
@@ -1121,7 +1122,8 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
const foldSettleSecondFrameRef = useRef(null);
const disclosureAnchorKeyRef = useRef(null);
const previousLatestTurnRef = useRef(props.latestTurn);
- const { width: viewportWidth } = useWindowDimensions();
+ const { width: windowWidth } = useWindowDimensions();
+ const [viewportWidth, setViewportWidth] = useState(windowWidth);
const [disclosureToggleSettling, setDisclosureToggleSettling] = useState(false);
const [interactionState, setInteractionState] = useState<{
readonly copiedRowId: string | null;
@@ -1147,6 +1149,11 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
const topContentInset = props.contentTopInset ?? insets.top + 44;
const bottomContentInset = props.contentBottomInset ?? 18;
+ const handleViewportLayout = useCallback((event: LayoutChangeEvent) => {
+ const nextWidth = Math.round(event.nativeEvent.layout.width);
+ setViewportWidth((current) => (Math.abs(current - nextWidth) > 1 ? nextWidth : current));
+ }, []);
+
const iconSubtleColor = useThemeColor("--color-icon-subtle");
const userBubbleColor = useThemeColor("--color-user-bubble");
const onMarkdownLinkPress = useCallback(
@@ -1451,7 +1458,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
return (
<>
-
+
({
- activityAt: new Date(thread.updatedAt ?? thread.createdAt).getTime(),
- title: thread.title,
- }),
-);
+import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
+import { buildThreadNavigationGroups } from "./thread-navigation-groups";
export function ThreadNavigationDrawer(props: {
readonly visible: boolean;
@@ -192,24 +179,9 @@ function ThreadNavigationDrawerContent(props: {
}) {
const projects = useProjects();
const threads = useThreadShells();
- const repositoryGroups = useMemo(
- () => groupProjectsByRepository({ projects, threads }),
- [projects, threads],
- );
const groupedThreads = useMemo(
- () =>
- repositoryGroups.map((group) => {
- const threads: EnvironmentThreadShell[] = [];
- for (const projectGroup of group.projects) {
- threads.push(...projectGroup.threads);
- }
- return {
- key: group.key,
- title: group.projects[0]?.project.title ?? group.title,
- threads: Arr.sort(threads, threadActivityOrder),
- };
- }),
- [repositoryGroups],
+ () => buildThreadNavigationGroups({ projects, threads }),
+ [projects, threads],
);
return (
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
new file mode 100644
index 0000000000..811b620a3f
--- /dev/null
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -0,0 +1,219 @@
+import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
+import { SymbolView } from "expo-symbols";
+import { useMemo, useState } from "react";
+import { Pressable, ScrollView, StyleSheet, TextInput, View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+
+import { AppText as Text } from "../../components/AppText";
+import { StatusPill } from "../../components/StatusPill";
+import { scopedThreadKey } from "../../lib/scopedEntities";
+import { relativeTime } from "../../lib/time";
+import { useThemeColor } from "../../lib/useThemeColor";
+import { useProjects, useThreadShells } from "../../state/entities";
+import { buildThreadNavigationGroups } from "./thread-navigation-groups";
+import { threadStatusTone } from "./threadPresentation";
+
+export function ThreadNavigationSidebar(props: {
+ readonly width: number;
+ readonly selectedThreadKey: string | null;
+ readonly onOpenSettings: () => void;
+ readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
+ readonly onStartNewTask: () => void;
+}) {
+ const insets = useSafeAreaInsets();
+ const projects = useProjects();
+ const threads = useThreadShells();
+ const [searchQuery, setSearchQuery] = useState("");
+ const groups = useMemo(
+ () => buildThreadNavigationGroups({ projects, threads, searchQuery }),
+ [projects, searchQuery, threads],
+ );
+
+ const backgroundColor = useThemeColor("--color-drawer");
+ const borderColor = useThemeColor("--color-border");
+ const foregroundColor = useThemeColor("--color-foreground");
+ const iconColor = useThemeColor("--color-icon-muted");
+ const mutedColor = useThemeColor("--color-foreground-muted");
+ const placeholderColor = useThemeColor("--color-placeholder");
+ const searchBackgroundColor = useThemeColor("--color-subtle-strong");
+ const selectedBackgroundColor = useThemeColor("--color-subtle-strong");
+ const pressedBackgroundColor = useThemeColor("--color-subtle");
+
+ return (
+
+
+
+ Threads
+
+ [
+ styles.headerButton,
+ { backgroundColor: pressed ? pressedBackgroundColor : "transparent" },
+ ]}
+ >
+
+
+ [
+ styles.headerButton,
+ { backgroundColor: pressed ? pressedBackgroundColor : "transparent" },
+ ]}
+ >
+
+
+
+
+
+
+
+
+
+
+ {groups.length === 0 ? (
+
+ {searchQuery.trim().length > 0 ? "No matching threads" : "No threads yet"}
+
+ ) : (
+ groups.map((group) => (
+
+
+ {group.title}
+
+
+ {group.threads.length === 0 ? (
+ No threads yet
+ ) : (
+ group.threads.map((thread) => {
+ const threadKey = scopedThreadKey(thread.environmentId, thread.id);
+ const selected = threadKey === props.selectedThreadKey;
+
+ return (
+ props.onSelectThread(thread)}
+ style={({ pressed }) => [
+ styles.threadRow,
+ {
+ backgroundColor: selected
+ ? selectedBackgroundColor
+ : pressed
+ ? pressedBackgroundColor
+ : "transparent",
+ },
+ ]}
+ >
+
+
+ {thread.title}
+
+
+ {relativeTime(thread.updatedAt ?? thread.createdAt)}
+
+
+
+
+ );
+ })
+ )}
+
+ ))
+ )}
+
+
+ );
+}
+
+const styles = StyleSheet.create({
+ header: {
+ minHeight: 48,
+ paddingLeft: 18,
+ paddingRight: 8,
+ flexDirection: "row",
+ alignItems: "center",
+ gap: 2,
+ },
+ headerButton: {
+ width: 44,
+ height: 44,
+ borderRadius: 12,
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ searchField: {
+ height: 36,
+ marginTop: 6,
+ marginHorizontal: 14,
+ paddingLeft: 10,
+ paddingRight: 5,
+ borderRadius: 10,
+ flexDirection: "row",
+ alignItems: "center",
+ gap: 7,
+ },
+ searchInput: {
+ flex: 1,
+ height: 36,
+ paddingVertical: 0,
+ paddingHorizontal: 0,
+ fontFamily: "DMSans_400Regular",
+ fontSize: 15,
+ },
+ section: {
+ gap: 4,
+ },
+ threadRow: {
+ minHeight: 58,
+ borderRadius: 10,
+ paddingHorizontal: 10,
+ paddingVertical: 8,
+ flexDirection: "row",
+ alignItems: "center",
+ gap: 8,
+ },
+ threadText: {
+ minWidth: 0,
+ flex: 1,
+ gap: 2,
+ },
+});
diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
index f8c916974e..ba112c25d4 100644
--- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
@@ -1,5 +1,5 @@
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
-import { useCallback, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useState } from "react";
import * as Option from "effect/Option";
import { EnvironmentId, type ProjectScript } from "@t3tools/contracts";
import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
@@ -47,6 +47,7 @@ import { useSelectedThreadWorktree } from "../../state/use-selected-thread-workt
import { useThreadComposerState } from "../../state/use-thread-composer-state";
import { threadEnvironment } from "../../state/threads";
import { projectThreadContentPresentation } from "./threadContentPresentation";
+import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
function firstRouteParam(value: string | string[] | undefined): string | null {
if (Array.isArray(value)) {
@@ -61,6 +62,7 @@ function OpeningThreadLoadingScreen() {
}
export function ThreadRouteScreen() {
+ const { layout } = useAdaptiveWorkspaceLayout();
const { state: workspaceState } = useWorkspaceState();
const { connectionState } = useRemoteConnectionStatus();
const { onReconnectEnvironment } = useRemoteConnections();
@@ -145,8 +147,16 @@ export function ThreadRouteScreen() {
const gitActionProgress = useGitActionProgress(gitActionProgressTarget);
const handleOpenDrawer = useCallback(() => {
- setDrawerVisible(true);
- }, []);
+ if (!layout.usesSplitView) {
+ setDrawerVisible(true);
+ }
+ }, [layout.usesSplitView]);
+
+ useEffect(() => {
+ if (layout.usesSplitView) {
+ setDrawerVisible(false);
+ }
+ }, [layout.usesSplitView]);
const handleOpenConnectionEditor = useCallback(() => {
void router.push("/connections");
@@ -328,6 +338,7 @@ export function ThreadRouteScreen() {
headerStyle: { backgroundColor: "transparent" },
headerShadowVisible: false,
headerTintColor: iconColor,
+ headerBackVisible: !layout.usesSplitView,
headerBackTitle: "",
headerTitle: () => (
- setDrawerVisible(false)}
- onSelectThread={(thread) => {
- router.replace(buildThreadRoutePath(thread));
- }}
- onStartNewTask={() => router.push("/new")}
- />
+ {layout.usesSplitView ? null : (
+ setDrawerVisible(false)}
+ onSelectThread={(thread) => {
+ router.replace(buildThreadRoutePath(thread));
+ }}
+ onStartNewTask={() => router.push("/new")}
+ />
+ )}
>
);
diff --git a/apps/mobile/src/features/threads/thread-navigation-groups.test.ts b/apps/mobile/src/features/threads/thread-navigation-groups.test.ts
new file mode 100644
index 0000000000..fb2f0ee576
--- /dev/null
+++ b/apps/mobile/src/features/threads/thread-navigation-groups.test.ts
@@ -0,0 +1,94 @@
+import type {
+ EnvironmentProject,
+ EnvironmentThreadShell,
+} from "@t3tools/client-runtime/state/shell";
+import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";
+import { describe, expect, it } from "vite-plus/test";
+
+import { buildThreadNavigationGroups } from "./thread-navigation-groups";
+
+const environmentId = EnvironmentId.make("environment-1");
+
+function makeProject(input: Pick): EnvironmentProject {
+ return {
+ environmentId,
+ workspaceRoot: `/workspaces/${input.id}`,
+ repositoryIdentity: null,
+ defaultModelSelection: null,
+ scripts: [],
+ createdAt: "2026-06-01T00:00:00.000Z",
+ updatedAt: "2026-06-01T00:00:00.000Z",
+ ...input,
+ };
+}
+
+function makeThread(
+ input: Pick &
+ Partial,
+): EnvironmentThreadShell {
+ return {
+ environmentId,
+ modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
+ runtimeMode: "full-access",
+ interactionMode: "default",
+ branch: null,
+ worktreePath: null,
+ latestTurn: null,
+ createdAt: "2026-06-01T00:00:00.000Z",
+ updatedAt: "2026-06-01T00:00:00.000Z",
+ archivedAt: null,
+ session: null,
+ latestUserMessageAt: null,
+ hasPendingApprovals: false,
+ hasPendingUserInput: false,
+ hasActionableProposedPlan: false,
+ ...input,
+ };
+}
+
+describe("buildThreadNavigationGroups", () => {
+ const project = makeProject({ id: ProjectId.make("project-1"), title: "T3 Code" });
+ const threads = [
+ makeThread({
+ id: ThreadId.make("older"),
+ projectId: project.id,
+ title: "Fix reconnect flow",
+ updatedAt: "2026-06-02T00:00:00.000Z",
+ }),
+ makeThread({
+ id: ThreadId.make("newer"),
+ projectId: project.id,
+ title: "Build adaptive sidebar",
+ updatedAt: "2026-06-03T00:00:00.000Z",
+ }),
+ ];
+
+ it("sorts each group by recent activity", () => {
+ expect(
+ buildThreadNavigationGroups({ projects: [project], threads })[0]?.threads.map(
+ (thread) => thread.id,
+ ),
+ ).toEqual(["newer", "older"]);
+ });
+
+ it("matches thread titles without dropping their group", () => {
+ const groups = buildThreadNavigationGroups({
+ projects: [project],
+ threads,
+ searchQuery: "reconnect",
+ });
+
+ expect(groups).toHaveLength(1);
+ expect(groups[0]?.threads.map((thread) => thread.id)).toEqual(["older"]);
+ });
+
+ it("keeps every thread when the project title matches", () => {
+ expect(
+ buildThreadNavigationGroups({
+ projects: [project],
+ threads,
+ searchQuery: "t3 code",
+ })[0]?.threads.map((thread) => thread.id),
+ ).toEqual(["newer", "older"]);
+ });
+});
diff --git a/apps/mobile/src/features/threads/thread-navigation-groups.ts b/apps/mobile/src/features/threads/thread-navigation-groups.ts
new file mode 100644
index 0000000000..ae50031b6d
--- /dev/null
+++ b/apps/mobile/src/features/threads/thread-navigation-groups.ts
@@ -0,0 +1,63 @@
+import type {
+ EnvironmentProject,
+ EnvironmentThreadShell,
+} from "@t3tools/client-runtime/state/shell";
+import * as Arr from "effect/Array";
+import * as Order from "effect/Order";
+
+import { groupProjectsByRepository } from "../../lib/repositoryGroups";
+
+export interface ThreadNavigationGroup {
+ readonly key: string;
+ readonly title: string;
+ readonly threads: ReadonlyArray;
+}
+
+const threadActivityOrder = Order.mapInput(
+ Order.Struct({
+ activityAt: Order.flip(Order.Number),
+ title: Order.String,
+ }),
+ (thread: EnvironmentThreadShell) => ({
+ activityAt: new Date(thread.updatedAt ?? thread.createdAt).getTime(),
+ title: thread.title,
+ }),
+);
+
+export function buildThreadNavigationGroups(input: {
+ readonly projects: ReadonlyArray;
+ readonly threads: ReadonlyArray;
+ readonly searchQuery?: string;
+}): ReadonlyArray {
+ const query = input.searchQuery?.trim().toLocaleLowerCase() ?? "";
+
+ return groupProjectsByRepository(input).flatMap((group) => {
+ const threads = Arr.sort(
+ group.projects.flatMap((projectGroup) => projectGroup.threads),
+ threadActivityOrder,
+ );
+ const title = group.projects[0]?.project.title ?? group.title;
+ const groupMatches =
+ query.length === 0 ||
+ title.toLocaleLowerCase().includes(query) ||
+ group.title.toLocaleLowerCase().includes(query) ||
+ group.projects.some((projectGroup) =>
+ projectGroup.project.title.toLocaleLowerCase().includes(query),
+ );
+ const matchingThreads = groupMatches
+ ? threads
+ : threads.filter((thread) => thread.title.toLocaleLowerCase().includes(query));
+
+ if (query.length > 0 && matchingThreads.length === 0) {
+ return [];
+ }
+
+ return [
+ {
+ key: group.key,
+ title,
+ threads: matchingThreads,
+ },
+ ];
+ });
+}
diff --git a/apps/mobile/src/lib/layout.test.ts b/apps/mobile/src/lib/layout.test.ts
new file mode 100644
index 0000000000..e9646722e5
--- /dev/null
+++ b/apps/mobile/src/lib/layout.test.ts
@@ -0,0 +1,51 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import { deriveLayout, SPLIT_LAYOUT_MIN_HEIGHT, SPLIT_LAYOUT_MIN_WIDTH } from "./layout";
+
+describe("deriveLayout", () => {
+ it.each([
+ { name: "small iPhone portrait", width: 375, height: 667 },
+ { name: "large iPhone portrait", width: 430, height: 932 },
+ { name: "small iPhone landscape", width: 667, height: 375 },
+ { name: "large iPhone landscape", width: 932, height: 430 },
+ { name: "short wide window", width: 1_024, height: 599 },
+ { name: "narrow tall window", width: 719, height: 1_024 },
+ ])("keeps a $name in the compact shell", ({ width, height }) => {
+ expect(deriveLayout({ width, height })).toEqual({
+ variant: "compact",
+ usesSplitView: false,
+ listPaneWidth: null,
+ shellPadding: 0,
+ });
+ });
+
+ it.each([
+ { name: "small tablet portrait", width: 744, height: 1_133 },
+ { name: "tablet landscape", width: 1_024, height: 768 },
+ { name: "large resizable window", width: 1_366, height: 1_024 },
+ { name: "foldable-sized window", width: 800, height: 700 },
+ ])("uses the split shell for a $name", ({ width, height }) => {
+ expect(deriveLayout({ width, height })).toMatchObject({
+ variant: "split",
+ usesSplitView: true,
+ });
+ });
+
+ it("switches only after both space requirements are met", () => {
+ expect(
+ deriveLayout({ width: SPLIT_LAYOUT_MIN_WIDTH, height: SPLIT_LAYOUT_MIN_HEIGHT }).variant,
+ ).toBe("split");
+ expect(
+ deriveLayout({ width: SPLIT_LAYOUT_MIN_WIDTH - 1, height: SPLIT_LAYOUT_MIN_HEIGHT }).variant,
+ ).toBe("compact");
+ expect(
+ deriveLayout({ width: SPLIT_LAYOUT_MIN_WIDTH, height: SPLIT_LAYOUT_MIN_HEIGHT - 1 }).variant,
+ ).toBe("compact");
+ });
+
+ it("keeps the sidebar within usable native-column bounds", () => {
+ expect(deriveLayout({ width: 720, height: 1_000 }).listPaneWidth).toBe(280);
+ expect(deriveLayout({ width: 1_024, height: 768 }).listPaneWidth).toBe(328);
+ expect(deriveLayout({ width: 1_600, height: 1_000 }).listPaneWidth).toBe(380);
+ });
+});
diff --git a/apps/mobile/src/lib/layout.ts b/apps/mobile/src/lib/layout.ts
index 2ae4314fdb..35b9f571c1 100644
--- a/apps/mobile/src/lib/layout.ts
+++ b/apps/mobile/src/lib/layout.ts
@@ -2,6 +2,19 @@ function clamp(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max);
}
+/**
+ * Use available space, not device or orientation labels, to choose the shell.
+ *
+ * The height floor deliberately keeps every current iPhone in the compact shell
+ * when it rotates to landscape, while still allowing iPad and foldable-sized
+ * windows to adopt the persistent sidebar as they resize.
+ */
+export const SPLIT_LAYOUT_MIN_WIDTH = 720;
+export const SPLIT_LAYOUT_MIN_HEIGHT = 600;
+
+const SPLIT_SIDEBAR_MIN_WIDTH = 280;
+const SPLIT_SIDEBAR_MAX_WIDTH = 380;
+
export type LayoutVariant = "compact" | "split";
export interface Layout {
@@ -13,8 +26,7 @@ export interface Layout {
export function deriveLayout(input: { readonly width: number; readonly height: number }): Layout {
const { width, height } = input;
- const shortestEdge = Math.min(width, height);
- const wideEnoughForSplit = width >= 900 || (width >= 700 && shortestEdge >= 700);
+ const wideEnoughForSplit = width >= SPLIT_LAYOUT_MIN_WIDTH && height >= SPLIT_LAYOUT_MIN_HEIGHT;
if (!wideEnoughForSplit) {
return {
@@ -28,7 +40,11 @@ export function deriveLayout(input: { readonly width: number; readonly height: n
return {
variant: "split",
usesSplitView: true,
- listPaneWidth: clamp(Math.round(width * 0.34), 320, 420),
- shellPadding: width >= 1180 ? 20 : 14,
+ listPaneWidth: clamp(
+ Math.round(width * 0.32),
+ SPLIT_SIDEBAR_MIN_WIDTH,
+ SPLIT_SIDEBAR_MAX_WIDTH,
+ ),
+ shellPadding: 0,
};
}