Skip to content

Commit 0027769

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/linux-arm64-large-page-sea
2 parents 41f7dfc + 2202787 commit 0027769

32 files changed

Lines changed: 628 additions & 164 deletions

‎apps/mobile/src/components/ui/Sheet.android.tsx‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@ import { View } from "react-native";
33
import { FormSheet } from "react-native-screens";
44
import { useResolveClassNames } from "uniwind";
55
import { AndroidSheetHeader } from "./AndroidScreenHeader";
6+
import { ScreenContent } from "./ScreenContent";
67
import type { SheetProps } from "./Sheet.types";
78
export type { SheetProps } from "./Sheet.types";
89

910
export function Sheet(props: SheetProps) {
10-
const containerStyle = useResolveClassNames("bg-sheet");
11+
const containerStyle = useResolveClassNames("bg-header");
1112
const [isOpen, setIsOpen] = useState(true);
1213
return (
1314
<FormSheet
1415
isOpen={isOpen}
1516
detents={[0.5, 0.9]}
16-
prefersGrabberVisible
17+
prefersGrabberVisible={false}
1718
nativeContainerStyle={containerStyle}
1819
onDismiss={props.onClose}
1920
onNativeDismiss={props.onClose}
2021
>
2122
{/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
22-
<View collapsable={false} className="absolute inset-0 flex-col-reverse bg-sheet">
23-
<View className="flex-1">{props.children}</View>
24-
<AndroidSheetHeader title={props.title} onBack={() => setIsOpen(false)} />
23+
<View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
24+
<ScreenContent>{props.children}</ScreenContent>
25+
<AndroidSheetHeader title={props.title} onBack={() => setIsOpen(false)} hideBottomBorder />
26+
<View
27+
pointerEvents="none"
28+
className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
29+
/>
2530
</View>
2631
</FormSheet>
2732
);

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@ import {
9595
currentWorkspaceSelections,
9696
workspaceSelectionCheck,
9797
} from "../workspace/workspace-selection-store";
98-
import { workspaceTabNavigationState } from "../workspace/workspace-tab-navigation";
98+
import {
99+
workspaceTabColumns,
100+
workspaceTabNavigationState,
101+
} from "../workspace/workspace-tab-navigation";
99102
import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
100103
import { workspaceRoutesOf } from "./workspace-overlay-routes";
104+
import { SettingsWorkspaceLayout } from "../settings/SettingsWorkspaceLayout";
101105

102106
export { useAdaptiveWorkspaceLayout };
103107

@@ -478,7 +482,7 @@ function AdaptiveWorkspaceLayoutContent(
478482
tab,
479483
currentWorkspaceSelections(),
480484
{
481-
columns: Platform.OS === "ios" && (options?.columns ?? layout.usesSplitView),
485+
columns: workspaceTabColumns(Platform.OS, tab, options?.columns ?? layout.usesSplitView),
482486
check: workspaceSelectionCheck,
483487
overlays,
484488
},
@@ -523,24 +527,27 @@ function AdaptiveWorkspaceLayoutContent(
523527
: undefined;
524528
const first = (value: string | string[] | undefined) =>
525529
Array.isArray(value) ? value[0] : value;
526-
const thread = appAtomRegistry
527-
.get(environmentThreadShells.navigationThreadShellsAtom)
528-
.find(
529-
(candidate) =>
530-
candidate.environmentId === first(params?.environmentId) &&
531-
candidate.id === first(params?.threadId),
532-
);
533-
const draft = params?.draft;
534-
const draftEnvironmentId = first(draft?.environmentId);
535-
const draftProjectId = first(draft?.projectId);
536-
const currentProject = thread
537-
? { environmentId: thread.environmentId, id: thread.projectId }
538-
: projects.find(
539-
(project) =>
540-
project.environmentId === draftEnvironmentId && project.id === draftProjectId,
541-
);
530+
const environmentId = first(params?.environmentId);
531+
const threadId = first(params?.threadId);
532+
// The full index, not the sidebar list: subagent and archived threads are current threads too.
533+
const projectId =
534+
environmentId && threadId
535+
? appAtomRegistry
536+
.get(
537+
environmentThreadShells.environmentThreadIndexAtom(EnvironmentId.make(environmentId)),
538+
)
539+
.get(ThreadId.make(threadId))?.projectId
540+
: undefined;
541+
const preferences = appAtomRegistry.get(mobilePreferencesAtom);
542+
const saved = AsyncResult.isSuccess(preferences) ? preferences.value : undefined;
542543
handleSelectThreadRoute(
543-
newTaskDestination(layout.usesSplitView, projects, currentProject, uuidv4()),
544+
newTaskDestination({
545+
projects,
546+
requestId: uuidv4(),
547+
useLastProject: saved?.useLastProjectForNewThreads,
548+
currentProject: environmentId && projectId ? { environmentId, projectId } : undefined,
549+
lastProject: saved?.lastThreadProject,
550+
}),
544551
);
545552
};
546553

@@ -905,7 +912,9 @@ function AdaptiveWorkspaceLayoutContent(
905912
compactAndroidSettings ? { ...safeAreaInsets, bottom: 0 } : safeAreaInsets
906913
}
907914
>
908-
<View className="flex-1">{props.children}</View>
915+
<View className="flex-1">
916+
<SettingsWorkspaceLayout>{props.children}</SettingsWorkspaceLayout>
917+
</View>
909918
</SafeAreaInsetsContext>
910919
{compactAndroidSettings ? (
911920
<AndroidWorkspaceNavigation onNewThread={handleStartNewTask} />
Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
22
import { useAtomSet, useAtomValue } from "@effect/atom-react";
3-
import { useNavigation } from "@react-navigation/native";
43
import { AsyncResult } from "effect/reactivity";
54
import { Platform, View } from "react-native";
65
import { useSafeAreaInsets } from "react-native-safe-area-context";
76

8-
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
97
import { AppText as Text } from "../../components/ui/AppText";
10-
import { NativeStackScreenOptions } from "../../native/StackHeader";
118
import { DEFAULT_FOLLOW_UP_BEHAVIOR, type FollowUpBehavior } from "../../lib/followUpBehavior";
129
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
1310
import { SettingsChoiceRow } from "./components/SettingsChoiceRow";
1411
import { SettingsSection } from "./components/SettingsSection";
12+
import { SettingsScreen } from "./components/SettingsScreen";
1513

1614
const FOLLOW_UP_OPTIONS: ReadonlyArray<{
1715
readonly behavior: FollowUpBehavior;
@@ -31,7 +29,6 @@ const FOLLOW_UP_OPTIONS: ReadonlyArray<{
3129
];
3230

3331
export function SettingsFollowUpRouteScreen() {
34-
const navigation = useNavigation();
3532
const insets = useSafeAreaInsets();
3633
const preferencesResult = useAtomValue(mobilePreferencesAtom);
3734
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
@@ -40,39 +37,39 @@ export function SettingsFollowUpRouteScreen() {
4037
? (preferencesResult.value.followUpBehavior ?? DEFAULT_FOLLOW_UP_BEHAVIOR)
4138
: null;
4239

43-
return (
40+
const content = (
41+
<ScrollView
42+
contentInsetAdjustmentBehavior="automatic"
43+
showsVerticalScrollIndicator={false}
44+
className="flex-1"
45+
contentContainerClassName="gap-3 px-5 pt-4"
46+
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
47+
>
48+
<SettingsSection title="While the agent is running">
49+
{FOLLOW_UP_OPTIONS.map((option, index) => (
50+
<SettingsChoiceRow
51+
key={option.behavior}
52+
label={option.label}
53+
description={option.description}
54+
selected={selectedBehavior === option.behavior}
55+
separated={index > 0}
56+
disabled={!preferencesReady}
57+
onPress={() => savePreferences({ followUpBehavior: option.behavior })}
58+
/>
59+
))}
60+
</SettingsSection>
61+
<Text className="px-2 text-sm text-foreground-muted">
62+
Long-press the send button to use the other option for a single message. With a hardware
63+
keyboard, hold Command while sending.
64+
</Text>
65+
</ScrollView>
66+
);
67+
68+
return Platform.OS === "android" ? (
69+
<SettingsScreen title="Chat">{content}</SettingsScreen>
70+
) : (
4471
<View collapsable={false} className="flex-1 bg-sheet">
45-
{Platform.OS === "android" ? (
46-
<>
47-
<NativeStackScreenOptions options={{ headerShown: false }} />
48-
<AndroidScreenHeader title="Chat" onBack={() => navigation.goBack()} />
49-
</>
50-
) : null}
51-
<ScrollView
52-
contentInsetAdjustmentBehavior="automatic"
53-
showsVerticalScrollIndicator={false}
54-
className="flex-1"
55-
contentContainerClassName="gap-3 px-5 pt-4"
56-
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
57-
>
58-
<SettingsSection title="While the agent is running">
59-
{FOLLOW_UP_OPTIONS.map((option, index) => (
60-
<SettingsChoiceRow
61-
key={option.behavior}
62-
label={option.label}
63-
description={option.description}
64-
selected={selectedBehavior === option.behavior}
65-
separated={index > 0}
66-
disabled={!preferencesReady}
67-
onPress={() => savePreferences({ followUpBehavior: option.behavior })}
68-
/>
69-
))}
70-
</SettingsSection>
71-
<Text className="px-2 text-sm text-foreground-muted">
72-
Long-press the send button to use the other option for a single message. With a hardware
73-
keyboard, hold Command while sending.
74-
</Text>
75-
</ScrollView>
72+
{content}
7673
</View>
7774
);
7875
}

‎apps/mobile/src/features/settings/SettingsProjectGroupingRouteScreen.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
1313
import { SettingsChoiceRow } from "./components/SettingsChoiceRow";
1414
import { SettingsSection } from "./components/SettingsSection";
15-
import { WorkingSectionSettings } from "./ThreadSettingsSections";
15+
import { NewThreadSettingsSection, WorkingSectionSettings } from "./ThreadSettingsSections";
1616

1717
const GROUPING_OPTIONS: ReadonlyArray<{
1818
readonly mode: SidebarProjectGroupingMode;
@@ -68,6 +68,7 @@ export function SettingsProjectGroupingRouteScreen() {
6868
))}
6969
</SettingsSection>
7070
<WorkingSectionSettings />
71+
<NewThreadSettingsSection />
7172
</ScrollView>
7273
</SettingsScreen>
7374
);

‎apps/mobile/src/features/settings/SettingsRouteScreen.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { deriveProjectGroupLabel } from "@t3tools/client-runtime/state/project-g
2424
import { useSafeAreaInsets } from "react-native-safe-area-context";
2525

2626
import { hasCloudPublicConfig } from "../cloud/publicConfig";
27-
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
27+
import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
2828
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
2929
import { SettingsRow } from "./components/SettingsRow";
3030
import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSection";
@@ -39,8 +39,6 @@ import { filterSettingsSections } from "./settings-search";
3939
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
4040

4141
export function SettingsRouteScreen() {
42-
const surface = useWorkspaceSurface();
43-
const workspace = useWorkspaceTabs();
4442
const { layout } = useAdaptiveWorkspaceLayout();
4543
const inSidebar = use(NativePrimaryColumnContext) !== null && layout.usesSplitView;
4644
// The page open beside the list: the route right above the Settings tab's route. While
@@ -52,6 +50,17 @@ export function SettingsRouteScreen() {
5250
? rememberedSettingsPage(currentWorkspaceSelections())
5351
: (state.routes[list + 1]?.name ?? null);
5452
});
53+
return <SettingsListScreen sidebar={inSidebar} selected={selected} />;
54+
}
55+
56+
export function SettingsListScreen(props: {
57+
readonly sidebar: boolean;
58+
readonly selected: string | null;
59+
}) {
60+
const surface = useWorkspaceSurface();
61+
const workspace = useWorkspaceTabs();
62+
const inSidebar = props.sidebar;
63+
const selected = props.selected;
5564
const sidebar = useMemo(() => (inSidebar ? { selected } : null), [inSidebar, selected]);
5665
const content = hasCloudPublicConfig() ? (
5766
<ConfiguredSettingsRouteScreen />
@@ -66,6 +75,7 @@ export function SettingsRouteScreen() {
6675
{Platform.OS === "android" ? (
6776
<SettingsScreen
6877
title="Settings"
78+
workspaceRoot={inSidebar}
6979
trailing={<AndroidSettingsEnvironmentFilter />}
7080
search={
7181
workspace
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { NavigationRouteContext } from "@react-navigation/native";
2+
import { Activity, useState, type ReactNode } from "react";
3+
import { View } from "react-native";
4+
5+
import { AppText } from "../../components/ui/AppText";
6+
import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
7+
import { useAndroidWorkspaceRoot } from "../workspace/AndroidWorkspaceTabsProvider";
8+
import { SettingsListScreen } from "./SettingsRouteScreen";
9+
import { SettingsScreen } from "./components/SettingsScreen";
10+
11+
const SETTINGS_LIST_ROUTE = { key: "settings-sidebar", name: "Settings" };
12+
13+
export function SettingsWorkspaceLayout(props: { readonly children: ReactNode }) {
14+
const root = useAndroidWorkspaceRoot();
15+
const { layout } = useAdaptiveWorkspaceLayout();
16+
const split = root?.settingsOpen === true && layout.usesSplitView;
17+
const [visited, setVisited] = useState(split);
18+
if (split && !visited) setVisited(true);
19+
const emptyDetail = split && root.settingsPage === null;
20+
const route = root?.settingsRoute ?? SETTINGS_LIST_ROUTE;
21+
22+
return (
23+
<View className="flex-1 flex-row">
24+
{visited ? (
25+
<Activity mode={split ? "visible" : "hidden"}>
26+
<View style={{ width: layout.listPaneWidth ?? 0, marginRight: layout.listPaneGap ?? 0 }}>
27+
<NavigationRouteContext value={route}>
28+
<SettingsListScreen sidebar selected={root?.settingsPage ?? null} />
29+
</NavigationRouteContext>
30+
</View>
31+
</Activity>
32+
) : null}
33+
<View className="flex-1">
34+
<View
35+
className="flex-1"
36+
pointerEvents={emptyDetail ? "none" : "auto"}
37+
accessibilityElementsHidden={emptyDetail}
38+
importantForAccessibility={emptyDetail ? "no-hide-descendants" : "auto"}
39+
style={emptyDetail ? { opacity: 0 } : undefined}
40+
>
41+
{props.children}
42+
</View>
43+
{emptyDetail ? (
44+
<View className="absolute inset-0">
45+
<NavigationRouteContext value={route}>
46+
<SettingsScreen title="Settings" workspaceRoot>
47+
<View className="flex-1 items-center justify-center p-6">
48+
<AppText className="text-foreground-muted">Select a setting</AppText>
49+
</View>
50+
</SettingsScreen>
51+
</NavigationRouteContext>
52+
</View>
53+
) : null}
54+
</View>
55+
</View>
56+
);
57+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { ReactNode } from "react";
2+
3+
export function SettingsWorkspaceLayout(props: { readonly children: ReactNode }) {
4+
return props.children;
5+
}

‎apps/mobile/src/features/settings/ThreadSettingsSections.tsx‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ export function WorkingSectionSettings() {
195195
);
196196
}
197197

198+
export function NewThreadSettingsSection() {
199+
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
200+
const preferences = useAtomValue(mobilePreferencesAtom);
201+
const useLastProject =
202+
AsyncResult.isSuccess(preferences) && preferences.value.useLastProjectForNewThreads !== false;
203+
204+
return (
205+
<SettingsSection title="New threads">
206+
<SettingsSwitchRow
207+
icon="square.and.pencil"
208+
label="Use last project"
209+
subtitle="Start new threads in the last project you used on this device."
210+
value={useLastProject}
211+
onValueChange={(value) => savePreferences({ useLastProjectForNewThreads: value })}
212+
/>
213+
</SettingsSection>
214+
);
215+
}
216+
198217
function LegacySettingsSection() {
199218
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
200219
const preferences = useAtomValue(mobilePreferencesAtom);

‎apps/mobile/src/features/settings/components/SettingsScreen.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
99
import { useWorkspaceSurface } from "../../workspace/useWorkspaceSurface";
1010
import { useDeviceType } from "../../../native/native-layout-metrics";
1111
import { useCompactWorkspaceTabs } from "../../workspace/useSystemWorkspaceTabBar";
12+
import { useAdaptiveWorkspaceLayout } from "../../layout/adaptive-workspace-context";
1213
import {
1314
ScreenScrollViewBottomInset,
1415
ScreenScrollViewSurface,
@@ -29,6 +30,7 @@ export function SettingsScreen(
2930
const surface = useWorkspaceSurface();
3031
const deviceType = useDeviceType();
3132
const compactTabs = useCompactWorkspaceTabs();
33+
const { layout } = useAdaptiveWorkspaceLayout();
3234
const cover = deviceType === "duo-folded";
3335
// Android opens Settings as a workspace tab; its root page has nothing to go back to.
3436
const workspaceRoot =
@@ -55,7 +57,11 @@ export function SettingsScreen(
5557
{props.formSheet ? (
5658
props.children
5759
) : (
58-
<SettingsScreenContent>{props.children}</SettingsScreenContent>
60+
<SettingsScreenContent
61+
insetHorizontal={Platform.OS === "android" && layout.usesSplitView}
62+
>
63+
{props.children}
64+
</SettingsScreenContent>
5965
)}
6066
</ScreenScrollViewSurface>
6167
</ScreenScrollViewBottomInset>

0 commit comments

Comments
 (0)