Skip to content

Commit 9e54016

Browse files
Yih-Chun HuYih-Chun Hu
authored andcommitted
chore: merge main into snooze customization
2 parents 06a4c2f + 6bbb2d8 commit 9e54016

360 files changed

Lines changed: 14880 additions & 4676 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/desktop/src/window/DesktopWindow.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function getIconOption(
131131
}
132132

133133
function getInitialWindowBackgroundColor(shouldUseDarkColors: boolean): string {
134-
return shouldUseDarkColors ? "#0a0a0a" : "#ffffff";
134+
return shouldUseDarkColors ? "#000000" : "#ffffff";
135135
}
136136

137137
type DisplayBounds = Pick<Electron.Rectangle, "x" | "y" | "width" | "height">;

‎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: 85 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ 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,
12+
CommonActions,
13+
createPathConfigForStaticNavigation,
1314
createStaticNavigation,
1415
getActionFromState,
1516
getStateFromPath,
17+
type NavigationAction,
18+
type NavigationState,
1619
} from "@react-navigation/native";
1720

1821
import { RegistryContext } from "@effect/atom-react";
@@ -21,12 +24,24 @@ import { ThreadArrangementHost } from "./features/threads/ThreadArrangementSheet
2124
import * as Dialog from "./components/ui/Dialog";
2225
import { CloudAuthProvider } from "./features/cloud/CloudAuthProvider";
2326
import { prepareNativeShowcaseCapture } from "./features/showcase/nativeShowcaseScene";
24-
import { IncomingShareProvider } from "./features/sharing/IncomingShareProvider";
27+
import {
28+
presentPendingIncomingShare,
29+
startIncomingShareInbox,
30+
} from "./features/sharing/IncomingShareProvider";
31+
import {
32+
installAgentNotificationNavigation,
33+
setAgentNotificationPathname,
34+
} from "./features/agent-awareness/notificationNavigation";
35+
import {
36+
installAppShortcuts,
37+
recordAppShortcutNavigationState,
38+
} from "./features/shortcuts/appShortcutsRuntime";
2539
import {
2640
AppearancePreferencesProvider,
41+
installAppearanceRuntime,
2742
useAppearancePreferences,
2843
} from "./features/settings/appearance/AppearancePreferencesProvider";
29-
import { RootStack } from "./Stack";
44+
import { RootStack, workspaceLocationFromState } from "./Stack";
3045
import { appAtomRegistry } from "./state/atom-registry";
3146
import { subscribeComposerDraftModelReconciliation } from "./state/use-composer-drafts";
3247
import { environmentThreadShells } from "./state/threads";
@@ -40,8 +55,9 @@ import {
4055
type FoundationHotModule,
4156
} from "./lib/foundation-fast-refresh";
4257
import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
43-
import { useUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
58+
import { installUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
4459
import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
60+
import { installSubscriptionUsageRefresh } from "./widgets/useSubscriptionUsage";
4561
import { GlobalVoiceInputControl } from "./features/voice-input/GlobalVoiceInputControl";
4662
import { restoreSettingsLinkState } from "./features/settings/settings-navigation";
4763
import {
@@ -52,6 +68,13 @@ import {
5268
} from "./features/workspace/workspace-selection-store";
5369
import { workspaceDetailLinkAction } from "./features/workspace/workspace-detail-selection";
5470
import { NativeLayoutMetricsProvider } from "./native/native-layout-metrics";
71+
import {
72+
attachRootNavigation,
73+
flushRootNavigationQueue,
74+
linkToRootPath,
75+
rootNavigationRef,
76+
} from "./lib/rootNavigation";
77+
import { pruneNewTaskBranchCheckouts } from "./features/threads/NewTaskDraftRouteScreen";
5578

5679
import "../global.css";
5780

@@ -62,6 +85,20 @@ if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
6285
void SplashScreen.preventAutoHideAsync().catch(() => {});
6386
void hydrateWorkspaceSelections();
6487

88+
const linkingConfig = {
89+
initialRouteName: "Home",
90+
screens: createPathConfigForStaticNavigation(RootStack, { initialRouteName: "Home" }) ?? {},
91+
} as const;
92+
93+
function getAppStateFromPath(path: string, options: Parameters<typeof getStateFromPath>[1]) {
94+
return takeScheduledTaskNewLink(
95+
restoreSettingsLinkState(
96+
restoreDraftLinkState(getStateFromPath(path, options), path),
97+
settingsLinkPage(),
98+
),
99+
);
100+
}
101+
65102
const appLinking = {
66103
prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
67104
config: { initialRouteName: "Home" },
@@ -74,24 +111,53 @@ const appLinking = {
74111
// Our router handles the selection; React Navigation's type only lists its own actions.
75112
(workspaceDetailLinkAction(state) as ReturnType<typeof getActionFromState>) ??
76113
getActionFromState(state, options),
77-
getStateFromPath: (path: string, options: Parameters<typeof getStateFromPath>[1]) =>
78-
takeScheduledTaskNewLink(
79-
restoreSettingsLinkState(
80-
restoreDraftLinkState(getStateFromPath(path, options), path),
81-
settingsLinkPage(),
82-
),
83-
),
114+
getStateFromPath: getAppStateFromPath,
84115
};
85116

117+
function appLinkAction(href: string): NavigationAction {
118+
const state = getAppStateFromPath(href, linkingConfig);
119+
if (!state) throw new Error(`Failed to parse the href to a navigation state (${href}).`);
120+
return appLinking.getActionFromState(state, linkingConfig) ?? CommonActions.reset(state);
121+
}
122+
123+
function linkToAppPath(href: string): void {
124+
linkToRootPath(href, appLinkAction);
125+
}
126+
86127
const Navigation = createStaticNavigation(RootStack);
87-
const navigationRef = createNavigationContainerRef();
128+
129+
function handleNavigationStateChange(state: NavigationState | undefined): void {
130+
recordWorkspaceSelections(state);
131+
presentPendingIncomingShare();
132+
if (!state) return;
133+
setAgentNotificationPathname(workspaceLocationFromState(state).pathname);
134+
recordAppShortcutNavigationState(state);
135+
pruneNewTaskBranchCheckouts(state);
136+
}
137+
138+
function handleNavigationReady(): void {
139+
handleNavigationStateChange(rootNavigationRef.getRootState());
140+
flushRootNavigationQueue();
141+
}
88142

89143
declare const module: { readonly hot?: FoundationHotModule } | undefined;
90144

91145
const appServiceDisposers = [
146+
installUiRuntimeMemoryWarningGc(),
147+
subscribeComposerDraftModelReconciliation({
148+
registry: appAtomRegistry,
149+
threadShellAtom: environmentThreadShells.threadShellAtom,
150+
threadRefsAtom: environmentThreadShells.threadRefsAtom,
151+
shellStateAtom: environmentShell.stateAtom,
152+
}),
153+
installAppearanceRuntime(),
154+
installSubscriptionUsageRefresh(),
92155
installPermissionUpdateNotice(),
93156
installThreadOutboxDelivery(),
94157
installComposerAttachmentUploads(),
158+
startIncomingShareInbox(),
159+
installAgentNotificationNavigation(linkToAppPath),
160+
installAppShortcuts(linkToAppPath),
95161
];
96162
disposeOnFoundationReplace(typeof module === "undefined" ? undefined : module.hot, () => {
97163
for (const dispose of appServiceDisposers) dispose();
@@ -108,18 +174,6 @@ function SplashScreenCoordinator() {
108174
}
109175

110176
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-
123177
return (
124178
<RegistryContext.Provider value={appAtomRegistry}>
125179
<CloudAuthProvider>
@@ -146,15 +200,13 @@ function AppContent() {
146200
{/* native-stack needs the theme's dark flag to select dark native headers. */}
147201
<GlobalVoiceInputControl>
148202
<NativeLayoutMetricsProvider>
149-
<IncomingShareProvider>
150-
<Navigation
151-
ref={navigationRef}
152-
linking={appLinking}
153-
onReady={() => recordWorkspaceSelections(navigationRef.getRootState())}
154-
theme={navigationTheme}
155-
onStateChange={recordWorkspaceSelections}
156-
/>
157-
</IncomingShareProvider>
203+
<Navigation
204+
ref={attachRootNavigation}
205+
linking={appLinking}
206+
onReady={handleNavigationReady}
207+
theme={navigationTheme}
208+
onStateChange={handleNavigationStateChange}
209+
/>
158210
<Dialog.Host />
159211
<ThreadArrangementHost />
160212
<ProjectChipIconRasterizer />

‎apps/mobile/src/Stack.tsx‎

Lines changed: 13 additions & 36 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

@@ -24,6 +24,11 @@ import { androidWorkspaceDestinationAnimation } from "./lib/android-workspace-na
2424
import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
2525
import { WorkspaceConnectionStatusProvider } from "./features/home/WorkspaceConnectionTitle";
2626
import { WorkspaceRootScreen } from "./features/workspace/WorkspaceRootScreen";
27+
import {
28+
recordHomeFocus,
29+
recordHomeTransitionEnd,
30+
recordHomeTransitionStart,
31+
} from "./features/home/home-route-visibility";
2732
import { AndroidWorkspaceTabsProvider } from "./features/workspace/AndroidWorkspaceTabsProvider";
2833
import {
2934
PullRequestRouteScreen,
@@ -41,9 +46,7 @@ import {
4146
type RenderFailureProps,
4247
} from "./components/RenderErrorBoundary";
4348
import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen";
44-
import { useAgentNotificationNavigation } from "./features/agent-awareness/notificationNavigation";
4549
import { ConnectOnboardingRouteScreen } from "./features/cloud/ConnectOnboardingRouteScreen";
46-
import { useConnectOnboardingNavigation } from "./features/cloud/connectOnboardingNavigation";
4750
import { AttachmentFileScreen } from "./features/files/AttachmentFileScreen";
4851
import { ThreadFilesTreeScreen, ThreadFileScreen } from "./features/files/ThreadFilesRouteScreen";
4952
import { AdaptiveWorkspaceLayout } from "./features/layout/AdaptiveWorkspaceLayout";
@@ -138,21 +141,12 @@ import {
138141
SettingsLegalDocumentCloseHeaderButton,
139142
SettingsLegalDocumentExternalHeaderButton,
140143
} from "./features/settings/components/SettingsLegalDocumentRouteScreen";
141-
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";
147144
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native/native-glass";
148145
import { deriveLayout } from "./lib/layout";
149146
import { useNativeLayoutMetrics } from "./native/native-layout-metrics";
150147
import { nativeHeaderScrollEdgeEffects } from "./native/StackHeader";
151148
import { HORIZONTAL_FORM_SHEET_OPTIONS, formSheetDetents } from "./native/sheet-surface";
152-
import {
153-
selectWorkspaceDetail,
154-
workspaceDetailRouter,
155-
} from "./features/workspace/workspace-detail-selection";
149+
import { workspaceDetailRouter } from "./features/workspace/workspace-detail-selection";
156150

157151
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
158152

@@ -481,7 +475,7 @@ const SETTINGS_SCREENS = {
481475
// iOS 26 header morphing requires one UINavigationBar; nested stacks make the whole screen slide.
482476
const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId";
483477

484-
function workspaceLocationFromState(state: NavigationState) {
478+
export function workspaceLocationFromState(state: NavigationState) {
485479
const routes = state.routes.filter((route) => !isWorkspaceOverlayRoute(route.name));
486480
const effectiveState =
487481
routes.length > 0 && routes.length !== state.routes.length
@@ -498,9 +492,6 @@ function RootStackLayout(props: {
498492
readonly children: React.ReactNode;
499493
readonly state: NavigationState;
500494
}) {
501-
const navigation = useNavigation();
502-
const { pendingShare } = useIncomingShare();
503-
const sharePresentationRef = useRef(EMPTY_INCOMING_SHARE_PRESENTATION_STATE);
504495
const path = getPathFromState(props.state, navigationPathConfig);
505496
const pathname = path.startsWith("/") ? path : `/${path}`;
506497
const workspaceLocation = workspaceLocationFromState(props.state);
@@ -516,25 +507,6 @@ function RootStackLayout(props: {
516507
const routeDraftId = Array.isArray(draftParams?.draftId)
517508
? draftParams.draftId[0]
518509
: draftParams?.draftId;
519-
useAgentNotificationNavigation(workspaceLocation.pathname);
520-
useConnectOnboardingNavigation();
521-
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]);
538510

539511
return (
540512
<NewTaskFlowProvider active={isDraftThreadRoute(draftRoute)} routeDraftId={routeDraftId}>
@@ -619,6 +591,11 @@ const RootStackConfig = createWorkspaceStackNavigator({
619591
Home: createNativeStackScreen({
620592
screen: WorkspaceRootScreen,
621593
linking: "",
594+
listeners: {
595+
transitionStart: ({ data }) => recordHomeTransitionStart(data.closing),
596+
transitionEnd: ({ data }) => recordHomeTransitionEnd(data.closing),
597+
focus: recordHomeFocus,
598+
},
622599
options: {
623600
...GLASS_HEADER_OPTIONS,
624601
...FIXED_DUO_HEADER,

0 commit comments

Comments
 (0)