Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
593aa69833 | ||
|
|
4f648f1e11 | ||
|
|
53ab016efd |
No files matched your search
@@ -1,72 +0,0 @@
|
||||
---
|
||||
description: Cursor Cloud environment setup and run notes for T3 Code (Cursor-specific; not for other editors/CI)
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Cursor Cloud specific instructions
|
||||
|
||||
These notes apply only to Cursor Cloud agents (kept out of the shared `AGENTS.md` since T3 Code is
|
||||
developed in many places). They cover the pre-provisioned VM environment and non-obvious run caveats.
|
||||
|
||||
## Toolchain
|
||||
|
||||
Pre-installed and wired into login shells (`~/.bashrc`/`~/.profile`): Node 24 (via nvm), the global
|
||||
`vp` (Vite+) CLI, and its bundled pnpm. `vp` is the package manager + task runner for this repo
|
||||
(`vp i`, `vp check`, `vp run typecheck`, `vp test`, `vp run --filter <pkg> <script>`).
|
||||
|
||||
- Node gotcha: the base image also ships an older Node on `/exec-daemon` that wins on `PATH` in
|
||||
non-login shells. Run commands in a login shell (`bash -lc '...'`) or prepend
|
||||
`$HOME/.nvm/versions/node/v24.13.1/bin` so Node 24 (`engines.node: ^24.13.1`) is used.
|
||||
- `vp check` also runs the formatter (not just lint); markdown edits must be formatter-clean. Run
|
||||
`vp check --fix` before committing.
|
||||
|
||||
## Running the web app
|
||||
|
||||
- `npm run dev` (from repo root) starts contracts (watch), web (Vite, port 5733), and the server
|
||||
(`node --watch`, port 13773) together, auto-wiring `VITE_HTTP_URL`/`VITE_WS_URL`. Use
|
||||
`npm run dev:server` / `npm run dev:web` for one side. If base ports are taken it auto-offsets to
|
||||
the next free pair, so read the actual ports from stdout. Avoid production `build`/`start` in dev.
|
||||
- Auth/pairing: the server is unauthenticated by default and prints a pairing URL to stdout on startup
|
||||
(e.g. `http://localhost:5733/pair#token=XXXX`). Open that URL in the browser to pair before the web
|
||||
UI can talk to the server. Server state (SQLite, auth, projects) lives under `~/.t3`
|
||||
(`T3CODE_HOME`); multiple `npm run dev` instances bind different ports but share that same DB.
|
||||
- Agent providers are external CLIs (`codex`, `claude`, `cursor-agent`, `opencode`) probed on `PATH`.
|
||||
Without one installed the UI loads but no agent can run. Claude Code
|
||||
(`npm i -g @anthropic-ai/claude-code`) works headlessly using `ANTHROPIC_API_KEY` from the
|
||||
environment (the server forwards `process.env` to the child; no interactive `claude auth login`
|
||||
needed). Provider probing runs at startup and refreshes roughly every 5 minutes — restart the dev
|
||||
server to pick up a newly installed provider CLI immediately.
|
||||
|
||||
## Android native builds (apps/mobile)
|
||||
|
||||
The Android toolchain is pre-installed and wired into login shells: OpenJDK 17
|
||||
(`JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64`; the base image's default `java` is 21, so builds must
|
||||
use `JAVA_HOME`), and the Android SDK at `$HOME/Android/Sdk` (`ANDROID_HOME`/`ANDROID_SDK_ROOT`) with
|
||||
platform-tools, `platforms;android-36`, `build-tools;36.0.0`, `ndk;27.1.12297006`, and `cmake;3.22.1`.
|
||||
Gradle auto-downloads any additional pinned SDK packages on demand.
|
||||
|
||||
- Generate the native project first: from `apps/mobile`,
|
||||
`EXPO_NO_GIT_STATUS=1 APP_VARIANT=development npx expo prebuild --clean --platform android`
|
||||
(the `android/` folder is generated, not committed). RN 0.85 defaults: compileSdk/targetSdk 36,
|
||||
minSdk 24, NDK `27.1.12297006` (see `react-native/gradle/libs.versions.toml`).
|
||||
- Build with Gradle from `apps/mobile/android`, e.g. `./gradlew :app:assembleDebug`. First build is
|
||||
slow (Kotlin + C++/NDK codegen). Limit ABIs to speed things up, e.g.
|
||||
`-PreactNativeArchitectures=arm64-v8a`. Verified working end-to-end on a native module:
|
||||
`./gradlew :react-native-worklets:assembleDebug` compiles Kotlin + C++ and emits an AAR + `.so`s.
|
||||
- No emulator: this VM has no `/dev/kvm` (nested virtualization), so a hardware-accelerated Android
|
||||
emulator will not run. Use a physical device (`adb`) or EAS cloud builds (`vp run eas:android:*`) to
|
||||
actually run the app. The full IDE GUI is unnecessary here — the SDK/NDK/Gradle toolchain that
|
||||
Android Studio bundles is what is installed.
|
||||
- Known blocker for the full-app `:app:assembleDebug` (pre-existing, app-level — not the environment):
|
||||
`:react-native-screens:compileDebugKotlin` fails because `patches/[email protected]`
|
||||
adds new codegen props (`subtitle`, `largeSubtitle`, `navigationItemStyle`,
|
||||
`headerCenterBarButtonItems`, `headerToolbarItems`) to the JS spec + iOS native code but includes no
|
||||
Android Kotlin setters, so the generated `ScreenStackHeaderConfigManagerInterface` is unimplemented.
|
||||
The mobile README documents only iOS for local builds and routes Android through EAS. Fixing local
|
||||
Android app builds requires an app/patch change (add the Android Kotlin setters), which is out of
|
||||
scope for environment setup.
|
||||
|
||||
## Known flaky tests (unrelated to setup)
|
||||
|
||||
- `apps/server/src/git/GitManager.test.ts` (cross-repo PR metadata, can time out at 12s).
|
||||
- `apps/server/src/provider/Layers/ProviderRegistry.test.ts` (codex binaryPath re-probe ordering).
|
||||
@@ -57,10 +57,7 @@ jobs:
|
||||
with:
|
||||
eas-version: latest
|
||||
token: ${{ secrets.EXPO_TOKEN }}
|
||||
# npm, not pnpm: this only installs eas-cli into the action's own
|
||||
# tool dir, and pnpm 11 hard-fails that install on dtrace-provider's
|
||||
# ignored build script (no allowBuilds config outside the repo).
|
||||
packager: npm
|
||||
packager: pnpm
|
||||
|
||||
- name: Pull preview environment variables
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
|
||||
@@ -80,10 +80,7 @@ jobs:
|
||||
with:
|
||||
eas-version: latest
|
||||
token: ${{ secrets.EXPO_TOKEN }}
|
||||
# npm, not pnpm: this only installs eas-cli into the action's own
|
||||
# tool dir, and pnpm 11 hard-fails that install on dtrace-provider's
|
||||
# ignored build script (no allowBuilds config outside the repo).
|
||||
packager: npm
|
||||
packager: pnpm
|
||||
|
||||
- name: Pull production environment variables
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
|
||||
@@ -15,7 +15,6 @@ const VARIANT_CONFIG: Record<
|
||||
readonly appName: string;
|
||||
readonly scheme: string;
|
||||
readonly iosIcon: string;
|
||||
readonly splashIcon: string;
|
||||
readonly iosBundleIdentifier: string;
|
||||
readonly androidPackage: string;
|
||||
readonly relyingParty?: string;
|
||||
@@ -25,7 +24,6 @@ const VARIANT_CONFIG: Record<
|
||||
appName: "T3 Code Dev",
|
||||
scheme: "t3code-dev",
|
||||
iosIcon: "./assets/icon-composer-dev.icon",
|
||||
splashIcon: "./assets/splash-icon-dev.png",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.dev",
|
||||
androidPackage: "com.t3tools.t3code.dev",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
@@ -34,7 +32,6 @@ const VARIANT_CONFIG: Record<
|
||||
appName: "T3 Code Preview",
|
||||
scheme: "t3code-preview",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
splashIcon: "./assets/splash-icon-prod.png",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.preview",
|
||||
androidPackage: "com.t3tools.t3code.preview",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
@@ -43,7 +40,6 @@ const VARIANT_CONFIG: Record<
|
||||
appName: "T3 Code",
|
||||
scheme: "t3code",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
splashIcon: "./assets/splash-icon-prod.png",
|
||||
iosBundleIdentifier: "com.t3tools.t3code",
|
||||
androidPackage: "com.t3tools.t3code",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
@@ -135,12 +131,12 @@ const config: ExpoConfig = {
|
||||
[
|
||||
"expo-splash-screen",
|
||||
{
|
||||
image: variant.splashIcon,
|
||||
image: "./assets/splash-icon.png",
|
||||
resizeMode: "contain",
|
||||
backgroundColor: "#ffffff",
|
||||
imageWidth: 220,
|
||||
dark: {
|
||||
image: variant.splashIcon,
|
||||
image: "./assets/splash-icon.png",
|
||||
backgroundColor: "#0a0a0a",
|
||||
},
|
||||
},
|
||||
@@ -159,12 +155,6 @@ const config: ExpoConfig = {
|
||||
},
|
||||
],
|
||||
"./plugins/withIosCocoaPodsUuidCache.cjs",
|
||||
// Must be listed BEFORE expo-widgets: same-type mods run last-registered-
|
||||
// first, so registering earlier makes this plugin's mods run AFTER
|
||||
// expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
|
||||
// would delete the asset catalog) and its xcodeproj mod creates the widget
|
||||
// target (which must exist before the compile phase can be attached).
|
||||
"./plugins/withWidgetLogoAsset.cjs",
|
||||
[
|
||||
"expo-widgets",
|
||||
{
|
||||
@@ -181,35 +171,12 @@ const config: ExpoConfig = {
|
||||
description: "Shows the current state of active T3 Code agents.",
|
||||
supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
|
||||
},
|
||||
{
|
||||
name: "NewThread",
|
||||
displayName: "New Thread",
|
||||
description: "Start a new T3 Code thread right from your Home Screen.",
|
||||
supportedFamilies: ["systemSmall", "systemMedium", "systemLarge"],
|
||||
// Per-instance options in the long-press "Edit Widget" sheet. Enum
|
||||
// parameters are compiled into Swift at prebuild, so the dynamic
|
||||
// project list cannot be offered as a picker — pins are typed as
|
||||
// text and matched against the synced projects inside the widget.
|
||||
configuration: {
|
||||
title: "New Thread",
|
||||
description: "Pin specific projects; the rest fills with your latest activity.",
|
||||
parameters: {
|
||||
pinnedProjects: {
|
||||
title: "Pinned projects (comma-separated)",
|
||||
type: "string",
|
||||
default: "",
|
||||
},
|
||||
showRecent: {
|
||||
title: "Fill with recent projects",
|
||||
type: "boolean",
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
// Must run after expo-widgets so the widget target exists when it wires in
|
||||
// the branded logo asset catalog.
|
||||
"./plugins/withWidgetLogoAsset.cjs",
|
||||
"./plugins/withIosSceneLifecycle.cjs",
|
||||
"./plugins/withAndroidCleartextTraffic.cjs",
|
||||
],
|
||||
@@ -222,15 +189,6 @@ const config: ExpoConfig = {
|
||||
publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
|
||||
jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
|
||||
},
|
||||
// Native Google sign-in credentials. @clerk/expo reads these from `extra`
|
||||
// under their exact env-var names (not nested), and its config plugin reads
|
||||
// the iOS URL scheme at prebuild to register it in Info.plist.
|
||||
// Unset values must be omitted (not null): the public manifest serializes
|
||||
// null to {}, which is truthy and would defeat Clerk's fallback checks.
|
||||
EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
|
||||
EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
|
||||
EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
|
||||
EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
|
||||
observability: {
|
||||
tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
|
||||
tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 302 KiB |
File renamed without changes.
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
@@ -9,10 +9,8 @@
|
||||
// drops the compiled Assets.car into the extension bundle. Marked
|
||||
// alwaysOutOfDate so the build system always runs it.
|
||||
//
|
||||
// Idempotent across re-runs. Returns true when it added the phase, false when
|
||||
// it was already present. Throws when the target does not exist — that means
|
||||
// this ran before expo-widgets created the target (plugin ordering bug) and
|
||||
// silently skipping would ship a widget without its assets.
|
||||
// Idempotent across re-runs. Returns true when it added the phase, false when it
|
||||
// was already present or the target was not found.
|
||||
|
||||
const PHASE_NAME = "Compile Widget Assets";
|
||||
|
||||
@@ -22,8 +20,8 @@ const ACTOOL_SCRIPT = [
|
||||
"set -e",
|
||||
'CATALOG="${SRCROOT}/ExpoWidgetsTarget/Assets.xcassets"',
|
||||
'if [ ! -d "$CATALOG" ]; then',
|
||||
' echo "error: widget asset catalog not found at $CATALOG (expo-widgets wiped it? check plugin ordering in app.config.ts)"',
|
||||
" exit 1",
|
||||
' echo "warning: widget asset catalog not found at $CATALOG"',
|
||||
" exit 0",
|
||||
"fi",
|
||||
'DEST="${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"',
|
||||
'mkdir -p "$DEST"',
|
||||
@@ -53,13 +51,7 @@ function findByName(map, name) {
|
||||
function addWidgetAssetCatalog(proj, opts) {
|
||||
const objects = proj.hash.project.objects;
|
||||
const target = findByName(objects.PBXNativeTarget, opts.targetName);
|
||||
if (!target) {
|
||||
throw new Error(
|
||||
`addWidgetAssetCatalog: target "${opts.targetName}" not found — ` +
|
||||
"withWidgetLogoAsset must be registered before expo-widgets so its " +
|
||||
"xcodeproj mod runs after the widget target is created.",
|
||||
);
|
||||
}
|
||||
if (!target) return false;
|
||||
|
||||
const phases = target.value.buildPhases || [];
|
||||
const existing = objects.PBXShellScriptBuildPhase || {};
|
||||
|
||||
@@ -5,15 +5,9 @@
|
||||
// expo-widgets generates ExpoWidgetsTarget without a Resources build phase and
|
||||
// has no asset support, so this plugin (a) writes an SVG template image set into
|
||||
// the generated widget asset catalog and (b) wires that catalog into the widget
|
||||
// target with an actool build phase.
|
||||
//
|
||||
// ORDERING: must be listed BEFORE "expo-widgets" in the plugins array. Expo
|
||||
// chains same-type mods so the last-registered runs FIRST; registering this
|
||||
// plugin earlier makes its mods run AFTER expo-widgets' mods. That matters
|
||||
// twice: expo-widgets' dangerous mod rmSync's ios/ExpoWidgetsTarget/ (deleting
|
||||
// any catalog written before it), and its xcodeproj mod is what creates the
|
||||
// widget target. Listed after expo-widgets, both steps silently no-op on a
|
||||
// fresh prebuild — which is how prod build 8 shipped without the logo.
|
||||
// target with a dedicated Resources build phase. Both steps are idempotent and
|
||||
// survive `expo prebuild --clean`. Must be listed AFTER "expo-widgets" in the
|
||||
// plugins array so the widget target exists when this runs.
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
@@ -26,5 +26,5 @@ if (added) {
|
||||
fs.writeFileSync(pbxprojPath, proj.writeSync());
|
||||
console.log("Added widget asset-compile phase to ExpoWidgetsTarget.");
|
||||
} else {
|
||||
console.log("No change: phase already present.");
|
||||
console.log("No change: phase already present or target not found.");
|
||||
}
|
||||
@@ -40,7 +40,6 @@ import { AddProjectSourceRoute } from "./features/projects/AddProjectSourceRoute
|
||||
import { NewTaskDraftRouteScreen } from "./features/threads/NewTaskDraftRouteScreen";
|
||||
import { NewTaskFlowProvider } from "./features/threads/new-task-flow-provider";
|
||||
import { NewTaskRouteScreen } from "./features/threads/NewTaskRouteScreen";
|
||||
import { useNewThreadWidgetSync } from "./features/threads/use-new-thread-widget-sync";
|
||||
import { SettingsAppearanceRouteScreen } from "./features/settings/SettingsAppearanceRouteScreen";
|
||||
import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteScreen";
|
||||
import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
|
||||
@@ -257,8 +256,6 @@ function RootStackLayout(props: {
|
||||
useThreadOutboxDrain();
|
||||
// Presents the T3 Connect onboarding sheet after an in-session sign-in.
|
||||
useConnectOnboardingNavigation();
|
||||
// Keeps the NewThread home-screen widget's project shortcuts current.
|
||||
useNewThreadWidgetSync();
|
||||
// Full pathname (sheets included) for keyboard-command scoping; the
|
||||
// workspace layout only reacts to the underlying non-overlay route.
|
||||
const path = getPathFromState(props.state, navigationPathConfig);
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
setAgentAwarenessRelayTokenProvider,
|
||||
unregisterAgentAwarenessDeviceForCurrentUser,
|
||||
} from "../agent-awareness/remoteRegistration";
|
||||
import { clearConnectOnboardingRequest, requestConnectOnboarding } from "./connectOnboarding";
|
||||
import { requestConnectOnboarding } from "./connectOnboarding";
|
||||
import { resolveCloudPublicConfig, resolveRelayClerkTokenOptions } from "./publicConfig";
|
||||
|
||||
function resetManagedRelayTokenCache() {
|
||||
@@ -68,17 +68,12 @@ function CloudAuthBridge(props: { readonly children: ReactNode }) {
|
||||
const nextAccount = isSignedIn && userId ? userId : null;
|
||||
observedAccountRef.current = nextAccount;
|
||||
|
||||
// Every sign-in or account switch that completes during this session (a
|
||||
// cold start observes undefined → account and must not re-prompt) requests
|
||||
// the T3 Connect onboarding sheet — account transitions clear the
|
||||
// connected environments, so each new session starts with no devices to
|
||||
// reach. The request itself is issued after the cleanup transition inside
|
||||
// activateSession, so the sheet never lists the previous account's
|
||||
// environments; sign-out drops any not-yet-presented request instead.
|
||||
const isAccountTransition =
|
||||
previousObservedAccount !== undefined && previousObservedAccount !== nextAccount;
|
||||
if (isAccountTransition && nextAccount === null) {
|
||||
clearConnectOnboardingRequest();
|
||||
// Every sign-in that completes during this session (a cold start observes
|
||||
// undefined → account and must not re-prompt) requests the T3 Connect
|
||||
// onboarding sheet — sign-out clears the connected environments, so each
|
||||
// new session starts with no devices to reach.
|
||||
if (previousObservedAccount === null && nextAccount !== null) {
|
||||
requestConnectOnboarding(nextAccount);
|
||||
}
|
||||
|
||||
const queueAccountCleanup = (
|
||||
@@ -128,9 +123,6 @@ function CloudAuthBridge(props: { readonly children: ReactNode }) {
|
||||
}
|
||||
previousTokenProviderRef.current = { userId, provider: tokenProvider };
|
||||
activateCloudRelayAccount(userId, tokenProvider);
|
||||
if (isAccountTransition) {
|
||||
requestConnectOnboarding(userId);
|
||||
}
|
||||
};
|
||||
const activateAfterTransition = (transition: Promise<void>) => {
|
||||
void (async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NativeHeaderToolbar } from "../../native/StackHeader";
|
||||
import { useAuth } from "@clerk/expo";
|
||||
import { StackActions, useNavigation } from "@react-navigation/native";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Pressable, RefreshControl, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
@@ -22,21 +22,6 @@ import { hasCloudPublicConfig } from "./publicConfig";
|
||||
* clears the connected environments, so each new session starts from zero.
|
||||
*/
|
||||
export function ConnectOnboardingRouteScreen() {
|
||||
const navigation = useNavigation();
|
||||
|
||||
// The route is deep-linkable; without cloud config the sheet would present
|
||||
// empty with no chrome to dismiss it, so bail back out instead.
|
||||
useEffect(() => {
|
||||
if (hasCloudPublicConfig()) {
|
||||
return;
|
||||
}
|
||||
if (navigation.canGoBack()) {
|
||||
navigation.goBack();
|
||||
} else {
|
||||
navigation.dispatch(StackActions.replace("Home"));
|
||||
}
|
||||
}, [navigation]);
|
||||
|
||||
return hasCloudPublicConfig() ? <ConfiguredConnectOnboardingRouteScreen /> : null;
|
||||
}
|
||||
|
||||
@@ -67,16 +52,14 @@ function ConfiguredConnectOnboardingRouteScreen() {
|
||||
navigation.goBack();
|
||||
}, [navigation]);
|
||||
|
||||
// Persist before dismissing so a quick sign-out/sign-in cannot race ahead
|
||||
// of the preference write; the write is a local secure-store update.
|
||||
const handleDontShowAgain = useCallback(() => {
|
||||
void (async () => {
|
||||
if (userId) {
|
||||
if (userId) {
|
||||
void (async () => {
|
||||
const result = await settlePromise(() => optOutOfConnectOnboarding(userId));
|
||||
reportAtomCommandResult(result, { label: "connect onboarding opt-out" });
|
||||
}
|
||||
navigation.goBack();
|
||||
})();
|
||||
})();
|
||||
}
|
||||
navigation.goBack();
|
||||
}, [navigation, userId]);
|
||||
|
||||
return (
|
||||
@@ -85,7 +68,6 @@ function ConfiguredConnectOnboardingRouteScreen() {
|
||||
<NativeHeaderToolbar.Button icon="xmark" onPress={handleClose} separateBackground />
|
||||
</NativeHeaderToolbar>
|
||||
<ScrollView
|
||||
alwaysBounceVertical
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={{ flex: 1 }}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useAtomValue } from "@effect/atom-react";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { appAtomRegistry } from "../../state/atom-registry";
|
||||
import { clearConnectOnboardingRequest, connectOnboardingRequestAtom } from "./connectOnboarding";
|
||||
import { isConnectOnboardingOptedOut } from "./connectOnboardingOptOut";
|
||||
|
||||
@@ -29,10 +28,7 @@ export function useConnectOnboardingNavigation(): void {
|
||||
void (async () => {
|
||||
// A failed preference read prefers showing the sheet.
|
||||
const optedOut = await isConnectOnboardingOptedOut(requestedAccountId).catch(() => false);
|
||||
// The cancelled flag covers effect re-runs, but a sign-out can clear
|
||||
// the request atom moments before this render commits — re-check the
|
||||
// atom so a stale request never presents the sheet.
|
||||
if (cancelled || appAtomRegistry.get(connectOnboardingRequestAtom) !== requestedAccountId) {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
clearConnectOnboardingRequest();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loadPreferences, updatePreferences } from "../../lib/storage";
|
||||
import { loadPreferences, savePreferencesPatch } from "../../lib/storage";
|
||||
|
||||
// Lives apart from connectOnboarding.ts so CloudAuthProvider (which imports
|
||||
// the request signal) never pulls lib/storage — expo-secure-store — into its
|
||||
@@ -12,10 +12,10 @@ export async function isConnectOnboardingOptedOut(accountId: string): Promise<bo
|
||||
|
||||
/** Persists "Don't show this again" for the account. */
|
||||
export async function optOutOfConnectOnboarding(accountId: string): Promise<void> {
|
||||
await updatePreferences((current) => {
|
||||
const optedOut = current.connectOnboardingOptOutAccounts ?? [];
|
||||
return optedOut.includes(accountId)
|
||||
? {}
|
||||
: { connectOnboardingOptOutAccounts: [...optedOut, accountId] };
|
||||
});
|
||||
const preferences = await loadPreferences();
|
||||
const optedOut = preferences.connectOnboardingOptOutAccounts ?? [];
|
||||
if (optedOut.includes(accountId)) {
|
||||
return;
|
||||
}
|
||||
await savePreferencesPatch({ connectOnboardingOptOutAccounts: [...optedOut, accountId] });
|
||||
}
|
||||
@@ -124,17 +124,7 @@ export function CloudEnvironmentRows(props: {
|
||||
Loading linked cloud environments.
|
||||
</Text>
|
||||
</View>
|
||||
) : controller.relayDiscovery.error ? null : (
|
||||
<View collapsable={false} className="rounded-[24px] bg-card p-5">
|
||||
<Text className="text-sm leading-normal text-foreground-muted">
|
||||
No additional linked cloud environments.
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Rendered alongside any connected rows — a failed discovery must not
|
||||
hide behind an otherwise-healthy list. */}
|
||||
{controller.relayDiscovery.error && !controller.relayDiscovery.isRefreshing ? (
|
||||
) : controller.relayDiscovery.error ? (
|
||||
<View collapsable={false} className="gap-3 rounded-[24px] bg-card p-5">
|
||||
<Text className="text-base font-t3-bold text-foreground">
|
||||
Could not load T3 Connect environments
|
||||
@@ -143,17 +133,14 @@ export function CloudEnvironmentRows(props: {
|
||||
{controller.relayDiscovery.errorTraceId ? (
|
||||
<CopyTraceIdButton traceId={controller.relayDiscovery.errorTraceId} />
|
||||
) : null}
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
onPress={() => {
|
||||
void controller.refreshRelayEnvironments();
|
||||
}}
|
||||
className="self-start rounded-full bg-subtle px-3.5 py-2 active:opacity-70"
|
||||
>
|
||||
<Text className="text-xs font-t3-bold text-foreground">Try again</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
) : null}
|
||||
) : (
|
||||
<View collapsable={false} className="rounded-[24px] bg-card p-5">
|
||||
<Text className="text-sm leading-normal text-foreground-muted">
|
||||
No additional linked cloud environments.
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,12 +112,7 @@ function AddProjectShell(props: { readonly children: ReactNode }) {
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
return (
|
||||
// collapsable={false} is load-bearing: if this wrapper is flattened, the
|
||||
// ScrollView lands directly under RNSSafeAreaView and RNS's formSheet
|
||||
// scroll-view frame correction mistakes this full-height wrapper for a
|
||||
// "header" sibling, coercing the ScrollView to zero height (blank sheet
|
||||
// as soon as the sheet re-lays-out, e.g. when the keyboard opens).
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<View className="flex-1 bg-sheet">
|
||||
<ScrollView
|
||||
keyboardShouldPersistTaps="handled"
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import type {
|
||||
EnvironmentProject,
|
||||
EnvironmentThreadShell,
|
||||
} from "@t3tools/client-runtime/state/shell";
|
||||
|
||||
import { makeNewThreadWidgetProps } from "./new-thread-widget";
|
||||
|
||||
function makeProject(overrides: {
|
||||
readonly id: string;
|
||||
readonly environmentId?: string;
|
||||
readonly title?: string;
|
||||
readonly updatedAt?: string;
|
||||
}): EnvironmentProject {
|
||||
return {
|
||||
id: overrides.id,
|
||||
environmentId: overrides.environmentId ?? "env-1",
|
||||
title: overrides.title ?? overrides.id,
|
||||
updatedAt: overrides.updatedAt ?? "2026-07-01T00:00:00.000Z",
|
||||
} as unknown as EnvironmentProject;
|
||||
}
|
||||
|
||||
function makeThread(overrides: {
|
||||
readonly projectId: string;
|
||||
readonly environmentId?: string;
|
||||
readonly updatedAt: string;
|
||||
}): EnvironmentThreadShell {
|
||||
return {
|
||||
id: `thread-${overrides.projectId}`,
|
||||
projectId: overrides.projectId,
|
||||
environmentId: overrides.environmentId ?? "env-1",
|
||||
updatedAt: overrides.updatedAt,
|
||||
} as unknown as EnvironmentThreadShell;
|
||||
}
|
||||
|
||||
describe("makeNewThreadWidgetProps", () => {
|
||||
it("orders projects by their newest thread activity", () => {
|
||||
const props = makeNewThreadWidgetProps(
|
||||
[
|
||||
makeProject({ id: "stale", updatedAt: "2026-07-06T00:00:00.000Z" }),
|
||||
makeProject({ id: "busy", updatedAt: "2026-07-01T00:00:00.000Z" }),
|
||||
],
|
||||
[makeThread({ projectId: "busy", updatedAt: "2026-07-07T00:00:00.000Z" })],
|
||||
);
|
||||
expect(props.projects?.map((project) => project.title)).toEqual(["busy", "stale"]);
|
||||
});
|
||||
|
||||
it("falls back to the project's own updatedAt when it has no threads", () => {
|
||||
const props = makeNewThreadWidgetProps(
|
||||
[
|
||||
makeProject({ id: "old", updatedAt: "2026-07-01T00:00:00.000Z" }),
|
||||
makeProject({ id: "fresh", updatedAt: "2026-07-07T00:00:00.000Z" }),
|
||||
],
|
||||
[],
|
||||
);
|
||||
expect(props.projects?.map((project) => project.title)).toEqual(["fresh", "old"]);
|
||||
});
|
||||
|
||||
it("ignores thread activity from a same-named project in another environment", () => {
|
||||
const props = makeNewThreadWidgetProps(
|
||||
[
|
||||
makeProject({ id: "proj", environmentId: "env-1", title: "one" }),
|
||||
makeProject({
|
||||
id: "proj",
|
||||
environmentId: "env-2",
|
||||
title: "two",
|
||||
updatedAt: "2026-07-02T00:00:00.000Z",
|
||||
}),
|
||||
],
|
||||
[
|
||||
makeThread({
|
||||
projectId: "proj",
|
||||
environmentId: "env-2",
|
||||
updatedAt: "2026-07-07T00:00:00.000Z",
|
||||
}),
|
||||
],
|
||||
);
|
||||
expect(props.projects?.map((project) => project.title)).toEqual(["two", "one"]);
|
||||
});
|
||||
|
||||
it("syncs every project so low-activity pins can still resolve", () => {
|
||||
const count = 25;
|
||||
const props = makeNewThreadWidgetProps(
|
||||
Array.from({ length: count }, (_, n) =>
|
||||
makeProject({
|
||||
id: `p${n}`,
|
||||
updatedAt: `2026-06-${String(n + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
}),
|
||||
),
|
||||
[],
|
||||
);
|
||||
expect(props.projects).toHaveLength(count);
|
||||
expect(props.projects?.[0]?.title).toBe(`p${count - 1}`);
|
||||
expect(props.projects?.[count - 1]?.title).toBe("p0");
|
||||
});
|
||||
|
||||
it("disambiguates duplicate titles with environment labels", () => {
|
||||
const props = makeNewThreadWidgetProps(
|
||||
[
|
||||
makeProject({
|
||||
id: "proj-a",
|
||||
environmentId: "env-1",
|
||||
title: "t3code",
|
||||
updatedAt: "2026-07-07T00:00:00.000Z",
|
||||
}),
|
||||
makeProject({
|
||||
id: "proj-b",
|
||||
environmentId: "env-2",
|
||||
title: "t3code",
|
||||
updatedAt: "2026-07-01T00:00:00.000Z",
|
||||
}),
|
||||
],
|
||||
[],
|
||||
new Map([
|
||||
["env-1", "Laptop"],
|
||||
["env-2", "Desktop"],
|
||||
]),
|
||||
);
|
||||
expect(props.projects?.map((project) => project.title)).toEqual([
|
||||
"t3code (Laptop)",
|
||||
"t3code (Desktop)",
|
||||
]);
|
||||
expect(props.projects?.[0]?.deepLink).toContain("environmentId=env-1");
|
||||
expect(props.projects?.[0]?.deepLink).toContain("title=t3code");
|
||||
expect(props.projects?.[1]?.deepLink).toContain("environmentId=env-2");
|
||||
});
|
||||
|
||||
it("falls back to environment id when labels are missing for duplicates", () => {
|
||||
const props = makeNewThreadWidgetProps(
|
||||
[
|
||||
makeProject({ id: "a", environmentId: "env-1", title: "shared" }),
|
||||
makeProject({ id: "b", environmentId: "env-2", title: "shared" }),
|
||||
],
|
||||
[],
|
||||
);
|
||||
expect(props.projects?.map((project) => project.title)).toEqual([
|
||||
"shared (env-1)",
|
||||
"shared (env-2)",
|
||||
]);
|
||||
});
|
||||
|
||||
it("URL-encodes deep link parameters", () => {
|
||||
const props = makeNewThreadWidgetProps(
|
||||
[makeProject({ id: "p 1", environmentId: "env&1", title: "T3 & friends" })],
|
||||
[],
|
||||
);
|
||||
expect(props.projects?.[0]?.deepLink).toBe(
|
||||
"/new/draft?environmentId=env%261&projectId=p%201&title=T3%20%26%20friends",
|
||||
);
|
||||
});
|
||||
|
||||
it("returns an empty list when there are no projects", () => {
|
||||
expect(makeNewThreadWidgetProps([], []).projects).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -1,100 +0,0 @@
|
||||
import type {
|
||||
EnvironmentProject,
|
||||
EnvironmentThreadShell,
|
||||
} from "@t3tools/client-runtime/state/shell";
|
||||
|
||||
import type { NewThreadWidgetProps } from "../../widgets/NewThread";
|
||||
|
||||
/**
|
||||
* Builds the home-screen widget payload: all projects ordered by recent
|
||||
* activity, each with a deep link into the new-task draft composer.
|
||||
*
|
||||
* The full set is synced (not just the visible rows) so pinned-project matching
|
||||
* inside the widget can resolve a deliberately pinned low-activity project.
|
||||
* Medium shows 3 rows and large 7; the widget layout slices after pin matching.
|
||||
*
|
||||
* "Recently active" means the newest thread update in the project, falling
|
||||
* back to the project's own updatedAt for projects with no threads — so the
|
||||
* widget surfaces where the user actually works, not what was created last.
|
||||
*
|
||||
* When two projects share a title, the display title is disambiguated with the
|
||||
* environment label (falling back to environment id, then project id) so pin
|
||||
* matching and the deep link target the intended workspace.
|
||||
*/
|
||||
export function makeNewThreadWidgetProps(
|
||||
projects: ReadonlyArray<EnvironmentProject>,
|
||||
threads: ReadonlyArray<EnvironmentThreadShell>,
|
||||
environmentLabels: ReadonlyMap<string, string> = new Map(),
|
||||
): NewThreadWidgetProps {
|
||||
const latestThreadActivity = new Map<string, string>();
|
||||
for (const thread of threads) {
|
||||
const key = projectActivityKey(thread.environmentId, thread.projectId);
|
||||
const previous = latestThreadActivity.get(key);
|
||||
// ISO-8601 timestamps order lexicographically.
|
||||
if (previous === undefined || thread.updatedAt > previous) {
|
||||
latestThreadActivity.set(key, thread.updatedAt);
|
||||
}
|
||||
}
|
||||
|
||||
const lastActivity = (project: EnvironmentProject): string => {
|
||||
const threadActivity = latestThreadActivity.get(
|
||||
projectActivityKey(project.environmentId, project.id),
|
||||
);
|
||||
return threadActivity !== undefined && threadActivity > project.updatedAt
|
||||
? threadActivity
|
||||
: project.updatedAt;
|
||||
};
|
||||
|
||||
const ordered = [...projects].sort((a, b) => lastActivity(b).localeCompare(lastActivity(a)));
|
||||
const displayTitles = disambiguateProjectTitles(ordered, environmentLabels);
|
||||
|
||||
return {
|
||||
projects: ordered.map((project, index) => ({
|
||||
title: displayTitles[index] ?? project.title,
|
||||
// Matches the NewTaskSheet > NewTaskDraft linking config in Stack.tsx;
|
||||
// the widget layout prefixes the scheme after a safety check. Keep the
|
||||
// original project title in the query — not the disambiguated display.
|
||||
deepLink:
|
||||
`/new/draft?environmentId=${encodeURIComponent(String(project.environmentId))}` +
|
||||
`&projectId=${encodeURIComponent(String(project.id))}` +
|
||||
`&title=${encodeURIComponent(project.title)}`,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
function disambiguateProjectTitles(
|
||||
projects: ReadonlyArray<EnvironmentProject>,
|
||||
environmentLabels: ReadonlyMap<string, string>,
|
||||
): string[] {
|
||||
const titleCounts = countBy((project) => project.title.toLowerCase(), projects);
|
||||
const withEnvironment = projects.map((project) => {
|
||||
if ((titleCounts.get(project.title.toLowerCase()) ?? 0) <= 1) {
|
||||
return project.title;
|
||||
}
|
||||
const envLabel =
|
||||
environmentLabels.get(String(project.environmentId)) ?? String(project.environmentId);
|
||||
return `${project.title} (${envLabel})`;
|
||||
});
|
||||
|
||||
const envTitleCounts = countBy((title) => title.toLowerCase(), withEnvironment);
|
||||
return withEnvironment.map((title, index) => {
|
||||
if ((envTitleCounts.get(title.toLowerCase()) ?? 0) <= 1) {
|
||||
return title;
|
||||
}
|
||||
const project = projects[index];
|
||||
return project ? `${title} · ${project.id}` : title;
|
||||
});
|
||||
}
|
||||
|
||||
function countBy<T>(keyOf: (value: T) => string, values: ReadonlyArray<T>): Map<string, number> {
|
||||
const counts = new Map<string, number>();
|
||||
for (const value of values) {
|
||||
const key = keyOf(value);
|
||||
counts.set(key, (counts.get(key) ?? 0) + 1);
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
function projectActivityKey(environmentId: string, projectId: string): string {
|
||||
return `${environmentId}\u0000${projectId}`;
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { Platform } from "react-native";
|
||||
|
||||
import { useProjects, useThreadShells } from "../../state/entities";
|
||||
import { useEnvironments } from "../../state/environments";
|
||||
import NewThreadWidget from "../../widgets/NewThread";
|
||||
import { makeNewThreadWidgetProps } from "./new-thread-widget";
|
||||
|
||||
// Last payload written to the widget timeline. Module-level (not React state)
|
||||
// so navigator remounts don't rewrite an unchanged payload: every write ends
|
||||
// in a WidgetCenter reload, and iOS throttles widgets that reload too often.
|
||||
let lastSyncedSignature: string | null = null;
|
||||
|
||||
/** Delay before retrying a failed snapshot write while entity data is unchanged. */
|
||||
const SNAPSHOT_RETRY_MS = 5_000;
|
||||
|
||||
/**
|
||||
* Keeps the NewThread home-screen widget's project shortcuts in sync with the
|
||||
* workspace. Writing the snapshot also persists the widget layout to the
|
||||
* shared app group, which is what lets the widget render at all — so this
|
||||
* must run on every launch, not only when projects change.
|
||||
*/
|
||||
export function useNewThreadWidgetSync(): void {
|
||||
const projects = useProjects();
|
||||
const threads = useThreadShells();
|
||||
const { environments } = useEnvironments();
|
||||
const environmentLabels = useMemo(() => {
|
||||
const labels = new Map<string, string>();
|
||||
for (const environment of environments) {
|
||||
labels.set(String(environment.environmentId), environment.label);
|
||||
}
|
||||
return labels;
|
||||
}, [environments]);
|
||||
|
||||
useEffect(() => {
|
||||
if (Platform.OS !== "ios") {
|
||||
return;
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
let retryTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const sync = () => {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
const props = makeNewThreadWidgetProps(projects, threads, environmentLabels);
|
||||
const signature = JSON.stringify(props);
|
||||
if (signature === lastSyncedSignature) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
NewThreadWidget.updateSnapshot(props);
|
||||
lastSyncedSignature = signature;
|
||||
} catch (error) {
|
||||
// Do not treat the write as succeeded. Schedule a retry so a transient
|
||||
// app-group failure still recovers when projects/threads stay the same.
|
||||
lastSyncedSignature = null;
|
||||
if (__DEV__) {
|
||||
console.warn("[new-thread-widget] snapshot update failed", error);
|
||||
}
|
||||
retryTimer = setTimeout(sync, SNAPSHOT_RETRY_MS);
|
||||
}
|
||||
};
|
||||
|
||||
sync();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
if (retryTimer !== null) {
|
||||
clearTimeout(retryTimer);
|
||||
}
|
||||
};
|
||||
}, [projects, threads, environmentLabels]);
|
||||
}
|
||||
@@ -199,28 +199,14 @@ export async function loadPreferences(): Promise<Preferences> {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
// Preference writes are read-modify-write over one JSON blob; concurrent
|
||||
// writers would drop each other's fields, so all writes are serialized here.
|
||||
let preferencesWriteQueue: Promise<unknown> = Promise.resolve();
|
||||
|
||||
export async function updatePreferences(
|
||||
update: (current: Preferences) => Partial<Preferences>,
|
||||
): Promise<Preferences> {
|
||||
const task = preferencesWriteQueue.then(async () => {
|
||||
const current = await loadPreferences();
|
||||
const next: Preferences = {
|
||||
...current,
|
||||
...update(current),
|
||||
};
|
||||
await writeJsonStorageItem(PREFERENCES_KEY, next);
|
||||
return next;
|
||||
});
|
||||
preferencesWriteQueue = task.catch(() => undefined);
|
||||
return task;
|
||||
}
|
||||
|
||||
export async function savePreferencesPatch(patch: Partial<Preferences>): Promise<Preferences> {
|
||||
return updatePreferences(() => patch);
|
||||
const current = await loadPreferences();
|
||||
const next: Preferences = {
|
||||
...current,
|
||||
...patch,
|
||||
};
|
||||
await writeJsonStorageItem(PREFERENCES_KEY, next);
|
||||
return next;
|
||||
}
|
||||
|
||||
export async function loadOrCreateAgentAwarenessDeviceId(): Promise<string> {
|
||||
|
||||
@@ -199,70 +199,6 @@ describe("AgentActivity widget layout", () => {
|
||||
).not.toContain("widgetURL");
|
||||
});
|
||||
|
||||
it("leads with the outcome instead of a zero count when nothing is active", () => {
|
||||
const layout = AgentActivity(
|
||||
{
|
||||
...props,
|
||||
subtitle: "Agent work completed",
|
||||
activeCount: 0,
|
||||
activities: [makeRow({ phase: "completed", status: "Done" })],
|
||||
},
|
||||
environment as never,
|
||||
);
|
||||
const banner = JSON.stringify(layout.banner);
|
||||
expect(banner).toContain("Agent work completed");
|
||||
expect(banner).not.toContain("0 active");
|
||||
expect(banner).toContain("#6ee7b7"); // emerald-300 header tint
|
||||
expect(JSON.stringify(layout.compactTrailing)).toContain("Done");
|
||||
expect(JSON.stringify(layout.compactTrailing)).not.toContain("0 active");
|
||||
expect(JSON.stringify(layout.expandedLeading)).toContain("Done");
|
||||
expect(JSON.stringify(layout.minimal)).toContain("checkmark.circle.fill");
|
||||
expect(JSON.stringify(layout.bannerSmall)).toContain("Done");
|
||||
});
|
||||
|
||||
it("reads Failed when the finished work ended in failure", () => {
|
||||
const layout = AgentActivity(
|
||||
{
|
||||
...props,
|
||||
subtitle: "Agent work failed",
|
||||
activeCount: 0,
|
||||
activities: [makeRow({ phase: "failed", status: "Failed" })],
|
||||
},
|
||||
environment as never,
|
||||
);
|
||||
const banner = JSON.stringify(layout.banner);
|
||||
expect(banner).toContain("Agent work failed");
|
||||
expect(banner).toContain("#fca5a5"); // red-300 header tint
|
||||
expect(JSON.stringify(layout.compactTrailing)).toContain("Failed");
|
||||
expect(JSON.stringify(layout.expandedLeading)).toContain("Failed");
|
||||
expect(JSON.stringify(layout.minimal)).toContain("xmark.octagon.fill");
|
||||
});
|
||||
|
||||
it("lets a failure dominate mixed finished outcomes across every presentation", () => {
|
||||
const layout = AgentActivity(
|
||||
{
|
||||
...props,
|
||||
// The server subtitle keys off the newest terminal row (completed
|
||||
// here); the layout must still read Failed everywhere so the header
|
||||
// text never disagrees with the tint, count slots, or minimal glyph.
|
||||
subtitle: "Agent work completed",
|
||||
activeCount: 0,
|
||||
activities: [
|
||||
makeRow({ phase: "completed", status: "Done" }),
|
||||
makeRow({ threadId: "thread-2", phase: "failed", status: "Failed" }),
|
||||
],
|
||||
},
|
||||
environment as never,
|
||||
);
|
||||
const banner = JSON.stringify(layout.banner);
|
||||
expect(banner).toContain("Agent work failed");
|
||||
expect(banner).not.toContain("Agent work completed");
|
||||
expect(banner).toContain("#fca5a5"); // red-300 header tint
|
||||
expect(JSON.stringify(layout.compactTrailing)).toContain("Failed");
|
||||
expect(JSON.stringify(layout.expandedLeading)).toContain("Failed");
|
||||
expect(JSON.stringify(layout.minimal)).toContain("xmark.octagon.fill");
|
||||
});
|
||||
|
||||
it("renders up to five rows in the banner", () => {
|
||||
const layout = AgentActivity(
|
||||
{
|
||||
|
||||
@@ -123,28 +123,16 @@ export function AgentActivity(
|
||||
? phaseTint(failedRow.phase)
|
||||
: tint;
|
||||
|
||||
// With nothing active the aggregate only carries recently finished work, so
|
||||
// "0 active agents" (and a lone "0" in the expanded island) read as broken.
|
||||
// Lead with the outcome instead. The outcome is derived here from the rows
|
||||
// rather than taken from the server subtitle (which keys off the newest
|
||||
// terminal row): every presentation — header text, tint, count slots,
|
||||
// minimal glyph — must agree, and a failure anywhere should dominate a
|
||||
// newer success.
|
||||
const allDone = props.activeCount === 0;
|
||||
const doneLabel = failedRow ? "Failed" : "Done";
|
||||
const outcomeLabel = failedRow ? "Agent work failed" : "Agent work completed";
|
||||
|
||||
// Header copy: "5 active agents" + (", 1 needs attention"). The banner renders
|
||||
// the two parts in-line so the attention half can carry the accent color;
|
||||
// `summary` is the short form for tight spots (expanded center, watch card).
|
||||
const agentWord = props.activeCount === 1 ? "agent" : "agents";
|
||||
const agentsLabel = allDone ? outcomeLabel : `${props.activeCount} active ${agentWord}`;
|
||||
const agentsLabel = `${props.activeCount} active ${agentWord}`;
|
||||
const attentionSuffix =
|
||||
attentionRows.length > 0
|
||||
? `${attentionRows.length} need${attentionRows.length === 1 ? "s" : ""} attention`
|
||||
: "";
|
||||
const activeLabel = allDone ? doneLabel : `${props.activeCount} active`;
|
||||
const summary = attentionSuffix || activeLabel;
|
||||
const summary = attentionSuffix || `${props.activeCount} active`;
|
||||
|
||||
// Any registered scheme variant routes back to this app; taps are delivered
|
||||
// to the widget's containing app, so the prod scheme is safe for all builds.
|
||||
@@ -154,6 +142,8 @@ export function AgentActivity(
|
||||
? `t3code://${deepLinkRow.deepLink.slice(1)}`
|
||||
: null;
|
||||
|
||||
const activeLabel = `${props.activeCount} active`;
|
||||
|
||||
// A scannable status glyph per phase — reads faster than colored words and
|
||||
// ties the compact / expanded / banner / watch presentations together.
|
||||
type SFName = NonNullable<ComponentProps<typeof Image>["systemName"]>;
|
||||
@@ -255,9 +245,7 @@ export function AgentActivity(
|
||||
<Text
|
||||
modifiers={[
|
||||
font({ weight: "semibold", size: 13 }),
|
||||
// The all-done header carries the outcome tint (emerald /
|
||||
// red) the way the Done/Failed status labels do.
|
||||
foregroundStyle(allDone ? headerTint : primaryForeground),
|
||||
foregroundStyle(primaryForeground),
|
||||
lineLimit(1),
|
||||
]}
|
||||
>
|
||||
@@ -334,17 +322,16 @@ export function AgentActivity(
|
||||
</Text>
|
||||
),
|
||||
// The shared/minimal form is a ~22pt circle — a single signal reads there,
|
||||
// the wordmark does not. Show the blocking/outcome phase glyph, else the
|
||||
// mark (all-done shows the hero row's checkmark/cross).
|
||||
// the wordmark does not. Show the blocking phase glyph, else the mark.
|
||||
minimal:
|
||||
(attentionRow || failedRow || allDone) && heroRow
|
||||
attentionRow || failedRow
|
||||
? renderGlyph(phaseSymbol(heroRow.phase), 13, phaseTint(heroRow.phase))
|
||||
: renderLogo(11, tint),
|
||||
expandedLeading: (
|
||||
<HStack spacing={5} alignment="center" modifiers={[padding({ leading: 4, vertical: 4 })]}>
|
||||
{renderLogo(15, tint)}
|
||||
<Text modifiers={[font({ weight: "bold", size: 13 }), foregroundStyle(tint)]}>
|
||||
{allDone ? doneLabel : `${props.activeCount}`}
|
||||
{`${props.activeCount}`}
|
||||
</Text>
|
||||
</HStack>
|
||||
),
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
vi.mock("@expo/ui/swift-ui", () => ({
|
||||
HStack: "HStack",
|
||||
Image: "Image",
|
||||
Link: "Link",
|
||||
Spacer: "Spacer",
|
||||
Text: "Text",
|
||||
VStack: "VStack",
|
||||
}));
|
||||
|
||||
vi.mock("@expo/ui/swift-ui/modifiers", () => ({
|
||||
containerBackground: (color: unknown) => ({ containerBackground: color }),
|
||||
font: (value: unknown) => value,
|
||||
foregroundStyle: (value: unknown) => value,
|
||||
frame: (value: unknown) => value,
|
||||
lineLimit: (value: unknown) => value,
|
||||
padding: (value: unknown) => value,
|
||||
resizable: (value: unknown) => value,
|
||||
widgetURL: (value: unknown) => ({ widgetURL: value }),
|
||||
}));
|
||||
|
||||
vi.mock("expo-widgets", () => ({
|
||||
createWidget: vi.fn((name: string, layout: unknown) => ({ layout, name })),
|
||||
}));
|
||||
|
||||
import {
|
||||
NewThread,
|
||||
type NewThreadWidgetConfiguration,
|
||||
type NewThreadWidgetProject,
|
||||
} from "./NewThread";
|
||||
|
||||
function makeProject(overrides: Partial<NewThreadWidgetProject>): NewThreadWidgetProject {
|
||||
return {
|
||||
title: "Project",
|
||||
deepLink: "/new/draft?environmentId=env-1&projectId=proj-1&title=Project",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function makeEnvironment(overrides: {
|
||||
readonly widgetFamily: "systemSmall" | "systemMedium" | "systemLarge";
|
||||
readonly colorScheme?: "light" | "dark";
|
||||
readonly configuration?: Partial<NewThreadWidgetConfiguration>;
|
||||
}) {
|
||||
return {
|
||||
date: new Date("2026-07-07T12:00:00.000Z"),
|
||||
widgetFamily: overrides.widgetFamily,
|
||||
colorScheme: overrides.colorScheme ?? "dark",
|
||||
configuration: { pinnedProjects: "", showRecent: true, ...overrides.configuration },
|
||||
} as never;
|
||||
}
|
||||
|
||||
const smallEnvironment = makeEnvironment({ widgetFamily: "systemSmall" });
|
||||
const mediumEnvironment = makeEnvironment({ widgetFamily: "systemMedium" });
|
||||
|
||||
describe("NewThread widget layout", () => {
|
||||
it("deep links the whole small widget to the new-task sheet", () => {
|
||||
const layout = JSON.stringify(NewThread({ projects: [] }, smallEnvironment));
|
||||
expect(layout).toContain('"widgetURL":"t3code://new"');
|
||||
expect(layout).toContain("New Thread");
|
||||
});
|
||||
|
||||
it("renders the small call to action even when projects are present", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread({ projects: [makeProject({ title: "t3code" })] }, smallEnvironment),
|
||||
);
|
||||
expect(layout).not.toContain("t3code://new/draft");
|
||||
expect(layout).toContain('"widgetURL":"t3code://new"');
|
||||
});
|
||||
|
||||
it("tolerates missing props and configuration (WidgetKit placeholder renders with none)", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{} as never,
|
||||
{
|
||||
date: new Date("2026-07-07T12:00:00.000Z"),
|
||||
widgetFamily: "systemMedium",
|
||||
colorScheme: "light",
|
||||
configuration: undefined,
|
||||
} as never,
|
||||
),
|
||||
);
|
||||
expect(layout).toContain('"widgetURL":"t3code://new"');
|
||||
});
|
||||
|
||||
it("links each medium row to its project's draft composer", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{
|
||||
projects: [
|
||||
makeProject({ title: "t3code", deepLink: "/new/draft?projectId=a" }),
|
||||
makeProject({ title: "marketing", deepLink: "/new/draft?projectId=b" }),
|
||||
],
|
||||
},
|
||||
mediumEnvironment,
|
||||
),
|
||||
);
|
||||
expect(layout).toContain("t3code");
|
||||
expect(layout).toContain("marketing");
|
||||
expect(layout).toContain('"destination":"t3code://new/draft?projectId=a"');
|
||||
expect(layout).toContain('"destination":"t3code://new/draft?projectId=b"');
|
||||
// Header link falls back to the plain new-task sheet.
|
||||
expect(layout).toContain('"destination":"t3code://new"');
|
||||
});
|
||||
|
||||
it("renders at most three rows on medium and seven on large", () => {
|
||||
const projects = [1, 2, 3, 4, 5, 6, 7, 8].map((n) =>
|
||||
makeProject({ title: `Project ${n}`, deepLink: `/new/draft?projectId=p${n}` }),
|
||||
);
|
||||
const medium = JSON.stringify(NewThread({ projects }, mediumEnvironment));
|
||||
expect(medium).toContain("Project 3");
|
||||
expect(medium).not.toContain("Project 4");
|
||||
const large = JSON.stringify(
|
||||
NewThread({ projects }, makeEnvironment({ widgetFamily: "systemLarge" })),
|
||||
);
|
||||
expect(large).toContain("Project 7");
|
||||
expect(large).not.toContain("Project 8");
|
||||
});
|
||||
|
||||
it("pins configured projects ahead of recents, in pin order", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{
|
||||
projects: [
|
||||
makeProject({ title: "recent" }),
|
||||
makeProject({ title: "beta" }),
|
||||
makeProject({ title: "alpha" }),
|
||||
],
|
||||
},
|
||||
makeEnvironment({
|
||||
widgetFamily: "systemMedium",
|
||||
configuration: { pinnedProjects: "Alpha, Beta" },
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(layout.indexOf("alpha")).toBeLessThan(layout.indexOf("beta"));
|
||||
expect(layout.indexOf("beta")).toBeLessThan(layout.indexOf("recent"));
|
||||
// Pinned rows carry the pin glyph; the recent row keeps the folder.
|
||||
expect(layout).toContain("pin.fill");
|
||||
expect(layout).toContain("folder");
|
||||
});
|
||||
|
||||
it("matches pins by case-insensitive prefix and skips unmatched pins", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{
|
||||
projects: [makeProject({ title: "recent" }), makeProject({ title: "T3 Marketing Site" })],
|
||||
},
|
||||
makeEnvironment({
|
||||
widgetFamily: "systemMedium",
|
||||
configuration: { pinnedProjects: "t3 mark, no-such-project" },
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(layout.indexOf("T3 Marketing Site")).toBeLessThan(layout.indexOf("recent"));
|
||||
expect(layout).toContain("pin.fill");
|
||||
});
|
||||
|
||||
it("pins can surface projects beyond the visible row budget", () => {
|
||||
const projects = [1, 2, 3, 4, 5].map((n) => makeProject({ title: `Project ${n}` }));
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{ projects },
|
||||
makeEnvironment({
|
||||
widgetFamily: "systemMedium",
|
||||
configuration: { pinnedProjects: "Project 5" },
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(layout).toContain("Project 5");
|
||||
expect(layout).toContain("Project 1");
|
||||
expect(layout).toContain("Project 2");
|
||||
expect(layout).not.toContain("Project 3");
|
||||
});
|
||||
|
||||
it("skips ambiguous pin titles instead of linking the first match", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{
|
||||
projects: [
|
||||
makeProject({
|
||||
title: "t3code (Laptop)",
|
||||
deepLink: "/new/draft?environmentId=env-1&projectId=a&title=t3code",
|
||||
}),
|
||||
makeProject({
|
||||
title: "t3code (Desktop)",
|
||||
deepLink: "/new/draft?environmentId=env-2&projectId=b&title=t3code",
|
||||
}),
|
||||
makeProject({ title: "recent", deepLink: "/new/draft?projectId=recent" }),
|
||||
],
|
||||
},
|
||||
makeEnvironment({
|
||||
widgetFamily: "systemMedium",
|
||||
configuration: { pinnedProjects: "t3code", showRecent: false },
|
||||
}),
|
||||
),
|
||||
);
|
||||
// Ambiguous bare title must not deep-link either duplicate.
|
||||
expect(layout).not.toContain("environmentId=env-1");
|
||||
expect(layout).not.toContain("environmentId=env-2");
|
||||
expect(layout).toContain('"widgetURL":"t3code://new"');
|
||||
});
|
||||
|
||||
it("pins a disambiguated title to the intended environment", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{
|
||||
projects: [
|
||||
makeProject({
|
||||
title: "t3code (Laptop)",
|
||||
deepLink: "/new/draft?environmentId=env-1&projectId=a&title=t3code",
|
||||
}),
|
||||
makeProject({
|
||||
title: "t3code (Desktop)",
|
||||
deepLink: "/new/draft?environmentId=env-2&projectId=b&title=t3code",
|
||||
}),
|
||||
],
|
||||
},
|
||||
makeEnvironment({
|
||||
widgetFamily: "systemMedium",
|
||||
configuration: { pinnedProjects: "t3code (Desktop)", showRecent: false },
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(layout).toContain("t3code (Desktop)");
|
||||
expect(layout).toContain(
|
||||
'"destination":"t3code://new/draft?environmentId=env-2&projectId=b&title=t3code"',
|
||||
);
|
||||
expect(layout).not.toContain("environmentId=env-1");
|
||||
});
|
||||
|
||||
it("hides recents when the fill toggle is off", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{ projects: [makeProject({ title: "pinned-one" }), makeProject({ title: "recent" })] },
|
||||
makeEnvironment({
|
||||
widgetFamily: "systemMedium",
|
||||
configuration: { pinnedProjects: "pinned-one", showRecent: false },
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(layout).toContain("pinned-one");
|
||||
expect(layout).not.toContain("recent");
|
||||
});
|
||||
|
||||
it("falls back to the call to action when recents are off and no pin matches", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{ projects: [makeProject({ title: "recent" })] },
|
||||
makeEnvironment({
|
||||
widgetFamily: "systemMedium",
|
||||
configuration: { pinnedProjects: "gone", showRecent: false },
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(layout).toContain('"widgetURL":"t3code://new"');
|
||||
expect(layout).not.toContain("recent");
|
||||
});
|
||||
|
||||
it("drops the link but keeps the row for unsafe deep links", () => {
|
||||
const layout = JSON.stringify(
|
||||
NewThread(
|
||||
{ projects: [makeProject({ title: "sneaky", deepLink: "//evil.example" })] },
|
||||
mediumEnvironment,
|
||||
),
|
||||
);
|
||||
expect(layout).toContain("sneaky");
|
||||
expect(layout).not.toContain("evil.example");
|
||||
});
|
||||
|
||||
it("adapts the container background to the color scheme", () => {
|
||||
const dark = JSON.stringify(NewThread({ projects: [] }, smallEnvironment));
|
||||
const light = JSON.stringify(
|
||||
NewThread(
|
||||
{ projects: [] },
|
||||
makeEnvironment({ widgetFamily: "systemSmall", colorScheme: "light" }),
|
||||
),
|
||||
);
|
||||
expect(dark).toContain('"containerBackground":"#0a0a0a"');
|
||||
expect(light).toContain('"containerBackground":"#ffffff"');
|
||||
});
|
||||
});
|
||||
@@ -1,211 +0,0 @@
|
||||
import { HStack, Image, Link, Spacer, Text, VStack } from "@expo/ui/swift-ui";
|
||||
import type { ComponentProps, JSX } from "react";
|
||||
import {
|
||||
containerBackground,
|
||||
font,
|
||||
foregroundStyle,
|
||||
frame,
|
||||
lineLimit,
|
||||
padding,
|
||||
resizable,
|
||||
widgetURL,
|
||||
} from "@expo/ui/swift-ui/modifiers";
|
||||
import { createWidget, type WidgetEnvironment } from "expo-widgets";
|
||||
|
||||
export interface NewThreadWidgetProject {
|
||||
readonly title: string;
|
||||
/** App-relative path to the prefilled draft composer, e.g. "/new/draft?environmentId=…". */
|
||||
readonly deepLink: string;
|
||||
}
|
||||
|
||||
export interface NewThreadWidgetProps {
|
||||
/**
|
||||
* Candidate projects, most recently active first. The medium/large widgets
|
||||
* render a slice of these as one-tap shortcuts into the draft composer.
|
||||
* The full workspace set is synced (not just the visible rows): pinned-
|
||||
* project matching happens here in the widget (the configuration is per
|
||||
* widget instance, so the app cannot precompute it), and a pin should
|
||||
* resolve even when its project has fallen out of the top displayed rows.
|
||||
* Optional because WidgetKit renders placeholder/gallery entries with no
|
||||
* props before the app has ever written a timeline.
|
||||
*/
|
||||
readonly projects?: ReadonlyArray<NewThreadWidgetProject>;
|
||||
}
|
||||
|
||||
/** Mirrors the `configuration.parameters` in app.config.ts. */
|
||||
export interface NewThreadWidgetConfiguration {
|
||||
/** Comma-separated project titles to pin ahead of recent projects. */
|
||||
readonly pinnedProjects: string;
|
||||
/** Whether to fill the remaining rows with recently active projects. */
|
||||
readonly showRecent: boolean;
|
||||
}
|
||||
|
||||
// This function is serialized into the widget extension's JS bundle, so it
|
||||
// must stay self-contained: no references to module-scope helpers, only the
|
||||
// imported view/modifier factories.
|
||||
export function NewThread(
|
||||
props: NewThreadWidgetProps,
|
||||
environment: WidgetEnvironment<NewThreadWidgetConfiguration>,
|
||||
): JSX.Element {
|
||||
"widget";
|
||||
|
||||
// Semantic label colors adapt to whatever material the OS renders the
|
||||
// widget on (light/dark home screen, tinted iOS 18 mode).
|
||||
const primaryForeground = "primary";
|
||||
const secondaryForeground = "secondary";
|
||||
// Home-screen widgets must supply their own container background on iOS 17+;
|
||||
// match the app's splash background per scheme.
|
||||
const containerColor = environment.colorScheme === "dark" ? "#0a0a0a" : "#ffffff";
|
||||
|
||||
// Any registered scheme variant routes back to this app; taps are delivered
|
||||
// to the widget's containing app, so the prod scheme is safe for all builds.
|
||||
const newThreadUrl = "t3code://new";
|
||||
const toWidgetUrl = (deepLink: string): string | null =>
|
||||
deepLink.startsWith("/") && !deepLink.startsWith("//") ? `t3code://${deepLink.slice(1)}` : null;
|
||||
|
||||
// SF Symbols and the logo ignore frame/foregroundStyle applied directly to
|
||||
// the image; size + tint them through a container the resizable image fills.
|
||||
type SFName = NonNullable<ComponentProps<typeof Image>["systemName"]>;
|
||||
const renderGlyph = (systemName: SFName, size: number, color: string) => (
|
||||
<HStack modifiers={[frame({ width: size, height: size }), foregroundStyle(color)]}>
|
||||
<Image systemName={systemName} modifiers={[resizable()]} />
|
||||
</HStack>
|
||||
);
|
||||
// The 3:2 frame matches the T3 mark's aspect ratio so it never distorts.
|
||||
const renderLogo = (height: number, color: string) => (
|
||||
<HStack modifiers={[frame({ width: height * 1.5, height }), foregroundStyle(color)]}>
|
||||
<Image assetName="T3Mark" modifiers={[resizable()]} />
|
||||
</HStack>
|
||||
);
|
||||
|
||||
const available = props.projects ?? [];
|
||||
const configuration = environment.configuration;
|
||||
|
||||
// Pins are typed titles (see app.config.ts for why there is no picker).
|
||||
// Match case-insensitively, exact title first and then prefix, preserving
|
||||
// the user's pin order. A query that matches more than one remaining project
|
||||
// is skipped (no ambiguous deep link) rather than picking the first by
|
||||
// activity order. Unmatched pins (typo, deleted project) are skipped.
|
||||
const pinnedQueries = (
|
||||
typeof configuration?.pinnedProjects === "string" ? configuration.pinnedProjects : ""
|
||||
)
|
||||
.split(",")
|
||||
.map((title) => title.trim().toLowerCase())
|
||||
.filter((title) => title.length > 0);
|
||||
const pinned: NewThreadWidgetProject[] = [];
|
||||
for (const query of pinnedQueries) {
|
||||
const unused = available.filter((project) => !pinned.includes(project));
|
||||
const exactMatches = unused.filter((project) => project.title.toLowerCase() === query);
|
||||
let match: NewThreadWidgetProject | undefined;
|
||||
if (exactMatches.length === 1) {
|
||||
match = exactMatches[0];
|
||||
} else if (exactMatches.length === 0) {
|
||||
const prefixMatches = unused.filter((project) =>
|
||||
project.title.toLowerCase().startsWith(query),
|
||||
);
|
||||
if (prefixMatches.length === 1) {
|
||||
match = prefixMatches[0];
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
pinned.push(match);
|
||||
}
|
||||
}
|
||||
|
||||
// Pinned first, then latest activity — unless recents are configured off.
|
||||
const rows = [...pinned];
|
||||
if (configuration?.showRecent !== false) {
|
||||
for (const project of available) {
|
||||
if (!rows.includes(project)) {
|
||||
rows.push(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
const rowLimit = environment.widgetFamily === "systemLarge" ? 7 : 3;
|
||||
const visible = rows.slice(0, rowLimit);
|
||||
|
||||
// The whole small widget is one tap target; the medium/large widgets add
|
||||
// per-row links, with the root widgetURL as the fallback for untargeted areas.
|
||||
const rootModifiers = [containerBackground(containerColor, "widget"), widgetURL(newThreadUrl)];
|
||||
|
||||
// Small family — and the larger families with nothing to list (no sync yet,
|
||||
// or recents off with no pin matched) — render a single centered call to action.
|
||||
if (environment.widgetFamily === "systemSmall" || visible.length === 0) {
|
||||
return (
|
||||
<VStack spacing={7} modifiers={rootModifiers}>
|
||||
<Spacer minLength={0} />
|
||||
{renderLogo(20, primaryForeground)}
|
||||
<HStack spacing={5} alignment="center">
|
||||
{renderGlyph("square.and.pencil", 12, secondaryForeground)}
|
||||
<Text
|
||||
modifiers={[font({ weight: "semibold", size: 13 }), foregroundStyle(primaryForeground)]}
|
||||
>
|
||||
New Thread
|
||||
</Text>
|
||||
</HStack>
|
||||
<Spacer minLength={0} />
|
||||
</VStack>
|
||||
);
|
||||
}
|
||||
|
||||
// Project shortcut row: tapping opens the draft composer with that project
|
||||
// preselected. Rows whose deep link fails the safety check still render,
|
||||
// but fall through to the root's plain new-thread tap target.
|
||||
const renderProjectRow = (project: NewThreadWidgetProject, isPinned: boolean) => {
|
||||
const url = toWidgetUrl(project.deepLink);
|
||||
const row = (
|
||||
<HStack spacing={7} alignment="center">
|
||||
{renderGlyph(isPinned ? "pin.fill" : "folder", 11, secondaryForeground)}
|
||||
<Text
|
||||
modifiers={[
|
||||
font({ weight: "semibold", size: 13 }),
|
||||
foregroundStyle(primaryForeground),
|
||||
lineLimit(1),
|
||||
]}
|
||||
>
|
||||
{project.title}
|
||||
</Text>
|
||||
<Spacer minLength={8} />
|
||||
{renderGlyph("chevron.forward", 9, secondaryForeground)}
|
||||
</HStack>
|
||||
);
|
||||
return url ? <Link destination={url}>{row}</Link> : row;
|
||||
};
|
||||
|
||||
// Pinned rows always precede recents, so index < pinned.length marks them.
|
||||
const renderRow = (index: number) => {
|
||||
const project = visible[index];
|
||||
return project ? renderProjectRow(project, index < pinned.length) : null;
|
||||
};
|
||||
|
||||
return (
|
||||
<VStack alignment="leading" spacing={8} modifiers={rootModifiers}>
|
||||
<Link destination={newThreadUrl}>
|
||||
<HStack spacing={7} alignment="center">
|
||||
{renderLogo(15, primaryForeground)}
|
||||
<Text
|
||||
modifiers={[font({ weight: "bold", size: 14 }), foregroundStyle(primaryForeground)]}
|
||||
>
|
||||
New Thread
|
||||
</Text>
|
||||
<Spacer minLength={8} />
|
||||
{renderGlyph("square.and.pencil", 14, secondaryForeground)}
|
||||
</HStack>
|
||||
</Link>
|
||||
<Spacer minLength={0} modifiers={[padding({ vertical: 1 })]} />
|
||||
{renderRow(0)}
|
||||
{renderRow(1)}
|
||||
{renderRow(2)}
|
||||
{renderRow(3)}
|
||||
{renderRow(4)}
|
||||
{renderRow(5)}
|
||||
{renderRow(6)}
|
||||
<Spacer minLength={0} />
|
||||
</VStack>
|
||||
);
|
||||
}
|
||||
|
||||
export default createWidget<NewThreadWidgetProps, NewThreadWidgetConfiguration>(
|
||||
"NewThread",
|
||||
NewThread,
|
||||
);
|
||||
@@ -85,6 +85,11 @@ export function useCloudLinkController() {
|
||||
return false;
|
||||
}
|
||||
const tokenResult = await settlePromise(() => getToken(resolveRelayClerkTokenOptions()));
|
||||
if (tokenResult._tag === "Failure") {
|
||||
reportUpdateFailure(squashAtomCommandFailure(tokenResult));
|
||||
return false;
|
||||
}
|
||||
const clerkToken = tokenResult.value;
|
||||
const wantsLink = desired.managedTunnel || desired.publish;
|
||||
|
||||
// A failure after this point may follow a partially applied mutation (e.g.
|
||||
@@ -92,11 +97,9 @@ export function useCloudLinkController() {
|
||||
// success or failure — refreshes the rendered state to whatever the server
|
||||
// actually holds now.
|
||||
if (!wantsLink) {
|
||||
// Unlink works without a relay token — a failed token read must not
|
||||
// leave the user unable to turn T3 Connect off.
|
||||
const unlinkResult = await unlinkPrimaryEnvironment({
|
||||
target,
|
||||
clerkToken: tokenResult._tag === "Success" ? (tokenResult.value ?? null) : null,
|
||||
clerkToken: clerkToken ?? null,
|
||||
});
|
||||
if (unlinkResult._tag === "Failure") {
|
||||
if (!isAtomCommandInterrupted(unlinkResult)) {
|
||||
@@ -106,11 +109,6 @@ export function useCloudLinkController() {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (tokenResult._tag === "Failure") {
|
||||
reportUpdateFailure(squashAtomCommandFailure(tokenResult));
|
||||
return false;
|
||||
}
|
||||
const clerkToken = tokenResult.value;
|
||||
if (!clerkToken) {
|
||||
reportUpdateFailure(new Error("Sign in to T3 Connect before enabling this."));
|
||||
return false;
|
||||
|
||||
@@ -136,29 +136,6 @@ export function CloudEnvironmentConnectRows({
|
||||
}
|
||||
|
||||
if (standalone && visibleEnvironments.length === 0) {
|
||||
// A failed or offline discovery is not "no environments" — misreporting it
|
||||
// as empty would read as the user's devices having disappeared.
|
||||
const discoveryProblem = environmentsState.offline
|
||||
? "You appear to be offline."
|
||||
: (Option.getOrNull(environmentsState.error)?.message ?? null);
|
||||
if (discoveryProblem !== null && !environmentsState.refreshing) {
|
||||
return (
|
||||
<div className={ITEM_ROW_CLASSNAME}>
|
||||
<p className="text-sm font-medium text-destructive">
|
||||
Could not load T3 Connect environments
|
||||
</p>
|
||||
<p className="mt-1 text-xs text-muted-foreground">{discoveryProblem}</p>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="mt-3"
|
||||
onClick={() => void refreshRelayEnvironments()}
|
||||
>
|
||||
Try again
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,7 @@ export function ConnectOnboardingDialog() {
|
||||
type OnboardingStep = "publish" | "devices";
|
||||
|
||||
function ConfiguredConnectOnboardingDialog() {
|
||||
// Mirrors ManagedRelayAuthProvider: a pending Clerk session must not read as
|
||||
// signed-out, or its later activation would look like a fresh sign-in.
|
||||
const { isLoaded, isSignedIn, userId } = useAuth({ treatPendingAsSignedOut: false });
|
||||
const { isLoaded, isSignedIn, userId } = useAuth();
|
||||
const [optOutState, setOptOutState] = useLocalStorage(
|
||||
CONNECT_ONBOARDING_OPT_OUT_STORAGE_KEY,
|
||||
EMPTY_CONNECT_ONBOARDING_OPT_OUT_STATE,
|
||||
@@ -91,30 +89,19 @@ function ConfiguredConnectOnboardingDialog() {
|
||||
|
||||
const optOutAccounts = optOutState.optOutAccounts;
|
||||
|
||||
// Every sign-in or account switch that completes during this session
|
||||
// requests the wizard — account transitions clear the connected relay
|
||||
// environments, so each new session starts with no devices to reach. A cold
|
||||
// load observes undefined → account and must not re-prompt.
|
||||
// Every sign-in that completes during this session requests the wizard. A
|
||||
// cold load observes undefined → account and must not re-prompt — only a
|
||||
// null → account transition is a sign-in.
|
||||
useEffect(() => {
|
||||
if (!isLoaded) return;
|
||||
// A loaded-but-incomplete snapshot (signed in, user id not yet populated)
|
||||
// must not be recorded as signed-out — the next render would then look
|
||||
// like a fresh sign-in on a cold load.
|
||||
if (isSignedIn && !userId) return;
|
||||
const previousAccount = observedAccountRef.current;
|
||||
const nextAccount = isSignedIn && userId ? userId : null;
|
||||
observedAccountRef.current = nextAccount;
|
||||
if (previousAccount !== undefined && previousAccount !== nextAccount && nextAccount !== null) {
|
||||
if (previousAccount === null && nextAccount !== null) {
|
||||
setRequestedAccount(nextAccount);
|
||||
}
|
||||
}, [isLoaded, isSignedIn, userId]);
|
||||
|
||||
// A manageable session implies a primary environment, so when the scopes
|
||||
// allow publishing, wait for the connection target too — otherwise the
|
||||
// wizard could open on the devices step moments before the publish step
|
||||
// becomes available and freeze there.
|
||||
const publishStepDecided = !canManageRelay || controller.linkState.target !== null;
|
||||
|
||||
// Open once the session scopes resolve so the step set is stable. Accounts
|
||||
// that chose "Don't show this again" are skipped.
|
||||
useEffect(() => {
|
||||
@@ -123,7 +110,7 @@ function ConfiguredConnectOnboardingDialog() {
|
||||
setRequestedAccount(null);
|
||||
return;
|
||||
}
|
||||
if (!sessionScopesKnown || !publishStepDecided) return;
|
||||
if (!sessionScopesKnown) return;
|
||||
setRequestedAccount(null);
|
||||
prefilledFromLinkStateRef.current = false;
|
||||
setExposeEnvironment(true);
|
||||
@@ -136,7 +123,6 @@ function ConfiguredConnectOnboardingDialog() {
|
||||
controller.linkState.target,
|
||||
openForAccount,
|
||||
optOutAccounts,
|
||||
publishStepDecided,
|
||||
requestedAccount,
|
||||
sessionScopesKnown,
|
||||
]);
|
||||
@@ -154,25 +140,19 @@ function ConfiguredConnectOnboardingDialog() {
|
||||
|
||||
// Toggles default on, but an environment that is already linked should show
|
||||
// its actual configuration instead of silently proposing to rewrite it.
|
||||
// Only when the link belongs to the account being onboarded, though — after
|
||||
// an account switch the cached link state can still describe the previous
|
||||
// account's setup.
|
||||
const linkStateData = controller.linkState.data;
|
||||
useEffect(() => {
|
||||
if (openForAccount === null || prefilledFromLinkStateRef.current || linkStateData === null) {
|
||||
return;
|
||||
}
|
||||
prefilledFromLinkStateRef.current = true;
|
||||
if (linkStateData.linked && linkStateData.cloudUserId === openForAccount) {
|
||||
if (linkStateData.linked) {
|
||||
setExposeEnvironment(linkStateData.managedTunnelActive ?? linkStateData.linked);
|
||||
setPublishAgentActivity(linkStateData.publishAgentActivity);
|
||||
}
|
||||
}, [linkStateData, openForAccount]);
|
||||
|
||||
const complete = () => {
|
||||
// Keep the wizard up while a link request is in flight so its outcome
|
||||
// (and any failure) stays visible.
|
||||
if (isApplying) return;
|
||||
const account = openForAccount;
|
||||
setOpenForAccount(null);
|
||||
if (account !== null && dontShowAgain) {
|
||||
@@ -212,9 +192,7 @@ function ConfiguredConnectOnboardingDialog() {
|
||||
<Dialog
|
||||
open={openForAccount !== null}
|
||||
onOpenChange={(open) => {
|
||||
// Keep the dialog up while a link request is in flight so its outcome
|
||||
// (and any failure) stays visible.
|
||||
if (!open && !isApplying) complete();
|
||||
if (!open) complete();
|
||||
}}
|
||||
>
|
||||
<DialogPopup className="max-w-xl">
|
||||
@@ -225,12 +203,7 @@ function ConfiguredConnectOnboardingDialog() {
|
||||
place.
|
||||
</DialogDescription>
|
||||
{steps.length > 1 ? (
|
||||
<OnboardingStepper
|
||||
steps={steps}
|
||||
currentStep={step}
|
||||
disabled={isApplying}
|
||||
onStepSelect={setStep}
|
||||
/>
|
||||
<OnboardingStepper steps={steps} currentStep={step} onStepSelect={setStep} />
|
||||
) : null}
|
||||
</DialogHeader>
|
||||
<DialogPanel>
|
||||
@@ -271,9 +244,7 @@ function ConfiguredConnectOnboardingDialog() {
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<Button disabled={isApplying} onClick={complete}>
|
||||
Done
|
||||
</Button>
|
||||
<Button onClick={complete}>Done</Button>
|
||||
)}
|
||||
</div>
|
||||
</DialogFooter>
|
||||
@@ -290,12 +261,10 @@ const STEP_LABELS: Record<OnboardingStep, string> = {
|
||||
function OnboardingStepper({
|
||||
steps,
|
||||
currentStep,
|
||||
disabled,
|
||||
onStepSelect,
|
||||
}: {
|
||||
readonly steps: ReadonlyArray<OnboardingStep>;
|
||||
readonly currentStep: OnboardingStep;
|
||||
readonly disabled: boolean;
|
||||
readonly onStepSelect: (step: OnboardingStep) => void;
|
||||
}) {
|
||||
const currentIndex = steps.indexOf(currentStep);
|
||||
@@ -305,7 +274,6 @@ function OnboardingStepper({
|
||||
<button
|
||||
key={step}
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] gap-x-2 rounded-lg border px-3 py-2 text-left",
|
||||
index === currentIndex
|
||||
|
||||
@@ -736,7 +736,7 @@ describe("makeAggregateState", () => {
|
||||
...state,
|
||||
threadId: "thread-done" as RelayAgentActivityState["threadId"],
|
||||
phase: "completed",
|
||||
updatedAt: "1970-01-01T00:44:00.000Z",
|
||||
updatedAt: "1970-01-01T00:50:00.000Z",
|
||||
};
|
||||
const aggregate = AgentActivityPublisher.makeAggregateState({
|
||||
activeStates: [active, staleCompleted],
|
||||
@@ -769,7 +769,7 @@ describe("makeAggregateState", () => {
|
||||
});
|
||||
expect(
|
||||
AgentActivityPublisher.makeAggregateState({
|
||||
activeStates: [{ ...lingeringCompleted, updatedAt: "1970-01-01T00:44:00.000Z" }],
|
||||
activeStates: [{ ...lingeringCompleted, updatedAt: "1970-01-01T00:50:00.000Z" }],
|
||||
terminalState: null,
|
||||
nowMs: hourMs,
|
||||
}),
|
||||
@@ -789,25 +789,16 @@ describe("makeAggregateState", () => {
|
||||
updatedAt: "1970-01-01T00:59:00.000Z",
|
||||
};
|
||||
const aggregate = AgentActivityPublisher.makeAggregateState({
|
||||
activeStates: [
|
||||
mkActive("a-1"),
|
||||
mkActive("a-2"),
|
||||
mkActive("a-3"),
|
||||
mkActive("a-4"),
|
||||
mkActive("a-5"),
|
||||
justCompleted,
|
||||
],
|
||||
activeStates: [mkActive("a-1"), mkActive("a-2"), mkActive("a-3"), justCompleted],
|
||||
terminalState: null,
|
||||
nowMs: hourMs,
|
||||
});
|
||||
|
||||
expect(aggregate?.activeCount).toBe(5);
|
||||
expect(aggregate?.activeCount).toBe(3);
|
||||
expect(aggregate?.activities).toMatchObject([
|
||||
{ threadId: "a-1" },
|
||||
{ threadId: "a-2" },
|
||||
{ threadId: "a-3" },
|
||||
{ threadId: "a-4" },
|
||||
{ threadId: "a-5" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -13,7 +13,6 @@ import * as Option from "effect/Option";
|
||||
import {
|
||||
isExpiredAgentActivityState,
|
||||
isTerminalPhase,
|
||||
MAX_ACTIVITY_ROWS,
|
||||
sanitizeAgentActivityAggregateState,
|
||||
} from "./agentActivityPayloads.ts";
|
||||
|
||||
@@ -229,7 +228,7 @@ function terminalAggregateState(state: RelayAgentActivityState): RelayAgentActiv
|
||||
// How long a finished thread keeps its Done/Failed row in the aggregate while
|
||||
// other agents are still active. Long enough to be seen on the lock screen,
|
||||
// short enough that the activity list stays about live work.
|
||||
export const TERMINAL_AGENT_ACTIVITY_DISPLAY_TTL_MS = 15 * 60 * 1_000;
|
||||
export const TERMINAL_AGENT_ACTIVITY_DISPLAY_TTL_MS = 5 * 60 * 1_000;
|
||||
|
||||
function isRecentTerminalState(state: RelayAgentActivityState, nowMs: number): boolean {
|
||||
if (!isTerminalPhase(state)) {
|
||||
@@ -274,7 +273,7 @@ export function makeAggregateState(input: {
|
||||
subtitle: newest.phase === "failed" ? "Agent work failed" : "Agent work completed",
|
||||
activeCount: 0,
|
||||
updatedAt: newest.updatedAt,
|
||||
activities: recentTerminal.slice(0, MAX_ACTIVITY_ROWS).map(aggregateRowForState),
|
||||
activities: recentTerminal.slice(0, 3).map(aggregateRowForState),
|
||||
});
|
||||
}
|
||||
// Recently finished threads ride along after the active ones (display slots
|
||||
@@ -283,10 +282,7 @@ export function makeAggregateState(input: {
|
||||
const recentTerminalStates = input.activeStates
|
||||
.filter((state) => isRecentTerminalState(state, input.nowMs))
|
||||
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
||||
const displayedStates = [
|
||||
...activeStates.slice(0, MAX_ACTIVITY_ROWS),
|
||||
...recentTerminalStates,
|
||||
].slice(0, MAX_ACTIVITY_ROWS);
|
||||
const displayedStates = [...activeStates.slice(0, 3), ...recentTerminalStates].slice(0, 3);
|
||||
const updatedAt = [...activeStates, ...recentTerminalStates].reduce((latest, state) =>
|
||||
state.updatedAt.localeCompare(latest.updatedAt) > 0 ? state : latest,
|
||||
).updatedAt;
|
||||
|
||||
@@ -373,7 +373,7 @@ describe("ApnsDeliveries", () => {
|
||||
...aggregate,
|
||||
title: longTitle,
|
||||
subtitle: longTitle,
|
||||
activities: [0, 1, 2, 3, 4, 5].map((index) =>
|
||||
activities: [0, 1, 2, 3].map((index) =>
|
||||
Object.assign({}, aggregate.activities[0]!, {
|
||||
projectTitle: longTitle,
|
||||
threadTitle: longTitle,
|
||||
@@ -396,7 +396,7 @@ describe("ApnsDeliveries", () => {
|
||||
const payloadAggregate = queuedJobs[0]?.payload.aggregate;
|
||||
expect(payloadAggregate?.title.length).toBeLessThanOrEqual(120);
|
||||
expect(payloadAggregate?.subtitle.length).toBeLessThanOrEqual(120);
|
||||
expect(payloadAggregate?.activities).toHaveLength(5);
|
||||
expect(payloadAggregate?.activities).toHaveLength(3);
|
||||
expect(payloadAggregate?.activities[0]?.projectTitle.length).toBeLessThanOrEqual(120);
|
||||
expect(payloadAggregate?.activities[0]?.status.length).toBeLessThanOrEqual(40);
|
||||
expect(payloadAggregate?.activities[0]?.deepLink).toBe("/");
|
||||
|
||||
@@ -43,9 +43,7 @@ export function isExpiredAgentActivityState(
|
||||
const MAX_SUMMARY_TEXT_LENGTH = 120;
|
||||
const MAX_STATUS_TEXT_LENGTH = 40;
|
||||
const MAX_DEEP_LINK_LENGTH = 512;
|
||||
// The Live Activity banner (lock screen / Notification Center) renders up to
|
||||
// five rows; the expanded Dynamic Island shows the top three of these.
|
||||
export const MAX_ACTIVITY_ROWS = 5;
|
||||
const MAX_ACTIVITY_ROWS = 3;
|
||||
|
||||
function truncateText(value: string, maxLength: number): string {
|
||||
const trimmed = value.trim();
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
"engines": {
|
||||
"node": "^24.13.1"
|
||||
},
|
||||
"packageManager": "pnpm@11.10.0",
|
||||
"packageManager": "pnpm@10.24.0",
|
||||
"msw": {
|
||||
"workerDirectory": [
|
||||
"apps/web/public"
|
||||
|
||||
@@ -222,27 +222,7 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () {
|
||||
error: Option.none(),
|
||||
});
|
||||
|
||||
// Signed out is the idle state, not a failure: the proactive refresh on
|
||||
// credentials-changed also runs on sign-out and must settle back to a
|
||||
// clean empty list. Only the session-level "no credentials" error is
|
||||
// benign — relay-side auth failures (expired/invalid tokens) happen
|
||||
// after this point and must surface as errors.
|
||||
const tokenResult = yield* Effect.result(session.clerkToken);
|
||||
if (tokenResult._tag === "Failure") {
|
||||
const failure = tokenResult.failure;
|
||||
if (failure._tag === "ConnectionBlockedError" && failure.reason === "authentication") {
|
||||
if ((yield* Ref.get(accountGeneration)) !== generation) {
|
||||
return;
|
||||
}
|
||||
yield* SubscriptionRef.update(state, (current) => ({
|
||||
...current,
|
||||
refreshing: false,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
return yield* Effect.fail(failure);
|
||||
}
|
||||
const clerkToken = tokenResult.success;
|
||||
const clerkToken = yield* session.clerkToken;
|
||||
if ((yield* Ref.get(accountGeneration)) !== generation) {
|
||||
return;
|
||||
}
|
||||
@@ -299,10 +279,15 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () {
|
||||
if ((yield* Ref.get(accountGeneration)) !== generation) {
|
||||
return;
|
||||
}
|
||||
// Signed out is the idle state, not a failure: the proactive
|
||||
// refresh on credentials-changed also runs on sign-out and must
|
||||
// settle back to a clean empty list.
|
||||
const signedOut =
|
||||
error._tag === "ConnectionBlockedError" && error.reason === "authentication";
|
||||
yield* SubscriptionRef.update(state, (current) => ({
|
||||
...current,
|
||||
refreshing: false,
|
||||
error: Option.some(error),
|
||||
error: signedOut ? Option.none() : Option.some(error),
|
||||
}));
|
||||
}),
|
||||
),
|
||||
|
||||
@@ -155,46 +155,6 @@ describe("vcsActionState", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("clears running presentation state once the action finishes", () => {
|
||||
const initial = beginVcsActionState({
|
||||
operation: "run_change_request",
|
||||
label: "Running source control action",
|
||||
actionId,
|
||||
});
|
||||
const pushing = applyVcsActionProgressEvent(
|
||||
initial,
|
||||
progress({
|
||||
actionId,
|
||||
action,
|
||||
cwd,
|
||||
kind: "phase_started",
|
||||
phase: "push",
|
||||
label: "Pushing...",
|
||||
}),
|
||||
);
|
||||
const finished = applyVcsActionProgressEvent(
|
||||
pushing,
|
||||
progress({
|
||||
actionId,
|
||||
action,
|
||||
cwd,
|
||||
kind: "action_finished",
|
||||
result,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(finished).toMatchObject({
|
||||
isRunning: false,
|
||||
operation: "run_change_request",
|
||||
actionId,
|
||||
action,
|
||||
currentLabel: null,
|
||||
currentPhaseLabel: null,
|
||||
lastOutputLine: null,
|
||||
error: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("retains a terminal action error for presentation", () => {
|
||||
const initial = beginVcsActionState({
|
||||
operation: "run_change_request",
|
||||
|
||||
@@ -386,10 +386,12 @@ export function applyVcsActionProgressEvent(
|
||||
};
|
||||
case "action_finished":
|
||||
return {
|
||||
...EMPTY_VCS_ACTION_STATE,
|
||||
...current,
|
||||
isRunning: false,
|
||||
actionId: event.actionId,
|
||||
action: event.action,
|
||||
operation: "run_change_request",
|
||||
error: null,
|
||||
};
|
||||
case "action_failed":
|
||||
return {
|
||||
|
||||
@@ -1,42 +1,3 @@
|
||||
diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt
|
||||
index 03d8d9f3a5c403c93282d53cbacf1a339e877e85..54d5eabc6c8a408e711a5be97286fdbb8ab1c461 100644
|
||||
--- a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt
|
||||
+++ b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt
|
||||
@@ -103,6 +103,34 @@ class ScreenStackHeaderConfigViewManager :
|
||||
config.setTitle(title)
|
||||
}
|
||||
|
||||
+ // The t3 patch adds these iOS glass-chrome props to the native spec; they have
|
||||
+ // no Android implementation, but the codegen-generated interface requires the
|
||||
+ // setters to exist. No-ops keep the Android build compiling.
|
||||
+ override fun setSubtitle(
|
||||
+ config: ScreenStackHeaderConfig,
|
||||
+ subtitle: String?,
|
||||
+ ) = Unit
|
||||
+
|
||||
+ override fun setLargeSubtitle(
|
||||
+ config: ScreenStackHeaderConfig,
|
||||
+ largeSubtitle: String?,
|
||||
+ ) = Unit
|
||||
+
|
||||
+ override fun setNavigationItemStyle(
|
||||
+ config: ScreenStackHeaderConfig,
|
||||
+ navigationItemStyle: String?,
|
||||
+ ) = Unit
|
||||
+
|
||||
+ override fun setHeaderCenterBarButtonItems(
|
||||
+ config: ScreenStackHeaderConfig,
|
||||
+ headerCenterBarButtonItems: ReadableArray?,
|
||||
+ ) = Unit
|
||||
+
|
||||
+ override fun setHeaderToolbarItems(
|
||||
+ config: ScreenStackHeaderConfig,
|
||||
+ headerToolbarItems: ReadableArray?,
|
||||
+ ) = Unit
|
||||
+
|
||||
override fun setTitleFontFamily(
|
||||
config: ScreenStackHeaderConfig,
|
||||
titleFontFamily: String?,
|
||||
diff --git a/ios/RNSBarButtonItem.h b/ios/RNSBarButtonItem.h
|
||||
index ea5325ea8d17b1ddfa790ff8dab48ce83142d4d3..acd2fd7ceb7162ed300abc4d3c9f0c24f4d63898 100644
|
||||
--- a/ios/RNSBarButtonItem.h
|
||||
@@ -1106,7 +1067,7 @@ index b7568ecfebd4f4420f2a8d3fec5184d7fc728dd1..41ca1f273f0175929e73105faa463978
|
||||
onPressHeaderBarButtonMenuItem?: CT.DirectEventHandler<OnPressHeaderBarButtonMenuItemEvent> | undefined;
|
||||
synchronousShadowStateUpdatesEnabled?: CT.WithDefault<boolean, false>;
|
||||
diff --git a/lib/typescript/types.d.ts b/lib/typescript/types.d.ts
|
||||
index 3b384e03891e38e936f370372a682d73440e7ec2..861ffed850e90f27916c427853b503dbe6ee9840 100644
|
||||
index 3b384e03891e38e936f370372a682d73440e7ec2..1e3a966806c8b8b312f75fb367f758efe49dde9d 100644
|
||||
--- a/lib/typescript/types.d.ts
|
||||
+++ b/lib/typescript/types.d.ts
|
||||
@@ -10,6 +10,7 @@ export type SearchBarCommands = {
|
||||
|
||||
Generated
+319
-295
File diff suppressed because it is too large.
Load diff
+10
-17
@@ -5,23 +5,6 @@ packages:
|
||||
- packages/*
|
||||
- scripts
|
||||
|
||||
# Successor to onlyBuiltDependencies/ignoredBuiltDependencies (pnpm 11).
|
||||
# true = allowed to run build scripts; false mirrors the pnpm 10 behavior
|
||||
# where anything outside onlyBuiltDependencies was silently not built.
|
||||
allowBuilds:
|
||||
browser-tabs-lock: false
|
||||
bufferutil: false
|
||||
core-js: false
|
||||
electron: true
|
||||
electron-winstaller: false
|
||||
esbuild: true
|
||||
msgpackr-extract: true
|
||||
msw: false
|
||||
node-pty: true
|
||||
sharp: true
|
||||
utf-8-validate: false
|
||||
workerd: false
|
||||
|
||||
catalog:
|
||||
"@clerk/backend": 3.8.4
|
||||
"@clerk/clerk-js": 6.22.0
|
||||
@@ -51,6 +34,16 @@ catalog:
|
||||
vite-plus: 0.2.2
|
||||
yaml: ^2.9.0
|
||||
|
||||
ignoredBuiltDependencies:
|
||||
- msw
|
||||
|
||||
onlyBuiltDependencies:
|
||||
- electron
|
||||
- esbuild
|
||||
- msgpackr-extract
|
||||
- node-pty
|
||||
- sharp
|
||||
|
||||
overrides:
|
||||
"@clerk/backend": "catalog:"
|
||||
"@clerk/clerk-js": "catalog:"
|
||||
|
||||
@@ -11,7 +11,7 @@ import { ChildProcessSpawner } from "effect/unstable/process";
|
||||
import {
|
||||
BuildCommandFailedError,
|
||||
createStageWorkspaceConfig,
|
||||
createStagePatchedDependencies,
|
||||
createStagePnpmConfig,
|
||||
createBuildConfig,
|
||||
DESKTOP_ASAR_UNPACK,
|
||||
InvalidMacPasskeyRpDomainError,
|
||||
@@ -168,7 +168,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
|
||||
it("carries only staged dependency patch metadata into staged desktop installs", () => {
|
||||
assert.deepStrictEqual(
|
||||
createStagePatchedDependencies(
|
||||
createStagePnpmConfig(
|
||||
{
|
||||
"@expo/[email protected]": "patches/@expo%[email protected]",
|
||||
"@ff-labs/[email protected]": "patches/@[email protected]",
|
||||
@@ -183,26 +183,28 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
},
|
||||
),
|
||||
{
|
||||
"@ff-labs/[email protected]": "patches/@[email protected]",
|
||||
"@pierre/[email protected]": "patches/@pierre%[email protected].patch",
|
||||
"[email protected]": "patches/[email protected].patch",
|
||||
patchedDependencies: {
|
||||
"@ff-labs/[email protected]": "patches/@[email protected].patch",
|
||||
"@pierre/[email protected]": "patches/@pierre%[email protected].patch",
|
||||
"[email protected]": "patches/[email protected]",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
createStagePatchedDependencies(
|
||||
assert.equal(
|
||||
createStagePnpmConfig(
|
||||
{
|
||||
"@expo/[email protected]": "patches/@expo%[email protected]",
|
||||
},
|
||||
{ effect: "4.0.0-beta.73" },
|
||||
),
|
||||
{},
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it("installs optional native dependencies for the target desktop architecture", () => {
|
||||
assert.deepStrictEqual(STAGE_INSTALL_ARGS, ["install", "--prod"]);
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "mac", arch: "x64" }), {
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig("mac", "x64"), {
|
||||
supportedArchitectures: {
|
||||
os: ["darwin"],
|
||||
cpu: ["x64"],
|
||||
@@ -210,21 +212,21 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
});
|
||||
// Windows artifacts also bundle the same-architecture WSL (Linux, glibc) backend, so the
|
||||
// staged install must fetch its native optional deps (e.g. ffi-rs) too.
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "win", arch: "x64" }), {
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig("win", "x64"), {
|
||||
supportedArchitectures: {
|
||||
os: ["win32", "linux"],
|
||||
cpu: ["x64"],
|
||||
libc: ["glibc"],
|
||||
},
|
||||
});
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "win", arch: "arm64" }), {
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig("win", "arm64"), {
|
||||
supportedArchitectures: {
|
||||
os: ["win32", "linux"],
|
||||
cpu: ["arm64"],
|
||||
libc: ["glibc"],
|
||||
},
|
||||
});
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "mac", arch: "universal" }), {
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig("mac", "universal"), {
|
||||
supportedArchitectures: {
|
||||
os: ["darwin"],
|
||||
cpu: ["arm64", "x64"],
|
||||
@@ -232,62 +234,6 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
});
|
||||
});
|
||||
|
||||
it("stages pnpm 11 allowBuilds and patchedDependencies in the workspace yaml", () => {
|
||||
assert.deepStrictEqual(
|
||||
createStageWorkspaceConfig({
|
||||
platform: "linux",
|
||||
arch: "x64",
|
||||
allowBuilds: {
|
||||
electron: true,
|
||||
"node-pty": true,
|
||||
"browser-tabs-lock": false,
|
||||
},
|
||||
patchedDependencies: {
|
||||
"[email protected]": "patches/[email protected]",
|
||||
},
|
||||
overrides: {
|
||||
effect: "4.0.0-beta.73",
|
||||
},
|
||||
}),
|
||||
{
|
||||
supportedArchitectures: {
|
||||
os: ["linux"],
|
||||
cpu: ["x64"],
|
||||
},
|
||||
allowBuilds: {
|
||||
electron: true,
|
||||
"node-pty": true,
|
||||
"browser-tabs-lock": false,
|
||||
},
|
||||
patchedDependencies: {
|
||||
"[email protected]": "patches/[email protected]",
|
||||
},
|
||||
overrides: {
|
||||
effect: "4.0.0-beta.73",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Empty maps must not be written — pnpm would still require reviewed
|
||||
// packages if allowBuilds is present but incomplete, and omitting empty
|
||||
// patchedDependencies keeps the stage yaml minimal.
|
||||
assert.deepStrictEqual(
|
||||
createStageWorkspaceConfig({
|
||||
platform: "mac",
|
||||
arch: "arm64",
|
||||
allowBuilds: {},
|
||||
patchedDependencies: {},
|
||||
overrides: {},
|
||||
}),
|
||||
{
|
||||
supportedArchitectures: {
|
||||
os: ["darwin"],
|
||||
cpu: ["arm64"],
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("unpacks the fff shared library for filesystem and FFI access", () => {
|
||||
assert.deepStrictEqual(DESKTOP_ASAR_UNPACK, ["node_modules/@ff-labs/fff-bin-*/**/*"]);
|
||||
});
|
||||
|
||||
@@ -40,7 +40,6 @@ const WorkspaceConfig = Schema.Struct({
|
||||
catalog: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
||||
overrides: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
||||
patchedDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
||||
allowBuilds: Schema.optional(Schema.Record(Schema.String, Schema.Boolean)),
|
||||
});
|
||||
type WorkspaceConfig = typeof WorkspaceConfig.Type;
|
||||
|
||||
@@ -50,14 +49,7 @@ const StageWorkspaceConfig = Schema.Struct({
|
||||
cpu: Schema.Array(Schema.String),
|
||||
libc: Schema.optional(Schema.Array(Schema.String)),
|
||||
}),
|
||||
// pnpm 11 only reads these from pnpm-workspace.yaml (not package.json#pnpm).
|
||||
// Without allowBuilds the staged `vp install --prod` fails with
|
||||
// ERR_PNPM_IGNORED_BUILDS for packages that have lifecycle scripts.
|
||||
allowBuilds: Schema.optional(Schema.Record(Schema.String, Schema.Boolean)),
|
||||
patchedDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
||||
overrides: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
||||
});
|
||||
type StageWorkspaceConfig = typeof StageWorkspaceConfig.Type;
|
||||
|
||||
const RepoRoot = Effect.service(Path.Path).pipe(
|
||||
Effect.flatMap((path) => path.fromFileUrl(new URL("..", import.meta.url))),
|
||||
@@ -571,6 +563,10 @@ interface StagePackageJson {
|
||||
readonly devDependencies: {
|
||||
readonly electron: string;
|
||||
};
|
||||
readonly overrides: Record<string, unknown>;
|
||||
readonly pnpm?: {
|
||||
readonly patchedDependencies?: Record<string, string>;
|
||||
};
|
||||
}
|
||||
|
||||
export const STAGE_INSTALL_ARGS = ["install", "--prod"] as const;
|
||||
@@ -880,14 +876,10 @@ const stageClerkPasskeyNativeBinaries = Effect.fn("stageClerkPasskeyNativeBinari
|
||||
}
|
||||
});
|
||||
|
||||
export function createStageWorkspaceConfig(input: {
|
||||
readonly platform: typeof BuildPlatform.Type;
|
||||
readonly arch: typeof BuildArch.Type;
|
||||
readonly allowBuilds?: Record<string, boolean>;
|
||||
readonly patchedDependencies?: Record<string, string>;
|
||||
readonly overrides?: Record<string, string>;
|
||||
}): StageWorkspaceConfig {
|
||||
const { platform, arch, allowBuilds, patchedDependencies, overrides } = input;
|
||||
export function createStageWorkspaceConfig(
|
||||
platform: typeof BuildPlatform.Type,
|
||||
arch: typeof BuildArch.Type,
|
||||
): typeof StageWorkspaceConfig.Type {
|
||||
const hostOs = platform === "mac" ? "darwin" : platform === "win" ? "win32" : "linux";
|
||||
const hostCpu = arch === "universal" ? ["arm64", "x64"] : [arch];
|
||||
// Windows artifacts also bundle the same-architecture WSL Linux backend, which loads
|
||||
@@ -895,37 +887,36 @@ export function createStageWorkspaceConfig(input: {
|
||||
// Pull the Linux (glibc) variants in addition to the host platform's so
|
||||
// they ship in the asar; without them the WSL backend crash-loops on require
|
||||
// ("Cannot find module '@yuuang/ffi-rs-linux-x64-gnu'").
|
||||
const supportedArchitectures =
|
||||
platform === "win"
|
||||
? {
|
||||
os: Array.from(new Set([hostOs, "linux"])),
|
||||
cpu: hostCpu,
|
||||
libc: ["glibc"],
|
||||
}
|
||||
: {
|
||||
os: [hostOs],
|
||||
cpu: hostCpu,
|
||||
};
|
||||
|
||||
if (platform === "win") {
|
||||
return {
|
||||
supportedArchitectures: {
|
||||
os: Array.from(new Set([hostOs, "linux"])),
|
||||
cpu: hostCpu,
|
||||
libc: ["glibc"],
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
supportedArchitectures,
|
||||
...(allowBuilds && Object.keys(allowBuilds).length > 0 ? { allowBuilds } : {}),
|
||||
...(patchedDependencies && Object.keys(patchedDependencies).length > 0
|
||||
? { patchedDependencies }
|
||||
: {}),
|
||||
...(overrides && Object.keys(overrides).length > 0 ? { overrides } : {}),
|
||||
supportedArchitectures: {
|
||||
os: [hostOs],
|
||||
cpu: hostCpu,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function createStagePatchedDependencies(
|
||||
export function createStagePnpmConfig(
|
||||
patchedDependencies: Record<string, string>,
|
||||
dependencies: Record<string, unknown>,
|
||||
): Record<string, string> {
|
||||
return Object.fromEntries(
|
||||
): StagePackageJson["pnpm"] | undefined {
|
||||
const stagePatchedDependencies = Object.fromEntries(
|
||||
Object.entries(patchedDependencies).filter(([patchKey]) =>
|
||||
Object.hasOwn(dependencies, getPatchedDependencyPackageName(patchKey)),
|
||||
),
|
||||
);
|
||||
|
||||
return Object.keys(stagePatchedDependencies).length > 0
|
||||
? { patchedDependencies: stagePatchedDependencies }
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function getPatchedDependencyPackageName(patchKey: string): string {
|
||||
@@ -1549,7 +1540,6 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
const workspaceCatalog = workspaceConfig.catalog ?? {};
|
||||
const workspaceOverrides = workspaceConfig.overrides ?? {};
|
||||
const workspacePatchedDependencies = workspaceConfig.patchedDependencies ?? {};
|
||||
const workspaceAllowBuilds = workspaceConfig.allowBuilds ?? {};
|
||||
|
||||
const platformConfig = PLATFORM_CONFIG[options.platform];
|
||||
if (!platformConfig) {
|
||||
@@ -1719,10 +1709,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
)
|
||||
: {}),
|
||||
};
|
||||
const stagePatchedDependencies = createStagePatchedDependencies(
|
||||
workspacePatchedDependencies,
|
||||
stageDependencies,
|
||||
);
|
||||
const stagePnpmConfig = createStagePnpmConfig(workspacePatchedDependencies, stageDependencies);
|
||||
const stagePackageJson: StagePackageJson = {
|
||||
name: "t3code",
|
||||
version: appVersion,
|
||||
@@ -1751,24 +1738,20 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
devDependencies: {
|
||||
electron: electronVersion,
|
||||
},
|
||||
overrides: resolvedOverrides,
|
||||
...(stagePnpmConfig ? { pnpm: stagePnpmConfig } : {}),
|
||||
};
|
||||
|
||||
const stagePackageJsonString = yield* encodeJsonString(stagePackageJson);
|
||||
yield* fs.writeFileString(path.join(stageAppDir, "package.json"), `${stagePackageJsonString}\n`);
|
||||
const stageWorkspaceConfig = createStageWorkspaceConfig({
|
||||
platform: options.platform,
|
||||
arch: options.arch,
|
||||
allowBuilds: workspaceAllowBuilds,
|
||||
patchedDependencies: stagePatchedDependencies,
|
||||
overrides: resolvedOverrides,
|
||||
});
|
||||
const stageWorkspaceConfig = createStageWorkspaceConfig(options.platform, options.arch);
|
||||
const stageWorkspaceConfigString = yield* encodeStageWorkspaceConfig(stageWorkspaceConfig);
|
||||
yield* fs.writeFileString(
|
||||
path.join(stageAppDir, "pnpm-workspace.yaml"),
|
||||
stageWorkspaceConfigString,
|
||||
);
|
||||
|
||||
if (Object.keys(stagePatchedDependencies).length > 0) {
|
||||
if (Object.keys(workspacePatchedDependencies).length > 0) {
|
||||
yield* fs.copy(path.join(repoRoot, "patches"), path.join(stageAppDir, "patches"));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user