Skip to content

Commit 8f2a9c3

Browse files
committed
Merge upstream/main into t3code/storage-settings-layers
2 parents 2f95fcf + 60aec28 commit 8f2a9c3

8 files changed

Lines changed: 325 additions & 115 deletions

File tree

‎apps/marketing/src/lib/site.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,25 @@ export const IOS_APP_STORE_URL =
66
export const ANDROID_PLAY_STORE_URL =
77
"https://play.google.com/store/apps/details?id=com.t3tools.t3code";
88

9+
// Runs at build time, so each deploy picks up the current count.
10+
async function fetchGithubStars(): Promise<string> {
11+
const token = process.env.GITHUB_TOKEN;
12+
try {
13+
const response = await fetch("https://api.github.com/repos/pingdotgg/t3code", {
14+
headers: token ? { Authorization: `Bearer ${token}` } : {},
15+
});
16+
if (!response.ok) throw new Error(`GitHub API responded ${response.status}`);
17+
const { stargazers_count: stars } = (await response.json()) as { stargazers_count: number };
18+
return stars < 1000 ? String(stars) : `${Math.floor(stars / 1000)}k+`;
19+
} catch (error) {
20+
// A deploy must not ship a made-up count; offline dev should still render.
21+
if (import.meta.env.PROD) throw new Error("Could not fetch GitHub stars", { cause: error });
22+
console.warn("Could not fetch GitHub stars", error);
23+
return "?";
24+
}
25+
}
26+
927
export const MARKETING_STATS = {
10-
githubStars: "40k+",
28+
githubStars: await fetchGithubStars(),
1129
users: "500,000",
1230
} as const;

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

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,22 @@ function AdaptiveWorkspaceLayoutContent(
825825
0,
826826
viewportWidth -
827827
renderedRailWidth.value -
828-
renderedSidebarWidth.value -
828+
(workspacePage ? 0 : renderedSidebarWidth.value) -
829829
renderedInspectorWidth.value,
830830
),
831831
);
832+
// Android can resize the native row before React removes its split panes on a fold.
833+
const androidSplit = Platform.OS === "android" && layout.usesSplitView;
834+
const androidContentSlotStyle = useAnimatedStyle(() => ({
835+
width: androidSplit ? renderedContentWidth.value : ("100%" as const),
836+
}));
837+
// While the sidebar animates, clip the settled navigator instead of reflowing its text every frame.
838+
const androidNavigatorLimit = useAnimatedStyle(() => ({
839+
maxWidth:
840+
androidSplit && contentTargetWidth !== null && renderedContentWidth.value < contentTargetWidth
841+
? contentTargetWidth
842+
: ("100%" as const),
843+
}));
832844

833845
const handleSelectThread = (thread: EnvironmentThreadShell) => {
834846
handleSelectThreadRoute({
@@ -899,11 +911,11 @@ function AdaptiveWorkspaceLayoutContent(
899911
>
900912
<AndroidHingeObserver onChange={handleHingeChange} />
901913
{shouldRenderNavigationRail ? (
902-
<Animated.View className="self-stretch" style={railAnimatedStyle} />
914+
<Animated.View className="shrink self-stretch" style={railAnimatedStyle} />
903915
) : null}
904916
{shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (
905917
<Animated.View
906-
className="self-stretch overflow-hidden"
918+
className="self-stretch overflow-hidden android:shrink"
907919
accessibilityElementsHidden={workspacePage || !panes.primarySidebarVisible}
908920
collapsable={false}
909921
importantForAccessibility={
@@ -966,26 +978,28 @@ function AdaptiveWorkspaceLayoutContent(
966978
</Animated.View>
967979
</Animated.View>
968980
) : null}
969-
<View
981+
<Animated.View
970982
className={
971983
Platform.OS === "android"
972-
? "flex-1 overflow-hidden bg-header"
984+
? "max-w-full shrink-0 overflow-hidden bg-header"
973985
: "flex-1 overflow-hidden bg-screen"
974986
}
987+
style={Platform.OS === "android" ? androidContentSlotStyle : undefined}
975988
collapsable={false}
976989
>
977-
<View
990+
<Animated.View
978991
collapsable={false}
979-
style={
992+
style={[
980993
contentTargetWidth !== null
981994
? {
982995
flex: 1,
983996
width: contentTargetWidth,
984997
alignSelf: contentAnchor.end ? "flex-end" : "flex-start",
985998
marginRight: contentAnchor.end ? contentEndGap : 0,
986999
}
987-
: { flex: 1 }
988-
}
1000+
: { flex: 1 },
1001+
Platform.OS === "android" ? androidNavigatorLimit : undefined,
1002+
]}
9891003
>
9901004
{/* Android holds the content still, so its floating controls keep its width. */}
9911005
<WorkspaceContentWidthContext
@@ -1028,8 +1042,8 @@ function AdaptiveWorkspaceLayoutContent(
10281042
) : null}
10291043
</WorkspaceSettledContentWidthContext>
10301044
</WorkspaceContentWidthContext>
1031-
</View>
1032-
</View>
1045+
</Animated.View>
1046+
</Animated.View>
10331047
<WorkspaceInspectorPane
10341048
pathname={props.pathname}
10351049
renderedInspectorWidth={renderedInspectorWidth}
@@ -1040,11 +1054,14 @@ function AdaptiveWorkspaceLayoutContent(
10401054
onClosed={handleWorkspaceInspectorClosed}
10411055
/>
10421056
{shouldRenderNavigationRail && navigationRailWidth > 0 ? (
1043-
// The rail reserves its slot above and draws over the panes, so it can widen over
1044-
// the list in place. It takes the whole workspace only while it is open.
1057+
// Its trailing inset clips the old rail as soon as Android fits the workspace to a cover display.
10451058
<View
1046-
className="absolute inset-y-0 left-0"
1047-
style={railOverlay ? { right: 0 } : { width: navigationRailWidth }}
1059+
className="absolute inset-y-0 left-0 overflow-hidden"
1060+
style={
1061+
railOverlay
1062+
? { right: 0 }
1063+
: { right: viewportWidth - navigationRailWidth, maxWidth: navigationRailWidth }
1064+
}
10481065
>
10491066
<AndroidWorkspaceNavigation
10501067
onNewThread={handleStartNewTask}

‎apps/mobile/src/features/threads/ComposerPopoverHost.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function useComposerPopoverHost() {
1919
/** Mount inside KeyboardStickyView for Android gestures. Hide explicitly because portal content outlives its subtree. */
2020
export function ComposerPopoverHost(props: {
2121
readonly hidden: boolean;
22+
readonly inFlow?: boolean;
2223
readonly popoverHeight: SharedValue<number>;
2324
readonly children: ReactNode;
2425
}) {
@@ -33,8 +34,8 @@ export function ComposerPopoverHost(props: {
3334
ref={hostRef}
3435
collapsable={false}
3536
pointerEvents="box-none"
36-
className="absolute inset-0"
37-
onLayout={() => setLayoutVersion((version) => version + 1)}
37+
className={props.inFlow ? undefined : "absolute inset-0"}
38+
onLayout={props.hidden ? undefined : () => setLayoutVersion((version) => version + 1)}
3839
>
3940
{props.children}
4041
{props.hidden ? null : content}

‎apps/mobile/src/features/threads/PendingUserInputCard.tsx‎

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ import {
1010
import { useRef } from "react";
1111
import { Platform, Pressable, ScrollView, View, type LayoutChangeEvent } from "react-native";
1212
import Animated, {
13-
Easing,
14-
FadeInUp,
15-
FadeOutDown,
1613
useAnimatedStyle,
1714
useSharedValue,
1815
type DerivedValue,
1916
type SharedValue,
2017
} from "react-native-reanimated";
2118

22-
import { USER_INPUT_TOGGLE_DURATION_MS } from "./pendingUserInputLayout";
23-
2419
import { SymbolView } from "../../components/ui/AppSymbol";
2520
import { AppText as Text } from "../../components/ui/AppText";
2621
import { ControlPill } from "../../components/ui/ControlPill";
@@ -43,8 +38,8 @@ export interface PendingUserInputCardProps {
4338
readonly collapsed: boolean;
4439
readonly onToggleCollapsed: () => void;
4540
readonly onStopThread?: () => void;
46-
readonly cardProgress?: SharedValue<number>;
47-
readonly cardCoverage?: SharedValue<number>;
41+
readonly cardProgress: SharedValue<number>;
42+
readonly cardCoverage: SharedValue<number>;
4843
readonly onInputFocusChange?: (focused: boolean) => void;
4944
readonly drafts: Record<string, PendingUserInputDraftAnswer>;
5045
readonly answers: Record<string, string | ReadonlyArray<string>> | null;
@@ -63,9 +58,6 @@ export interface PendingUserInputCardProps {
6358
readonly onDismiss: () => Promise<unknown>;
6459
}
6560

66-
/** Android cannot hit-test overlays beyond their parent's bounds; render its expanded card in-flow. */
67-
const EXPANDED_CARD_IS_OVERLAY = Platform.OS === "ios";
68-
6961
function proseDirectionStyle(text: string, setDirection: TextDirection | undefined) {
7062
const direction = textDirection(text);
7163
return {
@@ -111,14 +103,11 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
111103
.join(" "),
112104
);
113105

114-
const cardCoverage = props.cardCoverage;
106+
const { cardCoverage, cardProgress, maxHeight } = props;
115107
const barHeightRef = useRef(0);
116108
const cardHeightRef = useRef(0);
117109
const cardHeight = useSharedValue(0);
118110
const notifyCoverage = () => {
119-
if (!cardCoverage) {
120-
return;
121-
}
122111
// The card resizes with the keyboard every frame, so easing each sample would leave the
123112
// feed inset and floating controls trailing it.
124113
cardCoverage.set(Math.max(0, cardHeightRef.current - barHeightRef.current));
@@ -132,22 +121,25 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
132121
cardHeight.set(event.nativeEvent.layout.height);
133122
notifyCoverage();
134123
};
135-
const cardProgress = props.cardProgress;
136-
const maxHeight = props.maxHeight;
137124
const cardAnimatedStyle = useAnimatedStyle(() => {
138-
const progress = cardProgress === undefined ? 1 : cardProgress.value;
125+
const progress = cardProgress.value;
126+
const travel = Platform.OS === "android" ? cardCoverage.value : cardHeight.value;
139127
return {
140128
maxHeight: maxHeight.value,
141-
transform: [{ translateY: (1 - progress) * cardHeight.value }],
129+
opacity:
130+
Platform.OS === "android"
131+
? Math.min(1, (progress * cardHeight.value) / Math.max(1, cardHeight.value - travel))
132+
: 1,
133+
transform: [{ translateY: (1 - progress) * travel }],
142134
};
143135
});
144-
const cardMaxHeightStyle = useAnimatedStyle(() => ({ maxHeight: maxHeight.value }));
136+
// Android hit-tests inside the parent; its height is also the space the card takes below the feed.
137+
const androidBoundsStyle = useAnimatedStyle(() => ({
138+
paddingTop: cardCoverage.value * cardProgress.value,
139+
}));
145140
const overlayHeightStyle = useAnimatedStyle(() => ({ height: maxHeight.value }));
146141

147-
// Keep the iOS card mounted so expansion starts on the UI thread without waiting for React layout.
148-
const renderCard = EXPANDED_CARD_IS_OVERLAY || !props.collapsed;
149-
const showBar = props.collapsed || EXPANDED_CARD_IS_OVERLAY;
150-
const bar = showBar ? (
142+
const bar = (
151143
<View
152144
onLayout={handleBarLayout}
153145
pointerEvents={props.collapsed ? "auto" : "none"}
@@ -188,25 +180,15 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
188180
/>
189181
) : null}
190182
</View>
191-
) : null;
192-
const card = renderCard ? (
183+
);
184+
const card = (
193185
<Animated.View
194186
onLayout={handleCardLayout}
195187
pointerEvents={props.collapsed ? "none" : "auto"}
196188
accessibilityElementsHidden={props.collapsed}
197189
importantForAccessibility={props.collapsed ? "no-hide-descendants" : "auto"}
198-
entering={
199-
EXPANDED_CARD_IS_OVERLAY
200-
? undefined
201-
: FadeInUp.duration(USER_INPUT_TOGGLE_DURATION_MS).easing(Easing.out(Easing.cubic))
202-
}
203-
exiting={
204-
EXPANDED_CARD_IS_OVERLAY
205-
? undefined
206-
: FadeOutDown.duration(USER_INPUT_TOGGLE_DURATION_MS).easing(Easing.out(Easing.cubic))
207-
}
208190
className="overflow-hidden gap-2.5 rounded-[20px] border border-border bg-card-alt p-4"
209-
style={EXPANDED_CARD_IS_OVERLAY ? cardAnimatedStyle : cardMaxHeightStyle}
191+
style={cardAnimatedStyle}
210192
>
211193
<Pressable
212194
accessibilityRole="button"
@@ -345,21 +327,20 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
345327
</Text>
346328
) : null}
347329
</Animated.View>
348-
) : null;
330+
);
349331
return (
350-
<View className="relative">
332+
<Animated.View
333+
className="relative"
334+
style={Platform.OS === "android" ? androidBoundsStyle : undefined}
335+
>
351336
{bar}
352-
{EXPANDED_CARD_IS_OVERLAY ? (
353-
<Animated.View
354-
pointerEvents={props.collapsed ? "none" : "box-none"}
355-
className="absolute inset-x-0 bottom-0 justify-end overflow-hidden"
356-
style={overlayHeightStyle}
357-
>
358-
{card}
359-
</Animated.View>
360-
) : (
361-
card
362-
)}
363-
</View>
337+
<Animated.View
338+
pointerEvents={props.collapsed ? "none" : "box-none"}
339+
className="absolute inset-x-0 bottom-0 justify-end overflow-hidden"
340+
style={overlayHeightStyle}
341+
>
342+
{card}
343+
</Animated.View>
344+
</Animated.View>
364345
);
365346
}

0 commit comments

Comments
 (0)