Compare commits

...
Author SHA1 Message Date
Ben DavisandClaude Fable 5 3322fedc5a Restore react-native-keyboard-controller 1.21.7 from main
The branch predated main's #3545 bump and pinned 1.21.6; keep main's
version rather than silently downgrading it.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-01 16:54:42 -07:00
Ben DavisandClaude Fable 5 3be7de0663 Merge main into fix/mobile-device-builds-and-android-ui
Resolved pnpm-lock.yaml by re-running pnpm install against main's
lockfile so the branch's Expo SDK bumps re-resolve on top of main.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-01 16:22:50 -07:00
Julius Marminge 7b9eef7ac2 Restore the ultrathink frame border effect (#3625) 2026-07-01 00:25:36 +00:00
Julius Marminge 9d66b104fe Add Claude Sonnet 5 as the default Claude model (#3620) 2026-06-30 11:40:35 -07:00
Utkarsh Patil 51ea084c87 fix: warm WSL before preflight in WSL-only backend mode (#3588) 2026-06-30 11:27:34 -07:00
Hugo BlomandJulius Marminge 0615fd7df1 Add middle-click close for right panel tabs (#3161)
Co-authored-by: Julius Marminge <[email protected]>
2026-06-30 17:13:38 +00:00
t3-code[bot] 2448212367 chore(release): prepare v0.0.28 2026-06-29 22:57:48 +00:00
Julius Marminge fda6486233 Restore chat scroll affordances and add timeline minimap (#3587) 2026-06-29 19:35:16 +00:00
Ben Davis 2e5b83f4ce fix(mobile): disable unsupported push registration 2026-06-26 15:43:57 -07:00
Ben Davis 03cebdff1d fix(mobile): address review feedback 2026-06-26 15:26:57 -07:00
Ben Davis e61d5909ae fix(mobile): gate personal team bundle override 2026-06-26 15:15:23 -07:00
Ben Davis f55639d0eb fix(mobile): support standalone device builds and Android UI 2026-06-25 22:13:47 -07:00
35 changed files with 2191 additions and 631 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@t3tools/desktop",
"version": "0.0.27",
"version": "0.0.28",
"private": true,
"type": "module",
"main": "dist-electron/main.cjs",
@@ -607,6 +607,7 @@ export const make = Effect.gen(function* () {
const backendExposure = yield* serverExposure.backendConfig;
const persistedSettings = yield* settings.get;
const shared = yield* sharedInputs;
yield* wslEnvironment.preWarm(persistedSettings.wslDistro);
return yield* resolveWslStartConfig({
...shared,
port: backendExposure.port,
+24
View File
@@ -34,6 +34,30 @@ Build and run the local iOS dev client:
vp run ios:dev
```
If your Xcode account only has a Personal Team, use a bundle identifier you control and opt into the
reduced-capability local build. Personal Team builds omit the widget extension, push entitlement, and
native Sign in with Apple entitlement; builds without this opt-in are unchanged.
```bash
T3CODE_IOS_PERSONAL_TEAM=1 \
T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID=com.example.t3code.dev \
vp run ios:dev
```
Build and install a self-contained Release app that does not need Metro:
```bash
vp run ios:release
```
The Personal Team equivalent also needs a unique bundle identifier:
```bash
T3CODE_IOS_PERSONAL_TEAM=1 \
T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID=com.example.t3code \
vp run ios:release
```
Build and run the local iOS preview app:
```bash
+41 -18
View File
@@ -8,6 +8,20 @@ const repoEnv = loadRepoEnv();
Object.assign(process.env, repoEnv);
const APP_VARIANT = resolveAppVariant(repoEnv.APP_VARIANT);
const isIosPersonalTeamBuild = repoEnv.T3CODE_IOS_PERSONAL_TEAM === "1";
const personalTeamBundleIdentifier = repoEnv.T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID?.trim();
const IOS_BUNDLE_IDENTIFIER_PATTERN = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
if (
isIosPersonalTeamBuild &&
(!personalTeamBundleIdentifier ||
!IOS_BUNDLE_IDENTIFIER_PATTERN.test(personalTeamBundleIdentifier))
) {
throw new Error(
"T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID must be a reverse-DNS identifier such as com.example.t3code when T3CODE_IOS_PERSONAL_TEAM=1.",
);
}
const VARIANT_CONFIG: Record<
AppVariant,
@@ -54,6 +68,27 @@ function resolveAppVariant(value: string | undefined): AppVariant {
}
const variant = VARIANT_CONFIG[APP_VARIANT];
const iosBundleIdentifier =
isIosPersonalTeamBuild && personalTeamBundleIdentifier
? personalTeamBundleIdentifier
: variant.iosBundleIdentifier;
const widgetsPlugin = [
"expo-widgets",
{
bundleIdentifier: `${iosBundleIdentifier}.widgets`,
groupIdentifier: `group.${iosBundleIdentifier}`,
enablePushNotifications: true,
widgets: [
{
name: "AgentActivity",
displayName: "Agent Activity",
description: "Shows the current state of active T3 Code agents.",
supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
},
],
},
] satisfies NonNullable<ExpoConfig["plugins"]>[number];
const config: ExpoConfig = {
name: variant.appName,
@@ -76,7 +111,7 @@ const config: ExpoConfig = {
ios: {
icon: variant.iosIcon,
supportsTablet: true,
bundleIdentifier: variant.iosBundleIdentifier,
bundleIdentifier: iosBundleIdentifier,
infoPlist: {
NSAppTransportSecurity: {
NSAllowsArbitraryLoads: true,
@@ -102,9 +137,10 @@ const config: ExpoConfig = {
},
plugins: [
"expo-router",
"expo-asset",
"expo-font",
"expo-secure-store",
["@clerk/expo", { theme: "./clerk-theme.json" }],
["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
"expo-web-browser",
[
"expo-camera",
@@ -139,26 +175,13 @@ const config: ExpoConfig = {
},
},
],
[
"expo-widgets",
{
bundleIdentifier: `${variant.iosBundleIdentifier}.widgets`,
groupIdentifier: `group.${variant.iosBundleIdentifier}`,
enablePushNotifications: true,
widgets: [
{
name: "AgentActivity",
displayName: "Agent Activity",
description: "Shows the current state of active T3 Code agents.",
supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
},
],
},
],
...(!isIosPersonalTeamBuild ? [widgetsPlugin] : []),
"./plugins/withAndroidCleartextTraffic.cjs",
...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
],
extra: {
appVariant: APP_VARIANT,
iosPersonalTeamBuild: isIosPersonalTeamBuild,
relay: {
url: repoEnv.T3CODE_RELAY_URL ?? null,
},
+20 -18
View File
@@ -22,6 +22,7 @@
"ios:dev": "APP_VARIANT=development EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios",
"ios:preview": "APP_VARIANT=preview EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios",
"ios:prod": "APP_VARIANT=production EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios",
"ios:release": "APP_VARIANT=production EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios --configuration Release --no-bundler",
"eas:ios:dev": "eas build --profile development -p ios",
"eas:ios:preview": "eas build --profile preview -p ios",
"eas:ios:preview:dev": "eas build --profile preview:dev -p ios",
@@ -43,7 +44,7 @@
"@clerk/expo": "catalog:",
"@effect/atom-react": "catalog:",
"@expo-google-fonts/dm-sans": "^0.4.2",
"@expo/ui": "~56.0.8",
"@expo/ui": "~56.0.18",
"@legendapp/list": "3.2.0",
"@noble/curves": "catalog:",
"@noble/hashes": "catalog:",
@@ -59,34 +60,35 @@
"@t3tools/mobile-review-diff-native": "file:./modules/t3-review-diff",
"@t3tools/mobile-terminal-native": "file:./modules/t3-terminal",
"@t3tools/shared": "workspace:*",
"@tabler/icons-react-native": "^3.44.0",
"clsx": "^2.1.1",
"diff": "8.0.3",
"effect": "catalog:",
"expo": "^56.0.0",
"expo-asset": "~56.0.15",
"expo-auth-session": "~56.0.12",
"expo-build-properties": "~56.0.15",
"expo-camera": "~56.0.7",
"expo-clipboard": "~56.0.3",
"expo-constants": "~56.0.16",
"expo": "^56.0.12",
"expo-asset": "~56.0.17",
"expo-auth-session": "~56.0.14",
"expo-build-properties": "~56.0.19",
"expo-camera": "~56.0.8",
"expo-clipboard": "~56.0.4",
"expo-constants": "~56.0.18",
"expo-crypto": "~56.0.4",
"expo-dev-client": "~56.0.16",
"expo-file-system": "~56.0.7",
"expo-font": "~56.0.5",
"expo-dev-client": "~56.0.20",
"expo-file-system": "~56.0.8",
"expo-font": "~56.0.7",
"expo-glass-effect": "~56.0.4",
"expo-haptics": "~56.0.3",
"expo-image-picker": "~56.0.14",
"expo-linking": "~56.0.12",
"expo-image-picker": "~56.0.18",
"expo-linking": "~56.0.14",
"expo-network": "~56.0.5",
"expo-notifications": "~56.0.14",
"expo-notifications": "~56.0.18",
"expo-paste-input": "^0.1.15",
"expo-router": "~56.2.7",
"expo-router": "~56.2.11",
"expo-secure-store": "~56.0.4",
"expo-splash-screen": "~56.0.10",
"expo-symbols": "~56.0.5",
"expo-updates": "~56.0.17",
"expo-symbols": "~56.0.6",
"expo-updates": "~56.0.19",
"expo-web-browser": "~56.0.5",
"expo-widgets": "~56.0.15",
"expo-widgets": "~56.0.19",
"punycode": "^2.3.1",
"react": "19.2.3",
"react-dom": "19.2.3",
@@ -0,0 +1,10 @@
const { withEntitlementsPlist } = require("expo/config-plugins");
module.exports = function withoutIosPersonalTeamCapabilities(config) {
return withEntitlementsPlist(config, (modConfig) => {
delete modConfig.modResults["aps-environment"];
delete modConfig.modResults["com.apple.developer.applesignin"];
delete modConfig.modResults["com.apple.security.application-groups"];
return modConfig;
});
};
+1 -1
View File
@@ -5,6 +5,7 @@ import {
DMSans_700Bold,
useFonts,
} from "@expo-google-fonts/dm-sans";
import { RegistryContext } from "@effect/atom-react";
import { usePathname } from "expo-router";
import Stack from "expo-router/stack";
import { useCallback } from "react";
@@ -18,7 +19,6 @@ import { LoadingScreen } from "../components/LoadingScreen";
import { useWorkspaceState } from "../state/workspace";
import { useThreadOutboxDrain } from "../state/use-thread-outbox-drain";
import { RegistryContext } from "@effect/atom-react";
import { appAtomRegistry } from "../state/atom-registry";
import { CloudAuthProvider } from "../features/cloud/CloudAuthProvider";
import {
+1
View File
@@ -84,6 +84,7 @@ export default function HomeRouteScreen() {
<>
<HomeHeader
environments={environments}
searchQuery={searchQuery}
selectedEnvironmentId={selectedEnvironmentId}
projectSortOrder={listOptions.projectSortOrder}
threadSortOrder={listOptions.threadSortOrder}
+16 -4
View File
@@ -16,6 +16,7 @@ import {
squashAtomCommandFailure,
} from "@t3tools/client-runtime/state/runtime";
import { AppText as Text } from "../../components/AppText";
import { supportsAgentAwarenessPush } from "../../features/agent-awareness/capabilities";
import { setLiveActivityUpdatesEnabled } from "../../features/agent-awareness/liveActivityPreferences";
import { requestAgentNotificationPermission } from "../../features/agent-awareness/notificationPermissions";
import { refreshAgentAwarenessRegistration } from "../../features/agent-awareness/remoteRegistration";
@@ -74,6 +75,7 @@ function LocalSettingsRouteScreen() {
}
function ConfiguredSettingsRouteScreen() {
const agentAwarenessPushAvailable = supportsAgentAwarenessPush();
const insets = useSafeAreaInsets();
const { push } = useRouter();
const { expand: expandClerkSheet } = useClerkSettingsSheetDetent();
@@ -361,17 +363,27 @@ function ConfiguredSettingsRouteScreen() {
<SettingsSwitchRow
icon="bell.badge"
label="Device Notifications"
disabled={notificationStatus === "checking" || notificationStatus === "unsupported"}
value={notificationStatus === "enabled"}
disabled={
!agentAwarenessPushAvailable ||
notificationStatus === "checking" ||
notificationStatus === "unsupported"
}
value={agentAwarenessPushAvailable && notificationStatus === "enabled"}
onValueChange={handleDeviceNotificationsChange}
/>
<SettingsSwitchRow
disabled={
!isLoaded || liveActivityStatus === "checking" || liveActivityStatus === "linking"
!agentAwarenessPushAvailable ||
!isLoaded ||
liveActivityStatus === "checking" ||
liveActivityStatus === "linking"
}
icon="bolt.circle"
label="Live Activity Updates"
value={liveActivityStatus === "enabled" || liveActivityStatus === "linking"}
value={
agentAwarenessPushAvailable &&
(liveActivityStatus === "enabled" || liveActivityStatus === "linking")
}
onValueChange={handleLiveActivitiesChange}
/>
</SettingsSection>
+140
View File
@@ -0,0 +1,140 @@
import {
IconAdjustmentsHorizontal,
IconAlertTriangle,
IconArchive,
IconArrowBackUp,
IconArrowDownCircle,
IconArrowRightCircle,
IconArrowUp,
IconArrowUpRight,
IconBellRinging,
IconBolt,
IconCamera,
IconCheck,
IconChevronDown,
IconChevronRight,
IconChevronUp,
IconCircleCheck,
IconCircleXFilled,
IconCopy,
IconDeviceDesktop,
IconDots,
IconDotsCircleHorizontal,
IconEdit,
IconExternalLink,
IconEye,
IconFileText,
IconFilter,
IconFolder,
IconFolderPlus,
IconGitBranch,
IconGitMerge,
IconInfoCircle,
IconLayoutColumns,
IconLink,
IconMessage,
IconNetwork,
IconPlayerPlay,
IconPlayerStopFilled,
IconPlus,
IconRefresh,
IconSearch,
IconServer,
IconSettings,
IconTerminal2,
IconTrash,
IconTypography,
IconUserCircle,
IconWifiOff,
IconX,
type Icon,
} from "@tabler/icons-react-native";
import { Platform } from "react-native";
import { SymbolView as ExpoSymbolView, type SFSymbol, type SymbolViewProps } from "expo-symbols";
const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
"arrow.branch": IconGitBranch,
"arrow.clockwise": IconRefresh,
"arrow.down.circle": IconArrowDownCircle,
"arrow.right.circle": IconArrowRightCircle,
"arrow.triangle.branch": IconGitBranch,
"arrow.turn.left.up": IconArrowBackUp,
"arrow.up": IconArrowUp,
"arrow.up.right": IconArrowUpRight,
archivebox: IconArchive,
"archivebox.fill": IconArchive,
"bell.badge": IconBellRinging,
"bolt.circle": IconBolt,
"bolt.horizontal.circle": IconBolt,
camera: IconCamera,
checkmark: IconCheck,
"checkmark.circle": IconCircleCheck,
"chevron.down": IconChevronDown,
"chevron.right": IconChevronRight,
"chevron.up": IconChevronUp,
desktopcomputer: IconDeviceDesktop,
"doc.on.doc": IconCopy,
"doc.text": IconFileText,
ellipsis: IconDots,
"ellipsis.circle": IconDotsCircleHorizontal,
"exclamationmark.triangle": IconAlertTriangle,
eye: IconEye,
folder: IconFolder,
"folder.badge.plus": IconFolderPlus,
"folder.fill": IconFolder,
gearshape: IconSettings,
"info.circle": IconInfoCircle,
link: IconLink,
"line.3.horizontal.decrease.circle": IconFilter,
"line.3.horizontal.decrease.circle.fill": IconFilter,
magnifyingglass: IconSearch,
"person.crop.circle": IconUserCircle,
play: IconPlayerPlay,
plus: IconPlus,
"point.3.connected.trianglepath.dotted": IconNetwork,
"point.topleft.down.curvedto.point.bottomright.up": IconGitMerge,
safari: IconExternalLink,
"server.rack": IconServer,
"slider.horizontal.3": IconAdjustmentsHorizontal,
"square.and.pencil": IconEdit,
"square.split.2x1": IconLayoutColumns,
"stop.fill": IconPlayerStopFilled,
terminal: IconTerminal2,
"text.bubble": IconMessage,
"textformat.size": IconTypography,
trash: IconTrash,
"wifi.slash": IconWifiOff,
xmark: IconX,
"xmark.circle.fill": IconCircleXFilled,
};
export type { SFSymbol } from "expo-symbols";
export type AppSymbolName = SymbolViewProps["name"];
export function SymbolView(props: SymbolViewProps) {
if (Platform.OS !== "android") {
return <ExpoSymbolView {...props} />;
}
if (typeof props.name === "object" && props.name.android) {
return <ExpoSymbolView {...props} />;
}
const sfSymbol = typeof props.name === "string" ? props.name : props.name.ios;
const AndroidIcon = sfSymbol ? ANDROID_ICON_BY_SF_SYMBOL[sfSymbol] : undefined;
if (!AndroidIcon) {
return props.fallback ?? null;
}
return (
<AndroidIcon
accessibilityLabel={props.accessibilityLabel}
color={props.tintColor}
size={props.size}
strokeWidth={2}
style={props.style}
testID={props.testID}
/>
);
}
+1 -1
View File
@@ -1,10 +1,10 @@
import { MenuView } from "@react-native-menu/menu";
import type { ComponentProps, ReactNode } from "react";
import { Pressable, useColorScheme, View } from "react-native";
import { SymbolView } from "expo-symbols";
import { useThemeColor } from "../lib/useThemeColor";
import { cn } from "../lib/cn";
import { SymbolView } from "./AppSymbol";
import { AppText as Text } from "./AppText";
export function ControlPill(props: {
@@ -0,0 +1,5 @@
import Constants from "expo-constants";
export function supportsAgentAwarenessPush() {
return Constants.expoConfig?.extra?.iosPersonalTeamBuild !== true;
}
@@ -1,6 +1,7 @@
import type { RelayDeviceRegistrationRequest } from "@t3tools/contracts/relay";
import type { Preferences } from "../../lib/storage";
import { supportsAgentAwarenessPush } from "./capabilities";
export function makeRelayDeviceRegistrationRequest(input: {
readonly deviceId: string;
@@ -12,7 +13,8 @@ export function makeRelayDeviceRegistrationRequest(input: {
readonly notificationsEnabled: boolean;
readonly preferences: Preferences;
}): RelayDeviceRegistrationRequest {
const liveActivitiesEnabled = input.preferences.liveActivitiesEnabled !== false;
const pushAvailable = supportsAgentAwarenessPush();
const liveActivitiesEnabled = pushAvailable && input.preferences.liveActivitiesEnabled !== false;
return {
deviceId: input.deviceId,
label: input.label,
@@ -23,7 +25,7 @@ export function makeRelayDeviceRegistrationRequest(input: {
...(input.pushToStartToken ? { pushToStartToken: input.pushToStartToken } : {}),
preferences: {
liveActivitiesEnabled,
notificationsEnabled: input.notificationsEnabled,
notificationsEnabled: pushAvailable && input.notificationsEnabled,
notifyOnApproval: true,
notifyOnInput: true,
notifyOnCompletion: true,
@@ -213,6 +213,26 @@ describe("makeRelayDeviceRegistrationRequest", () => {
});
});
it("disables push features in Personal Team relay registrations", () => {
Constants.expoConfig!.extra = { iosPersonalTeamBuild: true };
expect(
makeRelayDeviceRegistrationRequest({
deviceId: "device-1",
label: "Julius's iPhone",
iosMajorVersion: 18,
appVersion: "1.0.0",
pushToken: "apns-token",
pushToStartToken: "push-to-start-token",
notificationsEnabled: true,
preferences: {},
}).preferences,
).toMatchObject({
liveActivitiesEnabled: false,
notificationsEnabled: false,
});
});
it("marks notification delivery disabled when APNs permission is unavailable", () => {
expect(
makeRelayDeviceRegistrationRequest({
+278 -1
View File
@@ -8,9 +8,15 @@ import {
DEFAULT_SIDEBAR_PROJECT_SORT_ORDER,
DEFAULT_SIDEBAR_THREAD_SORT_ORDER,
} from "@t3tools/contracts";
import type { MenuAction } from "@react-native-menu/menu";
import { Stack } from "expo-router";
import { Text as RNText, View } from "react-native";
import { useCallback, useEffect, useMemo, useRef } from "react";
import { Platform, Pressable, Text as RNText, TextInput, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import type { SearchBarCommands } from "react-native-screens";
import { ControlPill, ControlPillMenu } from "../../components/ControlPill";
import { SymbolView } from "../../components/AppSymbol";
import { useThemeColor } from "../../lib/useThemeColor";
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
import type { HomeProjectSortOrder } from "./homeThreadList";
@@ -60,6 +66,7 @@ const PROJECT_GROUPING_OPTIONS: ReadonlyArray<{
export function HomeHeader(props: {
readonly environments: ReadonlyArray<HomeHeaderEnvironment>;
readonly searchQuery: string;
readonly selectedEnvironmentId: EnvironmentId | null;
readonly projectSortOrder: HomeProjectSortOrder;
readonly threadSortOrder: SidebarThreadSortOrder;
@@ -72,6 +79,271 @@ export function HomeHeader(props: {
readonly onOpenSettings: () => void;
readonly onStartNewTask: () => void;
}) {
if (Platform.OS === "android") {
return <AndroidHomeHeader {...props} />;
}
return <IosHomeHeader {...props} />;
}
type HomeHeaderProps = Parameters<typeof HomeHeader>[0];
function checkedMenuTitle(checked: boolean, title: string) {
return checked ? `✓ ${title}` : title;
}
function AndroidHomeHeader(props: HomeHeaderProps) {
const insets = useSafeAreaInsets();
const iconColor = useThemeColor("--color-icon");
const mutedColor = useThemeColor("--color-foreground-muted");
const subtleColor = useThemeColor("--color-subtle");
const headerColor = useThemeColor("--color-header");
const headerBorderColor = useThemeColor("--color-header-border");
const inputColor = useThemeColor("--color-input");
const inputBorderColor = useThemeColor("--color-input-border");
const placeholderColor = useThemeColor("--color-placeholder");
const hasCustomListOptions =
props.selectedEnvironmentId !== null ||
props.projectSortOrder !== DEFAULT_SIDEBAR_PROJECT_SORT_ORDER ||
props.threadSortOrder !== DEFAULT_SIDEBAR_THREAD_SORT_ORDER ||
props.projectGroupingMode !== DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE;
const menuActions = useMemo<MenuAction[]>(
() => [
{
id: "environment",
title: "Environment",
subactions: [
{
id: "environment:all",
title: checkedMenuTitle(props.selectedEnvironmentId === null, "All environments"),
},
...props.environments.map((environment) => ({
id: `environment:${environment.environmentId}`,
title: checkedMenuTitle(
props.selectedEnvironmentId === environment.environmentId,
environment.label,
),
})),
],
},
{
id: "project-sort",
title: "Sort projects",
subactions: PROJECT_SORT_OPTIONS.map((option) => ({
id: `project-sort:${option.value}`,
title: checkedMenuTitle(props.projectSortOrder === option.value, option.label),
})),
},
{
id: "thread-sort",
title: "Sort threads",
subactions: THREAD_SORT_OPTIONS.map((option) => ({
id: `thread-sort:${option.value}`,
title: checkedMenuTitle(props.threadSortOrder === option.value, option.label),
})),
},
{
id: "project-grouping",
title: "Group projects",
subactions: PROJECT_GROUPING_OPTIONS.map((option) => ({
id: `project-grouping:${option.value}`,
title: checkedMenuTitle(props.projectGroupingMode === option.value, option.label),
})),
},
],
[
props.environments,
props.projectGroupingMode,
props.projectSortOrder,
props.selectedEnvironmentId,
props.threadSortOrder,
],
);
const handleMenuAction = useCallback(
(event: { nativeEvent: { event: string } }) => {
const id = event.nativeEvent.event;
if (id === "environment:all") {
props.onEnvironmentChange(null);
return;
}
if (id.startsWith("environment:")) {
const environmentId = id.slice("environment:".length);
const environment = props.environments.find(
(candidate) => candidate.environmentId === environmentId,
);
if (environment) {
props.onEnvironmentChange(environment.environmentId);
}
return;
}
const projectSort = PROJECT_SORT_OPTIONS.find(
(option) => id === `project-sort:${option.value}`,
);
if (projectSort) {
props.onProjectSortOrderChange(projectSort.value);
return;
}
const threadSort = THREAD_SORT_OPTIONS.find((option) => id === `thread-sort:${option.value}`);
if (threadSort) {
props.onThreadSortOrderChange(threadSort.value);
return;
}
const grouping = PROJECT_GROUPING_OPTIONS.find(
(option) => id === `project-grouping:${option.value}`,
);
if (grouping) {
props.onProjectGroupingModeChange(grouping.value);
}
},
[props],
);
return (
<>
<Stack.Screen options={{ headerShown: false }} />
<View
style={{
backgroundColor: headerColor,
borderBottomColor: headerBorderColor,
borderBottomWidth: 1,
paddingTop: Math.max(insets.top, 12),
paddingBottom: 12,
paddingHorizontal: 16,
}}
>
<View style={{ alignSelf: "center", gap: 12, maxWidth: 720, width: "100%" }}>
<View style={{ alignItems: "center", flexDirection: "row", gap: 10 }}>
<View style={{ alignItems: "center", flexDirection: "row", flex: 1, gap: 8 }}>
<RNText
style={{
color: iconColor,
fontFamily: "DMSans_700Bold",
fontSize: MOBILE_TYPOGRAPHY.title.fontSize,
letterSpacing: -0.5,
}}
>
T3 Code
</RNText>
<View
style={{
backgroundColor: subtleColor,
borderRadius: 99,
paddingHorizontal: 8,
paddingVertical: 3,
}}
>
<RNText
style={{
color: mutedColor,
fontFamily: "DMSans_700Bold",
fontSize: MOBILE_TYPOGRAPHY.micro.fontSize,
letterSpacing: 1.1,
textTransform: "uppercase",
}}
>
Alpha
</RNText>
</View>
</View>
<ControlPillMenu
actions={menuActions}
isAnchoredToRight
onPressAction={handleMenuAction}
>
<Pressable
accessibilityLabel="Filter and sort threads"
accessibilityRole="button"
style={{
alignItems: "center",
backgroundColor: subtleColor,
borderRadius: 99,
height: 44,
justifyContent: "center",
width: 44,
}}
>
<SymbolView
name={
hasCustomListOptions
? "line.3.horizontal.decrease.circle.fill"
: "line.3.horizontal.decrease.circle"
}
size={18}
tintColor={iconColor}
type="monochrome"
/>
</Pressable>
</ControlPillMenu>
<ControlPill
accessibilityLabel="Open settings"
icon="gearshape"
onPress={props.onOpenSettings}
/>
<ControlPill
accessibilityLabel="New task"
icon="square.and.pencil"
onPress={props.onStartNewTask}
variant="primary"
/>
</View>
<View
style={{
alignItems: "center",
backgroundColor: inputColor,
borderColor: inputBorderColor,
borderRadius: 16,
borderWidth: 1,
flexDirection: "row",
gap: 10,
minHeight: 48,
paddingHorizontal: 14,
}}
>
<SymbolView name="magnifyingglass" size={17} tintColor={mutedColor} type="monochrome" />
<TextInput
accessibilityLabel="Search threads"
autoCapitalize="none"
onChangeText={props.onSearchQueryChange}
placeholder="Search threads"
placeholderTextColor={placeholderColor}
style={{
color: iconColor,
flex: 1,
fontFamily: "DMSans_400Regular",
fontSize: MOBILE_TYPOGRAPHY.body.fontSize,
paddingVertical: 10,
}}
value={props.searchQuery}
/>
{props.searchQuery.length > 0 ? (
<Pressable
accessibilityLabel="Clear search"
hitSlop={10}
onPress={() => props.onSearchQueryChange("")}
>
<SymbolView
name="xmark.circle.fill"
size={17}
tintColor={mutedColor}
type="monochrome"
/>
</Pressable>
) : null}
</View>
</View>
</View>
</>
);
}
function IosHomeHeader(props: HomeHeaderProps) {
const searchBarRef = useRef<SearchBarCommands>(null);
const iconColor = useThemeColor("--color-icon");
const mutedColor = useThemeColor("--color-foreground-muted");
const subtleColor = useThemeColor("--color-subtle");
@@ -81,6 +353,10 @@ export function HomeHeader(props: {
props.threadSortOrder !== DEFAULT_SIDEBAR_THREAD_SORT_ORDER ||
props.projectGroupingMode !== DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE;
useEffect(() => {
searchBarRef.current?.setText(props.searchQuery);
}, [props.searchQuery]);
return (
<>
<Stack.Screen
@@ -92,6 +368,7 @@ export function HomeHeader(props: {
headerTintColor: iconColor,
headerTitle: "",
headerSearchBarOptions: {
ref: searchBarRef,
placeholder: "Search threads",
hideNavigationBar: false,
onChangeText: (event) => {
+15 -5
View File
@@ -8,9 +8,15 @@ import type {
SidebarThreadSortOrder,
} from "@t3tools/contracts";
import * as Haptics from "expo-haptics";
import { SymbolView } from "expo-symbols";
import { useCallback, useMemo, useRef, useState } from "react";
import { ActivityIndicator, Pressable, ScrollView, useWindowDimensions, View } from "react-native";
import {
ActivityIndicator,
Platform,
Pressable,
ScrollView,
useWindowDimensions,
View,
} from "react-native";
import ReanimatedSwipeable, {
type SwipeableMethods,
} from "react-native-gesture-handler/ReanimatedSwipeable";
@@ -25,6 +31,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useThemeColor } from "../../lib/useThemeColor";
import { AppText as Text } from "../../components/AppText";
import { SymbolView } from "../../components/AppSymbol";
import { EmptyState } from "../../components/EmptyState";
import { ProjectFavicon } from "../../components/ProjectFavicon";
import type { WorkspaceState } from "../../state/workspaceModel";
@@ -507,16 +514,19 @@ export function HomeScreen(props: HomeScreenProps) {
return (
<View className="flex-1 bg-screen">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
showsVerticalScrollIndicator={false}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
onScrollBeginDrag={() => openSwipeableRef.current?.close()}
className="flex-1"
contentContainerStyle={{
alignSelf: "center",
width: "100%",
maxWidth: 720,
paddingHorizontal: 16,
paddingTop: 8,
paddingBottom: 24,
paddingTop: Platform.OS === "android" ? 16 : 8,
paddingBottom: Math.max(insets.bottom, 24),
gap: 20,
}}
>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "t3",
"version": "0.0.27",
"version": "0.0.28",
"license": "MIT",
"repository": {
"type": "git",
@@ -193,6 +193,36 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
],
}),
},
{
slug: "claude-sonnet-5",
name: "Claude Sonnet 5",
isCustom: false,
capabilities: createModelCapabilities({
optionDescriptors: [
buildSelectOptionDescriptor({
id: "effort",
label: "Reasoning",
options: [
{ value: "low", label: "Low" },
{ value: "medium", label: "Medium" },
{ value: "high", label: "High", isDefault: true },
{ value: "xhigh", label: "Extra High" },
{ value: "max", label: "Max" },
{ value: "ultrathink", label: "Ultrathink" },
],
promptInjectedValues: ["ultrathink"],
}),
buildSelectOptionDescriptor({
id: "contextWindow",
label: "Context Window",
options: [
{ value: "200k", label: "200k", isDefault: true },
{ value: "1m", label: "1M" },
],
}),
],
}),
},
{
slug: "claude-sonnet-4-6",
name: "Claude Sonnet 4.6",
@@ -322,7 +352,12 @@ export function normalizeClaudeCliEffort(
if (effort === "ultracode") {
return "xhigh";
}
if (effort === "xhigh" && model !== "claude-fable-5" && model !== "claude-opus-4-8") {
if (
effort === "xhigh" &&
model !== "claude-fable-5" &&
model !== "claude-opus-4-8" &&
model !== "claude-sonnet-5"
) {
return "max";
}
if (effort === "max" && model === "claude-sonnet-4-6") {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@t3tools/web",
"version": "0.0.27",
"version": "0.0.28",
"private": true,
"type": "module",
"scripts": {
+1 -1
View File
@@ -239,7 +239,7 @@ export const BranchToolbar = memo(function BranchToolbar({
if (!hasActiveThread || !activeProject) return null;
return (
<div className="mx-auto flex w-full max-w-208 items-center gap-2 px-2.5 pb-3 pt-1 sm:px-3">
<div className="mx-auto flex w-full max-w-3xl items-center gap-2 px-2.5 pb-3 pt-1 sm:px-3">
{isMobile ? (
<MobileRunContextSelector
envLocked={envLocked}
+256 -21
View File
@@ -85,6 +85,7 @@ import {
isLatestTurnSettled,
} from "../session-logic";
import { type LegendListRef } from "@legendapp/list/react";
import { getAnchoredTurnMetrics, type TimelineScrollMode } from "./chat/timelineScrollAnchoring";
import {
buildPendingUserInputAnswers,
derivePendingUserInputProgress,
@@ -1161,6 +1162,7 @@ function ChatViewContent(props: ChatViewProps) {
const updateHeight = () => {
const nextHeight = Math.ceil(composerOverlayElement.getBoundingClientRect().height);
if (nextHeight <= 0) return;
setComposerOverlayHeight((currentHeight) =>
currentHeight === nextHeight ? currentHeight : nextHeight,
);
@@ -2012,7 +2014,6 @@ function ChatViewContent(props: ChatViewProps) {
: // Spread only fires for the few messages that actually changed;
// unchanged ones early-return their original reference.
// In-place mutation would break React's immutable state contract.
// oxlint-disable-next-line no-map-spread
messages.map((message) => {
if (
message.role !== "user" ||
@@ -3148,31 +3149,158 @@ function ChatViewContent(props: ChatViewProps) {
],
);
// Scrolling is explicit so streamed timeline updates never take control away
// from the user after the newly sent row has been positioned once.
const scrollToEnd = useCallback((animated = false) => {
void legendListRef.current?.scrollToEnd?.({ animated });
}, []);
// Debounce *showing* the scroll-to-bottom pill so it doesn't flash during
// thread switches. LegendList fires scroll events with isAtEnd=false while
// initialScrollAtEnd is settling; hiding is always immediate.
const showScrollDebouncer = useRef(
new Debouncer(() => setShowScrollToBottom(true), { wait: 150 }),
);
const timelineScrollModeRef = useRef<TimelineScrollMode>("following-end");
const pendingTimelineAnchorRef = useRef<MessageId | null>(null);
const positionedTimelineAnchorRef = useRef<MessageId | null>(null);
const settledTimelineAnchorRef = useRef<MessageId | null>(null);
const activeTimelineAnchorIndexRef = useRef<number | null>(null);
const anchorUserScrollGenerationRef = useRef(0);
const liveFollowUserScrollGenerationRef = useRef<number | null>(0);
const pendingAnchorScrollRestoreRef = useRef<{
readonly messageId: MessageId;
readonly offset: number;
readonly userScrollGeneration: number;
} | null>(null);
const anchorScrollRestoreFrameRef = useRef<number | null>(null);
const cancelTimelineLiveFollowForUserNavigation = useCallback(() => {
anchorUserScrollGenerationRef.current += 1;
timelineScrollModeRef.current = "free-scrolling";
liveFollowUserScrollGenerationRef.current = null;
pendingTimelineAnchorRef.current = null;
positionedTimelineAnchorRef.current = null;
settledTimelineAnchorRef.current = null;
activeTimelineAnchorIndexRef.current = null;
pendingAnchorScrollRestoreRef.current = null;
if (anchorScrollRestoreFrameRef.current !== null) {
cancelAnimationFrame(anchorScrollRestoreFrameRef.current);
anchorScrollRestoreFrameRef.current = null;
}
}, []);
const cancelTimelineLiveFollowForUserNavigationRef = useRef(
cancelTimelineLiveFollowForUserNavigation,
);
useEffect(() => {
cancelTimelineLiveFollowForUserNavigationRef.current =
cancelTimelineLiveFollowForUserNavigation;
}, [cancelTimelineLiveFollowForUserNavigation]);
const getActiveTimelineTurnMetrics = useCallback(
(list?: LegendListRef | null) => {
const resolvedList = list ?? legendListRef.current;
const anchorIndex = activeTimelineAnchorIndexRef.current;
const state = resolvedList?.getState();
if (!resolvedList || !state || anchorIndex === null) {
return null;
}
return getAnchoredTurnMetrics({
state,
anchorIndex,
composerOverlayHeight,
anchorOffset: CHAT_LIST_ANCHOR_OFFSET,
});
},
[composerOverlayHeight],
);
const timelineRealContentOverflowsViewport = useCallback(
(list?: LegendListRef | null) => {
const resolvedList = list ?? legendListRef.current;
const state = resolvedList?.getState();
if (!resolvedList || !state || state.data.length === 0) {
return false;
}
const lastRowIndex = state.data.length - 1;
const lastRowTop = state.positionAtIndex(lastRowIndex);
const lastRowHeight = state.sizeAtIndex(lastRowIndex);
if (
typeof lastRowTop !== "number" ||
typeof lastRowHeight !== "number" ||
!Number.isFinite(lastRowTop) ||
!Number.isFinite(lastRowHeight)
) {
return false;
}
const realContentBottom = lastRowTop + Math.max(1, lastRowHeight);
const visibleScrollLength = Math.max(
0,
(state.scrollLength ?? 0) - composerOverlayHeight - CHAT_LIST_ANCHOR_OFFSET,
);
return realContentBottom > visibleScrollLength;
},
[composerOverlayHeight],
);
// Live-follow stays active after send/thread-open until an actual list scroll
// gesture opts out.
const scrollToEnd = useCallback((animated = false) => {
isAtEndRef.current = true;
timelineScrollModeRef.current = "following-end";
liveFollowUserScrollGenerationRef.current = anchorUserScrollGenerationRef.current;
pendingTimelineAnchorRef.current = null;
activeTimelineAnchorIndexRef.current = null;
showScrollDebouncer.current.cancel();
setShowScrollToBottom(false);
void legendListRef.current?.scrollToEnd?.({ animated });
}, []);
useEffect(() => {
let removeListeners: (() => void) | null = null;
const frame = requestAnimationFrame(() => {
const scrollNode = legendListRef.current?.getScrollableNode();
if (!scrollNode) {
return;
}
const handleManualNavigation = () => {
cancelTimelineLiveFollowForUserNavigationRef.current();
};
scrollNode.addEventListener("wheel", handleManualNavigation, {
passive: true,
});
scrollNode.addEventListener("touchmove", handleManualNavigation, {
passive: true,
});
scrollNode.addEventListener("pointerdown", handleManualNavigation, {
passive: true,
});
removeListeners = () => {
scrollNode.removeEventListener("wheel", handleManualNavigation);
scrollNode.removeEventListener("touchmove", handleManualNavigation);
scrollNode.removeEventListener("pointerdown", handleManualNavigation);
};
});
return () => {
cancelAnimationFrame(frame);
removeListeners?.();
};
}, [activeThread?.id]);
const onTimelineAnchorReady = useCallback((messageId: MessageId, anchorIndex: number) => {
if (pendingTimelineAnchorRef.current === messageId) {
pendingTimelineAnchorRef.current = null;
}
activeTimelineAnchorIndexRef.current = anchorIndex;
if (positionedTimelineAnchorRef.current === messageId) {
return;
}
positionedTimelineAnchorRef.current = messageId;
settledTimelineAnchorRef.current = null;
requestAnimationFrame(() => {
const positionAnchor = (remainingAttempts: number) => {
requestAnimationFrame(() => {
if (positionedTimelineAnchorRef.current !== messageId) {
return;
}
const list = legendListRef.current;
if (!list) {
if (remainingAttempts > 0) {
positionAnchor(remainingAttempts - 1);
}
return;
}
const scrollNode = list.getScrollableNode();
@@ -3200,18 +3328,26 @@ function ChatViewContent(props: ChatViewProps) {
viewOffset: CHAT_LIST_ANCHOR_OFFSET,
});
});
});
};
requestAnimationFrame(() => positionAnchor(12));
}, []);
const onTimelineAnchorSizeChanged = useCallback((messageId: MessageId) => {
if (settledTimelineAnchorRef.current !== messageId) {
return;
}
if (liveFollowUserScrollGenerationRef.current === anchorUserScrollGenerationRef.current) {
return;
}
const scrollOffset = legendListRef.current?.getState().scroll;
if (scrollOffset === undefined) {
return;
}
if (pendingAnchorScrollRestoreRef.current === null) {
pendingAnchorScrollRestoreRef.current = { messageId, offset: scrollOffset };
pendingAnchorScrollRestoreRef.current = {
messageId,
offset: scrollOffset,
userScrollGeneration: anchorUserScrollGenerationRef.current,
};
}
if (anchorScrollRestoreFrameRef.current !== null) {
return;
@@ -3220,32 +3356,121 @@ function ChatViewContent(props: ChatViewProps) {
anchorScrollRestoreFrameRef.current = null;
const pending = pendingAnchorScrollRestoreRef.current;
pendingAnchorScrollRestoreRef.current = null;
if (pending && settledTimelineAnchorRef.current === pending.messageId) {
void legendListRef.current?.scrollToOffset({ offset: pending.offset, animated: false });
if (
pending &&
settledTimelineAnchorRef.current === pending.messageId &&
pending.userScrollGeneration === anchorUserScrollGenerationRef.current
) {
const list = legendListRef.current;
const currentScrollOffset = list?.getState().scroll;
if (
typeof currentScrollOffset === "number" &&
Math.abs(currentScrollOffset - pending.offset) <= 2
) {
void list?.scrollToOffset({ offset: pending.offset, animated: false });
}
}
});
}, []);
// Debounce *showing* the scroll-to-bottom pill so it doesn't flash during
// thread switches. LegendList fires scroll events with isAtEnd=false while
// initialScrollAtEnd is settling; hiding is always immediate.
const showScrollDebouncer = useRef(
new Debouncer(() => setShowScrollToBottom(true), { wait: 150 }),
);
const onIsAtEndChange = useCallback((isAtEnd: boolean) => {
if (
!isAtEnd &&
liveFollowUserScrollGenerationRef.current === anchorUserScrollGenerationRef.current
) {
showScrollDebouncer.current.cancel();
setShowScrollToBottom(false);
return;
}
if (isAtEndRef.current === isAtEnd) return;
isAtEndRef.current = isAtEnd;
if (isAtEnd) {
timelineScrollModeRef.current = "following-end";
liveFollowUserScrollGenerationRef.current = anchorUserScrollGenerationRef.current;
showScrollDebouncer.current.cancel();
setShowScrollToBottom(false);
} else {
timelineScrollModeRef.current = "free-scrolling";
liveFollowUserScrollGenerationRef.current = null;
showScrollDebouncer.current.maybeExecute();
}
}, []);
useEffect(() => {
if (!activeThread?.id) {
return;
}
if (liveFollowUserScrollGenerationRef.current !== anchorUserScrollGenerationRef.current) {
return;
}
let secondFrame: number | null = null;
const frame = requestAnimationFrame(() => {
secondFrame = requestAnimationFrame(() => {
if (liveFollowUserScrollGenerationRef.current !== anchorUserScrollGenerationRef.current) {
return;
}
if (pendingTimelineAnchorRef.current !== null) {
return;
}
if (
positionedTimelineAnchorRef.current !== null &&
settledTimelineAnchorRef.current !== positionedTimelineAnchorRef.current
) {
return;
}
const list = legendListRef.current;
if (!list) {
return;
}
if (timelineScrollModeRef.current === "anchoring-new-turn") {
const metrics = getActiveTimelineTurnMetrics(list);
if (!metrics) {
return;
}
if (metrics.scrollDeltaToRevealEnd <= 1) {
return;
}
const nextOffset = list.getState().scroll + metrics.scrollDeltaToRevealEnd;
void list.scrollToOffset({ offset: nextOffset, animated: false });
return;
}
if (timelineScrollModeRef.current !== "following-end") {
return;
}
if (!timelineRealContentOverflowsViewport(list)) {
return;
}
void list.scrollToEnd?.({ animated: false });
});
});
return () => {
cancelAnimationFrame(frame);
if (secondFrame !== null) {
cancelAnimationFrame(secondFrame);
}
};
}, [
activeThread?.id,
timelineEntries,
getActiveTimelineTurnMetrics,
timelineRealContentOverflowsViewport,
]);
useEffect(() => {
setPullRequestDialogState(null);
isAtEndRef.current = true;
timelineScrollModeRef.current = "following-end";
liveFollowUserScrollGenerationRef.current = anchorUserScrollGenerationRef.current;
pendingTimelineAnchorRef.current = null;
positionedTimelineAnchorRef.current = null;
settledTimelineAnchorRef.current = null;
activeTimelineAnchorIndexRef.current = null;
showScrollDebouncer.current.cancel();
setShowScrollToBottom(false);
if (planSidebarOpenOnNextThreadRef.current) {
@@ -3256,7 +3481,6 @@ function ChatViewContent(props: ChatViewProps) {
}
planSidebarDismissedForTurnRef.current = null;
// activeThreadRef resets transitively with the active thread.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeThread?.id]);
// Auto-open the plan sidebar when plan/todo steps arrive for the current turn.
@@ -3806,6 +4030,10 @@ function ChatViewContent(props: ChatViewProps) {
// anchored end-space target so it lands near the top while the response
// streams into the reserved space below it.
isAtEndRef.current = true;
timelineScrollModeRef.current = "anchoring-new-turn";
liveFollowUserScrollGenerationRef.current = anchorUserScrollGenerationRef.current;
pendingTimelineAnchorRef.current = messageIdForSend;
activeTimelineAnchorIndexRef.current = null;
showScrollDebouncer.current.cancel();
setShowScrollToBottom(false);
setTimelineAnchor({
@@ -4239,6 +4467,10 @@ function ChatViewContent(props: ChatViewProps) {
// Position this sent row once LegendList has measured the anchored tail.
isAtEndRef.current = true;
timelineScrollModeRef.current = "anchoring-new-turn";
liveFollowUserScrollGenerationRef.current = anchorUserScrollGenerationRef.current;
pendingTimelineAnchorRef.current = messageIdForSend;
activeTimelineAnchorIndexRef.current = null;
showScrollDebouncer.current.cancel();
setShowScrollToBottom(false);
setTimelineAnchor({
@@ -4868,9 +5100,10 @@ function ChatViewContent(props: ChatViewProps) {
onAnchorSizeChanged={onTimelineAnchorSizeChanged}
contentInsetEndAdjustment={composerOverlayHeight}
onIsAtEndChange={onIsAtEndChange}
onManualNavigation={cancelTimelineLiveFollowForUserNavigation}
/>
{/* scroll to bottom pill — shown when user has scrolled away from the bottom */}
{/* scroll to end pill — shown when user has scrolled away from the live edge */}
{showScrollToBottom && (
<div
className="pointer-events-none absolute left-1/2 z-30 flex -translate-x-1/2 justify-center py-1.5"
@@ -4878,11 +5111,13 @@ function ChatViewContent(props: ChatViewProps) {
>
<button
type="button"
aria-label="Scroll to end"
title="Scroll to end"
onClick={() => scrollToEnd(true)}
className="pointer-events-auto flex items-center gap-1.5 rounded-full border border-border/60 bg-card px-3 py-1 text-muted-foreground text-xs shadow-sm transition-colors hover:border-border hover:text-foreground hover:cursor-pointer"
>
<ChevronDownIcon className="size-3.5" />
Scroll to bottom
Scroll to end
</button>
</div>
)}
@@ -4898,7 +5133,7 @@ function ChatViewContent(props: ChatViewProps) {
aria-hidden="true"
className="chat-composer-horizontal-inset pointer-events-none absolute inset-x-0 top-1.5 bottom-0 z-0 sm:top-2"
>
<div className="relative mx-auto h-full w-full max-w-208 overflow-clip rounded-t-[20px]">
<div className="relative mx-auto h-full w-full max-w-3xl overflow-clip rounded-t-[20px]">
<div className="chat-composer-shared-blur absolute -inset-8" />
</div>
</div>
@@ -331,6 +331,19 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
},
[props],
);
const handleTabMouseDown = useCallback((event: ReactMouseEvent) => {
if (event.button !== 1) return;
event.preventDefault();
}, []);
const handleTabAuxClick = useCallback(
(event: ReactMouseEvent, surface: RightPanelSurface) => {
if (event.button !== 1) return;
event.preventDefault();
event.stopPropagation();
props.onCloseSurface(surface);
},
[props],
);
useEffect(() => {
const activeTab = tabListRef.current?.querySelector<HTMLElement>("[data-active-tab='true']");
@@ -367,6 +380,8 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
<div
key={surface.id}
data-active-tab={active}
onMouseDown={handleTabMouseDown}
onAuxClick={(event) => handleTabAuxClick(event, surface)}
onContextMenu={(event) => void handleTabContextMenu(event, surface)}
className={cn(
"group flex h-7 min-w-25 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-sm",
@@ -2044,7 +2044,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
<form
ref={composerFormRef}
onSubmit={submitComposer}
className="mx-auto w-full min-w-0 max-w-208"
className="mx-auto w-full min-w-0 max-w-3xl"
data-chat-composer-form="true"
>
<div
@@ -82,7 +82,7 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
};
return (
<div className={cn("group/banner-stack mx-auto mb-2 max-w-208", className)}>
<div className={cn("group/banner-stack mx-auto mb-2 max-w-3xl", className)}>
<div
className={cn(
"relative",
@@ -10,6 +10,59 @@ import { type ChatMessage, type ProposedPlan, type TurnDiffSummary } from "../..
import { type MessageId, type OrchestrationLatestTurn, type TurnId } from "@t3tools/contracts";
export const MAX_VISIBLE_WORK_LOG_ENTRIES = 1;
export const TIMELINE_MINIMAP_ITEM_SPACING = 8;
export const TIMELINE_MINIMAP_MIN_ITEMS = 2;
export const TIMELINE_MINIMAP_MAX_HEIGHT_CSS = "calc(100vh - 18rem)";
export const TIMELINE_CONTENT_MAX_WIDTH = 768;
export const TIMELINE_MINIMAP_PERSISTENT_GUTTER = 48;
export interface TimelineEndState {
readonly isAtEnd?: boolean;
readonly isNearEnd?: boolean;
}
export function resolveTimelineIsAtEnd(state: TimelineEndState | undefined): boolean | undefined {
return state?.isNearEnd ?? state?.isAtEnd;
}
export function resolveTimelineMinimapHeightStyle(itemCount: number): string {
const naturalHeight = Math.max(1, (itemCount - 1) * TIMELINE_MINIMAP_ITEM_SPACING);
return `min(${naturalHeight}px, ${TIMELINE_MINIMAP_MAX_HEIGHT_CSS})`;
}
export function resolveTimelineMinimapTopPercent(index: number, itemCount: number): number {
if (itemCount <= 1) {
return 0;
}
return (Math.max(0, Math.min(index, itemCount - 1)) / (itemCount - 1)) * 100;
}
export function resolveTimelineMinimapIndexFromPointer(input: {
readonly itemCount: number;
readonly railTop: number;
readonly railHeight: number;
readonly pointerY: number;
}): number | null {
if (input.itemCount <= 0 || input.railHeight <= 0) {
return null;
}
if (input.itemCount === 1) {
return 0;
}
const progress = Math.max(0, Math.min(1, (input.pointerY - input.railTop) / input.railHeight));
return Math.max(0, Math.min(input.itemCount - 1, Math.round(progress * (input.itemCount - 1))));
}
export function resolveTimelineMinimapHasPersistentGutter(viewportWidth: number): boolean {
if (!Number.isFinite(viewportWidth) || viewportWidth <= 0) {
return false;
}
const contentWidth = Math.min(viewportWidth, TIMELINE_CONTENT_MAX_WIDTH);
const sideGutter = Math.max(0, (viewportWidth - contentWidth) / 2);
return sideGutter >= TIMELINE_MINIMAP_PERSISTENT_GUTTER;
}
function computeElapsedMs(startIso: string, endIso: string): number | null {
const start = Date.parse(startIso);
@@ -22,7 +22,16 @@ vi.mock("@legendapp/list/react", async () => {
};
contentInsetEndAdjustment?: number;
className?: string;
maintainScrollAtEnd?: boolean;
maintainScrollAtEnd?:
| boolean
| {
animated?: boolean;
on?: {
dataChange?: boolean;
itemLayout?: boolean;
layout?: boolean;
};
};
maintainVisibleContentPosition?:
| boolean
| {
@@ -45,7 +54,27 @@ vi.mock("@legendapp/list/react", async () => {
data-anchor-on-ready={Boolean(props.anchoredEndSpace?.onReady)}
data-content-inset-end={props.contentInsetEndAdjustment}
data-class-name={props.className}
data-maintain-scroll-at-end={props.maintainScrollAtEnd}
data-maintain-scroll-at-end={props.maintainScrollAtEnd ? "enabled" : undefined}
data-maintain-scroll-at-end-animated={
typeof props.maintainScrollAtEnd === "object"
? props.maintainScrollAtEnd.animated
: undefined
}
data-maintain-scroll-at-end-data-change={
typeof props.maintainScrollAtEnd === "object"
? props.maintainScrollAtEnd.on?.dataChange
: undefined
}
data-maintain-scroll-at-end-item-layout={
typeof props.maintainScrollAtEnd === "object"
? props.maintainScrollAtEnd.on?.itemLayout
: undefined
}
data-maintain-scroll-at-end-layout={
typeof props.maintainScrollAtEnd === "object"
? props.maintainScrollAtEnd.on?.layout
: undefined
}
data-maintain-visible-content-position={
typeof props.maintainVisibleContentPosition === "object"
? "object"
@@ -162,6 +191,7 @@ function buildProps() {
onAnchorSizeChanged: () => {},
contentInsetEndAdjustment: 0,
onIsAtEndChange: () => {},
onManualNavigation: () => {},
};
}
@@ -189,6 +219,43 @@ function buildUserTimelineEntry(text: string) {
}
describe("MessagesTimeline", () => {
it("uses LegendList isNearEnd when deciding whether the live edge is visible", async () => {
const {
resolveTimelineIsAtEnd,
resolveTimelineMinimapHasPersistentGutter,
resolveTimelineMinimapHeightStyle,
resolveTimelineMinimapIndexFromPointer,
resolveTimelineMinimapTopPercent,
} = await import("./MessagesTimeline.logic");
expect(resolveTimelineIsAtEnd({ isNearEnd: true, isAtEnd: false })).toBe(true);
expect(resolveTimelineIsAtEnd({ isNearEnd: false, isAtEnd: true })).toBe(false);
expect(resolveTimelineIsAtEnd({ isAtEnd: true })).toBe(true);
expect(resolveTimelineIsAtEnd(undefined)).toBeUndefined();
expect(resolveTimelineMinimapHeightStyle(5)).toBe("min(32px, calc(100vh - 18rem))");
expect(resolveTimelineMinimapTopPercent(2, 5)).toBe(50);
expect(
resolveTimelineMinimapIndexFromPointer({
itemCount: 101,
railTop: 100,
railHeight: 500,
pointerY: 350,
}),
).toBe(50);
expect(
resolveTimelineMinimapIndexFromPointer({
itemCount: 101,
railTop: 100,
railHeight: 500,
pointerY: 999,
}),
).toBe(100);
expect(resolveTimelineMinimapHasPersistentGutter(832)).toBe(false);
expect(resolveTimelineMinimapHasPersistentGutter(863)).toBe(false);
expect(resolveTimelineMinimapHasPersistentGutter(864)).toBe(true);
});
it("anchors a sent attachment message using its measured height", async () => {
const { MessagesTimeline } = await import("./MessagesTimeline");
const onAnchorReady = vi.fn();
@@ -229,7 +296,7 @@ describe("MessagesTimeline", () => {
expect(markup).not.toContain("data-anchor-max-size=");
expect(markup).toContain('data-content-inset-end="144"');
expect(markup).toContain("[overflow-anchor:none]");
expect(markup).not.toContain("data-maintain-scroll-at-end=");
expect(markup).not.toContain('data-maintain-scroll-at-end="enabled"');
expect(markup).toContain('data-maintain-visible-content-position="object"');
expect(markup).toContain('data-maintain-visible-content-position-data="true"');
expect(markup).toContain('data-maintain-visible-content-position-size="false"');
@@ -248,6 +315,11 @@ describe("MessagesTimeline", () => {
);
expect(markup).toContain("Show full message");
expect(markup).toContain('data-maintain-scroll-at-end="enabled"');
expect(markup).toContain('data-maintain-scroll-at-end-animated="false"');
expect(markup).toContain('data-maintain-scroll-at-end-data-change="true"');
expect(markup).toContain('data-maintain-scroll-at-end-item-layout="true"');
expect(markup).toContain('data-maintain-scroll-at-end-layout="true"');
expect(markup).toContain('data-user-message-collapsed="true"');
expect(markup).toContain('data-user-message-fade="true"');
expect(markup).toContain('data-user-message-footer="true"');
+372 -22
View File
@@ -18,6 +18,7 @@ import {
useRef,
useState,
type KeyboardEvent,
type MouseEvent,
type ReactNode,
} from "react";
import { flushSync } from "react-dom";
@@ -69,8 +70,14 @@ import {
deriveMessagesTimelineRows,
normalizeCompactToolLabel,
resolveAssistantMessageCopyState,
resolveTimelineIsAtEnd,
resolveTimelineMinimapHasPersistentGutter,
resolveTimelineMinimapHeightStyle,
resolveTimelineMinimapIndexFromPointer,
resolveTimelineMinimapTopPercent,
type StableMessagesTimelineRowsState,
type MessagesTimelineRow,
TIMELINE_MINIMAP_MIN_ITEMS,
type TimelineLatestTurn,
} from "./MessagesTimeline.logic";
import { TerminalContextInlineChip } from "./TerminalContextInlineChip";
@@ -171,6 +178,7 @@ interface MessagesTimelineProps {
onAnchorSizeChanged: (messageId: MessageId, size: number) => void;
contentInsetEndAdjustment: number;
onIsAtEndChange: (isAtEnd: boolean) => void;
onManualNavigation: () => void;
}
// ---------------------------------------------------------------------------
@@ -203,9 +211,11 @@ export const MessagesTimeline = memo(function MessagesTimeline({
onAnchorSizeChanged,
contentInsetEndAdjustment,
onIsAtEndChange,
onManualNavigation,
}: MessagesTimelineProps) {
const [expandedTurnIds, setExpandedTurnIds] = useState<ReadonlySet<TurnId>>(new Set());
const [expandedWorkGroupIds, setExpandedWorkGroupIds] = useState<ReadonlySet<string>>(new Set());
const [minimapStripMap] = useState(() => new Map<string, HTMLSpanElement>());
const onToggleTurnFold = useCallback((turnId: TurnId) => {
setExpandedTurnIds((existing) => {
@@ -307,6 +317,11 @@ export const MessagesTimeline = memo(function MessagesTimeline({
],
);
const rows = useStableRows(rawRows);
const minimapItems = useMemo(() => deriveTimelineMinimapItems(rows), [rows]);
const [timelineViewportElement, setTimelineViewportElement] = useState<HTMLDivElement | null>(
null,
);
const [minimapHasPersistentGutter, setMinimapHasPersistentGutter] = useState(false);
const handleAnchorReady = useCallback(
(info: { anchorIndex: number | undefined }) => {
if (anchorMessageId !== null && info.anchorIndex !== undefined) {
@@ -334,10 +349,62 @@ export const MessagesTimeline = memo(function MessagesTimeline({
const handleScroll = useCallback(() => {
const state = listRef.current?.getState?.();
if (state) {
onIsAtEndChange(state.isAtEnd);
const isAtEnd = resolveTimelineIsAtEnd(state);
if (isAtEnd !== undefined) {
onIsAtEndChange(isAtEnd);
}
}, [listRef, onIsAtEndChange]);
if (!state || minimapItems.length === 0) {
return;
}
const scrollTop = state.scroll ?? 0;
const scrollBottom = scrollTop + (state.scrollLength ?? 0);
for (const item of minimapItems) {
const strip = minimapStripMap.get(item.id);
if (!strip) {
continue;
}
const rowTop = resolveTimelineRowTop(state, item.rowIndex);
const rowHeight = resolveTimelineRowHeight(state, item.rowIndex);
const inView =
rowTop !== null &&
rowTop < scrollBottom &&
rowTop + Math.max(1, rowHeight ?? 1) > scrollTop;
strip.dataset.inView = inView ? "true" : "false";
}
}, [listRef, minimapItems, minimapStripMap, onIsAtEndChange]);
useEffect(() => {
const frame = requestAnimationFrame(handleScroll);
return () => cancelAnimationFrame(frame);
}, [handleScroll, rows.length]);
useEffect(() => {
if (!timelineViewportElement) {
return;
}
const measure = () => {
const viewportWidth = timelineViewportElement.getBoundingClientRect().width;
const nextHasPersistentGutter = resolveTimelineMinimapHasPersistentGutter(viewportWidth);
setMinimapHasPersistentGutter((current) =>
current === nextHasPersistentGutter ? current : nextHasPersistentGutter,
);
};
const frame = requestAnimationFrame(measure);
const observer = new ResizeObserver(measure);
observer.observe(timelineViewportElement);
return () => {
cancelAnimationFrame(frame);
observer.disconnect();
};
}, [timelineViewportElement, rows.length]);
const sharedState = useMemo<TimelineRowSharedState>(
() => ({
@@ -403,25 +470,53 @@ export const MessagesTimeline = memo(function MessagesTimeline({
return (
<TimelineRowCtx value={sharedState}>
<TimelineRowActivityCtx value={activityState}>
<LegendList<MessagesTimelineRow>
ref={listRef}
data={rows}
keyExtractor={keyExtractor}
getItemType={getItemType}
renderItem={renderItem}
estimatedItemSize={90}
initialScrollAtEnd
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}
contentInsetEndAdjustment={contentInsetEndAdjustment}
maintainVisibleContentPosition={{
data: true,
size: false,
}}
onScroll={handleScroll}
className="scrollbar-gutter-both h-full min-h-0 overflow-x-hidden overscroll-y-contain px-3 [overflow-anchor:none] sm:px-5"
ListHeaderComponent={TIMELINE_LIST_HEADER}
ListFooterComponent={TIMELINE_LIST_FOOTER}
/>
<div ref={setTimelineViewportElement} className="relative h-full min-h-0">
<LegendList<MessagesTimelineRow>
ref={listRef}
data={rows}
keyExtractor={keyExtractor}
getItemType={getItemType}
renderItem={renderItem}
estimatedItemSize={90}
initialScrollAtEnd
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}
contentInsetEndAdjustment={contentInsetEndAdjustment}
maintainScrollAtEnd={
anchoredEndSpace
? false
: {
animated: false,
on: {
dataChange: true,
itemLayout: true,
layout: true,
},
}
}
maintainVisibleContentPosition={{
data: true,
size: false,
}}
onScroll={handleScroll}
className="scrollbar-gutter-both h-full min-h-0 overflow-x-hidden overscroll-y-contain px-3 [overflow-anchor:none] sm:px-5"
ListHeaderComponent={TIMELINE_LIST_HEADER}
ListFooterComponent={TIMELINE_LIST_FOOTER}
/>
<TimelineMinimap
items={minimapItems}
bottomInset={contentInsetEndAdjustment}
hasPersistentGutter={minimapHasPersistentGutter}
stripMap={minimapStripMap}
onSelect={(item) => {
onManualNavigation();
void listRef.current?.scrollToIndex({
index: item.rowIndex,
animated: true,
viewOffset: 24,
});
}}
/>
</div>
</TimelineRowActivityCtx>
</TimelineRowCtx>
);
@@ -435,6 +530,261 @@ function getItemType(item: MessagesTimelineRow) {
return item.kind === "message" ? `message:${item.message.role}` : item.kind;
}
interface TimelineMinimapItem {
readonly id: string;
readonly rowIndex: number;
readonly userText: string | null;
readonly assistantText: string | null;
}
interface TimelinePositionState {
readonly contentLength?: number;
readonly scroll?: number;
readonly scrollLength?: number;
readonly positionAtIndex?: (index: number) => number | undefined;
readonly sizeAtIndex?: (index: number) => number | undefined;
}
function deriveTimelineMinimapItems(
rows: ReadonlyArray<MessagesTimelineRow>,
): TimelineMinimapItem[] {
const items: TimelineMinimapItem[] = [];
for (let index = 0; index < rows.length; index += 1) {
const row = rows[index];
if (row?.kind !== "message" || row.message.role !== "user") {
continue;
}
items.push({
id: row.id,
rowIndex: index,
userText: compactMinimapPreview(row.message.text),
assistantText: compactMinimapPreview(resolveFinalAssistantTextForTurn(rows, index)),
});
}
return items;
}
function resolveFinalAssistantTextForTurn(
rows: ReadonlyArray<MessagesTimelineRow>,
userRowIndex: number,
) {
let finalAssistantText: string | null = null;
for (let index = userRowIndex + 1; index < rows.length; index += 1) {
const row = rows[index];
if (row?.kind !== "message") {
continue;
}
if (row.message.role === "user") {
break;
}
if (row.message.role === "assistant") {
finalAssistantText = row.message.text ?? null;
}
}
return finalAssistantText;
}
function compactMinimapPreview(text: string | null | undefined) {
const compact = text?.replace(/\s+/g, " ").trim() ?? "";
return compact.length > 0 ? compact : null;
}
function resolveTimelineRowTop(state: TimelinePositionState, rowIndex: number) {
const top = state.positionAtIndex?.(rowIndex);
return typeof top === "number" && Number.isFinite(top) ? top : null;
}
function resolveTimelineRowHeight(state: TimelinePositionState, rowIndex: number) {
const height = state.sizeAtIndex?.(rowIndex);
return typeof height === "number" && Number.isFinite(height) ? height : null;
}
function TimelineMinimap({
bottomInset,
hasPersistentGutter,
items,
stripMap,
onSelect,
}: {
bottomInset: number;
hasPersistentGutter: boolean;
items: ReadonlyArray<TimelineMinimapItem>;
stripMap: Map<string, HTMLSpanElement>;
onSelect: (item: TimelineMinimapItem) => void;
}) {
const [activeIndex, setActiveIndex] = useState<number | null>(null);
const resolvedActiveIndex =
activeIndex !== null && activeIndex < items.length ? activeIndex : null;
const activeItem = resolvedActiveIndex === null ? null : (items[resolvedActiveIndex] ?? null);
const activeTopPercent =
resolvedActiveIndex === null
? 0
: resolveTimelineMinimapTopPercent(resolvedActiveIndex, items.length);
const activeTooltipTranslate =
resolvedActiveIndex === null
? "-50%"
: resolvedActiveIndex === 0
? "0%"
: resolvedActiveIndex === items.length - 1
? "-100%"
: "-50%";
const resolveActiveIndexFromPointer = useCallback(
(event: MouseEvent<HTMLElement>) => {
const rect = event.currentTarget.getBoundingClientRect();
return resolveTimelineMinimapIndexFromPointer({
itemCount: items.length,
railTop: rect.top,
railHeight: rect.height,
pointerY: event.clientY,
});
},
[items.length],
);
const updateActiveIndexFromPointer = useCallback(
(event: MouseEvent<HTMLElement>) => {
const nextIndex = resolveActiveIndexFromPointer(event);
setActiveIndex(nextIndex);
},
[resolveActiveIndexFromPointer],
);
const moveActiveIndex = useCallback(
(delta: number) => {
setActiveIndex((current) => {
const base = current ?? 0;
return Math.max(0, Math.min(items.length - 1, base + delta));
});
},
[items.length],
);
if (items.length < TIMELINE_MINIMAP_MIN_ITEMS) {
return null;
}
const safeBottomInset = Math.max(0, Math.ceil(bottomInset));
return (
<div
className={cn(
"group/minimap pointer-events-auto absolute top-0 left-0 z-40 hidden w-18 [@media(pointer:fine)]:block",
hasPersistentGutter
? "opacity-100"
: "opacity-0 transition-opacity duration-150 hover:opacity-100 focus-within:opacity-100",
)}
data-testid="timeline-minimap"
data-persistent-gutter={hasPersistentGutter ? "true" : "false"}
style={{ bottom: safeBottomInset }}
>
<div className="relative h-full w-full select-none">
<button
aria-label={`Jump to message: ${activeItem?.userText ?? "User message"}`}
className="pointer-events-auto absolute top-1/2 left-3 w-10 -translate-y-1/2 cursor-pointer bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70"
onBlur={() => setActiveIndex(null)}
onClick={(event) => {
const nextIndex = resolveActiveIndexFromPointer(event);
const nextItem = nextIndex === null ? null : (items[nextIndex] ?? null);
if (nextItem) {
onSelect(nextItem);
}
event.currentTarget.blur();
}}
onFocus={() => setActiveIndex((current) => current ?? 0)}
onKeyDown={(event) => {
if (event.key === "ArrowDown") {
event.preventDefault();
moveActiveIndex(1);
} else if (event.key === "ArrowUp") {
event.preventDefault();
moveActiveIndex(-1);
} else if (event.key === "Home") {
event.preventDefault();
setActiveIndex(0);
} else if (event.key === "End") {
event.preventDefault();
setActiveIndex(items.length - 1);
} else if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
if (activeItem) {
onSelect(activeItem);
}
}
}}
onMouseLeave={() => setActiveIndex(null)}
onMouseMove={updateActiveIndexFromPointer}
onMouseDown={(event) => {
event.preventDefault();
}}
style={{ height: resolveTimelineMinimapHeightStyle(items.length) }}
type="button"
>
<div className="absolute top-0 left-3 h-full w-px bg-border/15" />
{items.map((item, index) => {
const top = `${resolveTimelineMinimapTopPercent(index, items.length)}%`;
const activeDistance =
resolvedActiveIndex === null ? null : Math.abs(index - resolvedActiveIndex);
return (
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute left-0 h-0.5 -translate-y-1/2 rounded-full bg-muted-foreground/35 transition-[background-color,width] duration-150 data-[in-view=true]:bg-foreground/90",
activeDistance === 0
? "w-6 bg-muted-foreground/75"
: activeDistance === 1
? "w-4"
: activeDistance === 2
? "w-2.5"
: "w-2",
)}
data-in-view="false"
data-minimap-strip
key={item.id}
ref={(node) => {
if (node) {
stripMap.set(item.id, node);
} else {
stripMap.delete(item.id);
}
}}
style={{ top }}
/>
);
})}
{activeItem ? (
<span
className="pointer-events-none absolute left-8 w-80 rounded-xl border border-border/70 bg-popover/95 p-3 text-left text-popover-foreground shadow-xl shadow-black/25 backdrop-blur"
style={{
top: `${activeTopPercent}%`,
transform: `translateY(${activeTooltipTranslate})`,
}}
>
<span className="block max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium leading-5">
{activeItem.userText ?? "User message"}
</span>
{activeItem.assistantText ? (
<span
className="mt-1 max-h-[3.75rem] overflow-hidden text-muted-foreground text-sm leading-5"
style={{
display: "-webkit-box",
WebkitBoxOrient: "vertical",
WebkitLineClamp: 3,
}}
>
{activeItem.assistantText}
</span>
) : null}
</span>
) : null}
</button>
</div>
</div>
);
}
// ---------------------------------------------------------------------------
// TimelineRowContent — the actual row component
// ---------------------------------------------------------------------------
@@ -0,0 +1,138 @@
import { describe, expect, it } from "vite-plus/test";
import { getAnchoredTurnMetrics, getRowBottom } from "./timelineScrollAnchoring";
function buildState({
positions,
sizes,
scroll = 0,
scrollLength = 700,
}: {
readonly positions: readonly number[];
readonly sizes: readonly number[];
readonly scroll?: number;
readonly scrollLength?: number;
}) {
return {
data: positions.map((_, index) => index),
scroll,
scrollLength,
positionAtIndex: (index: number) => positions[index],
sizeAtIndex: (index: number) => sizes[index],
};
}
describe("timeline scroll anchoring", () => {
it("measures row bottoms from LegendList row position and size", () => {
const state = buildState({
positions: [0, 120],
sizes: [80, 40],
});
expect(getRowBottom(state, 1)).toBe(160);
});
it("treats the active turn as fitting when it fits above the composer", () => {
const state = buildState({
positions: [0, 300, 460],
sizes: [240, 80, 140],
scrollLength: 760,
});
const metrics = getAnchoredTurnMetrics({
state,
anchorIndex: 1,
composerOverlayHeight: 180,
anchorOffset: 16,
});
expect(metrics?.turnHeight).toBe(300);
expect(metrics?.usableViewportHeight).toBe(564);
expect(metrics?.overflowsUsableViewport).toBe(false);
expect(metrics?.targetScrollToRevealEnd).toBe(36);
expect(metrics?.scrollDeltaToRevealEnd).toBe(36);
});
it("targets the real row end instead of any temporary reserved tail", () => {
const state = buildState({
positions: [0, 1720, 1880],
sizes: [1600, 80, 120],
scroll: 1900,
scrollLength: 760,
});
const metrics = getAnchoredTurnMetrics({
state,
anchorIndex: 1,
composerOverlayHeight: 180,
anchorOffset: 16,
});
expect(metrics?.lastBottom).toBe(2000);
expect(metrics?.targetScrollToRevealEnd).toBe(1436);
expect(metrics?.scrollDeltaToRevealEnd).toBe(0);
});
it("reports overflow only for the current anchored turn", () => {
const state = buildState({
positions: [0, 900, 1180],
sizes: [800, 220, 300],
scroll: 900,
scrollLength: 760,
});
const metrics = getAnchoredTurnMetrics({
state,
anchorIndex: 1,
composerOverlayHeight: 180,
anchorOffset: 16,
});
expect(metrics?.turnHeight).toBe(580);
expect(metrics?.usableViewportHeight).toBe(564);
expect(metrics?.overflowsUsableViewport).toBe(true);
});
it("returns the minimal positive scroll delta needed to reveal the turn end", () => {
const state = buildState({
positions: [0, 900, 1180],
sizes: [800, 220, 360],
scroll: 900,
scrollLength: 760,
});
const metrics = getAnchoredTurnMetrics({
state,
anchorIndex: 1,
composerOverlayHeight: 180,
anchorOffset: 16,
});
expect(metrics?.lastBottom).toBe(1540);
expect(metrics?.visibleUsableBottom).toBe(1464);
expect(metrics?.scrollDeltaToRevealEnd).toBe(76);
});
it("subtracts composer height from usable viewport height", () => {
const state = buildState({
positions: [0, 300],
sizes: [120, 470],
scrollLength: 700,
});
const withoutComposer = getAnchoredTurnMetrics({
state,
anchorIndex: 1,
composerOverlayHeight: 0,
anchorOffset: 16,
});
const withComposer = getAnchoredTurnMetrics({
state,
anchorIndex: 1,
composerOverlayHeight: 220,
anchorOffset: 16,
});
expect(withoutComposer?.overflowsUsableViewport).toBe(false);
expect(withComposer?.overflowsUsableViewport).toBe(true);
});
});
@@ -0,0 +1,78 @@
export type TimelineScrollMode = "following-end" | "anchoring-new-turn" | "free-scrolling";
export interface TimelineListMeasurementState {
readonly data: readonly unknown[];
readonly scroll: number;
readonly scrollLength: number;
readonly positionAtIndex: (index: number) => number | undefined;
readonly sizeAtIndex: (index: number) => number | undefined;
}
export interface AnchoredTurnMetrics {
readonly anchorTop: number;
readonly lastBottom: number;
readonly turnHeight: number;
readonly usableViewportHeight: number;
readonly visibleUsableBottom: number;
readonly overflowsUsableViewport: boolean;
readonly targetScrollToRevealEnd: number;
readonly scrollDeltaToRevealEnd: number;
}
export function getRowBottom(state: TimelineListMeasurementState, index: number): number | null {
const top = state.positionAtIndex(index);
const height = state.sizeAtIndex(index);
if (
typeof top !== "number" ||
typeof height !== "number" ||
!Number.isFinite(top) ||
!Number.isFinite(height)
) {
return null;
}
return top + Math.max(1, height);
}
export function getAnchoredTurnMetrics({
state,
anchorIndex,
composerOverlayHeight,
anchorOffset,
}: {
readonly state: TimelineListMeasurementState;
readonly anchorIndex: number;
readonly composerOverlayHeight: number;
readonly anchorOffset: number;
}): AnchoredTurnMetrics | null {
if (state.data.length === 0) {
return null;
}
const boundedAnchorIndex = Math.max(0, Math.min(anchorIndex, state.data.length - 1));
const anchorTop = state.positionAtIndex(boundedAnchorIndex);
const lastBottom = getRowBottom(state, state.data.length - 1);
if (typeof anchorTop !== "number" || !Number.isFinite(anchorTop) || lastBottom === null) {
return null;
}
const usableViewportHeight = Math.max(
0,
state.scrollLength - composerOverlayHeight - anchorOffset,
);
const turnHeight = Math.max(0, lastBottom - anchorTop);
const visibleUsableBottom = state.scroll + usableViewportHeight;
const targetScrollToRevealEnd = Math.max(0, lastBottom - usableViewportHeight);
const scrollDeltaToRevealEnd = Math.max(0, targetScrollToRevealEnd - state.scroll);
return {
anchorTop,
lastBottom,
turnHeight,
usableViewportHeight,
visibleUsableBottom,
overflowsUsableViewport: turnHeight > usableViewportHeight,
targetScrollToRevealEnd,
scrollDeltaToRevealEnd,
};
}
@@ -32,7 +32,7 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
*/
const CUSTOM_MODEL_PLACEHOLDER_BY_KIND: Partial<Record<ProviderDriverKind, string>> = {
[ProviderDriverKind.make("codex")]: "gpt-6.7-codex-ultra-preview",
[ProviderDriverKind.make("claudeAgent")]: "claude-sonnet-5-0",
[ProviderDriverKind.make("claudeAgent")]: "claude-sonnet-5",
[ProviderDriverKind.make("cursor")]: "claude-sonnet-4-6",
[ProviderDriverKind.make("opencode")]: "openai/gpt-5",
};
+23
View File
@@ -812,12 +812,35 @@ label:has(> select#reasoning-effort) select {
#ec4899 90%,
#ff6b6b 100%
);
position: relative;
background: transparent;
}
.ultrathink-frame::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
padding: 2px;
background-image: var(--ultrathink-spectrum);
background-size: 220% 220%;
pointer-events: none;
filter: saturate(0.82) brightness(0.92);
-webkit-mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
mask-composite: exclude;
animation: ultrathink-rainbow 10s linear infinite;
}
.ultrathink-frame > * {
position: relative;
}
.ultrathink-chroma {
animation: ultrathink-chroma-shift 10s linear infinite;
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@t3tools/contracts",
"version": "0.0.27",
"version": "0.0.28",
"private": true,
"files": [
"dist"
+5 -2
View File
@@ -138,7 +138,7 @@ export const DEFAULT_GIT_TEXT_GENERATION_MODEL = "gpt-5.4-mini";
export const DEFAULT_MODEL_BY_PROVIDER: Partial<Record<ProviderDriverKind, string>> = {
[CODEX_DRIVER_KIND]: DEFAULT_MODEL,
[CLAUDE_DRIVER_KIND]: "claude-sonnet-4-6",
[CLAUDE_DRIVER_KIND]: "claude-sonnet-5",
[CURSOR_DRIVER_KIND]: "auto",
[GROK_DRIVER_KIND]: "grok-build",
[OPENCODE_DRIVER_KIND]: "openai/gpt-5",
@@ -174,7 +174,10 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER: Partial<
"opus-4.6": "claude-opus-4-6",
"claude-opus-4.6": "claude-opus-4-6",
"claude-opus-4-6-20251117": "claude-opus-4-6",
sonnet: "claude-sonnet-4-6",
sonnet: "claude-sonnet-5",
"sonnet-5": "claude-sonnet-5",
"claude-sonnet-5.0": "claude-sonnet-5",
"claude-sonnet-5-0": "claude-sonnet-5",
"sonnet-4.6": "claude-sonnet-4-6",
"claude-sonnet-4.6": "claude-sonnet-4-6",
"claude-sonnet-4-6-20251117": "claude-sonnet-4-6",
+1 -88
View File
@@ -1,13 +1,7 @@
import { describe, expect, it } from "vite-plus/test";
import {
DEFAULT_MODEL,
ProviderDriverKind,
ProviderInstanceId,
type ModelCapabilities,
} from "@t3tools/contracts";
import { ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
import {
applyClaudePromptEffortPrefix,
buildProviderOptionSelectionsFromDescriptors,
createModelCapabilities,
createModelSelection,
@@ -16,11 +10,6 @@ import {
getProviderOptionDescriptors,
getProviderOptionBooleanSelectionValue,
getProviderOptionStringSelectionValue,
isClaudeUltrathinkPrompt,
normalizeModelSlug,
resolveModelSlugForProvider,
resolveSelectableModel,
trimOrNull,
} from "./model.ts";
const codexCaps: ModelCapabilities = createModelCapabilities({
@@ -70,82 +59,6 @@ const claudeCaps: ModelCapabilities = createModelCapabilities({
],
});
describe("normalizeModelSlug", () => {
it("maps known aliases to canonical slugs", () => {
const claude = ProviderDriverKind.make("claudeAgent");
expect(normalizeModelSlug("gpt-5-codex")).toBe("gpt-5.4");
expect(normalizeModelSlug("5.3")).toBe("gpt-5.3-codex");
expect(normalizeModelSlug("sonnet", claude)).toBe("claude-sonnet-4-6");
});
it("returns null for empty or missing values", () => {
expect(normalizeModelSlug("")).toBeNull();
expect(normalizeModelSlug(" ")).toBeNull();
expect(normalizeModelSlug(null)).toBeNull();
expect(normalizeModelSlug(undefined)).toBeNull();
});
});
describe("resolveModelSlugForProvider", () => {
it("returns defaults when the model is missing", () => {
expect(resolveModelSlugForProvider(ProviderDriverKind.make("codex"), undefined)).toBe(
DEFAULT_MODEL,
);
expect(resolveModelSlugForProvider(ProviderDriverKind.make("ollama"), undefined)).toBe(
DEFAULT_MODEL,
);
expect(resolveModelSlugForProvider(ProviderDriverKind.make("grok"), undefined)).toBe(
"grok-build",
);
});
it("preserves normalized unknown models", () => {
expect(
resolveModelSlugForProvider(ProviderDriverKind.make("codex"), "custom/internal-model"),
).toBe("custom/internal-model");
});
});
describe("resolveSelectableModel", () => {
it("resolves exact slugs, labels, and aliases", () => {
const options = [
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
{ slug: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
];
expect(resolveSelectableModel(ProviderDriverKind.make("codex"), "gpt-5.3-codex", options)).toBe(
"gpt-5.3-codex",
);
expect(resolveSelectableModel(ProviderDriverKind.make("codex"), "gpt-5.3 codex", options)).toBe(
"gpt-5.3-codex",
);
expect(resolveSelectableModel(ProviderDriverKind.make("claudeAgent"), "sonnet", options)).toBe(
"claude-sonnet-4-6",
);
});
});
describe("misc helpers", () => {
it("detects ultrathink prompts", () => {
expect(isClaudeUltrathinkPrompt("Please ultrathink about this")).toBe(true);
expect(isClaudeUltrathinkPrompt("Ultrathink:\nInvestigate")).toBe(true);
expect(isClaudeUltrathinkPrompt("Investigate")).toBe(false);
});
it("prefixes ultrathink prompts once", () => {
expect(applyClaudePromptEffortPrefix("Investigate", "ultrathink")).toBe(
"Ultrathink:\nInvestigate",
);
expect(applyClaudePromptEffortPrefix("Ultrathink:\nInvestigate", "ultrathink")).toBe(
"Ultrathink:\nInvestigate",
);
});
it("trims strings to null", () => {
expect(trimOrNull(" hi ")).toBe("hi");
expect(trimOrNull(" ")).toBeNull();
});
});
describe("descriptor helpers", () => {
it("applies selection values to capability descriptors", () => {
expect(
+554 -436
View File
File diff suppressed because it is too large. Load diff