Skip to content

Commit 89d48bb

Browse files
Merge remote-tracking branch 'origin/main' into pr-24741
2 parents cf82adf + 401b017 commit 89d48bb

141 files changed

Lines changed: 5878 additions & 2032 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.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Agent Context Budget
2+
3+
# Fails when a PR raises a value in agentContextBudget.json above main's. AgentContextBudget.test.ts
4+
# keeps that file equal to the measured context, so the context cannot grow by editing the file.
5+
# To accept growth on purpose, a maintainer adds the agent-context-increase label.
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, reopened, labeled, unlabeled]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: agent-context-budget-${{ github.event.pull_request.number }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
budget:
19+
name: Agent context budget
20+
runs-on: ubuntu-24.04
21+
timeout-minutes: 5
22+
env:
23+
BUDGET: apps/server/src/provider/agentContextBudget.json
24+
ALLOW_INCREASE: ${{ contains(github.event.pull_request.labels.*.name, 'agent-context-increase') }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v6
28+
with:
29+
sparse-checkout: apps/server/src/provider/agentContextBudget.json
30+
sparse-checkout-cone-mode: false
31+
32+
- name: Compare with main
33+
run: |
34+
git fetch --quiet --depth=1 origin main
35+
if ! git cat-file -e "FETCH_HEAD:$BUDGET" 2>/dev/null; then
36+
echo "main has no agent context budget yet."
37+
exit 0
38+
fi
39+
git show "FETCH_HEAD:$BUDGET" > "$RUNNER_TEMP/main.json"
40+
grown=$(jq -r --slurpfile main "$RUNNER_TEMP/main.json" '
41+
to_entries[]
42+
| select($main[0][.key] != null and .value > $main[0][.key])
43+
| "\(.key): \($main[0][.key]) -> \(.value) (+\(.value - $main[0][.key]))"
44+
' "$BUDGET")
45+
if [ -z "$grown" ]; then
46+
echo "Agent context is not larger than main."
47+
exit 0
48+
fi
49+
printf 'Agent context grew compared to main:\n%s\n' "$grown"
50+
if [ "$ALLOW_INCREASE" = "true" ]; then
51+
echo "Accepted by the agent-context-increase label."
52+
exit 0
53+
fi
54+
echo "::error file=$BUDGET::Agent context grew compared to main. Cut the added text, or ask a maintainer to add the agent-context-increase label."
55+
exit 1

‎apps/desktop/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@t3tools/desktop",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"private": true,
55
"type": "module",
66
"main": "dist-electron/boot.cjs",

‎apps/mobile/src/App.tsx‎

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ import { ThreadArrangementHost } from "./features/threads/ThreadArrangementSheet
2121
import * as Dialog from "./components/ui/Dialog";
2222
import { CloudAuthProvider } from "./features/cloud/CloudAuthProvider";
2323
import { prepareNativeShowcaseCapture } from "./features/showcase/nativeShowcaseScene";
24-
import { IncomingShareProvider } from "./features/sharing/IncomingShareProvider";
24+
import {
25+
presentPendingIncomingShare,
26+
startIncomingShareInbox,
27+
} from "./features/sharing/IncomingShareProvider";
2528
import {
2629
AppearancePreferencesProvider,
30+
installAppearanceRuntime,
2731
useAppearancePreferences,
2832
} from "./features/settings/appearance/AppearancePreferencesProvider";
2933
import { RootStack } from "./Stack";
@@ -40,8 +44,9 @@ import {
4044
type FoundationHotModule,
4145
} from "./lib/foundation-fast-refresh";
4246
import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
43-
import { useUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
47+
import { installUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
4448
import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
49+
import { installSubscriptionUsageRefresh } from "./widgets/useSubscriptionUsage";
4550
import { GlobalVoiceInputControl } from "./features/voice-input/GlobalVoiceInputControl";
4651
import { restoreSettingsLinkState } from "./features/settings/settings-navigation";
4752
import {
@@ -90,6 +95,7 @@ const Navigation = createStaticNavigation(RootStack);
9095
function handleNavigationStateChange(state: NavigationState | undefined): void {
9196
recordWorkspaceSelections(state);
9297
if (state) pruneNewTaskBranchCheckouts(state);
98+
presentPendingIncomingShare();
9399
}
94100

95101
function handleNavigationReady(): void {
@@ -99,9 +105,19 @@ function handleNavigationReady(): void {
99105
declare const module: { readonly hot?: FoundationHotModule } | undefined;
100106

101107
const appServiceDisposers = [
108+
installUiRuntimeMemoryWarningGc(),
109+
subscribeComposerDraftModelReconciliation({
110+
registry: appAtomRegistry,
111+
threadShellAtom: environmentThreadShells.threadShellAtom,
112+
threadRefsAtom: environmentThreadShells.threadRefsAtom,
113+
shellStateAtom: environmentShell.stateAtom,
114+
}),
115+
installAppearanceRuntime(),
116+
installSubscriptionUsageRefresh(),
102117
installPermissionUpdateNotice(),
103118
installThreadOutboxDelivery(),
104119
installComposerAttachmentUploads(),
120+
startIncomingShareInbox(),
105121
];
106122
disposeOnFoundationReplace(typeof module === "undefined" ? undefined : module.hot, () => {
107123
for (const dispose of appServiceDisposers) dispose();
@@ -118,18 +134,6 @@ function SplashScreenCoordinator() {
118134
}
119135

120136
export default function App() {
121-
useUiRuntimeMemoryWarningGc();
122-
useEffect(
123-
() =>
124-
subscribeComposerDraftModelReconciliation({
125-
registry: appAtomRegistry,
126-
threadShellAtom: environmentThreadShells.threadShellAtom,
127-
threadRefsAtom: environmentThreadShells.threadRefsAtom,
128-
shellStateAtom: environmentShell.stateAtom,
129-
}),
130-
[],
131-
);
132-
133137
return (
134138
<RegistryContext.Provider value={appAtomRegistry}>
135139
<CloudAuthProvider>
@@ -156,15 +160,13 @@ function AppContent() {
156160
{/* native-stack needs the theme's dark flag to select dark native headers. */}
157161
<GlobalVoiceInputControl>
158162
<NativeLayoutMetricsProvider>
159-
<IncomingShareProvider>
160-
<Navigation
161-
ref={attachRootNavigation}
162-
linking={appLinking}
163-
onReady={handleNavigationReady}
164-
theme={navigationTheme}
165-
onStateChange={handleNavigationStateChange}
166-
/>
167-
</IncomingShareProvider>
163+
<Navigation
164+
ref={attachRootNavigation}
165+
linking={appLinking}
166+
onReady={handleNavigationReady}
167+
theme={navigationTheme}
168+
onStateChange={handleNavigationStateChange}
169+
/>
168170
<Dialog.Host />
169171
<ThreadArrangementHost />
170172
<ProjectChipIconRasterizer />

‎apps/mobile/src/Stack.tsx‎

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
createNativeStackScreen,
1616
type NativeStackNavigationOptions,
1717
} from "@react-navigation/native-stack";
18-
import { useEffect, useRef, type ReactNode } from "react";
18+
import type { ReactNode } from "react";
1919
import { Platform, Pressable, ScrollView, StyleSheet, useWindowDimensions } from "react-native";
2020
import { useResolveClassNames } from "uniwind";
2121

@@ -139,20 +139,12 @@ import {
139139
SettingsLegalDocumentExternalHeaderButton,
140140
} from "./features/settings/components/SettingsLegalDocumentRouteScreen";
141141
import { useAppShortcuts } from "./features/shortcuts/useAppShortcuts";
142-
import { useIncomingShare } from "./features/sharing/IncomingShareProvider";
143-
import {
144-
EMPTY_INCOMING_SHARE_PRESENTATION_STATE,
145-
transitionIncomingSharePresentation,
146-
} from "./features/sharing/incoming-share-presentation";
147142
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native/native-glass";
148143
import { deriveLayout } from "./lib/layout";
149144
import { useNativeLayoutMetrics } from "./native/native-layout-metrics";
150145
import { nativeHeaderScrollEdgeEffects } from "./native/StackHeader";
151146
import { HORIZONTAL_FORM_SHEET_OPTIONS, formSheetDetents } from "./native/sheet-surface";
152-
import {
153-
selectWorkspaceDetail,
154-
workspaceDetailRouter,
155-
} from "./features/workspace/workspace-detail-selection";
147+
import { workspaceDetailRouter } from "./features/workspace/workspace-detail-selection";
156148

157149
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
158150

@@ -498,9 +490,6 @@ function RootStackLayout(props: {
498490
readonly children: React.ReactNode;
499491
readonly state: NavigationState;
500492
}) {
501-
const navigation = useNavigation();
502-
const { pendingShare } = useIncomingShare();
503-
const sharePresentationRef = useRef(EMPTY_INCOMING_SHARE_PRESENTATION_STATE);
504493
const path = getPathFromState(props.state, navigationPathConfig);
505494
const pathname = path.startsWith("/") ? path : `/${path}`;
506495
const workspaceLocation = workspaceLocationFromState(props.state);
@@ -519,22 +508,6 @@ function RootStackLayout(props: {
519508
useAgentNotificationNavigation(workspaceLocation.pathname);
520509
useConnectOnboardingNavigation();
521510
useAppShortcuts(props.state);
522-
useEffect(() => {
523-
const transition = transitionIncomingSharePresentation(sharePresentationRef.current, {
524-
isShareSheetPresented: isDraftThreadRoute(props.state.routes[props.state.index]),
525-
pendingShareId: pendingShare?.id ?? null,
526-
});
527-
sharePresentationRef.current = transition.state;
528-
if (!transition.shareIdToPresent) {
529-
return;
530-
}
531-
navigation.dispatch(
532-
selectWorkspaceDetail({
533-
name: "Thread",
534-
params: { draft: { incomingShareId: transition.shareIdToPresent } },
535-
}),
536-
);
537-
}, [navigation, pendingShare, props.state]);
538511

539512
return (
540513
<NewTaskFlowProvider active={isDraftThreadRoute(draftRoute)} routeDraftId={routeDraftId}>

‎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+
}

0 commit comments

Comments
 (0)