The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 02:00 UTC
fix(mobile): feature screens use the components/ui menu, dialog and search primitives (#33193)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 8, 2026 at 20:52 UTC
637507056c9e46e8bca21e557e8c61044a314563
18 files changed
+561
-1051
apps/mobile/src/components/ui/AppBar.android.tsx
+4
-4
@@ -13,12 +13,12 @@ import { ScreenHeaderButton } from "./ScreenHeaderButton.android";
13
import { Menu } from "./Menu";
14
import { Button } from "./Button";
15
import { SearchField } from "./SearchField";
16
-import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
16
+import { findAppBarMenuItem, menuActionsFromAppBarItems } from "./menuActionItems";
17
import type { AppBarMenuItem, AppBarProps, AppBarSearch } from "./AppBar.types";
18
import { useHasWorkspaceAppBar, WorkspaceAppBar } from "./WorkspaceAppBar.android";
19
20
function selectMenuItem(items: ReadonlyArray<AppBarMenuItem>, id: string) {
21
- const action = findHeaderMenuAction(items, id);
21
+ const action = findAppBarMenuItem(items, id);
22
if (action && !action.disabled) action.onPress();
23
}
24
@@ -134,7 +134,7 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
134
? {
135
accessibilityLabel: menu.title,
136
customized: icon?.endsWith(".fill") === true,
137
- actions: androidHeaderMenuActions(menu.items),
137
+ actions: menuActionsFromAppBarItems(menu.items),
138
onSelect: (id) => selectMenuItem(menu.items, id),
139
}
140
: undefined
@@ -146,7 +146,7 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
146
const menuView = props.menus?.map((menu) => (
147
<Menu
148
key={menu.title}
149
- actions={androidHeaderMenuActions(menu.items)}
149
+ actions={menuActionsFromAppBarItems(menu.items)}
150
isAnchoredToRight
151
title={menu.status ?? menu.title}
152
onPressAction={({ nativeEvent }) => selectMenuItem(menu.items, nativeEvent.event)}
apps/mobile/src/components/ui/headerMenu.android.ts
-48
@@ -1,51 +1,3 @@
1
-import type { MenuAction } from "@react-native-menu/menu";
2
-import type { AppBarMenuItem } from "./AppBar.types";
3
-
4
-export function androidHeaderMenuActions(items: ReadonlyArray<AppBarMenuItem>): MenuAction[] {
5
- return items.flatMap((item): MenuAction[] =>
6
- "items" in item
7
- ? item.inline && !item.title
8
- ? androidHeaderMenuActions(item.items)
9
- : [
10
- {
11
- id: item.id,
12
- title: item.title ?? "",
13
- image: item.icon,
14
- subactions: androidHeaderMenuActions(item.items),
15
- },
16
- ]
17
- : [
18
- {
19
- id: item.id,
20
- title: item.title,
21
- subtitle: item.subtitle,
22
- image: item.icon,
23
- imageColor: item.iconColor,
24
- state: item.selected ? "on" : undefined,
25
- attributes:
26
- item.disabled || item.destructive
27
- ? { disabled: item.disabled, destructive: item.destructive }
28
- : undefined,
29
- },
30
- ],
31
- );
32
-}
33
-
34
-export function findHeaderMenuAction(
35
- items: ReadonlyArray<AppBarMenuItem>,
36
- id: string,
37
-): Extract<AppBarMenuItem, { readonly onPress: () => void }> | undefined {
38
- for (const item of items) {
39
- if ("items" in item) {
40
- const action = findHeaderMenuAction(item.items, id);
41
- if (action) return action;
42
- } else if (item.id === id) {
43
- return item;
44
- }
45
- }
46
- return undefined;
47
-}
48
-
1
export function splitAndroidHeaderActions<Action extends { readonly overflowOnly?: boolean }>(
2
actions: ReadonlyArray<Action>,
3
wide: boolean,
apps/mobile/src/components/ui/menuActionItems.test.ts
+11
-5
@@ -1,11 +1,14 @@
1
import type { MenuAction } from "@react-native-menu/menu";
2
import { describe, expect, it, vi } from "vite-plus/test";
3
4
-import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
5
-import { appBarMenuItemsFromActions } from "./menuActionItems";
4
+import {
5
+ appBarMenuItemsFromActions,
6
+ findAppBarMenuItem,
7
+ menuActionsFromAppBarItems,
8
+} from "./menuActionItems";
9
10
describe("appBarMenuItemsFromActions", () => {
8
- it("round-trips a filter menu through AppBar items back to Android actions", () => {
11
+ it("round-trips a filter menu through AppBar items back to menu actions", () => {
12
const actions: MenuAction[] = [
13
{
14
id: "labels",
@@ -26,7 +29,7 @@ describe("appBarMenuItemsFromActions", () => {
29
30
const items = appBarMenuItemsFromActions(actions, onSelect);
31
29
- expect(androidHeaderMenuActions(items)).toEqual([
32
+ expect(menuActionsFromAppBarItems(items)).toEqual([
33
{
34
id: "labels",
35
title: "Labels",
@@ -53,7 +56,10 @@ describe("appBarMenuItemsFromActions", () => {
56
],
57
},
58
]);
56
- findHeaderMenuAction(items, "label:docs")?.onPress();
59
+ findAppBarMenuItem(items, "label:docs")?.onPress();
60
expect(onSelect).toHaveBeenCalledWith("label:docs");
61
+ expect(
62
+ menuActionsFromAppBarItems([{ id: "devices", title: "Devices", inline: true, items: [] }]),
63
+ ).toMatchObject([{ id: "devices", title: "Devices", displayInline: true }]);
64
});
65
});
apps/mobile/src/components/ui/menuActionItems.ts
+47
@@ -27,3 +27,50 @@ export function appBarMenuItemsFromActions(
27
};
28
});
29
}
30
+
31
+/** Adapts `AppBar` menu items to a `Menu`'s actions; `findAppBarMenuItem` resolves a selection. */
32
+export function menuActionsFromAppBarItems(items: ReadonlyArray<AppBarMenuItem>): MenuAction[] {
33
+ return items.flatMap((item): MenuAction[] =>
34
+ "items" in item
35
+ ? item.inline && !item.title
36
+ ? menuActionsFromAppBarItems(item.items)
37
+ : [
38
+ {
39
+ id: item.id,
40
+ title: item.title ?? "",
41
+ image: item.icon,
42
+ displayInline: item.inline,
43
+ subactions: menuActionsFromAppBarItems(item.items),
44
+ },
45
+ ]
46
+ : [
47
+ {
48
+ id: item.id,
49
+ title: item.title,
50
+ subtitle: item.subtitle,
51
+ image: item.icon,
52
+ imageColor: item.iconColor,
53
+ state: item.selected ? "on" : undefined,
54
+ attributes:
55
+ item.disabled || item.destructive
56
+ ? { disabled: item.disabled, destructive: item.destructive }
57
+ : undefined,
58
+ },
59
+ ],
60
+ );
61
+}
62
+
63
+export function findAppBarMenuItem(
64
+ items: ReadonlyArray<AppBarMenuItem>,
65
+ id: string,
66
+): Extract<AppBarMenuItem, { readonly onPress: () => void }> | undefined {
67
+ for (const item of items) {
68
+ if ("items" in item) {
69
+ const action = findAppBarMenuItem(item.items, id);
70
+ if (action) return action;
71
+ } else if (item.id === id) {
72
+ return item;
73
+ }
74
+ }
75
+ return undefined;
76
+}
apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
+6
-13
@@ -16,16 +16,15 @@ import { Pressable, StatusBar, View } from "react-native";
16
import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
17
import { useSafeAreaInsets } from "react-native-safe-area-context";
18
19
-import { SymbolView } from "../../components/ui/AppSymbol";
19
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
20
import { AppText } from "../../components/ui/AppText";
21
import { ControlPill } from "../../components/ui/ControlPill";
22
import { Menu } from "../../components/ui/Menu";
23
import { GlassSurface } from "../../components/ui/GlassSurface";
24
import {
26
- androidHeaderMenuActions,
27
- findHeaderMenuAction,
28
-} from "../../components/ui/headerMenu.android";
25
+ findAppBarMenuItem,
26
+ menuActionsFromAppBarItems,
27
+} from "../../components/ui/menuActionItems";
28
import { AppBar } from "../../components/ui/AppBar";
29
import { useBarOverlap } from "../../components/ui/useBarInset";
30
import type { AppBarMenuItem } from "../../components/ui/AppBar.types";
@@ -376,21 +375,15 @@ export function DevicePreviewScreen({
375
function DeviceOptionsMenu({ items }: { readonly items: ReadonlyArray<AppBarMenuItem> }) {
376
return (
377
<Menu
379
- actions={androidHeaderMenuActions(items)}
378
+ actions={menuActionsFromAppBarItems(items)}
379
isAnchoredToRight
380
title="Device options"
381
onPressAction={({ nativeEvent }) => {
383
- const action = findHeaderMenuAction(items, nativeEvent.event);
382
+ const action = findAppBarMenuItem(items, nativeEvent.event);
383
if (action && !action.disabled) action.onPress();
384
}}
385
>
387
- <Pressable
388
- accessibilityLabel="Device options"
389
- accessibilityRole="button"
390
- className="size-11 items-center justify-center rounded-full bg-subtle"
391
- >
392
- <SymbolView name="ellipsis" size={18} tintColorClassName="accent-icon" />
393
- </Pressable>
386
+ <ControlPill icon="ellipsis" accessibilityLabel="Device options" />
387
</Menu>
388
);
389
}
apps/mobile/src/features/layout/workspace/WorkspaceDock.tsx
deleted
-71
@@ -1,71 +0,0 @@
1
-import { Keyboard, Pressable, View } from "react-native";
2
-
3
-import { SymbolView } from "../../../components/ui/AppSymbol";
4
-import { GlassSurface } from "../../../components/ui/GlassSurface";
5
-import { useWorkspaceTabs } from "./WorkspaceTabsContext";
6
-import { WORKSPACE_DOCK } from "./workspace-tabs-state";
7
-import { PullRequestGlyph } from "../../pull-requests/pullRequestGlyphs";
8
-
9
-export function WorkspaceDock(props: { readonly onNewTask: () => void }) {
10
- const workspace = useWorkspaceTabs()!;
11
- return (
12
- <View
13
- className="w-full flex-row items-center justify-between"
14
- style={{ gap: WORKSPACE_DOCK.gap }}
15
- >
16
- <GlassSurface
17
- style={{
18
- width: WORKSPACE_DOCK.tabsWidth,
19
- height: WORKSPACE_DOCK.height,
20
- borderRadius: WORKSPACE_DOCK.height / 2,
21
- }}
22
- >
23
- <View className="flex-1 flex-row p-1" accessibilityRole="tablist">
24
- {(["threads", "pullRequests"] as const).map((tab) => {
25
- const selected = workspace.state.selectedTab === tab;
26
- return (
27
- <Pressable
28
- key={tab}
29
- accessibilityRole="tab"
30
- accessibilityLabel={tab === "threads" ? "Threads" : "Pull requests"}
31
- accessibilityState={{ selected }}
32
- onPress={() => {
33
- if (selected) return;
34
- Keyboard.dismiss();
35
- workspace.dispatch({ type: "select", tab });
36
- }}
37
- className={
38
- selected
39
- ? "flex-1 items-center justify-center rounded-full bg-subtle-strong"
40
- : "flex-1 items-center justify-center rounded-full"
41
- }
42
- >
43
- <SymbolView
44
- name={tab === "threads" ? "text.bubble" : PullRequestGlyph.pullRequest}
45
- size={23}
46
- tintColorClassName={selected ? "accent-focus" : "accent-icon"}
47
- />
48
- </Pressable>
49
- );
50
- })}
51
- </View>
52
- </GlassSurface>
53
- <GlassSurface
54
- style={{
55
- width: WORKSPACE_DOCK.height,
56
- height: WORKSPACE_DOCK.height,
57
- borderRadius: WORKSPACE_DOCK.height / 2,
58
- }}
59
- >
60
- <Pressable
61
- accessibilityRole="button"
62
- accessibilityLabel="New chat"
63
- onPress={props.onNewTask}
64
- className="flex-1 items-center justify-center"
65
- >
66
- <SymbolView name="square.and.pencil" size={23} tintColorClassName="accent-icon" />
67
- </Pressable>
68
- </GlassSurface>
69
- </View>
70
- );
71
-}
apps/mobile/src/features/layout/workspace/WorkspaceSearchField.tsx
deleted
-60
@@ -1,60 +0,0 @@
1
-import type { Ref } from "react";
2
-import { Keyboard, Pressable, TextInput, View, type TextInputInstance } from "react-native";
3
-import { useResolveClassNames } from "uniwind";
4
-
5
-import { SymbolView } from "../../../components/ui/AppSymbol";
6
-import { GlassSurface } from "../../../components/ui/GlassSurface";
7
-import { WORKSPACE_TOOLBAR, type WorkspaceTab } from "./workspace-tabs-state";
8
-
9
-export function WorkspaceSearchField({
10
- ref,
11
- ...props
12
-}: {
13
- readonly ref?: Ref<TextInputInstance>;
14
- readonly tab: WorkspaceTab;
15
- readonly query: string;
16
- readonly onChangeQuery: (query: string) => void;
17
- readonly onFocus: () => void;
18
- readonly onBlur?: () => void;
19
- readonly onClear: () => void;
20
-}) {
21
- const inputStyle = useResolveClassNames("text-foreground font-sans text-base");
22
- const placeholderStyle = useResolveClassNames("text-foreground-muted");
23
- const label = props.tab === "pullRequests" ? "Search pull requests" : "Search threads";
24
- return (
25
- <GlassSurface
26
- className="min-w-0 flex-1"
27
- style={{ height: WORKSPACE_TOOLBAR.height, borderRadius: WORKSPACE_TOOLBAR.height / 2 }}
28
- >
29
- <View className="flex-1 flex-row items-center pl-4">
30
- <SymbolView name="magnifyingglass" size={20} tintColorClassName="accent-icon-muted" />
31
- <TextInput
32
- ref={ref}
33
- accessibilityLabel={label}
34
- placeholder={label}
35
- placeholderTextColor={placeholderStyle.color}
36
- value={props.query}
37
- onChangeText={props.onChangeQuery}
38
- onFocus={props.onFocus}
39
- onBlur={props.onBlur}
40
- onSubmitEditing={() => Keyboard.dismiss()}
41
- autoCapitalize="none"
42
- autoCorrect={false}
43
- returnKeyType="search"
44
- maxLength={props.tab === "pullRequests" ? 200 : undefined}
45
- style={[inputStyle, { flex: 1, minWidth: 0, paddingHorizontal: 8, paddingVertical: 0 }]}
46
- />
47
- {props.query ? (
48
- <Pressable
49
- accessibilityRole="button"
50
- accessibilityLabel="Clear search"
51
- onPress={props.onClear}
52
- className="h-11 w-11 items-center justify-center"
53
- >
54
- <SymbolView name="xmark.circle.fill" size={18} tintColorClassName="accent-icon-muted" />
55
- </Pressable>
56
- ) : null}
57
- </View>
58
- </GlassSurface>
59
- );
60
-}
apps/mobile/src/features/layout/workspace/WorkspaceToolbar.ios.tsx
deleted
-222
@@ -1,222 +0,0 @@
1
-import { useActiveNewTask } from "../../../state/active-new-task";
2
-import { Toolbar } from "../../../components/ui/Toolbar";
3
-import { useFocusEffect, useIsFocused } from "@react-navigation/native";
4
-import { use, useCallback, useEffect, useRef } from "react";
5
-import { isDuoDevice } from "../../../lib/device-type";
6
-import { useDeviceType } from "../../../native/native-layout-metrics";
7
-import { createNativeHeaderMenu } from "../../../components/ui/nativeHeaderMenu.ios";
8
-import { useSettingsEnvironmentMenu } from "../../settings/components/SettingsEnvironmentFilterHeader";
9
-import type { SearchBarCommands } from "react-native-screens";
10
-
11
-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../../native/native-glass";
12
-import { NativeStackScreenOptions } from "../../../native/StackHeader";
13
-import {
14
- NativePrimaryColumnContext,
15
- NativeWorkspaceTabActivityContext,
16
-} from "../../../native/v5-workspace-context";
17
-import { useHardwareKeyboardCommand } from "../../keyboard/hardwareKeyboardCommands";
18
-import { useAdaptiveWorkspaceLayout } from "../AdaptiveWorkspaceLayout";
19
-import { useWorkspaceTabs } from "./WorkspaceTabsContext";
20
-import { shouldRestoreNativeSearch } from "./workspace-tabs-state";
21
-import { useFloatingWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
22
-import { WorkspaceTabToolbarButtons } from "./WorkspaceSectionToolbar";
23
-
24
-const SEARCH_LABELS = {
25
- threads: "Search threads",
26
- pullRequests: "Search pull requests",
27
- settings: "Search settings",
28
-} as const;
29
-
30
-export function WorkspaceToolbar(props: {
31
- readonly onNewTask: () => void;
32
- readonly sidebar?: boolean;
33
-}) {
34
- const workspace = useWorkspaceTabs()!;
35
- const activeNewTask = useActiveNewTask();
36
- const deviceType = useDeviceType();
37
- const sidebarTabs = useSidebarWorkspaceTabs();
38
- const floatingTabs = useFloatingWorkspaceTabs();
39
- const duoSearch = NATIVE_LIQUID_GLASS_SUPPORTED && isDuoDevice(deviceType);
40
- const bottomSearch = duoSearch && sidebarTabs !== "picker";
41
- // On the Duo, compose belongs to the threads tab, in the detail column's bar when unfolded.
42
- const nativeToolbarCompose =
43
- deviceType === "duo-folded" &&
44
- !workspace.settingsOpen &&
45
- workspace.state.selectedTab === "threads" &&
46
- activeNewTask === null;
47
- const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
48
- const focused = useIsFocused();
49
- const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
50
- const searchRef = useRef<SearchBarCommands>(null);
51
- const settingsMenu = useSettingsEnvironmentMenu();
52
- // The Settings list takes the selected tab's place, so search follows it.
53
- const selectedTab = workspace.settingsOpen ? "settings" : workspace.state.selectedTab;
54
- const tab = workspace.state.tabs[selectedTab];
55
- const searchLabel = SEARCH_LABELS[selectedTab === "usage" ? "threads" : selectedTab];
56
- const { isTabActive: isListTabActive } = workspace;
57
- // A retained tab slot stays mounted while another is shown.
58
- const isTabActive = (tab: typeof selectedTab) =>
59
- tab === "settings" ? tabActive : isListTabActive(tab);
60
- const foldedSearch = deviceType === "duo-folded";
61
- const primaryColumn = use(NativePrimaryColumnContext);
62
- // UIKit hosts integrated search outside the sidebar's sliding content.
63
- // Mount it after native appearance so it cannot precede the pane's reveal.
64
- const searchVisible = foldedSearch
65
- ? tab.searchMode !== "resting"
66
- : deviceType !== "duo-unfolded" || primaryColumn?.presented !== false;
67
- const enterSearch = useCallback(() => {
68
- workspace.dispatch({
69
- type: "scroll",
70
- tab: selectedTab,
71
- offset: workspace.getScrollOffset(selectedTab),
72
- });
73
- workspace.dispatch({ type: "search", tab: selectedTab });
74
- if (props.sidebar && !panes.primarySidebarVisible) togglePrimarySidebar();
75
- }, [workspace, selectedTab, props.sidebar, panes.primarySidebarVisible, togglePrimarySidebar]);
76
- const focusSearch = () => {
77
- if (!isTabActive(selectedTab)) return false;
78
- if (duoSearch || !NATIVE_LIQUID_GLASS_SUPPORTED) enterSearch();
79
- searchRef.current?.focus();
80
- return true;
81
- };
82
- const cancelSearch = () => {
83
- workspace.recordScrollOffset(selectedTab, tab.searchEntryOffset);
84
- workspace.dispatch({ type: "cancel", tab: selectedTab });
85
- };
86
- const searchFocused = () =>
87
- tab.searchMode === "resting"
88
- ? enterSearch()
89
- : workspace.dispatch({ type: "search", tab: selectedTab });
90
- useHardwareKeyboardCommand("focusSearch", focusSearch);
91
- // The sidebar remains visible while its detail owns navigation focus.
92
- const searchHostVisible = focused || primaryColumn?.presented === true;
93
- const restoreSearch = () => {
94
- if (
95
- searchHostVisible &&
96
- searchVisible &&
97
- isTabActive(selectedTab) &&
98
- shouldRestoreNativeSearch(tab, duoSearch)
99
- ) {
100
- searchRef.current?.setText(tab.query);
101
- // Integrated search collapses to its button when its screen reappears,
102
- // which would hide the query that still filters the list.
103
- if (NATIVE_LIQUID_GLASS_SUPPORTED) {
104
- searchRef.current?.setActive(true);
105
- if (tab.searchMode === "active") searchRef.current?.focus();
106
- }
107
- }
108
- };
109
- useFocusEffect(
110
- useCallback(() => {
111
- const frame = requestAnimationFrame(restoreSearch);
112
- return () => cancelAnimationFrame(frame);
113
- }, [restoreSearch]),
114
- );
115
- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- schedules a frame to restore the native search bar's text and focus when its tab becomes active
116
- useEffect(() => {
117
- if (!tabActive) return;
118
- const frame = requestAnimationFrame(restoreSearch);
119
- return () => cancelAnimationFrame(frame);
120
- // oxlint-disable-next-line react/exhaustive-effect-dependencies -- Moving the search bar to the bottom toolbar restores its focus and query.
121
- }, [restoreSearch, tabActive, bottomSearch]);
122
- const composeButton = nativeToolbarCompose ? (
123
- <Toolbar.Button
124
- identifier="workspace-compose"
125
- accessibilityLabel="New chat"
126
- icon="square.and.pencil"
127
- onPress={props.onNewTask}
128
- separateBackground
129
- />
130
- ) : null;
131
- const searchButton = foldedSearch ? (
132
- <Toolbar.Button
133
- identifier="workspace-search"
134
- accessibilityLabel={searchVisible ? "Close search" : searchLabel}
135
- icon={searchVisible ? "xmark" : "magnifyingglass"}
136
- onPress={searchVisible ? () => searchRef.current?.cancelSearch() : focusSearch}
137
- separateBackground
138
- />
139
- ) : null;
140
- return (
141
- <>
142
- <NativeStackScreenOptions
143
- optionsVersion={[selectedTab, tab.searchMode]}
144
- listeners={{ transitionEnd: restoreSearch }}
145
- options={{
146
- // Without Liquid Glass, Settings keeps its search field out instead of a search button,
147
- // which would take the header's trailing items from the scope filter.
148
- headerSearchBarOptions:
149
- (NATIVE_LIQUID_GLASS_SUPPORTED ||
150
- tab.searchMode !== "resting" ||
151
- workspace.settingsOpen) &&
152
- searchVisible
153
- ? {
154
- ref: searchRef,
155
- autoFocus: tab.searchMode === "active",
156
- autoCapitalize: "none",
157
- hideNavigationBar: false,
158
- hideWhenScrolling: false,
159
- obscureBackground: false,
160
- placement: NATIVE_LIQUID_GLASS_SUPPORTED
161
- ? bottomSearch
162
- ? "integrated"
163
- : "integratedButton"
164
- : "stacked",
165
- allowToolbarIntegration:
166
- NATIVE_LIQUID_GLASS_SUPPORTED &&
167
- deviceType !== "phone" &&
168
- sidebarTabs !== "picker",
169
- placeholder: searchLabel,
170
- cancelButtonHidden: foldedSearch,
171
- onFocus: searchFocused,
172
- onBlur: () => workspace.dispatch({ type: "expand", tab: selectedTab }),
173
- onSearchButtonPress: () => searchRef.current?.blur(),
174
- onChangeText: ({ nativeEvent }) =>
175
- workspace.dispatch({
176
- type: "query",
177
- query: nativeEvent.text,
178
- tab: selectedTab,
179
- }),
180
- onCancelButtonPress: cancelSearch,
181
- }
182
- : undefined,
183
- }}
184
- />
185
- {/* UIKit lays trailing items out from the edge inward. */}
186
- {workspace.settingsOpen ? (
187
- <Toolbar placement="right">
188
- {searchButton}
189
- {createNativeHeaderMenu(settingsMenu)}
190
- </Toolbar>
191
- ) : (
192
- <Toolbar placement="right">
193
- {searchButton}
194
- {nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
195
- {composeButton}
196
- {selectedTab !== "threads" ||
197
- isDuoDevice(deviceType) ||
198
- (deviceType === "pad" && layout.usesSplitView) ||
199
- sidebarTabs === "picker" ||
200
- floatingTabs ? null : (
201
- <Toolbar.Button
202
- accessibilityLabel="New chat"
203
- icon="square.and.pencil"
204
- onPress={props.onNewTask}
205
- />
206
- )}
207
- {NATIVE_LIQUID_GLASS_SUPPORTED ? null : (
208
- <Toolbar.Button
209
- accessibilityLabel={searchLabel}
210
- icon="magnifyingglass"
211
- onPress={focusSearch}
212
- />
213
- )}
214
- </Toolbar>
215
- )}
216
- <Toolbar placement="bottom">
217
- {sidebarTabs === "toolbar" ? <WorkspaceTabToolbarButtons /> : null}
218
- {bottomSearch && searchVisible ? <Toolbar.SearchBarSlot /> : null}
219
- </Toolbar>
220
- </>
221
- );
222
-}
apps/mobile/src/features/layout/workspace/WorkspaceToolbar.tsx
+204
-122
@@ -1,140 +1,222 @@
1
-import { useFocusEffect } from "@react-navigation/native";
2
-import { useCallback, useEffect, useRef, useState } from "react";
3
-import {
4
- Keyboard,
5
- Pressable,
6
- View,
7
- useWindowDimensions,
8
- type TextInputInstance,
9
-} from "react-native";
10
-import { KeyboardStickyView, useKeyboardState } from "react-native-keyboard-controller";
11
-import { useSafeAreaInsets } from "react-native-safe-area-context";
1
+import { useActiveNewTask } from "../../../state/active-new-task";
2
+import { Toolbar } from "../../../components/ui/Toolbar";
3
+import { useFocusEffect, useIsFocused } from "@react-navigation/native";
4
+import { use, useCallback, useEffect, useRef } from "react";
5
+import { isDuoDevice } from "../../../lib/device-type";
6
+import { useDeviceType } from "../../../native/native-layout-metrics";
7
+import { createNativeHeaderMenu } from "../../../components/ui/nativeHeaderMenu.ios";
8
+import { useSettingsEnvironmentMenu } from "../../settings/components/SettingsEnvironmentFilterHeader";
9
+import type { SearchBarCommands } from "react-native-screens";
10
13
-import { SymbolView, type AppSymbolName } from "../../../components/ui/AppSymbol";
14
-import { GlassSurface } from "../../../components/ui/GlassSurface";
15
-import { useHardwareBack } from "../../../lib/backHandler";
11
+import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../../native/native-glass";
12
+import { NativeStackScreenOptions } from "../../../native/StackHeader";
13
+import {
14
+ NativePrimaryColumnContext,
15
+ NativeWorkspaceTabActivityContext,
16
+} from "../../../native/v5-workspace-context";
17
import { useHardwareKeyboardCommand } from "../../keyboard/hardwareKeyboardCommands";
17
-import { WorkspaceDock } from "./WorkspaceDock";
18
-import { WorkspaceSearchField } from "./WorkspaceSearchField";
18
+import { useAdaptiveWorkspaceLayout } from "../AdaptiveWorkspaceLayout";
19
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
20
-import { WORKSPACE_TOOLBAR, type WorkspaceTab } from "./workspace-tabs-state";
21
-import { PullRequestGlyph } from "../../pull-requests/pullRequestGlyphs";
20
+import { shouldRestoreNativeSearch } from "./workspace-tabs-state";
21
+import { useFloatingWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
22
+import { WorkspaceTabToolbarButtons } from "./WorkspaceSectionToolbar";
23
23
-const TABS: ReadonlyArray<{ id: WorkspaceTab; label: string; icon: AppSymbolName }> = [
24
- { id: "threads", label: "Threads", icon: "text.bubble" },
25
- { id: "pullRequests", label: "PRs", icon: PullRequestGlyph.pullRequest },
26
-];
27
-
28
-function ToolbarButton(props: {
29
- label: string;
30
- icon: AppSymbolName;
31
- onPress: () => void;
32
- size?: number;
33
-}) {
34
- const size = props.size ?? WORKSPACE_TOOLBAR.height;
35
- return (
36
- <GlassSurface style={{ width: size, height: size, borderRadius: size / 2 }}>
37
- <Pressable
38
- accessibilityRole="button"
39
- accessibilityLabel={props.label}
40
- onPress={props.onPress}
41
- className="flex-1 items-center justify-center"
42
- >
43
- <SymbolView name={props.icon} size={22} tintColorClassName="accent-icon" />
44
- </Pressable>
45
- </GlassSurface>
46
- );
47
-}
24
+const SEARCH_LABELS = {
25
+ threads: "Search threads",
26
+ pullRequests: "Search pull requests",
27
+ settings: "Search settings",
28
+} as const;
29
30
export function WorkspaceToolbar(props: {
50
- readonly sidebar?: boolean;
31
readonly onNewTask: () => void;
32
+ readonly sidebar?: boolean;
33
}) {
53
- const workspace = useWorkspaceTabs();
54
- const input = useRef<TextInputInstance>(null);
55
- const [focusRequest, setFocusRequest] = useState(0);
56
- const insets = useSafeAreaInsets();
57
- const { width } = useWindowDimensions();
58
- const edge = width < 360 ? 12 : WORKSPACE_TOOLBAR.edge;
59
- const gap = width < 360 ? 6 : WORKSPACE_TOOLBAR.gap;
60
- const keyboardVisible = useKeyboardState((state) => state.isVisible);
34
+ const workspace = useWorkspaceTabs()!;
35
+ const activeNewTask = useActiveNewTask();
36
+ const deviceType = useDeviceType();
37
+ const sidebarTabs = useSidebarWorkspaceTabs();
38
+ const floatingTabs = useFloatingWorkspaceTabs();
39
+ const duoSearch = NATIVE_LIQUID_GLASS_SUPPORTED && isDuoDevice(deviceType);
40
+ const bottomSearch = duoSearch && sidebarTabs !== "picker";
41
+ // On the Duo, compose belongs to the threads tab, in the detail column's bar when unfolded.
42
+ const nativeToolbarCompose =
43
+ deviceType === "duo-folded" &&
44
+ !workspace.settingsOpen &&
45
+ workspace.state.selectedTab === "threads" &&
46
+ activeNewTask === null;
47
+ const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
48
+ const focused = useIsFocused();
49
+ const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
50
+ const searchRef = useRef<SearchBarCommands>(null);
51
+ const settingsMenu = useSettingsEnvironmentMenu();
52
+ // The Settings list takes the selected tab's place, so search follows it.
53
+ const selectedTab = workspace.settingsOpen ? "settings" : workspace.state.selectedTab;
54
+ const tab = workspace.state.tabs[selectedTab];
55
+ const searchLabel = SEARCH_LABELS[selectedTab === "usage" ? "threads" : selectedTab];
56
+ const { isTabActive: isListTabActive } = workspace;
57
+ // A retained tab slot stays mounted while another is shown.
58
+ const isTabActive = (tab: typeof selectedTab) =>
59
+ tab === "settings" ? tabActive : isListTabActive(tab);
60
+ const foldedSearch = deviceType === "duo-folded";
61
+ const primaryColumn = use(NativePrimaryColumnContext);
62
+ // UIKit hosts integrated search outside the sidebar's sliding content.
63
+ // Mount it after native appearance so it cannot precede the pane's reveal.
64
+ const searchVisible = foldedSearch
65
+ ? tab.searchMode !== "resting"
66
+ : deviceType !== "duo-unfolded" || primaryColumn?.presented !== false;
67
+ const enterSearch = useCallback(() => {
68
+ workspace.dispatch({
69
+ type: "scroll",
70
+ tab: selectedTab,
71
+ offset: workspace.getScrollOffset(selectedTab),
72
+ });
73
+ workspace.dispatch({ type: "search", tab: selectedTab });
74
+ if (props.sidebar && !panes.primarySidebarVisible) togglePrimarySidebar();
75
+ }, [workspace, selectedTab, props.sidebar, panes.primarySidebarVisible, togglePrimarySidebar]);
76
const focusSearch = () => {
62
- if (!workspace) return false;
63
- const tab = workspace.state.selectedTab;
64
- if (tab !== "threads" && tab !== "pullRequests") return false;
65
- workspace.dispatch({ type: "scroll", tab, offset: workspace.getScrollOffset(tab) });
66
- workspace.dispatch({ type: "search" });
67
- setFocusRequest((request) => request + 1);
77
+ if (!isTabActive(selectedTab)) return false;
78
+ if (duoSearch || !NATIVE_LIQUID_GLASS_SUPPORTED) enterSearch();
79
+ searchRef.current?.focus();
80
return true;
81
};
70
- useHardwareKeyboardCommand("focusSearch", focusSearch);
71
- useFocusEffect(useCallback(() => () => Keyboard.dismiss(), []));
82
const cancelSearch = () => {
73
- Keyboard.dismiss();
74
- if (workspace)
75
- workspace.recordScrollOffset(
76
- workspace.state.selectedTab,
77
- workspace.state.tabs[workspace.state.selectedTab].searchEntryOffset,
78
- );
79
- workspace?.dispatch({ type: "cancel" });
83
+ workspace.recordScrollOffset(selectedTab, tab.searchEntryOffset);
84
+ workspace.dispatch({ type: "cancel", tab: selectedTab });
85
};
81
- const searchOpen =
82
- workspace !== null &&
83
- workspace.state.tabs[workspace.state.selectedTab].searchMode !== "resting";
84
- useHardwareBack(searchOpen, () => {
85
- if (keyboardVisible) Keyboard.dismiss();
86
- else cancelSearch();
87
- return true;
88
- });
89
- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- focuses the search TextInput after a focus request renders it
86
+ const searchFocused = () =>
87
+ tab.searchMode === "resting"
88
+ ? enterSearch()
89
+ : workspace.dispatch({ type: "search", tab: selectedTab });
90
+ useHardwareKeyboardCommand("focusSearch", focusSearch);
91
+ // The sidebar remains visible while its detail owns navigation focus.
92
+ const searchHostVisible = focused || primaryColumn?.presented === true;
93
+ const restoreSearch = () => {
94
+ if (
95
+ searchHostVisible &&
96
+ searchVisible &&
97
+ isTabActive(selectedTab) &&
98
+ shouldRestoreNativeSearch(tab, duoSearch)
99
+ ) {
100
+ searchRef.current?.setText(tab.query);
101
+ // Integrated search collapses to its button when its screen reappears,
102
+ // which would hide the query that still filters the list.
103
+ if (NATIVE_LIQUID_GLASS_SUPPORTED) {
104
+ searchRef.current?.setActive(true);
105
+ if (tab.searchMode === "active") searchRef.current?.focus();
106
+ }
107
+ }
108
+ };
109
+ useFocusEffect(
110
+ useCallback(() => {
111
+ const frame = requestAnimationFrame(restoreSearch);
112
+ return () => cancelAnimationFrame(frame);
113
+ }, [restoreSearch]),
114
+ );
115
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- schedules a frame to restore the native search bar's text and focus when its tab becomes active
116
useEffect(() => {
91
- if (focusRequest > 0) input.current?.focus();
92
- }, [focusRequest]);
93
- if (!workspace) return null;
94
- const { state, dispatch } = workspace;
95
- const tab = state.tabs[state.selectedTab];
96
- const activeTab = TABS.find((item) => item.id === state.selectedTab)!;
97
- const searching = tab.searchMode !== "resting";
98
- const expanded = tab.searchMode === "expanded" && !keyboardVisible;
99
- const showNavigation = !searching || expanded;
100
- const bottom = Math.max(insets.bottom, 12);
101
-
117
+ if (!tabActive) return;
118
+ const frame = requestAnimationFrame(restoreSearch);
119
+ return () => cancelAnimationFrame(frame);
120
+ // oxlint-disable-next-line react/exhaustive-effect-dependencies -- Moving the search bar to the bottom toolbar restores its focus and query.
121
+ }, [restoreSearch, tabActive, bottomSearch]);
122
+ const composeButton = nativeToolbarCompose ? (
123
+ <Toolbar.Button
124
+ identifier="workspace-compose"
125
+ accessibilityLabel="New chat"
126
+ icon="square.and.pencil"
127
+ onPress={props.onNewTask}
128
+ separateBackground
129
+ />
130
+ ) : null;
131
+ const searchButton = foldedSearch ? (
132
+ <Toolbar.Button
133
+ identifier="workspace-search"
134
+ accessibilityLabel={searchVisible ? "Close search" : searchLabel}
135
+ icon={searchVisible ? "xmark" : "magnifyingglass"}
136
+ onPress={searchVisible ? () => searchRef.current?.cancelSearch() : focusSearch}
137
+ separateBackground
138
+ />
139
+ ) : null;
140
return (
103
- <KeyboardStickyView
104
- pointerEvents="box-none"
105
- className="absolute inset-x-0 bottom-0"
106
- offset={{ closed: 0, opened: bottom - 8 }}
107
- >
108
- <View
109
- pointerEvents="box-none"
110
- style={{ paddingHorizontal: edge, paddingBottom: bottom, gap: 10 }}
111
- >
112
- {searching ? (
113
- <View className="flex-row items-center" style={{ gap }}>
114
- {!keyboardVisible && !expanded ? (
115
- <ToolbarButton
116
- label={`Show tabs, ${activeTab.label} selected`}
117
- icon={activeTab.icon}
118
- size={48}
119
- onPress={() => dispatch({ type: "expand" })}
120
- />
121
- ) : null}
122
- <WorkspaceSearchField
123
- ref={input}
124
- tab={state.selectedTab}
125
- query={tab.query}
126
- onChangeQuery={(query) => dispatch({ type: "query", query })}
127
- onFocus={() => dispatch({ type: "search" })}
128
- onClear={() => {
129
- dispatch({ type: "query", query: "" });
130
- focusSearch();
131
- }}
141
+ <>
142
+ <NativeStackScreenOptions
143
+ optionsVersion={[selectedTab, tab.searchMode]}
144
+ listeners={{ transitionEnd: restoreSearch }}
145
+ options={{
146
+ // Without Liquid Glass, Settings keeps its search field out instead of a search button,
147
+ // which would take the header's trailing items from the scope filter.
148
+ headerSearchBarOptions:
149
+ (NATIVE_LIQUID_GLASS_SUPPORTED ||
150
+ tab.searchMode !== "resting" ||
151
+ workspace.settingsOpen) &&
152
+ searchVisible
153
+ ? {
154
+ ref: searchRef,
155
+ autoFocus: tab.searchMode === "active",
156
+ autoCapitalize: "none",
157
+ hideNavigationBar: false,
158
+ hideWhenScrolling: false,
159
+ obscureBackground: false,
160
+ placement: NATIVE_LIQUID_GLASS_SUPPORTED
161
+ ? bottomSearch
162
+ ? "integrated"
163
+ : "integratedButton"
164
+ : "stacked",
165
+ allowToolbarIntegration:
166
+ NATIVE_LIQUID_GLASS_SUPPORTED &&
167
+ deviceType !== "phone" &&
168
+ sidebarTabs !== "picker",
169
+ placeholder: searchLabel,
170
+ cancelButtonHidden: foldedSearch,
171
+ onFocus: searchFocused,
172
+ onBlur: () => workspace.dispatch({ type: "expand", tab: selectedTab }),
173
+ onSearchButtonPress: () => searchRef.current?.blur(),
174
+ onChangeText: ({ nativeEvent }) =>
175
+ workspace.dispatch({
176
+ type: "query",
177
+ query: nativeEvent.text,
178
+ tab: selectedTab,
179
+ }),
180
+ onCancelButtonPress: cancelSearch,
181
+ }
182
+ : undefined,
183
+ }}
184
+ />
185
+ {/* UIKit lays trailing items out from the edge inward. */}
186
+ {workspace.settingsOpen ? (
187
+ <Toolbar placement="right">
188
+ {searchButton}
189
+ {createNativeHeaderMenu(settingsMenu)}
190
+ </Toolbar>
191
+ ) : (
192
+ <Toolbar placement="right">
193
+ {searchButton}
194
+ {nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
195
+ {composeButton}
196
+ {selectedTab !== "threads" ||
197
+ isDuoDevice(deviceType) ||
198
+ (deviceType === "pad" && layout.usesSplitView) ||
199
+ sidebarTabs === "picker" ||
200
+ floatingTabs ? null : (
201
+ <Toolbar.Button
202
+ accessibilityLabel="New chat"
203
+ icon="square.and.pencil"
204
+ onPress={props.onNewTask}
205
+ />
206
+ )}
207
+ {NATIVE_LIQUID_GLASS_SUPPORTED ? null : (
208
+ <Toolbar.Button
209
+ accessibilityLabel={searchLabel}
210
+ icon="magnifyingglass"
211
+ onPress={focusSearch}
212
/>
133
- <ToolbarButton label="Cancel search" icon="xmark" size={48} onPress={cancelSearch} />
134
- </View>
135
- ) : null}
136
- {showNavigation ? <WorkspaceDock onNewTask={props.onNewTask} /> : null}
137
- </View>
138
- </KeyboardStickyView>
213
+ )}
214
+ </Toolbar>
215
+ )}
216
+ <Toolbar placement="bottom">
217
+ {sidebarTabs === "toolbar" ? <WorkspaceTabToolbarButtons /> : null}
218
+ {bottomSearch && searchVisible ? <Toolbar.SearchBarSlot /> : null}
219
+ </Toolbar>
220
+ </>
221
);
222
}
apps/mobile/src/features/projects/suggestAppAccess.ts
+4
-2
@@ -5,7 +5,9 @@ import type {
5
} from "@t3tools/contracts";
6
import { appSignInTargetForRemote } from "@t3tools/client-runtime/source-control-clients";
7
import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
8
-import { Alert, Linking } from "react-native";
8
+import { Linking } from "react-native";
9
+
10
+import * as Dialog from "../../components/ui/Dialog";
11
12
/**
13
* After a clone, suggests installing the forge app on the repository's owner when the server is
@@ -24,7 +26,7 @@ export async function suggestAppAccessForRemote(
26
const result = await check({ environmentId, input: target.input });
27
if (result._tag !== "Success" || result.value.status !== "not-covered") return;
28
const owner = target.input.repository.split("/")[0] ?? target.input.repository;
27
- Alert.alert(
29
+ Dialog.alert(
30
`Give ${target.appSignIn.appName} access to ${owner}`,
31
`It isn't installed there, so GitHub requests for ${target.input.repository} use your own login and its lower rate limit.`,
32
[
apps/mobile/src/features/pull-requests/usePullRequestListActions.ts
+9
-9
@@ -8,7 +8,7 @@ import {
8
import type { EnvironmentId, PullRequestAction } from "@t3tools/contracts";
9
import { Atom, AsyncResult } from "effect/reactivity";
10
import { use, useRef, useState } from "react";
11
-import { Linking, Platform } from "react-native";
11
+import { Linking } from "react-native";
12
import type { MenuProps } from "../../components/ui/Menu.types";
13
import { composerPullRequests } from "../../state/pull-requests";
14
import { useAtomCommand } from "../../state/use-atom-command";
@@ -156,24 +156,24 @@ export function usePullRequestListActions(
156
{
157
id: "open",
158
title: `Open ${terminology.singular}`,
159
- image: Platform.OS === "ios" ? "arrow.up.right" : "open_in_new",
159
+ image: "arrow.up.right",
160
},
161
...(writableEnvironments.has(entry.environmentId) && entry.state === "open"
162
? [
163
{
164
id: "request-review",
165
title: "Request review",
166
- image: Platform.OS === "ios" ? "person.badge.plus" : "person_add",
166
+ image: "person.badge.plus",
167
},
168
{
169
id: entry.isDraft ? "ready" : "draft",
170
title: entry.isDraft ? "Mark ready for review" : "Convert to draft",
171
- image: Platform.OS === "ios" ? "pencil" : "edit",
171
+ image: "pencil",
172
},
173
{
174
id: "close",
175
title: pullRequestActionLabel("close", terminology),
176
- image: Platform.OS === "ios" ? "xmark" : "close",
176
+ image: "xmark",
177
attributes: { destructive: true },
178
},
179
]
@@ -182,20 +182,20 @@ export function usePullRequestListActions(
182
{
183
id: "reopen",
184
title: pullRequestActionLabel("reopen", terminology),
185
- image: Platform.OS === "ios" ? "arrow.clockwise" : "refresh",
185
+ image: "arrow.clockwise",
186
},
187
]
188
: []),
189
{
190
id: "share",
191
title: "Share…",
192
- image: Platform.OS === "ios" ? "square.and.arrow.up" : "share",
192
+ image: "square.and.arrow.up",
193
},
194
- { id: "copy", title: "Copy link", image: Platform.OS === "ios" ? "link" : "link" },
194
+ { id: "copy", title: "Copy link", image: "link" },
195
{
196
id: "provider",
197
title: openOnProviderLabel(entry.provider),
198
- image: Platform.OS === "ios" ? "safari" : "open_in_browser",
198
+ image: "safari",
199
},
200
];
201
};
apps/mobile/src/features/settings/ScheduledTaskPickerScreens.tsx
+20
-67
@@ -1,28 +1,21 @@
1
import { useNavigation } from "@react-navigation/native";
2
import { isListedThreadLineage } from "@t3tools/contracts";
3
import * as Haptics from "expo-haptics";
4
-import { useMemo, useRef, useState } from "react";
5
-import { FlatList, Platform, type TextInputInstance, View } from "react-native";
4
+import { useMemo, useState } from "react";
5
+import { FlatList, Platform } from "react-native";
6
import { useSafeAreaInsets } from "react-native-safe-area-context";
7
8
import { AppText as Text } from "../../components/ui/AppText";
9
-import { SearchField } from "../../components/ui/SearchField";
9
import { SelectionRow } from "../../components/ui/SelectionRow";
11
-import { Toolbar } from "../../components/ui/Toolbar";
10
+import { useSearchToolbarInset } from "../../components/ui/useBarInset";
11
import { buildModelOptions, groupByProvider } from "../../lib/modelOptions";
12
import { resolveProviderOptionDescriptors } from "../../lib/providerOptions";
14
-import { NativeStackScreenOptions } from "../../native/StackHeader";
15
-import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
13
import {
14
useEnvironmentServerConfig,
15
useProjects,
16
useVisibleThreadShells,
17
} from "../../state/entities";
18
import { useDebouncedValue, usePaginatedBranches, useThreadSearch } from "../../state/queries";
22
-import {
23
- createNativeMailSearchToolbarItem,
24
- NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
25
-} from "../layout/native-mail-search-toolbar";
19
import { BranchPickerScreen } from "../threads/NewTaskContextPickerScreens";
20
import { ThreadSettingsPickerScreen } from "../threads/ThreadSettingsSheet";
21
import { SettingsScreen } from "./components/SettingsScreen";
@@ -191,8 +184,6 @@ const THREAD_SEARCH_PLACEHOLDER = "Search threads, including older ones";
184
export function ScheduledTaskThreadPickerRouteScreen() {
185
const navigation = useNavigation();
186
const insets = useSafeAreaInsets();
194
- const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
195
- const searchRef = useRef<TextInputInstance>(null);
187
const { editor, setEditor } = useScheduledTaskEditor();
188
const environmentId = editor?.environmentId ?? null;
189
const projectId = editor?.draft.projectId ?? null;
@@ -200,6 +191,16 @@ export function ScheduledTaskThreadPickerRouteScreen() {
191
const currentLabel = useScheduledTaskDestinationLabel(environmentId, threadId);
192
const shells = useVisibleThreadShells();
193
const [query, setQuery] = useState("");
194
+ const search = {
195
+ value: query,
196
+ onChangeText: setQuery,
197
+ placeholder: THREAD_SEARCH_PLACEHOLDER,
198
+ accessibilityLabel: "Search threads",
199
+ clearAccessibilityLabel: "Clear thread search",
200
+ mode: "inline" as const,
201
+ compactToolbar: true,
202
+ };
203
+ const searchToolbarInset = useSearchToolbarInset(search);
204
// Mounts older settled threads matching the query, which shells may leave out.
205
useThreadSearch(
206
environmentId !== null && projectId !== null ? [environmentId] : [],
@@ -209,10 +210,10 @@ export function ScheduledTaskThreadPickerRouteScreen() {
210
211
if (!editor) return <MissingTaskDraft />;
212
212
- const search = query.trim().toLocaleLowerCase();
213
+ const needle = query.trim().toLocaleLowerCase();
214
const rows = [
214
- ...(search ? [] : [{ key: "new-thread", title: NEW_THREAD_DESTINATION_LABEL, thread: null }]),
215
- ...(threadId !== null && currentLabel.toLocaleLowerCase().includes(search)
215
+ ...(needle ? [] : [{ key: "new-thread", title: NEW_THREAD_DESTINATION_LABEL, thread: null }]),
216
+ ...(threadId !== null && currentLabel.toLocaleLowerCase().includes(needle)
217
? [{ key: threadId, title: currentLabel, thread: null }]
218
: []),
219
...shells
@@ -223,7 +224,7 @@ export function ScheduledTaskThreadPickerRouteScreen() {
224
thread.id !== threadId &&
225
thread.archivedAt === null &&
226
isListedThreadLineage(thread.lineage) &&
226
- thread.title.toLocaleLowerCase().includes(search),
227
+ thread.title.toLocaleLowerCase().includes(needle),
228
)
229
.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt))
230
.map((thread) => ({
@@ -235,40 +236,7 @@ export function ScheduledTaskThreadPickerRouteScreen() {
236
const selectedKey = threadId ?? (editor.draft.threadMode === "new_thread" ? "new-thread" : null);
237
238
return (
238
- <SettingsScreen title="Destination">
239
- {Platform.OS === "ios" ? (
240
- <NativeStackScreenOptions
241
- options={{
242
- unstable_headerToolbarItems: usesNativeMailSearchToolbar
243
- ? () => [
244
- createNativeMailSearchToolbarItem({
245
- onSearchTextChange: setQuery,
246
- placeholder: THREAD_SEARCH_PLACEHOLDER,
247
- searchTextChangeId: "scheduled-task-thread-search-text",
248
- showsSearchDismissButton: true,
249
- }),
250
- ]
251
- : undefined,
252
- headerSearchBarOptions: usesNativeMailSearchToolbar
253
- ? undefined
254
- : {
255
- allowToolbarIntegration: true,
256
- autoCapitalize: "none",
257
- hideNavigationBar: false,
258
- hideWhenScrolling: false,
259
- obscureBackground: false,
260
- onCancelButtonPress: () => setQuery(""),
261
- onChangeText: (event) => setQuery(event.nativeEvent.text),
262
- placeholder: THREAD_SEARCH_PLACEHOLDER,
263
- },
264
- }}
265
- />
266
- ) : null}
267
- {Platform.OS === "ios" && !usesNativeMailSearchToolbar ? (
268
- <Toolbar placement="bottom">
269
- <Toolbar.SearchBarSlot />
270
- </Toolbar>
271
- ) : null}
239
+ <SettingsScreen title="Destination" search={search}>
240
<FlatList
241
data={rows}
242
keyExtractor={(row) => row.key}
@@ -281,25 +249,10 @@ export function ScheduledTaskThreadPickerRouteScreen() {
249
contentContainerStyle={{
250
paddingHorizontal: 16,
251
paddingTop: 16,
284
- paddingBottom: usesNativeMailSearchToolbar
285
- ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16
252
+ paddingBottom: searchToolbarInset
253
+ ? searchToolbarInset + 16
254
: Math.max(insets.bottom, 16) + 16,
255
}}
288
- ListHeaderComponent={
289
- Platform.OS === "ios" ? undefined : (
290
- <View className="pb-4">
291
- <SearchField
292
- inputRef={searchRef}
293
- autoFocus={false}
294
- accessibilityLabel="Search threads"
295
- clearAccessibilityLabel="Clear thread search"
296
- onChangeText={setQuery}
297
- placeholder={THREAD_SEARCH_PLACEHOLDER}
298
- value={query}
299
- />
300
- </View>
301
- )
302
- }
256
ListEmptyComponent={
257
<Text className="p-5 text-center text-sm text-foreground-muted">No matching threads</Text>
258
}
apps/mobile/src/features/settings/components/SourceControlSignInSection.tsx
+6
-5
@@ -8,8 +8,9 @@ import {
8
import * as Cause from "effect/Cause";
9
import * as Clipboard from "expo-clipboard";
10
import { useRef, useState } from "react";
11
-import { Alert, Linking } from "react-native";
11
+import { Linking } from "react-native";
12
13
+import * as Dialog from "../../../components/ui/Dialog";
14
import { useEnvironmentQuery } from "../../../state/query";
15
import { serverEnvironment } from "../../../state/server";
16
import { sourceControlEnvironment } from "../../../state/sourceControl";
@@ -119,7 +120,7 @@ function AppSignInRow(props: {
120
121
const showCode = (prompt: SourceControlSignInPrompt) => {
122
void Clipboard.setStringAsync(prompt.userCode).catch(() => undefined);
122
- Alert.alert(
123
+ Dialog.alert(
124
prompt.userCode,
125
`Enter this code on GitHub, then approve ${appSignIn.appName}. It is copied. The server finishes signing in even if you leave the app.`,
126
[
@@ -142,7 +143,7 @@ function AppSignInRow(props: {
143
const started = await start({ environmentId, input });
144
if (started._tag !== "Success") {
145
setPending(null);
145
- Alert.alert("Could not start the sign-in", failureMessage(started.cause));
146
+ Dialog.alert("Could not start the sign-in", failureMessage(started.cause));
147
return;
148
}
149
const prompt = started.value;
@@ -154,7 +155,7 @@ function AppSignInRow(props: {
155
attempt.current = null;
156
setPending(null);
157
if (finished._tag !== "Success") {
157
- Alert.alert("Sign-in did not finish", failureMessage(finished.cause));
158
+ Dialog.alert("Sign-in did not finish", failureMessage(finished.cause));
159
}
160
};
161
@@ -171,7 +172,7 @@ function AppSignInRow(props: {
172
173
const onPress = () => {
174
if (signedIn) {
174
- Alert.alert(
175
+ Dialog.alert(
176
appSignIn.appName,
177
"Signed in. GitHub requests use the app's higher rate limit, in repositories where the app is installed.",
178
[
apps/mobile/src/features/threads/CustomSnoozeSheet.android.tsx
+4
-2
@@ -33,14 +33,16 @@ import { AppState, useWindowDimensions } from "react-native";
33
import { OverlayPortal } from "../../components/ui/OverlayPortal";
34
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
35
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
36
-import type { CustomSnoozeSheet as SharedCustomSnoozeSheet } from "./CustomSnoozeSheet.shared";
36
import {
37
applySnoozePickerDate,
38
applySnoozePickerTime,
39
snoozeDateToPickerDate,
40
} from "./customSnoozeDate";
41
43
-type Props = Parameters<typeof SharedCustomSnoozeSheet>[0];
42
+type Props = {
43
+ readonly onClose: () => void;
44
+ readonly onSnooze: (snoozedUntil: string) => void;
45
+};
46
47
const roundedCorner = Shape.RoundedCorner;
48
apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx
deleted
-243
@@ -1,243 +0,0 @@
1
-import { SheetHeader } from "../../components/ui/SheetHeader";
2
-import {
3
- DatePicker,
4
- Host,
5
- HStack,
6
- Picker,
7
- Popover,
8
- RNHostView,
9
- Spacer,
10
- Text,
11
- VStack,
12
-} from "@expo/ui/swift-ui";
13
-import {
14
- accessibilityHidden,
15
- clipped,
16
- font,
17
- datePickerStyle,
18
- foregroundStyle,
19
- frame,
20
- labelsHidden,
21
- padding,
22
- pickerStyle,
23
- tag,
24
-} from "@expo/ui/swift-ui/modifiers";
25
-import {
26
- localSnoozeDate,
27
- localSnoozeTime,
28
- resolveCustomSnooze,
29
- type CustomSnoozeInput,
30
-} from "@t3tools/client-runtime/state/thread-settled";
31
-import { useState, type ReactNode } from "react";
32
-import { StandaloneStack } from "../layout/nested-stacks";
33
-import { ScrollView, useWindowDimensions, View } from "react-native";
34
-
35
-import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
36
-
37
-const durationAmounts = Array.from({ length: 99 }, (_, index) => index + 1);
38
-const modes = [
39
- { value: "date", label: "Date and time" },
40
- { value: "duration", label: "Duration" },
41
-] as const;
42
-const units = [
43
- { value: "minutes", label: "Minutes" },
44
- { value: "hours", label: "Hours" },
45
- { value: "days", label: "Days" },
46
-] as const;
47
-
48
-export function CustomSnoozeSheet(props: {
49
- readonly onClose: () => void;
50
- readonly onSnooze: (snoozedUntil: string) => void;
51
-}) {
52
- const { width, height } = useWindowDimensions();
53
- const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
54
- const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
55
- const [amount, setAmount] = useState(2);
56
- const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
57
- const [error, setError] = useState<string | null>(null);
58
- const { themeVariables: colors, themeAppearance } = useAppearancePreferences();
59
- const popoverWidth = Math.min(360, width - 32);
60
- const popoverHeight = Math.min(error ? 364 : 324, height - 96);
61
- const updateDate = (value: Date) => {
62
- setDate(value);
63
- setError(null);
64
- };
65
-
66
- const submit = () => {
67
- const input: CustomSnoozeInput =
68
- mode === "date"
69
- ? { mode, date: localSnoozeDate(date), time: localSnoozeTime(date) }
70
- : { mode, amount: String(amount), unit };
71
- const snoozedUntil = resolveCustomSnooze(input, new Date());
72
- if (!snoozedUntil) {
73
- setError(
74
- mode === "date" ? "Choose a date and time in the future." : "Enter a positive duration.",
75
- );
76
- return;
77
- }
78
- props.onSnooze(snoozedUntil);
79
- props.onClose();
80
- };
81
-
82
- return (
83
- <Host
84
- style={{ position: "absolute", top: 0, right: 0, bottom: 0, left: 0 }}
85
- colorScheme={themeAppearance}
86
- seedColor={colors["--color-primary"]}
87
- >
88
- <Popover
89
- isPresented
90
- onIsPresentedChange={(presented) => {
91
- if (!presented) props.onClose();
92
- }}
93
- >
94
- <Popover.Trigger>
95
- <Spacer
96
- modifiers={[frame({ maxWidth: Infinity, maxHeight: Infinity }), accessibilityHidden()]}
97
- />
98
- </Popover.Trigger>
99
- <Popover.Content>
100
- <SnoozePopoverNavigation
101
- width={popoverWidth}
102
- height={popoverHeight}
103
- onClose={props.onClose}
104
- onSubmit={submit}
105
- >
106
- <Host
107
- matchContents={{ vertical: true }}
108
- colorScheme={themeAppearance}
109
- style={{ width: popoverWidth }}
110
- >
111
- <VStack
112
- spacing={16}
113
- modifiers={[padding({ all: 16 }), foregroundStyle(colors["--color-foreground"])]}
114
- >
115
- <Picker
116
- label="Snooze mode"
117
- selection={mode}
118
- onSelectionChange={(value: CustomSnoozeInput["mode"]) => {
119
- setMode(value);
120
- setError(null);
121
- }}
122
- modifiers={[pickerStyle("segmented")]}
123
- >
124
- {modes.map((option) => (
125
- <Text key={option.value} modifiers={[tag(option.value)]}>
126
- {option.label}
127
- </Text>
128
- ))}
129
- </Picker>
130
- {mode === "date" ? (
131
- <DatePicker
132
- title="Snooze until"
133
- selection={date}
134
- displayedComponents={["date", "hourAndMinute"]}
135
- onDateChange={updateDate}
136
- modifiers={[
137
- datePickerStyle("wheel"),
138
- labelsHidden(),
139
- frame({ maxWidth: Infinity, minHeight: 180, maxHeight: 180 }),
140
- ]}
141
- />
142
- ) : (
143
- <HStack spacing={0}>
144
- <Picker
145
- label="Duration amount"
146
- selection={amount}
147
- onSelectionChange={(value: number) => {
148
- setAmount(value);
149
- setError(null);
150
- }}
151
- modifiers={[
152
- pickerStyle("wheel"),
153
- labelsHidden(),
154
- frame({ minWidth: 0, maxWidth: Infinity, minHeight: 180, maxHeight: 180 }),
155
- clipped(),
156
- ]}
157
- >
158
- {durationAmounts.map((value) => (
159
- <Text
160
- key={value}
161
- modifiers={[tag(value), foregroundStyle(colors["--color-foreground"])]}
162
- >
163
- {String(value)}
164
- </Text>
165
- ))}
166
- </Picker>
167
- <Picker
168
- label="Duration unit"
169
- selection={unit}
170
- onSelectionChange={(value: typeof unit) => {
171
- setUnit(value);
172
- setError(null);
173
- }}
174
- modifiers={[
175
- pickerStyle("wheel"),
176
- labelsHidden(),
177
- frame({ minWidth: 0, maxWidth: Infinity, minHeight: 180, maxHeight: 180 }),
178
- clipped(),
179
- ]}
180
- >
181
- {units.map((option) => (
182
- <Text
183
- key={option.value}
184
- modifiers={[
185
- tag(option.value),
186
- foregroundStyle(colors["--color-foreground"]),
187
- ]}
188
- >
189
- {option.label}
190
- </Text>
191
- ))}
192
- </Picker>
193
- </HStack>
194
- )}
195
- {error ? (
196
- <Text
197
- modifiers={[
198
- font({ textStyle: "footnote" }),
199
- foregroundStyle(colors["--color-danger-foreground"]),
200
- ]}
201
- >
202
- {error}
203
- </Text>
204
- ) : null}
205
- </VStack>
206
- </Host>
207
- </SnoozePopoverNavigation>
208
- </Popover.Content>
209
- </Popover>
210
- </Host>
211
- );
212
-}
213
-
214
-function SnoozePopoverNavigation(props: {
215
- readonly width: number;
216
- readonly height: number;
217
- readonly onClose: () => void;
218
- readonly onSubmit: () => void;
219
- readonly children: ReactNode;
220
-}) {
221
- return (
222
- <VStack modifiers={[frame({ width: props.width, height: props.height })]}>
223
- <RNHostView>
224
- <View style={{ width: props.width, height: props.height }}>
225
- <StandaloneStack>
226
- <SheetHeader
227
- title="Custom snooze"
228
- onCancel={props.onClose}
229
- accessibilityLabel="Cancel custom snooze"
230
- confirm={{ label: "Snooze", onPress: props.onSubmit }}
231
- />
232
- <ScrollView
233
- contentInsetAdjustmentBehavior="automatic"
234
- showsVerticalScrollIndicator={false}
235
- >
236
- {props.children}
237
- </ScrollView>
238
- </StandaloneStack>
239
- </View>
240
- </RNHostView>
241
- </VStack>
242
- );
243
-}
apps/mobile/src/features/threads/CustomSnoozeSheet.shared.tsx
deleted
-174
@@ -1,174 +0,0 @@
1
-import { Button } from "../../components/ui/Button";
2
-import { DateTimePicker } from "@expo/ui/community/datetime-picker";
3
-import {
4
- localSnoozeDate,
5
- localSnoozeTime,
6
- resolveCustomSnooze,
7
- type CustomSnoozeInput,
8
-} from "@t3tools/client-runtime/state/thread-settled";
9
-import { useState } from "react";
10
-import {
11
- KeyboardAvoidingView,
12
- Modal,
13
- Platform,
14
- Pressable,
15
- ScrollView,
16
- TextInput,
17
- View,
18
-} from "react-native";
19
-import { AppText } from "../../components/ui/AppText";
20
-import { SegmentedControl } from "../../components/ui/SegmentedControl";
21
-
22
-export function CustomSnoozeSheet(props: {
23
- readonly onClose: () => void;
24
- readonly onSnooze: (snoozedUntil: string) => void;
25
-}) {
26
- const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
27
- const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
28
- const [picker, setPicker] = useState<"date" | "time" | null>(null);
29
- const [amount, setAmount] = useState("2");
30
- const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
31
- const [error, setError] = useState<string | null>(null);
32
- return (
33
- <Modal visible transparent animationType="fade" onRequestClose={props.onClose}>
34
- <KeyboardAvoidingView
35
- className="flex-1 items-center justify-center bg-backdrop px-6"
36
- behavior={Platform.OS === "ios" ? "padding" : undefined}
37
- >
38
- <ScrollView
39
- className="max-h-[80%] w-full max-w-md grow-0 rounded-3xl bg-screen"
40
- keyboardShouldPersistTaps="handled"
41
- contentInsetAdjustmentBehavior="automatic"
42
- contentContainerStyle={{ padding: 24, paddingBottom: 24, gap: 20 }}
43
- >
44
- <AppText accessibilityRole="header" className="text-xl font-t3-semibold">
45
- Custom snooze
46
- </AppText>
47
- <AppText className="text-base text-foreground-secondary">
48
- Choose when snoozed threads return to your inbox.
49
- </AppText>
50
- <SegmentedControl
51
- options={
52
- [
53
- { value: "date", label: "Date and time" },
54
- { value: "duration", label: "Duration" },
55
- ] as const
56
- }
57
- selected={mode}
58
- onSelect={(value) => {
59
- setMode(value);
60
- setPicker(null);
61
- setError(null);
62
- }}
63
- role="tab"
64
- />
65
- {mode === "date" ? (
66
- <View className="gap-3">
67
- {(["date", "time"] as const).map((value) => (
68
- <Pressable
69
- key={value}
70
- accessibilityRole="button"
71
- accessibilityLabel={value === "date" ? "Choose date" : "Choose time"}
72
- className="min-h-12 flex-row items-center justify-between rounded-xl bg-subtle px-3"
73
- onPress={() => setPicker(value)}
74
- >
75
- <AppText>{value === "date" ? "Date" : "Time"}</AppText>
76
- <AppText>
77
- {value === "date"
78
- ? date.toLocaleDateString()
79
- : date.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}
80
- </AppText>
81
- </Pressable>
82
- ))}
83
- {picker && (
84
- <DateTimePicker
85
- value={date}
86
- mode={picker}
87
- display={Platform.OS === "ios" ? "spinner" : "default"}
88
- onDismiss={() => setPicker(null)}
89
- onValueChange={(_, selected) => {
90
- const next = new Date(date);
91
- if (picker === "date")
92
- next.setFullYear(
93
- selected.getFullYear(),
94
- selected.getMonth(),
95
- selected.getDate(),
96
- );
97
- else next.setHours(selected.getHours(), selected.getMinutes(), 0, 0);
98
- setDate(next);
99
- setError(null);
100
- }}
101
- />
102
- )}
103
- </View>
104
- ) : (
105
- <View className="gap-3">
106
- <AppText>Snooze for</AppText>
107
- <TextInput
108
- accessibilityLabel="Duration"
109
- className="min-h-12 rounded-xl bg-subtle px-3 text-base text-foreground"
110
- keyboardType="decimal-pad"
111
- value={amount}
112
- onChangeText={(value) => {
113
- setAmount(value);
114
- setError(null);
115
- }}
116
- />
117
- <View className="flex-row gap-2">
118
- {(["minutes", "hours", "days"] as const).map((value) => (
119
- <Pressable
120
- key={value}
121
- accessibilityRole="radio"
122
- accessibilityState={{ checked: unit === value }}
123
- className={
124
- unit === value
125
- ? "min-h-12 flex-1 items-center justify-center rounded-xl bg-subtle"
126
- : "min-h-12 flex-1 items-center justify-center rounded-xl"
127
- }
128
- onPress={() => {
129
- setUnit(value);
130
- setError(null);
131
- }}
132
- >
133
- <AppText>
134
- {value === "minutes" ? "Minutes" : value === "hours" ? "Hours" : "Days"}
135
- </AppText>
136
- </Pressable>
137
- ))}
138
- </View>
139
- </View>
140
- )}
141
- {error && (
142
- <AppText accessibilityRole="alert" className="text-danger-foreground">
143
- {error}
144
- </AppText>
145
- )}
146
- <View className="flex-row justify-end gap-3">
147
- <Button label="Cancel" tone="text" onPress={props.onClose} />
148
- <Button
149
- label="Snooze"
150
- tone="secondary"
151
- onPress={() => {
152
- const input: CustomSnoozeInput =
153
- mode === "date"
154
- ? { mode, date: localSnoozeDate(date), time: localSnoozeTime(date) }
155
- : { mode, amount: amount.replace(",", "."), unit };
156
- const snoozedUntil = resolveCustomSnooze(input, new Date());
157
- if (!snoozedUntil) {
158
- setError(
159
- mode === "date"
160
- ? "Choose a date and time in the future."
161
- : "Enter a positive duration.",
162
- );
163
- return;
164
- }
165
- props.onSnooze(snoozedUntil);
166
- props.onClose();
167
- }}
168
- />
169
- </View>
170
- </ScrollView>
171
- </KeyboardAvoidingView>
172
- </Modal>
173
- );
174
-}
apps/mobile/src/features/threads/CustomSnoozeSheet.tsx
+243
-1
@@ -1 +1,243 @@
1
-export { CustomSnoozeSheet } from "./CustomSnoozeSheet.shared";
1
+import { SheetHeader } from "../../components/ui/SheetHeader";
2
+import {
3
+ DatePicker,
4
+ Host,
5
+ HStack,
6
+ Picker,
7
+ Popover,
8
+ RNHostView,
9
+ Spacer,
10
+ Text,
11
+ VStack,
12
+} from "@expo/ui/swift-ui";
13
+import {
14
+ accessibilityHidden,
15
+ clipped,
16
+ font,
17
+ datePickerStyle,
18
+ foregroundStyle,
19
+ frame,
20
+ labelsHidden,
21
+ padding,
22
+ pickerStyle,
23
+ tag,
24
+} from "@expo/ui/swift-ui/modifiers";
25
+import {
26
+ localSnoozeDate,
27
+ localSnoozeTime,
28
+ resolveCustomSnooze,
29
+ type CustomSnoozeInput,
30
+} from "@t3tools/client-runtime/state/thread-settled";
31
+import { useState, type ReactNode } from "react";
32
+import { StandaloneStack } from "../layout/nested-stacks";
33
+import { ScrollView, useWindowDimensions, View } from "react-native";
34
+
35
+import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
36
+
37
+const durationAmounts = Array.from({ length: 99 }, (_, index) => index + 1);
38
+const modes = [
39
+ { value: "date", label: "Date and time" },
40
+ { value: "duration", label: "Duration" },
41
+] as const;
42
+const units = [
43
+ { value: "minutes", label: "Minutes" },
44
+ { value: "hours", label: "Hours" },
45
+ { value: "days", label: "Days" },
46
+] as const;
47
+
48
+export function CustomSnoozeSheet(props: {
49
+ readonly onClose: () => void;
50
+ readonly onSnooze: (snoozedUntil: string) => void;
51
+}) {
52
+ const { width, height } = useWindowDimensions();
53
+ const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
54
+ const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
55
+ const [amount, setAmount] = useState(2);
56
+ const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
57
+ const [error, setError] = useState<string | null>(null);
58
+ const { themeVariables: colors, themeAppearance } = useAppearancePreferences();
59
+ const popoverWidth = Math.min(360, width - 32);
60
+ const popoverHeight = Math.min(error ? 364 : 324, height - 96);
61
+ const updateDate = (value: Date) => {
62
+ setDate(value);
63
+ setError(null);
64
+ };
65
+
66
+ const submit = () => {
67
+ const input: CustomSnoozeInput =
68
+ mode === "date"
69
+ ? { mode, date: localSnoozeDate(date), time: localSnoozeTime(date) }
70
+ : { mode, amount: String(amount), unit };
71
+ const snoozedUntil = resolveCustomSnooze(input, new Date());
72
+ if (!snoozedUntil) {
73
+ setError(
74
+ mode === "date" ? "Choose a date and time in the future." : "Enter a positive duration.",
75
+ );
76
+ return;
77
+ }
78
+ props.onSnooze(snoozedUntil);
79
+ props.onClose();
80
+ };
81
+
82
+ return (
83
+ <Host
84
+ style={{ position: "absolute", top: 0, right: 0, bottom: 0, left: 0 }}
85
+ colorScheme={themeAppearance}
86
+ seedColor={colors["--color-primary"]}
87
+ >
88
+ <Popover
89
+ isPresented
90
+ onIsPresentedChange={(presented) => {
91
+ if (!presented) props.onClose();
92
+ }}
93
+ >
94
+ <Popover.Trigger>
95
+ <Spacer
96
+ modifiers={[frame({ maxWidth: Infinity, maxHeight: Infinity }), accessibilityHidden()]}
97
+ />
98
+ </Popover.Trigger>
99
+ <Popover.Content>
100
+ <SnoozePopoverNavigation
101
+ width={popoverWidth}
102
+ height={popoverHeight}
103
+ onClose={props.onClose}
104
+ onSubmit={submit}
105
+ >
106
+ <Host
107
+ matchContents={{ vertical: true }}
108
+ colorScheme={themeAppearance}
109
+ style={{ width: popoverWidth }}
110
+ >
111
+ <VStack
112
+ spacing={16}
113
+ modifiers={[padding({ all: 16 }), foregroundStyle(colors["--color-foreground"])]}
114
+ >
115
+ <Picker
116
+ label="Snooze mode"
117
+ selection={mode}
118
+ onSelectionChange={(value: CustomSnoozeInput["mode"]) => {
119
+ setMode(value);
120
+ setError(null);
121
+ }}
122
+ modifiers={[pickerStyle("segmented")]}
123
+ >
124
+ {modes.map((option) => (
125
+ <Text key={option.value} modifiers={[tag(option.value)]}>
126
+ {option.label}
127
+ </Text>
128
+ ))}
129
+ </Picker>
130
+ {mode === "date" ? (
131
+ <DatePicker
132
+ title="Snooze until"
133
+ selection={date}
134
+ displayedComponents={["date", "hourAndMinute"]}
135
+ onDateChange={updateDate}
136
+ modifiers={[
137
+ datePickerStyle("wheel"),
138
+ labelsHidden(),
139
+ frame({ maxWidth: Infinity, minHeight: 180, maxHeight: 180 }),
140
+ ]}
141
+ />
142
+ ) : (
143
+ <HStack spacing={0}>
144
+ <Picker
145
+ label="Duration amount"
146
+ selection={amount}
147
+ onSelectionChange={(value: number) => {
148
+ setAmount(value);
149
+ setError(null);
150
+ }}
151
+ modifiers={[
152
+ pickerStyle("wheel"),
153
+ labelsHidden(),
154
+ frame({ minWidth: 0, maxWidth: Infinity, minHeight: 180, maxHeight: 180 }),
155
+ clipped(),
156
+ ]}
157
+ >
158
+ {durationAmounts.map((value) => (
159
+ <Text
160
+ key={value}
161
+ modifiers={[tag(value), foregroundStyle(colors["--color-foreground"])]}
162
+ >
163
+ {String(value)}
164
+ </Text>
165
+ ))}
166
+ </Picker>
167
+ <Picker
168
+ label="Duration unit"
169
+ selection={unit}
170
+ onSelectionChange={(value: typeof unit) => {
171
+ setUnit(value);
172
+ setError(null);
173
+ }}
174
+ modifiers={[
175
+ pickerStyle("wheel"),
176
+ labelsHidden(),
177
+ frame({ minWidth: 0, maxWidth: Infinity, minHeight: 180, maxHeight: 180 }),
178
+ clipped(),
179
+ ]}
180
+ >
181
+ {units.map((option) => (
182
+ <Text
183
+ key={option.value}
184
+ modifiers={[
185
+ tag(option.value),
186
+ foregroundStyle(colors["--color-foreground"]),
187
+ ]}
188
+ >
189
+ {option.label}
190
+ </Text>
191
+ ))}
192
+ </Picker>
193
+ </HStack>
194
+ )}
195
+ {error ? (
196
+ <Text
197
+ modifiers={[
198
+ font({ textStyle: "footnote" }),
199
+ foregroundStyle(colors["--color-danger-foreground"]),
200
+ ]}
201
+ >
202
+ {error}
203
+ </Text>
204
+ ) : null}
205
+ </VStack>
206
+ </Host>
207
+ </SnoozePopoverNavigation>
208
+ </Popover.Content>
209
+ </Popover>
210
+ </Host>
211
+ );
212
+}
213
+
214
+function SnoozePopoverNavigation(props: {
215
+ readonly width: number;
216
+ readonly height: number;
217
+ readonly onClose: () => void;
218
+ readonly onSubmit: () => void;
219
+ readonly children: ReactNode;
220
+}) {
221
+ return (
222
+ <VStack modifiers={[frame({ width: props.width, height: props.height })]}>
223
+ <RNHostView>
224
+ <View style={{ width: props.width, height: props.height }}>
225
+ <StandaloneStack>
226
+ <SheetHeader
227
+ title="Custom snooze"
228
+ onCancel={props.onClose}
229
+ accessibilityLabel="Cancel custom snooze"
230
+ confirm={{ label: "Snooze", onPress: props.onSubmit }}
231
+ />
232
+ <ScrollView
233
+ contentInsetAdjustmentBehavior="automatic"
234
+ showsVerticalScrollIndicator={false}
235
+ >
236
+ {props.children}
237
+ </ScrollView>
238
+ </StandaloneStack>
239
+ </View>
240
+ </RNHostView>
241
+ </VStack>
242
+ );
243
+}
apps/mobile/src/features/threads/ThreadQueueControl.tsx
+3
-3
@@ -11,7 +11,7 @@ import { Atom } from "effect/reactivity";
11
import { Image } from "expo-image";
12
import * as Haptics from "expo-haptics";
13
import { useEffect, useRef, useState } from "react";
14
-import { Platform, Pressable, ScrollView, View } from "react-native";
14
+import { Pressable, ScrollView, View } from "react-native";
15
import { GestureHandlerRootView } from "react-native-gesture-handler";
16
import ReanimatedSwipeable, {
17
type SwipeableMethods,
@@ -264,7 +264,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
264
id: "steer",
265
title: "Send now",
266
attributes: { disabled: !controls.canSend },
267
- image: Platform.OS === "ios" ? "arrow.up" : "arrow_upward",
267
+ image: "arrow.up",
268
},
269
]
270
: []),
@@ -272,7 +272,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
272
id: "edit",
273
title: "Edit",
274
attributes: { disabled: !controls.canEdit },
275
- image: Platform.OS === "ios" ? "pencil" : "edit",
275
+ image: "pencil",
276
},
277
{
278
id: "remove",