fix: reconcile main's round-6 features after the rebase
- ChatView: #5880 auto-settle-on-merge setting flows into effectiveSettled, #5644 browser favicon project registration effect, activeProjectRef memo, desktopByTabId on both RightPanelTabs mounts - server: provide ServerSecretStore to the McpSessionRegistry's ServerEnvironment layer (#6325 reads publish opt-in per descriptor) - mobile: 3-way merged main's deltas into the v2 thread screens (NewTaskDraftScreen keeps the branch title seed + main's environmentId, threadListV2 keeps both new test suites, queries imports deduped) Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
8dcbdcac52
commit
d6e8dd8161
7 files changed
+615
-549
No files matched your search
@@ -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 <SymbolView name="folder" size={16} tintColor={iconColor} type="monochrome" />;
|
||||
}
|
||||
return branchName ? `Current · ${branchName}` : "Current checkout";
|
||||
|
||||
return (
|
||||
<View className="size-4">
|
||||
<SymbolView name="folder" size={16} tintColor={iconColor} type="monochrome" />
|
||||
<View className="absolute -right-1 -bottom-1">
|
||||
<SymbolView name="arrow.triangle.branch" size={9} tintColor={iconColor} type="monochrome" />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
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<string | null>(null);
|
||||
const [isCancellingShareImport, setIsCancellingShareImport] = useState(false);
|
||||
const [cancelledIncomingShareId, setCancelledIncomingShareId] = useState<string | null>(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<typeof requestAnimationFrame> | 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<typeof flow.setWorkspaceMode>[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<void> {
|
||||
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 (
|
||||
<View className="flex-1 bg-sheet">
|
||||
<View className="flex-1 bg-sheet" collapsable={false}>
|
||||
{Platform.OS === "android" ? (
|
||||
<>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
@@ -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 = (
|
||||
<ComposerEditor
|
||||
ref={promptInputRef}
|
||||
// Native autoFocus fires becomeFirstResponder in didMoveToWindow, which
|
||||
// forces the iOS keyboard bring-up during the formSheet present
|
||||
// animation and stalls it. The runAfterInteractions effect above focuses
|
||||
// the editor once the transition settles instead.
|
||||
// The context-first screen intentionally opens with the keyboard closed.
|
||||
// Focusing is a user action, so presenting the form sheet has one motion.
|
||||
autoFocus={false}
|
||||
editable={!isIncomingShareTransferPending}
|
||||
multiline
|
||||
scrollEnabled={isExpanded}
|
||||
scrollEnabled
|
||||
value={flow.prompt}
|
||||
skills={flow.selectedProviderSkills}
|
||||
onChangeText={flow.setPrompt}
|
||||
onFocus={() => 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 = (
|
||||
<>
|
||||
<ComposerToolbarButton
|
||||
icon="plus"
|
||||
onPress={() => 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 = (
|
||||
<View className="items-center gap-6 px-6" testID="new-task-hero">
|
||||
<View className="w-full items-center gap-1.5">
|
||||
<Text className="text-center text-2xl font-t3-medium tracking-tight text-foreground">
|
||||
What should we build
|
||||
</Text>
|
||||
<View className="max-w-full flex-row items-center justify-center">
|
||||
<Text className="text-2xl font-t3-medium tracking-tight text-foreground">in </Text>
|
||||
<Pressable
|
||||
accessibilityHint="Opens the project picker"
|
||||
accessibilityLabel={`Change project from ${selectedProject.title}`}
|
||||
accessibilityRole="button"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
onPress={chooseProject}
|
||||
className="min-w-0 max-w-[250px] active:opacity-65"
|
||||
style={{
|
||||
borderBottomColor: projectUnderlineColor,
|
||||
borderBottomWidth: 1,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
className="text-2xl font-t3-medium tracking-tight text-foreground"
|
||||
numberOfLines={1}
|
||||
>
|
||||
{selectedProject.title}
|
||||
</Text>
|
||||
</Pressable>
|
||||
<Text className="text-2xl font-t3-medium tracking-tight text-foreground">?</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<ComposerInlineControl
|
||||
accessibilityLabel={`Environment: ${selectedEnvironmentLabel}`}
|
||||
chevronDirection="right"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="desktopcomputer"
|
||||
label={`on ${selectedEnvironmentLabel}`}
|
||||
maxWidth={260}
|
||||
onPress={
|
||||
flow.environments.length > 1 ? () => openContextPicker("NewTaskEnvironment") : undefined
|
||||
}
|
||||
showChevron={flow.environments.length > 1}
|
||||
static={flow.environments.length <= 1}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
const heroViewport = (
|
||||
<View className="flex-1" collapsable={false}>
|
||||
<ScrollView
|
||||
alwaysBounceVertical={isKeyboardVisible}
|
||||
className="flex-1"
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
contentContainerClassName="grow items-center pb-[236px] pt-12 ios:pt-[72px]"
|
||||
keyboardDismissMode={Platform.OS === "ios" ? "interactive" : "on-drag"}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={{ flex: 1 }}
|
||||
testID="new-task-hero-scroll"
|
||||
>
|
||||
{hero}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
|
||||
const workspaceControls = (
|
||||
<View className="flex-row items-center gap-1 px-2">
|
||||
<ComposerInlineControl
|
||||
accessibilityHint={`Switches to ${flow.workspaceMode === "local" ? "a new worktree" : "the current checkout"}`}
|
||||
accessibilityLabel={workspaceLabel}
|
||||
disabled={isIncomingShareTransferPending}
|
||||
iconNode={
|
||||
<NewTaskWorkspaceIcon
|
||||
workspaceMode={flow.workspaceMode}
|
||||
worktreePath={flow.selectedWorktreePath}
|
||||
/>
|
||||
}
|
||||
label={workspaceLabel}
|
||||
maxWidth={flow.workspaceMode === "local" ? 220 : 148}
|
||||
onPress={() => flow.setWorkspaceMode(flow.workspaceMode === "local" ? "worktree" : "local")}
|
||||
showChevron={false}
|
||||
disabled={isIncomingShareTransferPending}
|
||||
/>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Thread settings"
|
||||
|
||||
<ComposerInlineControl
|
||||
accessibilityLabel={`${flow.workspaceMode === "worktree" ? "Base branch" : "Branch"}: ${selectedBranchLabel}`}
|
||||
chevronDirection="right"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
iconNode={<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />}
|
||||
label={settingsSummaryLabel}
|
||||
maxWidth={320}
|
||||
onPress={settingsSheetPresentation.open}
|
||||
icon="arrow.triangle.branch"
|
||||
label={showBranchLoading ? "Loading branches…" : selectedBranchLabel}
|
||||
maxWidth={190}
|
||||
onPress={() => openContextPicker("NewTaskBranch")}
|
||||
/>
|
||||
<ControlPillMenu
|
||||
actions={environmentMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleEnvironmentMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Environment"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="desktopcomputer"
|
||||
label={selectedEnvironmentLabel}
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
<ControlPillMenu
|
||||
actions={workspaceMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleWorkspaceMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Workspace"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="point.topleft.down.curvedto.point.bottomright.up"
|
||||
label={workspaceLabel}
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
|
||||
const settingsSheet = (
|
||||
<ThreadSettingsSheet
|
||||
visible={settingsSheetPresentation.isVisible}
|
||||
onClose={settingsSheetPresentation.close}
|
||||
onDismissed={settingsSheetPresentation.onDismissed}
|
||||
providerGroups={flow.providerGroups}
|
||||
selectedModel={flow.selectedModel}
|
||||
onSelectModel={(option) => flow.setSelectedModelKey(option.key, option.selection.options)}
|
||||
optionDescriptors={providerOptionDescriptors}
|
||||
onUpdateOptionSelections={flow.setSelectedModelOptions}
|
||||
runtimeMode={flow.runtimeMode}
|
||||
onUpdateRuntimeMode={flow.setRuntimeMode}
|
||||
/>
|
||||
);
|
||||
const composerDock = (
|
||||
<View className="bg-sheet px-4 pt-1" style={{ paddingBottom: controlsBottomPadding }}>
|
||||
<View className="pb-1">{workspaceControls}</View>
|
||||
|
||||
const startButton = (
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel={
|
||||
flow.submitting ? "Starting task" : environmentConnected ? "Start task" : "Queue task"
|
||||
}
|
||||
icon={environmentConnected ? "arrow.up" : "tray.and.arrow.up"}
|
||||
onPress={() => void handleStart()}
|
||||
variant="primary"
|
||||
showChevron={false}
|
||||
disabled={!canStart}
|
||||
/>
|
||||
<ComposerSurface
|
||||
animateLayout={false}
|
||||
isDarkMode={isDarkMode}
|
||||
style={{
|
||||
borderRadius: 26,
|
||||
minHeight: 140,
|
||||
overflow: "hidden",
|
||||
paddingBottom: 6,
|
||||
paddingHorizontal: 14,
|
||||
paddingTop: 14,
|
||||
}}
|
||||
>
|
||||
{flow.attachments.length > 0 ? (
|
||||
<View className="pb-2.5">
|
||||
<ComposerAttachmentStrip
|
||||
attachments={flow.attachments}
|
||||
imageBorderRadius={16}
|
||||
imageSize={72}
|
||||
onRemove={isIncomingShareTransferPending ? () => undefined : flow.removeAttachment}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{promptEditor}
|
||||
|
||||
<ComposerToolbarRow paddingBottom={0} paddingHorizontal={0} paddingTop={4}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={sheetFadeOpaque}
|
||||
fadeTransparent={sheetFadeTransparent}
|
||||
contentPaddingRight={8}
|
||||
>
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Add attachment"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="plus"
|
||||
onPress={() => void handlePickImages()}
|
||||
showChevron={false}
|
||||
/>
|
||||
<ComposerInlineControl
|
||||
accessibilityLabel="Model and reasoning settings"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
emphasized
|
||||
iconNode={
|
||||
<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />
|
||||
}
|
||||
label={flow.selectedModelOption?.label ?? "Choose model"}
|
||||
maxWidth={152}
|
||||
onPress={settingsSheetPresentation.open}
|
||||
/>
|
||||
{flow.planModeEnabled ? (
|
||||
<ComposerInlineControl
|
||||
accessibilityHint={`Switches to ${flow.interactionMode === "plan" ? "Build" : "Plan"} mode`}
|
||||
accessibilityLabel={`Interaction mode: ${flow.interactionMode === "plan" ? "Plan" : "Build"}`}
|
||||
disabled={isIncomingShareTransferPending}
|
||||
emphasized
|
||||
icon={
|
||||
flow.interactionMode === "plan"
|
||||
? { ios: "list.bullet.clipboard", android: "auto_awesome" }
|
||||
: { ios: "hammer", android: "construction" }
|
||||
}
|
||||
label={flow.interactionMode === "plan" ? "Plan" : "Build"}
|
||||
onPress={() =>
|
||||
flow.setInteractionMode(flow.interactionMode === "plan" ? "default" : "plan")
|
||||
}
|
||||
showChevron={false}
|
||||
/>
|
||||
) : null}
|
||||
</ComposerToolbarScroller>
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel={
|
||||
flow.submitting ? "Starting task" : environmentConnected ? "Start task" : "Queue task"
|
||||
}
|
||||
disabled={!canStart}
|
||||
icon={environmentConnected ? "arrow.up" : "tray.and.arrow.up"}
|
||||
onPress={() => void handleStart()}
|
||||
showChevron={false}
|
||||
variant="primary"
|
||||
/>
|
||||
</ComposerToolbarRow>
|
||||
</ComposerSurface>
|
||||
</View>
|
||||
);
|
||||
|
||||
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 (
|
||||
<View className="flex-1 bg-screen">
|
||||
<View className="flex-1 bg-sheet" collapsable={false}>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
<AndroidScreenHeader title="New Thread" onBack={() => navigation.goBack()} />
|
||||
|
||||
<View className="flex-1" />
|
||||
<AndroidScreenHeader title="New task" onBack={closeNewTask} />
|
||||
{heroViewport}
|
||||
|
||||
<KeyboardStickyView
|
||||
enabled={isKeyboardVisible}
|
||||
style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}
|
||||
offset={{ closed: 0, opened: 0 }}
|
||||
offset={{ closed: 0, opened: keyboardOpenedOffset }}
|
||||
>
|
||||
<View
|
||||
className="px-4 pt-2"
|
||||
style={{
|
||||
paddingBottom: controlsBottomPadding,
|
||||
experimental_backgroundImage: isDarkMode
|
||||
? "linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.85) 40%, rgba(0,0,0,0.95) 100%)"
|
||||
: "linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0.85) 40%, rgba(255,255,255,0.95) 100%)",
|
||||
}}
|
||||
>
|
||||
<ComposerSurface
|
||||
isDarkMode={isDarkMode}
|
||||
style={
|
||||
isExpanded
|
||||
? {
|
||||
borderRadius: 20,
|
||||
overflow: "hidden",
|
||||
paddingHorizontal: 14,
|
||||
paddingVertical: 12,
|
||||
}
|
||||
: {
|
||||
borderRadius: 999,
|
||||
overflow: "hidden",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
paddingLeft: 18,
|
||||
paddingRight: 5,
|
||||
paddingVertical: 5,
|
||||
}
|
||||
}
|
||||
>
|
||||
{isExpanded && flow.attachments.length > 0 ? (
|
||||
<View className="pb-2.5">
|
||||
<ComposerAttachmentStrip
|
||||
attachments={flow.attachments}
|
||||
onRemove={
|
||||
isIncomingShareTransferPending ? () => undefined : flow.removeAttachment
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
<View className={isExpanded ? undefined : "min-w-0 flex-1"}>{promptEditor}</View>
|
||||
{!isExpanded ? (
|
||||
<ControlPill
|
||||
icon="arrow.up"
|
||||
variant="primary"
|
||||
disabled={!canStart}
|
||||
onPress={() => void handleStart()}
|
||||
/>
|
||||
) : null}
|
||||
</ComposerSurface>
|
||||
|
||||
{isExpanded ? (
|
||||
<ComposerToolbarRow paddingBottom={8} paddingHorizontal={0} paddingTop={8}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={isDarkMode ? "rgba(0,0,0,0.95)" : "rgba(255,255,255,0.95)"}
|
||||
fadeTransparent={isDarkMode ? "rgba(0,0,0,0)" : "rgba(255,255,255,0)"}
|
||||
>
|
||||
{toolbarPills}
|
||||
</ComposerToolbarScroller>
|
||||
{startButton}
|
||||
</ComposerToolbarRow>
|
||||
) : null}
|
||||
</View>
|
||||
{composerDock}
|
||||
</KeyboardStickyView>
|
||||
{settingsSheet}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-sheet">
|
||||
<NativeStackScreenOptions options={{ title: selectedProject.title }} />
|
||||
<View className="flex-1 bg-sheet" collapsable={false}>
|
||||
<NativeStackScreenOptions
|
||||
options={{
|
||||
headerBackVisible: false,
|
||||
headerShadowVisible: false,
|
||||
title: "",
|
||||
}}
|
||||
/>
|
||||
<NativeHeaderToolbar placement="left">
|
||||
<NativeHeaderToolbar.Button
|
||||
accessibilityLabel="Cancel new task"
|
||||
label="Cancel"
|
||||
onPress={closeNewTask}
|
||||
/>
|
||||
</NativeHeaderToolbar>
|
||||
|
||||
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
|
||||
<View className="min-h-0 flex-1 px-5 pt-2">{promptEditor}</View>
|
||||
|
||||
<View className="border-t border-border" style={{ paddingBottom: controlsBottomPadding }}>
|
||||
{flow.attachments.length > 0 ? (
|
||||
<View className="px-4 pt-3">
|
||||
<ComposerAttachmentStrip
|
||||
attachments={flow.attachments}
|
||||
onRemove={isIncomingShareTransferPending ? () => undefined : flow.removeAttachment}
|
||||
imageSize={88}
|
||||
imageBorderRadius={20}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
<ComposerToolbarRow paddingBottom={controlsBottomPadding} paddingHorizontal={6}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={sheetFadeOpaque}
|
||||
fadeTransparent={sheetFadeTransparent}
|
||||
>
|
||||
{toolbarPills}
|
||||
</ComposerToolbarScroller>
|
||||
{startButton}
|
||||
</ComposerToolbarRow>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
{settingsSheet}
|
||||
{heroViewport}
|
||||
<KeyboardStickyView
|
||||
style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}
|
||||
offset={{ closed: 0, opened: keyboardOpenedOffset }}
|
||||
>
|
||||
{composerDock}
|
||||
</KeyboardStickyView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -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 (
|
||||
<Animated.View layout={COMPOSER_LAYOUT_TRANSITION} style={shadowStyle}>
|
||||
<LiquidGlassView
|
||||
effect="regular"
|
||||
interactive
|
||||
colorScheme={props.isDarkMode ? "dark" : "light"}
|
||||
style={props.style}
|
||||
>
|
||||
{props.children}
|
||||
</LiquidGlassView>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Animated.View layout={COMPOSER_LAYOUT_TRANSITION} style={shadowStyle}>
|
||||
<View
|
||||
style={[
|
||||
props.style,
|
||||
{
|
||||
backgroundColor: props.isDarkMode ? "rgba(44,44,46,0.96)" : "rgba(255,255,255,0.96)",
|
||||
borderWidth: 1,
|
||||
borderColor: props.isDarkMode ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.06)",
|
||||
},
|
||||
]}
|
||||
<Animated.View
|
||||
layout={props.animateLayout === false ? undefined : COMPOSER_LAYOUT_TRANSITION}
|
||||
style={shadowStyle}
|
||||
>
|
||||
<GlassSurface
|
||||
chrome="none"
|
||||
fallbackStyle={{
|
||||
backgroundColor: props.isDarkMode ? "rgba(44,44,46,0.96)" : "rgba(255,255,255,0.96)",
|
||||
borderWidth: 1,
|
||||
borderColor: props.isDarkMode ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.06)",
|
||||
}}
|
||||
glassEffectStyle="regular"
|
||||
// The composer is a passive material containing interactive controls.
|
||||
// Expo GlassView defaults to non-interactive and both layouts share it.
|
||||
tintColor="transparent"
|
||||
style={props.style}
|
||||
>
|
||||
{props.children}
|
||||
</View>
|
||||
</GlassSurface>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
@@ -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<string>());
|
||||
const { onExpandedChange } = props;
|
||||
|
||||
const [previewImageUri, setPreviewImageUri] = useState<string | null>(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<ExistingThreadSettingsRouteSession>(
|
||||
() => ({
|
||||
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 (
|
||||
<Animated.View
|
||||
@@ -738,10 +741,12 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
style={
|
||||
isExpanded
|
||||
? {
|
||||
borderRadius: 20,
|
||||
borderRadius: 26,
|
||||
minHeight: 140,
|
||||
overflow: "hidden" as const,
|
||||
paddingBottom: 6,
|
||||
paddingHorizontal: 14,
|
||||
paddingVertical: 12,
|
||||
paddingTop: 14,
|
||||
}
|
||||
: {
|
||||
borderRadius: 999,
|
||||
@@ -791,7 +796,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
style={
|
||||
isExpanded
|
||||
? {
|
||||
minHeight: 80,
|
||||
minHeight: 72,
|
||||
maxHeight: 160,
|
||||
paddingHorizontal: 4,
|
||||
paddingVertical: 4,
|
||||
@@ -840,15 +845,12 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
)}
|
||||
</Animated.View>
|
||||
) : null}
|
||||
</ComposerSurface>
|
||||
|
||||
{isExpanded ? (
|
||||
// Toolbar row — matches draft page layout (expanded only)
|
||||
<Animated.View entering={FadeIn.duration(160)} exiting={FadeOut.duration(120)}>
|
||||
<ComposerToolbarRow paddingBottom={8} paddingHorizontal={0} paddingTop={8}>
|
||||
{isExpanded ? (
|
||||
<ComposerToolbarRow paddingBottom={0} paddingHorizontal={0} paddingTop={4}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={toolbarFadeOpaque}
|
||||
fadeTransparent={toolbarFadeTransparent}
|
||||
contentPaddingRight={8}
|
||||
>
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Add attachment"
|
||||
@@ -856,31 +858,16 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
onPress={() => void props.onPickDraftImages()}
|
||||
showChevron={false}
|
||||
/>
|
||||
{settingsMenu ? (
|
||||
<ControlPillMenu
|
||||
actions={settingsMenu.actions}
|
||||
onPressAction={({ nativeEvent }) => handleSettingsMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Thread settings"
|
||||
iconNode={
|
||||
<ProviderIcon provider={currentModelOption?.providerDriver} size={16} />
|
||||
}
|
||||
label={settingsSummaryLabel}
|
||||
maxWidth={320}
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
) : (
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Thread settings"
|
||||
iconNode={
|
||||
<ProviderIcon provider={currentModelOption?.providerDriver} size={16} />
|
||||
}
|
||||
label={settingsSummaryLabel}
|
||||
maxWidth={320}
|
||||
onPress={settingsSheetPresentation.open}
|
||||
/>
|
||||
)}
|
||||
<ComposerInlineControl
|
||||
accessibilityLabel="Model and reasoning settings"
|
||||
emphasized
|
||||
iconNode={
|
||||
<ProviderIcon provider={currentModelOption?.providerDriver} size={16} />
|
||||
}
|
||||
label={currentModelOption?.label ?? currentModelSelection.model}
|
||||
maxWidth={152}
|
||||
onPress={openSettings}
|
||||
/>
|
||||
{showStopAction ? (
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Stop"
|
||||
@@ -900,8 +887,8 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
showChevron={false}
|
||||
/>
|
||||
</ComposerToolbarRow>
|
||||
</Animated.View>
|
||||
) : null}
|
||||
) : null}
|
||||
</ComposerSurface>
|
||||
|
||||
{/* Queue count */}
|
||||
{props.queueCount > 0 ? (
|
||||
@@ -914,21 +901,6 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
) : null}
|
||||
</Animated.View>
|
||||
|
||||
<ThreadSettingsSheet
|
||||
visible={settingsSheetPresentation.isVisible}
|
||||
onClose={settingsSheetPresentation.close}
|
||||
onDismissed={settingsSheetPresentation.onDismissed}
|
||||
providerGroups={threadProviderGroups}
|
||||
selectedModel={currentModelSelection}
|
||||
onSelectModel={(option) => props.onUpdateModelSelection(option.selection)}
|
||||
optionDescriptors={providerOptionDescriptors}
|
||||
onUpdateOptionSelections={(options) =>
|
||||
props.onUpdateModelSelection({ ...currentModelSelection, options })
|
||||
}
|
||||
runtimeMode={currentRuntimeMode}
|
||||
onUpdateRuntimeMode={props.onUpdateRuntimeMode}
|
||||
/>
|
||||
|
||||
<ImageViewing
|
||||
images={previewImageUri ? [{ uri: previewImageUri }] : []}
|
||||
imageIndex={0}
|
||||
|
||||
@@ -327,6 +327,21 @@ describe("buildThreadListV2Items", () => {
|
||||
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: [
|
||||
|
||||
@@ -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<VcsRef> = [];
|
||||
const INITIAL_BRANCH_CURSORS = [undefined] as const;
|
||||
const EMPTY_THREAD_SEARCH_MATCHES: ReadonlyArray<EnvironmentThreadSearchMatch> = 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<A>(value: A, delayMs: number): A {
|
||||
export function useDebouncedValue<A>(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<number | undefined>;
|
||||
}>({
|
||||
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<string, VcsRef>();
|
||||
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(
|
||||
() => ({
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -686,7 +686,6 @@ export const MessagesTimeline = memo(function MessagesTimeline({
|
||||
/>
|
||||
<TimelineMinimap
|
||||
items={minimapItems}
|
||||
bottomInset={contentInsetEndAdjustment}
|
||||
hasPersistentGutter={minimapHasPersistentGutter}
|
||||
hitStripWidth={minimapHitStripWidth}
|
||||
stripMap={minimapStripMap}
|
||||
@@ -817,14 +816,12 @@ function timelineMinimapEventTargetsPreview(target: EventTarget): boolean {
|
||||
}
|
||||
|
||||
function TimelineMinimap({
|
||||
bottomInset,
|
||||
hasPersistentGutter,
|
||||
hitStripWidth,
|
||||
items,
|
||||
stripMap,
|
||||
onSelect,
|
||||
}: {
|
||||
bottomInset: number;
|
||||
hasPersistentGutter: boolean;
|
||||
hitStripWidth: number;
|
||||
items: ReadonlyArray<TimelineMinimapItem>;
|
||||
@@ -884,19 +881,16 @@ function TimelineMinimap({
|
||||
return null;
|
||||
}
|
||||
|
||||
const safeBottomInset = Math.max(0, Math.ceil(bottomInset));
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"group/minimap pointer-events-none absolute top-0 left-0 z-40 hidden w-18 [@media(pointer:fine)]:block",
|
||||
"group/minimap pointer-events-none absolute inset-y-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
|
||||
|
||||
Reference in new issue
Block a user