diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
index f440134b2f..bbcd1986d0 100644
--- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
@@ -1,9 +1,14 @@
-import { NativeStackScreenOptions } from "../../native/StackHeader";
-import { StackActions, useNavigation, usePreventRemove } from "@react-navigation/native";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import { Alert, InteractionManager, Platform, View, useColorScheme } from "react-native";
+import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import {
- KeyboardAvoidingView,
+ StackActions,
+ useFocusEffect,
+ useNavigation,
+ usePreventRemove,
+} from "@react-navigation/native";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { Alert, Platform, Pressable, ScrollView, View, useColorScheme } from "react-native";
+import {
+ KeyboardController,
KeyboardStickyView,
useKeyboardState,
} from "react-native-keyboard-controller";
@@ -11,7 +16,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useThemeColor } from "../../lib/useThemeColor";
import { useFontFamily } from "../../lib/useFontFamily";
-import { EnvironmentId } from "@t3tools/contracts";
import {
isAtomCommandInterrupted,
squashAtomCommandFailure,
@@ -20,22 +24,24 @@ import { deriveThreadTitleSeed } from "@t3tools/client-runtime/operations";
import { ComposerEditor, type ComposerEditorHandle } from "../../components/ComposerEditor";
import {
+ ComposerInlineControl,
ComposerToolbarButton,
ComposerToolbarRow,
ComposerToolbarScroller,
- ComposerToolbarTrigger,
-} from "../../components/ComposerToolbarTrigger";
+} from "../../components/ComposerToolbar";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
-import { ControlPill, ControlPillMenu } from "../../components/ControlPill";
import { ProviderIcon } from "../../components/ProviderIcon";
+import { SymbolView } from "../../components/AppSymbol";
+import { AppText as Text } from "../../components/AppText";
import { ComposerSurface } from "./ThreadComposer";
-import { ThreadSettingsSheet, threadSettingsSummaryLabel } from "./ThreadSettingsSheet";
-import { useThreadSettingsSheetPresentation } from "./use-thread-settings-sheet-presentation";
+import {
+ useThreadSettingsSheetPresentation,
+ type NavigationWithFinishTransitioning,
+} from "./use-thread-settings-sheet-presentation";
import { makeTurnCommandMetadata } from "../../lib/commandMetadata";
import { convertPastedImagesToAttachments, pickComposerImages } from "../../lib/composerImages";
-import { resolveProviderOptionDescriptors } from "../../lib/providerOptions";
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
import {
clearComposerDraftContent,
@@ -50,21 +56,33 @@ import { deriveThreadTitleFromPrompt } from "../../lib/projectThreadStartTurn";
import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/remoteRegistration";
import { enqueueThreadOutboxMessage, removeThreadOutboxMessage } from "../../state/thread-outbox";
import { useRemoteConnectionStatus } from "../../state/use-remote-environment-registry";
-import { branchBadgeLabel, useNewTaskFlow } from "./new-task-flow-provider";
+import { useNewTaskFlow } from "./new-task-flow-provider";
import { useCreateProjectThread } from "./use-project-actions";
import { resolveDraftProjectSelection } from "./new-task-project-selection";
+import {
+ resolveNewTaskBranchLabel,
+ resolveNewTaskWorkspaceLabel,
+} from "./new-task-context-presentation";
import { useIncomingShare } from "../sharing/IncomingShareProvider";
-function formatWorkspaceLabel(input: {
- readonly workspaceMode: string;
- readonly currentBranchName: string | null;
- readonly selectedBranchName: string | null;
-}): string {
- const branchName = input.selectedBranchName ?? input.currentBranchName;
- if (input.workspaceMode === "worktree") {
- return branchName ? `New worktree · ${branchName}` : "New worktree";
+function NewTaskWorkspaceIcon(props: {
+ readonly workspaceMode: "local" | "worktree";
+ readonly worktreePath: string | null;
+}) {
+ const iconColor = useThemeColor("--color-icon-muted");
+
+ if (props.workspaceMode === "local" && props.worktreePath === null) {
+ return ;
}
- return branchName ? `Current · ${branchName}` : "Current checkout";
+
+ return (
+
+
+
+
+
+
+ );
}
export function NewTaskDraftScreen(props: {
@@ -91,7 +109,8 @@ export function NewTaskDraftScreen(props: {
const insets = useSafeAreaInsets();
const colorScheme = useColorScheme();
const isKeyboardVisible = useKeyboardState((state) => state.isVisible);
- const controlsBottomPadding = isKeyboardVisible ? 8 : Math.max(insets.bottom, 10);
+ const controlsBottomPadding = Math.max(insets.bottom, 10);
+ const keyboardOpenedOffset = Math.max(0, controlsBottomPadding - 8);
const { projectScopes, selectedProject, selectedProjectKey, setProject } = flow;
const { connectedEnvironments } = useRemoteConnectionStatus();
const selectedEnvironmentServerConfig = useEnvironmentServerConfig(
@@ -109,6 +128,49 @@ export function NewTaskDraftScreen(props: {
editorRef: promptInputRef,
isEditorFocused: isComposerFocused,
});
+ useEffect(() => {
+ if (Platform.OS !== "ios") {
+ return;
+ }
+
+ navigation.getParent()?.setOptions({ gestureEnabled: !isKeyboardVisible });
+ }, [isKeyboardVisible, navigation]);
+ useEffect(() => {
+ return () => {
+ if (Platform.OS === "ios") {
+ navigation.getParent()?.setOptions({ gestureEnabled: true });
+ }
+ };
+ }, [navigation]);
+ const settingsRoutePresentedRef = useRef(false);
+ useEffect(() => {
+ if (!settingsSheetPresentation.isVisible || settingsRoutePresentedRef.current) {
+ return;
+ }
+
+ settingsRoutePresentedRef.current = true;
+ navigation.dispatch(StackActions.push("ThreadSettings"));
+ }, [navigation, settingsSheetPresentation.isVisible]);
+ useFocusEffect(
+ useCallback(() => {
+ if (!settingsRoutePresentedRef.current) {
+ return;
+ }
+
+ settingsRoutePresentedRef.current = false;
+ settingsSheetPresentation.onDismissed();
+ }, [settingsSheetPresentation.onDismissed]),
+ );
+ useEffect(
+ () =>
+ // UIKit's completion callback for the sheet dismissal, surfaced by the
+ // native-stack patch. This is when the queued keyboard restore runs.
+ (navigation as unknown as NavigationWithFinishTransitioning).addListener(
+ "finishTransitioning",
+ settingsSheetPresentation.onStackTransitionsFinished,
+ ),
+ [navigation, settingsSheetPresentation.onStackTransitionsFinished],
+ );
const [importingShareKey, setImportingShareKey] = useState(null);
const [isCancellingShareImport, setIsCancellingShareImport] = useState(false);
const [cancelledIncomingShareId, setCancelledIncomingShareId] = useState(null);
@@ -228,9 +290,9 @@ export function NewTaskDraftScreen(props: {
}, [props.pendingTaskId, cancelEditingPendingTask]);
const foregroundColor = useThemeColor("--color-foreground");
+ const projectUnderlineColor = useThemeColor("--color-foreground-muted");
const regularFontFamily = useFontFamily("regular");
const bodyText = useScaledTextRole("body");
- const headlineText = useScaledTextRole("headline");
const sheetFadeOpaque = colorScheme === "dark" ? "rgba(14,14,14,0.98)" : "rgba(242,242,247,0.98)";
const sheetFadeTransparent = colorScheme === "dark" ? "rgba(14,14,14,0)" : "rgba(242,242,247,0)";
@@ -316,7 +378,7 @@ export function NewTaskDraftScreen(props: {
return;
}
loadedBranchesProjectKeyRef.current = projectKey;
- void flow.loadBranches();
+ flow.loadBranches();
}, [flow.loadBranches, selectedProject]);
useEffect(() => {
@@ -518,121 +580,6 @@ export function NewTaskDraftScreen(props: {
shareImportAttempt,
]);
- useEffect(() => {
- // Android starts with the collapsed composer pill (like an open thread)
- // and only expands/focuses when tapped.
- if (!selectedProject || Platform.OS === "android") {
- return;
- }
-
- let focusFrame: ReturnType | null = null;
- const interaction = InteractionManager.runAfterInteractions(() => {
- focusFrame = requestAnimationFrame(() => {
- // The delayed focus can land after the settings sheet opened, which
- // would pop the keyboard underneath its modal.
- if (!settingsSheetPresentation.isActiveRef.current) {
- promptInputRef.current?.focus();
- } else {
- settingsSheetPresentation.restoreFocusAfterSave();
- }
- });
- });
-
- return () => {
- interaction.cancel();
- if (focusFrame !== null) {
- cancelAnimationFrame(focusFrame);
- }
- };
- }, [
- selectedProject,
- settingsSheetPresentation.isActiveRef,
- settingsSheetPresentation.restoreFocusAfterSave,
- ]);
-
- const environmentMenuActions = useMemo(
- () =>
- flow.environments.map((environment) => ({
- id: `environment:${environment.environmentId}`,
- title: environment.environmentLabel,
- attributes: isIncomingShareTransferPending ? { disabled: true } : undefined,
- state:
- flow.selectedEnvironmentId === environment.environmentId ? ("on" as const) : undefined,
- })),
- [flow.environments, flow.selectedEnvironmentId, isIncomingShareTransferPending],
- );
-
- const providerOptionDescriptors = useMemo(
- () =>
- resolveProviderOptionDescriptors({
- capabilities: flow.selectedModelOption?.capabilities,
- selections: flow.selectedModel?.options,
- }),
- [flow.selectedModel?.options, flow.selectedModelOption?.capabilities],
- );
-
- const workspaceMenuActions = useMemo(() => {
- const branchActions =
- flow.availableBranches.length === 0
- ? [
- {
- id: "workspace:branch:none",
- title: flow.branchesLoading ? "Loading branches…" : "No branches available",
- attributes: { disabled: true },
- },
- ]
- : flow.availableBranches.slice(0, 12).map((branch) => {
- const badge = branchBadgeLabel({
- branch,
- project: flow.selectedProject,
- });
-
- return {
- id: `workspace:branch:${branch.name}`,
- title: branch.name,
- subtitle: badge ? badge.toUpperCase() : undefined,
- state: flow.selectedBranchName === branch.name ? ("on" as const) : undefined,
- };
- });
-
- return [
- {
- id: "workspace:mode",
- title: "Mode",
- subtitle: flow.workspaceMode === "local" ? "Current checkout" : "New worktree",
- subactions: (["local", "worktree"] as const).map((value) => ({
- id: `workspace:mode:${value}`,
- title: value === "local" ? "Current checkout" : "New worktree",
- state: flow.workspaceMode === value ? ("on" as const) : undefined,
- })),
- },
- {
- id: "workspace:branch",
- title: "Branch",
- subtitle: flow.selectedBranchName ?? "Choose branch",
- subactions: branchActions,
- },
- ...(flow.workspaceMode === "worktree"
- ? [
- {
- id: "workspace:start-from-origin",
- title: "Start from origin",
- subtitle: "Base the worktree on the latest origin branch",
- image: "arrow.triangle.pull",
- state: flow.startFromOrigin ? ("on" as const) : undefined,
- },
- ]
- : []),
- ];
- }, [
- flow.availableBranches,
- flow.branchesLoading,
- flow.selectedBranchName,
- flow.selectedProject,
- flow.startFromOrigin,
- flow.workspaceMode,
- ]);
-
const selectedEnvironmentLabel =
flow.environments.find(
(environment) => environment.environmentId === flow.selectedEnvironmentId,
@@ -641,50 +588,17 @@ export function NewTaskDraftScreen(props: {
flow.availableBranches.find((branch) => branch.current)?.name ??
flow.availableBranches.find((branch) => branch.isDefault)?.name ??
null;
- const settingsSummaryLabel = threadSettingsSummaryLabel({
- modelLabel: flow.selectedModelOption?.label ?? "Model",
- optionDescriptors: providerOptionDescriptors,
- runtimeMode: flow.runtimeMode,
- interactionMode: flow.interactionMode,
+ const selectedBranchName = flow.selectedBranchName ?? currentBranchName;
+ const selectedBranchLabel = resolveNewTaskBranchLabel({
+ branchName: selectedBranchName,
+ startFromOrigin: flow.startFromOrigin,
+ workspaceMode: flow.workspaceMode,
});
- const workspaceLabel = useMemo(
- () =>
- formatWorkspaceLabel({
- currentBranchName,
- selectedBranchName: flow.selectedBranchName,
- workspaceMode: flow.workspaceMode,
- }),
- [currentBranchName, flow.selectedBranchName, flow.workspaceMode],
- );
- function handleEnvironmentMenuAction(event: string) {
- if (isIncomingShareTransferPending || !event.startsWith("environment:")) {
- return;
- }
- flow.selectEnvironment(EnvironmentId.make(event.slice("environment:".length)));
- }
-
- function handleWorkspaceMenuAction(event: string) {
- if (isIncomingShareTransferPending) {
- return;
- }
- if (event.startsWith("workspace:mode:")) {
- flow.setWorkspaceMode(
- event.slice("workspace:mode:".length) as Parameters[0],
- );
- return;
- }
- if (event === "workspace:start-from-origin") {
- flow.setStartFromOrigin(!flow.startFromOrigin);
- return;
- }
- if (event.startsWith("workspace:branch:")) {
- const branchName = event.slice("workspace:branch:".length);
- const branch = flow.availableBranches.find((candidate) => candidate.name === branchName);
- if (branch) {
- flow.selectBranch(branch);
- }
- }
- }
+ const workspaceLabel = resolveNewTaskWorkspaceLabel({
+ workspaceMode: flow.workspaceMode,
+ worktreePath: flow.selectedWorktreePath,
+ });
+ const showBranchLoading = flow.branchesLoading && flow.availableBranches.length === 0;
async function handlePickImages(): Promise {
if (isIncomingShareTransferPending) {
@@ -734,7 +648,9 @@ export function NewTaskDraftScreen(props: {
draft.workspaceSelection?.worktreePath ?? flow.selectedWorktreePath;
const startFromOrigin = draft.workspaceSelection?.startFromOrigin ?? flow.startFromOrigin;
const runtimeMode = draft.runtimeMode ?? flow.runtimeMode;
- const interactionMode = draft.interactionMode ?? flow.interactionMode;
+ const interactionMode = flow.planModeEnabled
+ ? (draft.interactionMode ?? flow.interactionMode)
+ : "default";
const initialMessageText = draft.text.trim();
if (
@@ -794,6 +710,7 @@ export function NewTaskDraftScreen(props: {
// -only Activity start. If creation fails, the token registration's replay
// finds no work and ends the card within seconds.
armAgentAwarenessLiveActivityForLocalWork({
+ environmentId: selectedProject.environmentId,
threadTitle: deriveThreadTitleSeed({
text: initialMessageText,
attachments: draft.attachments,
@@ -855,7 +772,7 @@ export function NewTaskDraftScreen(props: {
if (!selectedProject) {
return (
-
+
{Platform.OS === "android" ? (
<>
@@ -870,11 +787,6 @@ export function NewTaskDraftScreen(props: {
const isAndroid = Platform.OS === "android";
const isDarkMode = colorScheme === "dark";
- // Android expansion follows native editor focus so relayout cannot race
- // the touch gesture that opens the keyboard.
- // The settings sheet dismisses the keyboard, so its flag keeps the Android
- // draft composer expanded through the blur (mirrors ThreadComposer).
- const isExpanded = !isAndroid || isComposerFocused || settingsSheetPresentation.isActive;
const canStart =
Boolean(flow.selectedProject) &&
Boolean(flow.selectedModel) &&
@@ -886,235 +798,279 @@ export function NewTaskDraftScreen(props: {
const promptEditor = (
setIsComposerFocused(true)}
onBlur={() => setIsComposerFocused(false)}
onPasteImages={(uris) => void handleNativePasteImages(uris)}
- placeholder={`Describe a coding task in ${selectedProject.title}`}
- // Same collapsed centering as ThreadComposer: native vertical gravity
- // in a pill-height box.
- singleLineCentered={!isExpanded}
- contentInsetVertical={isAndroid ? 0 : undefined}
- style={
- isAndroid
- ? isExpanded
- ? { minHeight: 80, maxHeight: 160, paddingHorizontal: 4, paddingVertical: 4 }
- : { height: 36 }
- : { flex: 1, minHeight: 0 }
- }
- textStyle={
- isAndroid
- ? { ...bodyText, color: foregroundColor, fontFamily: regularFontFamily }
- : headlineText
- }
+ placeholder="Ask anything…"
+ singleLineCentered={false}
+ contentInsetVertical={0}
+ style={{
+ minHeight: 72,
+ maxHeight: 160,
+ paddingHorizontal: 4,
+ paddingVertical: 4,
+ }}
+ textStyle={{ ...bodyText, color: foregroundColor, fontFamily: regularFontFamily }}
/>
);
- const toolbarPills = (
- <>
- void handlePickImages()}
+ const closeNewTask = () => {
+ void KeyboardController.dismiss({ animated: true });
+ const parentNavigation = navigation.getParent();
+ if (parentNavigation) {
+ parentNavigation.goBack();
+ return;
+ }
+ navigation.goBack();
+ };
+ const chooseProject = () => {
+ if (isIncomingShareTransferPending) {
+ return;
+ }
+ promptInputRef.current?.blur();
+ void KeyboardController.dismiss({ animated: true });
+ navigation.dispatch(StackActions.push("NewTask", { incomingShareId: props.incomingShareId }));
+ };
+ const openContextPicker = (routeName: "NewTaskBranch" | "NewTaskEnvironment") => {
+ if (isIncomingShareTransferPending) {
+ return;
+ }
+ promptInputRef.current?.blur();
+ void KeyboardController.dismiss({ animated: true });
+ navigation.dispatch(StackActions.push(routeName));
+ };
+
+ const hero = (
+
+
+
+ What should we build
+
+
+ in
+
+
+ {selectedProject.title}
+
+
+ ?
+
+
+
+ 1 ? () => openContextPicker("NewTaskEnvironment") : undefined
+ }
+ showChevron={flow.environments.length > 1}
+ static={flow.environments.length <= 1}
+ />
+
+ );
+ const heroViewport = (
+
+
+ {hero}
+
+
+ );
+
+ const workspaceControls = (
+
+
+ }
+ label={workspaceLabel}
+ maxWidth={flow.workspaceMode === "local" ? 220 : 148}
+ onPress={() => flow.setWorkspaceMode(flow.workspaceMode === "local" ? "worktree" : "local")}
showChevron={false}
- disabled={isIncomingShareTransferPending}
/>
- }
- label={settingsSummaryLabel}
- maxWidth={320}
- onPress={settingsSheetPresentation.open}
+ icon="arrow.triangle.branch"
+ label={showBranchLoading ? "Loading branches…" : selectedBranchLabel}
+ maxWidth={190}
+ onPress={() => openContextPicker("NewTaskBranch")}
/>
- handleEnvironmentMenuAction(nativeEvent.event)}
- >
-
-
- handleWorkspaceMenuAction(nativeEvent.event)}
- >
-
-
- >
+
);
- const settingsSheet = (
- flow.setSelectedModelKey(option.key, option.selection.options)}
- optionDescriptors={providerOptionDescriptors}
- onUpdateOptionSelections={flow.setSelectedModelOptions}
- runtimeMode={flow.runtimeMode}
- onUpdateRuntimeMode={flow.setRuntimeMode}
- />
- );
+ const composerDock = (
+
+ {workspaceControls}
- const startButton = (
- void handleStart()}
- variant="primary"
- showChevron={false}
- disabled={!canStart}
- />
+
+ {flow.attachments.length > 0 ? (
+
+ undefined : flow.removeAttachment}
+ />
+
+ ) : null}
+
+ {promptEditor}
+
+
+
+ void handlePickImages()}
+ showChevron={false}
+ />
+
+ }
+ label={flow.selectedModelOption?.label ?? "Choose model"}
+ maxWidth={152}
+ onPress={settingsSheetPresentation.open}
+ />
+ {flow.planModeEnabled ? (
+
+ flow.setInteractionMode(flow.interactionMode === "plan" ? "default" : "plan")
+ }
+ showChevron={false}
+ />
+ ) : null}
+
+ void handleStart()}
+ showChevron={false}
+ variant="primary"
+ />
+
+
+
);
if (isAndroid) {
- // The draft is a thread that doesn't exist yet, so it mirrors the thread
- // page: in-screen header, empty feed canvas above, and the same floating
- // composer chrome as ThreadComposer (collapsed pill → expanded card).
- //
- // Composer positioning mirrors ThreadDetailScreen's floating overlay
- // (KeyboardStickyView, absolute bottom overlay) rather than
- // KeyboardAvoidingView's automaticOffset+padding: automaticOffset
- // resolves the composer's on-screen frame via a native
- // viewPositionInWindow measurement, which this app's Android
- // edge-to-edge setup (KeyboardProvider's native content-view margin
- // handling neutralizes windowSoftInputMode="adjustResize" while active)
- // makes unreliable — the composer stayed under the keyboard instead of
- // translating above it. KeyboardStickyView sticks directly to the
- // animated keyboard height instead, sidestepping that measurement.
return (
-
+
- navigation.goBack()} />
-
-
+
+ {heroViewport}
-
-
- {isExpanded && flow.attachments.length > 0 ? (
-
- undefined : flow.removeAttachment
- }
- />
-
- ) : null}
- {promptEditor}
- {!isExpanded ? (
- void handleStart()}
- />
- ) : null}
-
-
- {isExpanded ? (
-
-
- {toolbarPills}
-
- {startButton}
-
- ) : null}
-
+ {composerDock}
- {settingsSheet}
);
}
return (
-
-
+
+
+
+
+
-
- {promptEditor}
-
-
- {flow.attachments.length > 0 ? (
-
- undefined : flow.removeAttachment}
- imageSize={88}
- imageBorderRadius={20}
- />
-
- ) : null}
-
-
- {toolbarPills}
-
- {startButton}
-
-
-
- {settingsSheet}
+ {heroViewport}
+
+ {composerDock}
+
);
}
diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx
index 0daaae7bf1..b63293258c 100644
--- a/apps/mobile/src/features/threads/ThreadComposer.tsx
+++ b/apps/mobile/src/features/threads/ThreadComposer.tsx
@@ -14,7 +14,7 @@ import {
serializeComposerFileLink,
type ComposerTrigger,
} from "@t3tools/shared/composerTrigger";
-import * as Haptics from "expo-haptics";
+import { StackActions, useFocusEffect, useNavigation } from "@react-navigation/native";
import type { ReactNode } from "react";
import { memo, useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";
import {
@@ -41,18 +41,19 @@ import { scopedThreadKey } from "../../lib/scopedEntities";
import { AppText as Text } from "../../components/AppText";
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
+import { GlassSurface } from "../../components/GlassSurface";
import {
ComposerEditor,
type ComposerEditorHandle,
type ComposerEditorSelection,
} from "../../components/ComposerEditor";
import {
+ ComposerInlineControl,
ComposerToolbarButton,
ComposerToolbarRow,
ComposerToolbarScroller,
- ComposerToolbarTrigger,
-} from "../../components/ComposerToolbarTrigger";
-import { ControlPill, ControlPillMenu } from "../../components/ControlPill";
+} from "../../components/ComposerToolbar";
+import { ControlPill } from "../../components/ControlPill";
import { ProviderIcon } from "../../components/ProviderIcon";
import type { DraftComposerImageAttachment } from "../../lib/composerImages";
import { buildModelOptions, groupByProvider } from "../../lib/modelOptions";
@@ -63,15 +64,17 @@ import {
normalizeSearchQuery,
scoreQueryMatch,
} from "@t3tools/shared/searchRanking";
-import {
- applyProviderOptionSelection,
- resolveProviderOptionDescriptors,
-} from "../../lib/providerOptions";
+import { resolveProviderOptionDescriptors } from "../../lib/providerOptions";
import { useComposerPathSearch } from "../../state/use-composer-path-search";
import { ComposerCommandPopover, type ComposerCommandItem } from "./ComposerCommandPopover";
-import { buildThreadSettingsMenu } from "./thread-settings-menu";
-import { ThreadSettingsSheet, threadSettingsSummaryLabel } from "./ThreadSettingsSheet";
-import { useThreadSettingsSheetPresentation } from "./use-thread-settings-sheet-presentation";
+import {
+ type ExistingThreadSettingsRouteSession,
+ useExistingThreadSettingsRoutePresentation,
+} from "./ThreadSettingsSheet";
+import {
+ useThreadSettingsSheetPresentation,
+ type NavigationWithFinishTransitioning,
+} from "./use-thread-settings-sheet-presentation";
/**
* Height of the collapsed composer (pill + vertical padding, excluding safe-area inset).
@@ -83,7 +86,7 @@ export const COMPOSER_COLLAPSED_CHROME = 60;
* Height of the expanded composer (card + toolbar + vertical padding, excluding safe-area inset).
* Used by the parent to compute the larger feed bottom inset when the composer is focused.
*/
-export const COMPOSER_EXPANDED_CHROME = 174;
+export const COMPOSER_EXPANDED_CHROME = 156;
export interface ThreadComposerProps {
readonly draftMessage: string;
@@ -124,8 +127,8 @@ export interface ThreadComposerProps {
}
/**
- * The pill / card container — renders as LiquidGlassView on supported
- * iOS 26+ devices (progressive blur, native morph), opaque View otherwise.
+ * The pill / card container — renders with Expo's native GlassView on supported
+ * iOS 26+ devices and keeps the existing opaque fallback elsewhere.
* Exported so NewTaskDraftScreen can render the same composer chrome.
*/
// One timing for every piece of the expanded↔compact morph so the surface,
@@ -141,6 +144,8 @@ export function ComposerSurface(props: {
readonly children: ReactNode;
readonly style: ViewStyle;
readonly isDarkMode: boolean;
+ /** Existing thread composers morph between pill and card layouts. */
+ readonly animateLayout?: boolean;
}) {
// Drop shadow lives on a wrapper: `overflow: "hidden"` on the surface itself
// (needed to clip content to the pill shape) would clip the shadow on iOS.
@@ -153,35 +158,26 @@ export function ComposerSurface(props: {
elevation: 10,
};
- if (isLiquidGlassSupported) {
- return (
-
-
- {props.children}
-
-
- );
- }
-
return (
-
-
+
{props.children}
-
+
);
}
@@ -272,6 +268,7 @@ const ComposerConnectionStatusPill = memo(function ComposerConnectionStatusPill(
});
export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposerProps) {
+ const navigation = useNavigation();
const isDarkMode = useColorScheme() === "dark";
const foregroundColor = useThemeColor("--color-foreground");
const bodyText = useScaledTextRole("body");
@@ -282,14 +279,16 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
editorRef: inputRef,
isEditorFocused: isFocused,
});
+ const settingsRoutePresentation = useExistingThreadSettingsRoutePresentation();
+ const settingsRoutePresentedRef = useRef(false);
const wasExpandedBeforePreviewRef = useRef(false);
const inFlightThreadIdsRef = useRef(new Set());
const { onExpandedChange } = props;
const [previewImageUri, setPreviewImageUri] = useState(null);
const hasContent = props.draftMessage.trim().length > 0 || props.draftAttachments.length > 0;
- // Opening and closing count as active so the composer stays expanded while
- // focus moves between its native editor and the settings modal.
+ // Opening and presentation count as active so the composer stays expanded
+ // while focus moves between its native editor and the settings picker.
const isExpanded = isFocused || settingsSheetPresentation.isActive;
const canSend = hasContent;
@@ -333,7 +332,6 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
: "Send";
const currentModelSelection = props.selectedThread.modelSelection;
const currentRuntimeMode = props.selectedThread.runtimeMode;
- const currentInteractionMode = props.selectedThread.interactionMode ?? "default";
const connectionStatus = composerConnectionStatus({
connectionError: props.connectionError,
connectionState: props.connectionState,
@@ -543,6 +541,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
// after the send so its preference read and native Activity start don't
// contend with the queued-message feedback on the tap frame.
armAgentAwarenessLiveActivityForLocalWork({
+ environmentId: props.environmentId,
threadTitle: props.selectedThread.title,
projectTitle: props.environmentLabel ?? "T3 Code",
});
@@ -625,67 +624,71 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
}),
[currentModelOption?.capabilities, currentModelSelection.options],
);
- const settingsSummaryLabel = threadSettingsSummaryLabel({
- modelLabel: currentModelOption?.label ?? currentModelSelection.model,
- optionDescriptors: providerOptionDescriptors,
- runtimeMode: currentRuntimeMode,
- interactionMode: currentInteractionMode,
- });
-
- // iOS gets a native menu on the trigger pill: the everyday adjustments
- // apply without resigning the keyboard, while "All Settings…" (and the
- // Android trigger) still route through the sheet, which must dismiss it.
- const settingsMenu = useMemo(
- () =>
- Platform.OS === "ios"
- ? buildThreadSettingsMenu({
- providerGroups: threadProviderGroups,
- selectedModel: currentModelSelection,
- optionDescriptors: providerOptionDescriptors,
- runtimeMode: currentRuntimeMode,
- })
- : null,
- [threadProviderGroups, currentModelSelection, providerOptionDescriptors, currentRuntimeMode],
- );
-
- const onUpdateModelSelection = props.onUpdateModelSelection;
- const onUpdateRuntimeMode = props.onUpdateRuntimeMode;
- const handleSettingsMenuAction = useCallback(
- (eventId: string) => {
- const event = settingsMenu?.events.get(eventId);
- if (!event) {
- return;
- }
- switch (event.type) {
- case "select-model":
- void Haptics.selectionAsync();
- onUpdateModelSelection(event.option.selection);
- return;
- case "set-option": {
- const options = applyProviderOptionSelection(providerOptionDescriptors, {
- id: event.optionId,
- value: event.value,
- });
- if (options) {
- void Haptics.selectionAsync();
- onUpdateModelSelection({ ...currentModelSelection, options });
- }
- return;
- }
- case "set-runtime":
- void Haptics.selectionAsync();
- onUpdateRuntimeMode(event.mode);
- return;
- }
- },
+ const settingsOwnerId = scopedThreadKey(props.environmentId, props.selectedThread.id);
+ const settingsRouteSession = useMemo(
+ () => ({
+ ownerId: settingsOwnerId,
+ providerGroups: threadProviderGroups,
+ selectedModel: currentModelSelection,
+ onSelectModel: (option) => props.onUpdateModelSelection(option.selection),
+ optionDescriptors: providerOptionDescriptors,
+ onUpdateOptionSelections: (options) =>
+ props.onUpdateModelSelection({ ...currentModelSelection, options }),
+ runtimeMode: currentRuntimeMode,
+ onUpdateRuntimeMode: props.onUpdateRuntimeMode,
+ }),
[
currentModelSelection,
- onUpdateModelSelection,
- onUpdateRuntimeMode,
+ currentRuntimeMode,
+ props.onUpdateModelSelection,
+ props.onUpdateRuntimeMode,
providerOptionDescriptors,
- settingsMenu,
+ settingsOwnerId,
+ threadProviderGroups,
],
);
+ const openSettings = useCallback(() => {
+ settingsRoutePresentation.present(settingsRouteSession);
+ settingsSheetPresentation.open();
+ }, [settingsRoutePresentation.present, settingsRouteSession, settingsSheetPresentation.open]);
+
+ useEffect(() => {
+ if (settingsSheetPresentation.isActive) {
+ settingsRoutePresentation.present(settingsRouteSession);
+ }
+ }, [settingsRoutePresentation.present, settingsRouteSession, settingsSheetPresentation.isActive]);
+
+ useEffect(() => {
+ if (!settingsSheetPresentation.isVisible || settingsRoutePresentedRef.current) {
+ return;
+ }
+
+ settingsRoutePresentedRef.current = true;
+ navigation.dispatch(StackActions.push("ThreadSettingsSheet"));
+ }, [navigation, settingsSheetPresentation.isVisible]);
+
+ useFocusEffect(
+ useCallback(() => {
+ if (!settingsRoutePresentedRef.current) {
+ return;
+ }
+
+ settingsRoutePresentedRef.current = false;
+ settingsSheetPresentation.onDismissed();
+ settingsRoutePresentation.clear(settingsOwnerId);
+ }, [settingsOwnerId, settingsRoutePresentation.clear, settingsSheetPresentation.onDismissed]),
+ );
+
+ useEffect(
+ () =>
+ // UIKit's completion callback for the sheet dismissal, surfaced by the
+ // native-stack patch. This is when the queued keyboard restore runs.
+ (navigation as unknown as NavigationWithFinishTransitioning).addListener(
+ "finishTransitioning",
+ settingsSheetPresentation.onStackTransitionsFinished,
+ ),
+ [navigation, settingsSheetPresentation.onStackTransitionsFinished],
+ );
return (
) : null}
-
-
- {isExpanded ? (
- // Toolbar row — matches draft page layout (expanded only)
-
-
+ {isExpanded ? (
+
void props.onPickDraftImages()}
showChevron={false}
/>
- {settingsMenu ? (
- handleSettingsMenuAction(nativeEvent.event)}
- >
-
- }
- label={settingsSummaryLabel}
- maxWidth={320}
- />
-
- ) : (
-
- }
- label={settingsSummaryLabel}
- maxWidth={320}
- onPress={settingsSheetPresentation.open}
- />
- )}
+
+ }
+ label={currentModelOption?.label ?? currentModelSelection.model}
+ maxWidth={152}
+ onPress={openSettings}
+ />
{showStopAction ? (
-
- ) : null}
+ ) : null}
+
{/* Queue count */}
{props.queueCount > 0 ? (
@@ -914,21 +901,6 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
) : null}
- props.onUpdateModelSelection(option.selection)}
- optionDescriptors={providerOptionDescriptors}
- onUpdateOptionSelections={(options) =>
- props.onUpdateModelSelection({ ...currentModelSelection, options })
- }
- runtimeMode={currentRuntimeMode}
- onUpdateRuntimeMode={props.onUpdateRuntimeMode}
- />
-
{
expect(layout.nextSnoozeWakeAt).toBeNull();
});
+ it("keeps a merged thread active when auto-settle on merge is off", () => {
+ const merged = makeThread({ id: ThreadId.make("merged"), title: "Merged" });
+ const layout = buildThreadListV2Items({
+ threads: [merged],
+ environmentId: null,
+ searchQuery: "",
+ changeRequestStateByKey: new Map([[`${environmentId}:${merged.id}`, "merged"]]),
+ autoSettleOnMerge: false,
+ now: NOW,
+ });
+
+ expect(layout.items.map((item) => item.thread.id)).toEqual(["merged"]);
+ expect(layout.settledCount).toBe(0);
+ });
+
it("hides snoozed threads and counts them — visibility parity with web", () => {
const layout = buildThreadListV2Items({
threads: [
diff --git a/apps/mobile/src/state/queries.ts b/apps/mobile/src/state/queries.ts
index 741d9ea810..f65b0960b9 100644
--- a/apps/mobile/src/state/queries.ts
+++ b/apps/mobile/src/state/queries.ts
@@ -1,13 +1,17 @@
-import type { EnvironmentId } from "@t3tools/contracts";
+import type { VcsRefTarget } from "@t3tools/client-runtime/state/vcs";
+import type { EnvironmentId, ThreadId, VcsListRefsResult, VcsRef } from "@t3tools/contracts";
import {
createThreadSearchResultsAtomFamily,
makeThreadSearchKey,
type EnvironmentThreadSearchMatch,
} from "@t3tools/client-runtime/state/thread-search";
import { useAtomValue } from "@effect/atom-react";
-import { Atom } from "effect/unstable/reactivity";
-import { useEffect, useMemo, useState } from "react";
+import * as Cause from "effect/Cause";
+import * as Option from "effect/Option";
+import { AsyncResult, Atom } from "effect/unstable/reactivity";
+import { useCallback, useEffect, useMemo, useState } from "react";
+import { appAtomRegistry } from "./atom-registry";
import { orchestrationEnvironment } from "./orchestration";
import { projectEnvironment } from "./projects";
import { useEnvironmentQuery } from "./query";
@@ -22,6 +26,8 @@ const COMPOSER_PATH_SEARCH_DEBOUNCE_MS = 200;
const COMPOSER_PATH_SEARCH_LIMIT = 20;
const THREAD_SEARCH_DEBOUNCE_MS = 200;
const VCS_REF_LIST_LIMIT = 100;
+const EMPTY_REFS: ReadonlyArray = [];
+const INITIAL_BRANCH_CURSORS = [undefined] as const;
const EMPTY_THREAD_SEARCH_MATCHES: ReadonlyArray = Object.freeze([]);
const EMPTY_THREAD_SEARCH_ATOM = Atom.make({
matches: EMPTY_THREAD_SEARCH_MATCHES,
@@ -43,7 +49,7 @@ export interface ComposerPathSearchTarget {
readonly query: string | null;
}
-function useDebouncedValue(value: A, delayMs: number): A {
+export function useDebouncedValue(value: A, delayMs: number): A {
const [debounced, setDebounced] = useState(value);
useEffect(() => {
@@ -103,6 +109,113 @@ export function useBranches(input: {
);
}
+export function usePaginatedBranches(target: VcsRefTarget) {
+ const query = target.query?.trim() ?? "";
+ const targetKey =
+ target.environmentId !== null && target.cwd !== null
+ ? JSON.stringify([target.environmentId, target.cwd, query])
+ : null;
+ const [pagination, setPagination] = useState<{
+ readonly targetKey: string | null;
+ readonly cursors: ReadonlyArray;
+ }>({
+ targetKey,
+ cursors: INITIAL_BRANCH_CURSORS,
+ });
+ const cursors = pagination.targetKey === targetKey ? pagination.cursors : INITIAL_BRANCH_CURSORS;
+ const pageAtoms = useMemo(
+ () =>
+ target.environmentId !== null && target.cwd !== null
+ ? cursors.map((cursor) =>
+ vcsEnvironment.listRefs({
+ environmentId: target.environmentId!,
+ input: {
+ cwd: target.cwd!,
+ ...(query.length > 0 ? { query } : {}),
+ ...(cursor === undefined ? {} : { cursor }),
+ limit: VCS_REF_LIST_LIMIT,
+ },
+ }),
+ )
+ : [],
+ [cursors, query, target.cwd, target.environmentId],
+ );
+ const pagesAtom = useMemo(
+ () =>
+ Atom.make((get) => pageAtoms.map((atom) => get(atom))).pipe(
+ Atom.withLabel(`mobile:vcs-ref-pages:${targetKey ?? "empty"}`),
+ ),
+ [pageAtoms, targetKey],
+ );
+ const results = useAtomValue(pagesAtom);
+ const values = results.flatMap((result) => {
+ const value = Option.getOrNull(AsyncResult.value(result));
+ return value === null ? [] : [value];
+ });
+ const refs = new Map();
+ for (const value of values) {
+ for (const ref of value.refs) {
+ refs.set(ref.name, ref);
+ }
+ }
+ const first = values[0] ?? null;
+ const last = values.at(-1) ?? null;
+ const data: VcsListRefsResult | null =
+ first === null || last === null
+ ? null
+ : {
+ refs: [...refs.values()],
+ isRepo: first.isRepo,
+ hasPrimaryRemote: first.hasPrimaryRemote,
+ nextCursor: last.nextCursor,
+ totalCount: Math.max(...values.map((value) => value.totalCount)),
+ };
+ const lastResult = results.at(-1);
+ const isFetchingNextPage =
+ results.length > 1 &&
+ lastResult?.waiting === true &&
+ Option.isNone(AsyncResult.value(lastResult));
+ const failed = results.find((result) => result._tag === "Failure");
+ const error =
+ failed?._tag === "Failure"
+ ? (() => {
+ const cause = Cause.squash(failed.cause);
+ return cause instanceof Error && cause.message.trim().length > 0
+ ? cause.message
+ : "Failed to load refs.";
+ })()
+ : null;
+ const refresh = useCallback(() => {
+ const firstPage = pageAtoms[0];
+ setPagination({ targetKey, cursors: INITIAL_BRANCH_CURSORS });
+ if (firstPage !== undefined) {
+ appAtomRegistry.refresh(firstPage);
+ }
+ }, [pageAtoms, targetKey]);
+ const loadNext = useCallback(() => {
+ if (targetKey === null || data?.nextCursor === null || data?.nextCursor === undefined) {
+ return;
+ }
+ setPagination((current) => {
+ const currentCursors =
+ current.targetKey === targetKey ? current.cursors : INITIAL_BRANCH_CURSORS;
+ return currentCursors.includes(data.nextCursor!)
+ ? { targetKey, cursors: currentCursors }
+ : { targetKey, cursors: [...currentCursors, data.nextCursor!] };
+ });
+ }, [data?.nextCursor, targetKey]);
+
+ return {
+ data,
+ refs: data?.refs ?? EMPTY_REFS,
+ error,
+ isPending: results.some((result) => result.waiting),
+ isFetchingNextPage,
+ refresh,
+ loadNext,
+ };
+}
+
export function useComposerPathSearch(target: ComposerPathSearchTarget) {
const normalizedTarget = useMemo(
() => ({
diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts
index d218490f8b..e11e336503 100644
--- a/apps/server/src/server.ts
+++ b/apps/server/src/server.ts
@@ -651,7 +651,11 @@ export const makeServerLayer = Layer.unwrap(
return serverApplicationLayer.pipe(
Layer.provideMerge(runtimeServicesLive),
- Layer.provideMerge(McpSessionRegistry.layer.pipe(Layer.provide(ServerEnvironment.layer))),
+ Layer.provideMerge(
+ McpSessionRegistry.layer.pipe(
+ Layer.provide(ServerEnvironment.layer.pipe(Layer.provide(ServerSecretStore.layer))),
+ ),
+ ),
Layer.provide(activationLayer),
Layer.provideMerge(serverRelayBrokerTracingLayer),
Layer.provideMerge(HttpServerLive),
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 0d86465008..a381b073be 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -183,6 +183,7 @@ import {
projectScriptIdFromCommand,
} from "~/projectScripts";
import { newDraftId, newMessageId, newThreadId } from "~/lib/utils";
+import { registerFaviconProjectForThread } from "~/browserFaviconStore";
import { getProviderModelCapabilities, resolveSelectableProvider } from "../providerModels";
import { NO_PROVIDER_MODEL_SELECTION } from "../providerInstances";
import { useClientSettings, useEnvironmentSettings } from "../hooks/useSettings";
@@ -1789,9 +1790,11 @@ function ChatViewContent(props: ChatViewProps) {
});
}, [activeThreadKey, existingOpenTerminalThreadKeys, terminalUiState.terminalOpen]);
const latestRunSettled = isLatestRunSettled(activeLatestRun, activeRuntime);
- const activeProjectRef = activeThread
- ? scopeProjectRef(activeThread.environmentId, activeThread.projectId)
- : null;
+ const activeProjectRef = useMemo(
+ () =>
+ activeThread ? scopeProjectRef(activeThread.environmentId, activeThread.projectId) : null,
+ [activeThread?.environmentId, activeThread?.projectId],
+ );
const activeProject = useProject(activeProjectRef);
const handleNewThreadInActiveProject = useCallback(() => {
startNewThreadForProject(activeProjectRef, handleNewThread);
@@ -1841,6 +1844,10 @@ function ChatViewContent(props: ChatViewProps) {
// drive the environment picker in BranchToolbar.
const allProjects = useProjects();
const primaryEnvironmentId = primaryEnvironment?.environmentId ?? null;
+ useEffect(() => {
+ if (!activeThreadRef || !activeProjectRef) return;
+ registerFaviconProjectForThread(activeThreadRef, activeProjectRef);
+ }, [activeProjectRef, activeThreadRef]);
const activeEnvironment =
activeThread == null ? null : (environmentById.get(activeThread.environmentId) ?? null);
const activeEnvironmentConnectionPhase = activeEnvironment?.connection.phase ?? "available";
@@ -4291,6 +4298,7 @@ function ChatViewContent(props: ChatViewProps) {
// so the banner and the sidebar row never disagree.
const activeThreadShell = useThreadShell(isServerThread ? activeThreadRef : null);
const autoSettleAfterDays = useClientSettings((settings) => settings.sidebarAutoSettleAfterDays);
+ const autoSettleOnMerge = useClientSettings((settings) => settings.sidebarAutoSettleOnMerge);
const activeThreadPr = resolveThreadPr({
threadBranch: activeThread?.branch ?? null,
gitStatus: gitStatusQuery.data ?? null,
@@ -4327,12 +4335,14 @@ function ChatViewContent(props: ChatViewProps) {
return effectiveSettled(activeThreadShell, {
now: `${nowMinute}:00.000Z`,
autoSettleAfterDays,
+ autoSettleOnMerge,
changeRequestState: activeThreadPr?.state ?? null,
});
}, [
activeThreadPr?.state,
activeThreadShell,
autoSettleAfterDays,
+ autoSettleOnMerge,
nowMinute,
supportsSettlement,
]);
@@ -6764,6 +6774,7 @@ function ChatViewContent(props: ChatViewProps) {
activeSurfaceId={activeRightPanelSurface?.id ?? null}
pendingSurfaceIds={pendingFileSurfaceIds}
previewSessions={activePreviewState.sessions}
+ desktopByTabId={activePreviewState.desktopByTabId}
terminalLabelsById={activeTerminalLabelsById}
onActivate={activateRightPanelSurface}
onCloseSurface={closeRightPanelSurface}
@@ -6799,6 +6810,7 @@ function ChatViewContent(props: ChatViewProps) {
activeSurfaceId={activeRightPanelSurface?.id ?? null}
pendingSurfaceIds={pendingFileSurfaceIds}
previewSessions={activePreviewState.sessions}
+ desktopByTabId={activePreviewState.desktopByTabId}
terminalLabelsById={activeTerminalLabelsById}
onActivate={activateRightPanelSurface}
onCloseSurface={closeRightPanelSurface}
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index ff129f1882..e8fc5955f8 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -686,7 +686,6 @@ export const MessagesTimeline = memo(function MessagesTimeline({
/>
;
@@ -884,19 +881,16 @@ function TimelineMinimap({
return null;
}
- const safeBottomInset = Math.max(0, Math.ceil(bottomInset));
-
return (