Skip to content

Commit 44ee2c9

Browse files
committed
merge: sync mobile sidebar demand fix with main
2 parents 1652982 + 32bf48f commit 44ee2c9

195 files changed

Lines changed: 10111 additions & 1855 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@t3tools/provider-acp-registry": "workspace:*",
7777
"@t3tools/provider-core": "workspace:*",
7878
"@t3tools/provider-cursor": "workspace:*",
79+
"@t3tools/provider-fx": "workspace:*",
7980
"@t3tools/provider-grok": "workspace:*",
8081
"@t3tools/provider-muse": "workspace:*",
8182
"@t3tools/provider-opencode": "workspace:*",

‎apps/mobile/src/App.tsx‎

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { GestureHandlerRootView } from "react-native-gesture-handler";
99
import { KeyboardProvider } from "react-native-keyboard-controller";
1010
import { SafeAreaProvider } from "react-native-safe-area-context";
1111
import {
12-
createNavigationContainerRef,
1312
createStaticNavigation,
1413
getActionFromState,
1514
getStateFromPath,
15+
type NavigationState,
1616
} from "@react-navigation/native";
1717

1818
import { RegistryContext } from "@effect/atom-react";
@@ -40,8 +40,9 @@ import {
4040
type FoundationHotModule,
4141
} from "./lib/foundation-fast-refresh";
4242
import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
43-
import { useUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
43+
import { installUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
4444
import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
45+
import { installSubscriptionUsageRefresh } from "./widgets/useSubscriptionUsage";
4546
import { GlobalVoiceInputControl } from "./features/voice-input/GlobalVoiceInputControl";
4647
import { restoreSettingsLinkState } from "./features/settings/settings-navigation";
4748
import {
@@ -52,6 +53,8 @@ import {
5253
} from "./features/workspace/workspace-selection-store";
5354
import { workspaceDetailLinkAction } from "./features/workspace/workspace-detail-selection";
5455
import { NativeLayoutMetricsProvider } from "./native/native-layout-metrics";
56+
import { attachRootNavigation, rootNavigationRef } from "./lib/rootNavigation";
57+
import { pruneNewTaskBranchCheckouts } from "./features/threads/NewTaskDraftRouteScreen";
5558

5659
import "../global.css";
5760

@@ -84,11 +87,27 @@ const appLinking = {
8487
};
8588

8689
const Navigation = createStaticNavigation(RootStack);
87-
const navigationRef = createNavigationContainerRef();
90+
91+
function handleNavigationStateChange(state: NavigationState | undefined): void {
92+
recordWorkspaceSelections(state);
93+
if (state) pruneNewTaskBranchCheckouts(state);
94+
}
95+
96+
function handleNavigationReady(): void {
97+
handleNavigationStateChange(rootNavigationRef.getRootState());
98+
}
8899

89100
declare const module: { readonly hot?: FoundationHotModule } | undefined;
90101

91102
const appServiceDisposers = [
103+
installUiRuntimeMemoryWarningGc(),
104+
subscribeComposerDraftModelReconciliation({
105+
registry: appAtomRegistry,
106+
threadShellAtom: environmentThreadShells.threadShellAtom,
107+
threadRefsAtom: environmentThreadShells.threadRefsAtom,
108+
shellStateAtom: environmentShell.stateAtom,
109+
}),
110+
installSubscriptionUsageRefresh(),
92111
installPermissionUpdateNotice(),
93112
installThreadOutboxDelivery(),
94113
installComposerAttachmentUploads(),
@@ -108,18 +127,6 @@ function SplashScreenCoordinator() {
108127
}
109128

110129
export default function App() {
111-
useUiRuntimeMemoryWarningGc();
112-
useEffect(
113-
() =>
114-
subscribeComposerDraftModelReconciliation({
115-
registry: appAtomRegistry,
116-
threadShellAtom: environmentThreadShells.threadShellAtom,
117-
threadRefsAtom: environmentThreadShells.threadRefsAtom,
118-
shellStateAtom: environmentShell.stateAtom,
119-
}),
120-
[],
121-
);
122-
123130
return (
124131
<RegistryContext.Provider value={appAtomRegistry}>
125132
<CloudAuthProvider>
@@ -148,11 +155,11 @@ function AppContent() {
148155
<NativeLayoutMetricsProvider>
149156
<IncomingShareProvider>
150157
<Navigation
151-
ref={navigationRef}
158+
ref={attachRootNavigation}
152159
linking={appLinking}
153-
onReady={() => recordWorkspaceSelections(navigationRef.getRootState())}
160+
onReady={handleNavigationReady}
154161
theme={navigationTheme}
155-
onStateChange={recordWorkspaceSelections}
162+
onStateChange={handleNavigationStateChange}
156163
/>
157164
</IncomingShareProvider>
158165
<Dialog.Host />

‎apps/mobile/src/components/ui/SegmentedControl.ios.tsx‎

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { requireNativeView } from "expo";
22
import { View, type NativeSyntheticEvent, type ViewProps } from "react-native";
33

4-
import {
5-
flattenThemeColor,
6-
themeColorWithAlpha,
7-
themeColorWithContrast,
8-
} from "../../lib/mobileTheme";
4+
import { SegmentedControl as FlatSegmentedControl } from "./SegmentedControl.shared";
5+
import { segmentedControlColors } from "./segmentedControlColors";
96
import { useControlTheme } from "./useControlTheme";
107
import type { SegmentedControlProps } from "./SegmentedControl.types";
118

@@ -27,17 +24,16 @@ const NativeSegmentedControl = requireNativeView<
2724
export function SegmentedControl<Value extends string | number>(
2825
props: SegmentedControlProps<Value>,
2926
) {
30-
const { colors, colorScheme } = useControlTheme();
31-
const trackColor = flattenThemeColor(
32-
themeColorWithAlpha(colors["--color-prominent-action"], colorScheme === "dark" ? 0.18 : 0.07),
33-
colors["--color-screen"],
27+
const { colors, colorScheme, themeId } = useControlTheme();
28+
// UIKit adds a gray fill over the sunken card track.
29+
if (props.variant === "card") return <FlatSegmentedControl {...props} />;
30+
const { trackColor, selectedColor, selectedTextColor, mutedColor } = segmentedControlColors(
31+
colors,
32+
colorScheme,
33+
props.variant,
34+
"ios",
35+
themeId,
3436
);
35-
const selectedColor =
36-
colorScheme === "dark" ? colors["--color-prominent-action"] : colors["--color-secondary"];
37-
const selectedTextColor =
38-
colorScheme === "dark"
39-
? colors["--color-prominent-action-foreground"]
40-
: colors["--color-secondary-foreground"];
4137
return (
4238
<View className={props.className}>
4339
<NativeSegmentedControl
@@ -46,11 +42,7 @@ export function SegmentedControl<Value extends string | number>(
4642
trackColor={trackColor}
4743
selectedColor={selectedColor}
4844
textColor={selectedTextColor}
49-
mutedColor={themeColorWithContrast(
50-
colors["--color-foreground-muted"],
51-
trackColor,
52-
colorScheme === "dark" ? 7 : 4.5,
53-
)}
45+
mutedColor={mutedColor}
5446
appearance={colorScheme}
5547
onSelectionChange={({ nativeEvent }) => {
5648
const option = props.options[nativeEvent.index];
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { useState } from "react";
2+
import { I18nManager, Platform, Pressable, View } from "react-native";
3+
import Animated, { useAnimatedStyle, useReducedMotion, withTiming } from "react-native-reanimated";
4+
5+
import { segmentedControlColors } from "./segmentedControlColors";
6+
import { AppText } from "./AppText";
7+
import { useControlTheme } from "./useControlTheme";
8+
import type { SegmentedControlProps } from "./SegmentedControl.types";
9+
10+
export type { SegmentedControlProps } from "./SegmentedControl.types";
11+
12+
export function SegmentedControl<Value extends string | number>(
13+
props: SegmentedControlProps<Value>,
14+
) {
15+
const { colorScheme, colors, themeId } = useControlTheme();
16+
const [layout, setLayout] = useState({ width: 0, height: 0 });
17+
const { width } = layout;
18+
const reduceMotion = useReducedMotion();
19+
const selectedIndex = props.options.findIndex((option) => option.value === props.selected);
20+
const segmentWidth = props.options.length ? Math.max(0, width - 6) / props.options.length : 0;
21+
const selectionOffset = selectedIndex * segmentWidth * (I18nManager.isRTL ? -1 : 1);
22+
const selectionStyle = useAnimatedStyle(() => ({
23+
width: segmentWidth,
24+
transform: [{ translateX: withTiming(selectionOffset, { duration: reduceMotion ? 0 : 160 }) }],
25+
}));
26+
const { trackColor, selectedColor, selectedTextColor, mutedColor } = segmentedControlColors(
27+
colors,
28+
colorScheme,
29+
props.variant,
30+
Platform.OS,
31+
themeId,
32+
);
33+
const minHeight = props.size === "compact" ? 32 : Platform.OS === "android" ? 40 : 36;
34+
35+
return (
36+
<View collapsable={false} className={props.className}>
37+
<View
38+
onLayout={(event) => setLayout(event.nativeEvent.layout)}
39+
className="flex-row rounded-full p-[3px]"
40+
style={{
41+
minHeight,
42+
backgroundColor: trackColor,
43+
}}
44+
>
45+
{selectedIndex >= 0 && width > 0 ? (
46+
<Animated.View
47+
pointerEvents="none"
48+
className="absolute bottom-[3px] start-[3px] top-[3px] rounded-full"
49+
style={[
50+
{
51+
backgroundColor: selectedColor,
52+
},
53+
selectionStyle,
54+
]}
55+
/>
56+
) : null}
57+
{props.options.map((option) => {
58+
const selected = option.value === props.selected;
59+
return (
60+
<Pressable
61+
key={`${typeof option.value}:${option.value}`}
62+
accessibilityRole={props.role ?? "button"}
63+
accessibilityLabel={option.accessibilityLabel ?? option.label}
64+
accessibilityState={{ selected }}
65+
onPress={() => props.onSelect(option.value)}
66+
className="flex-1 items-center justify-center rounded-full px-2 py-1 active:opacity-70"
67+
style={{ minHeight: minHeight - 6 }}
68+
>
69+
<AppText
70+
textRole="footnote"
71+
className={selected ? "font-t3-bold" : "font-t3-medium"}
72+
style={{
73+
color: selected ? selectedTextColor : mutedColor,
74+
}}
75+
>
76+
{option.label}
77+
</AppText>
78+
</Pressable>
79+
);
80+
})}
81+
</View>
82+
</View>
83+
);
84+
}
Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1 @@
1-
import { useState } from "react";
2-
import { I18nManager, Platform, Pressable, View } from "react-native";
3-
import Animated, { useAnimatedStyle, useReducedMotion, withTiming } from "react-native-reanimated";
4-
5-
import { AppText } from "./AppText";
6-
import { useControlTheme } from "./useControlTheme";
7-
import type { SegmentedControlProps } from "./SegmentedControl.types";
8-
9-
export type { SegmentedControlProps } from "./SegmentedControl.types";
10-
11-
export function SegmentedControl<Value extends string | number>(
12-
props: SegmentedControlProps<Value>,
13-
) {
14-
const { colorScheme, colors } = useControlTheme();
15-
const [layout, setLayout] = useState({ width: 0, height: 0 });
16-
const { width } = layout;
17-
const reduceMotion = useReducedMotion();
18-
const selectedIndex = props.options.findIndex((option) => option.value === props.selected);
19-
const segmentWidth = props.options.length ? Math.max(0, width - 6) / props.options.length : 0;
20-
const selectionOffset = selectedIndex * segmentWidth * (I18nManager.isRTL ? -1 : 1);
21-
const selectionStyle = useAnimatedStyle(() => ({
22-
width: segmentWidth,
23-
transform: [{ translateX: withTiming(selectionOffset, { duration: reduceMotion ? 0 : 160 }) }],
24-
}));
25-
const dark = colorScheme === "dark";
26-
const minHeight = props.size === "compact" ? 32 : Platform.OS === "android" ? 40 : 36;
27-
28-
return (
29-
<View collapsable={false} className={props.className}>
30-
<View
31-
onLayout={(event) => setLayout(event.nativeEvent.layout)}
32-
className="flex-row rounded-full p-[3px]"
33-
style={{
34-
minHeight,
35-
backgroundColor: colors[dark ? "--color-screen" : "--color-grouped-card"],
36-
}}
37-
>
38-
{selectedIndex >= 0 && width > 0 ? (
39-
<Animated.View
40-
pointerEvents="none"
41-
className="absolute bottom-[3px] start-[3px] top-[3px] rounded-full"
42-
style={[
43-
{
44-
backgroundColor: colors[dark ? "--color-secondary" : "--color-screen"],
45-
},
46-
selectionStyle,
47-
]}
48-
/>
49-
) : null}
50-
{props.options.map((option) => {
51-
const selected = option.value === props.selected;
52-
return (
53-
<Pressable
54-
key={`${typeof option.value}:${option.value}`}
55-
accessibilityRole={props.role ?? "button"}
56-
accessibilityLabel={option.accessibilityLabel ?? option.label}
57-
accessibilityState={{ selected }}
58-
onPress={() => props.onSelect(option.value)}
59-
className="flex-1 items-center justify-center rounded-full px-2 py-1 active:opacity-70"
60-
style={{ minHeight: minHeight - 6 }}
61-
>
62-
<AppText
63-
textRole="footnote"
64-
className={selected ? "font-t3-bold" : "font-t3-medium"}
65-
style={{
66-
color:
67-
colors[selected ? "--color-secondary-foreground" : "--color-foreground-muted"],
68-
}}
69-
>
70-
{option.label}
71-
</AppText>
72-
</Pressable>
73-
);
74-
})}
75-
</View>
76-
</View>
77-
);
78-
}
1+
export { SegmentedControl, type SegmentedControlProps } from "./SegmentedControl.shared";

‎apps/mobile/src/components/ui/SegmentedControl.types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface SegmentedControlProps<Value extends number | string> {
88
readonly onSelect: (value: Value) => void;
99
/** Compact uses a 32-point capsule; default uses 36 points on iOS and 40 on Android. */
1010
readonly size?: "default" | "compact";
11+
readonly variant?: "standalone" | "card";
1112
readonly role?: "tab" | "button";
1213
readonly className?: string;
1314
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import {
2+
flattenThemeColor,
3+
themeColorContrastRatio,
4+
themeColorWithAlpha,
5+
themeColorWithContrast,
6+
type MobileThemeAppearance,
7+
type MobileThemeId,
8+
type MobileThemeVariables,
9+
} from "../../lib/mobileTheme";
10+
import type { SegmentedControlProps } from "./SegmentedControl.types";
11+
12+
export function segmentedControlColors(
13+
colors: MobileThemeVariables,
14+
appearance: MobileThemeAppearance,
15+
variant: SegmentedControlProps<string>["variant"],
16+
platform: string,
17+
themeId: MobileThemeId,
18+
) {
19+
const dark = appearance === "dark";
20+
const card = variant === "card";
21+
const accent =
22+
colors[themeId === "material-you" ? "--color-primary" : "--color-prominent-action"];
23+
const trackColor = card
24+
? dark
25+
? colors["--color-screen"]
26+
: flattenThemeColor(
27+
themeColorWithAlpha(colors["--color-foreground"], 0.07),
28+
colors["--color-grouped-card"],
29+
)
30+
: flattenThemeColor(themeColorWithAlpha(accent, dark ? 0.1 : 0.07), colors["--color-screen"]);
31+
let selectedColor = colors["--color-secondary"];
32+
if (card && !dark) selectedColor = colors["--color-screen"];
33+
if (dark && (!card || themeId === "t3-code")) {
34+
selectedColor = flattenThemeColor(themeColorWithAlpha(accent, 0.32), colors["--color-screen"]);
35+
}
36+
let selectedTextColor =
37+
colors[!card && dark ? "--color-foreground" : "--color-secondary-foreground"];
38+
if (!card && !dark && platform === "android") {
39+
const selection = colors["--color-thread-selected"];
40+
if (
41+
themeColorContrastRatio(selection, trackColor) >
42+
themeColorContrastRatio(selectedColor, trackColor)
43+
) {
44+
selectedColor = selection;
45+
selectedTextColor = colors["--color-thread-selected-foreground"];
46+
}
47+
}
48+
return {
49+
trackColor,
50+
selectedColor,
51+
selectedTextColor: themeColorWithContrast(selectedTextColor, selectedColor),
52+
mutedColor: themeColorWithContrast(
53+
colors["--color-foreground-muted"],
54+
trackColor,
55+
dark && !card ? 7 : 4.5,
56+
),
57+
};
58+
}

0 commit comments

Comments
 (0)