Skip to content
TypeScript

refactor(mobile): retire the legacy grouped thread list (#13183)

Julius Marminge0c91f687de60
diff --git a/apps/mobile/src/features/home/HomeHeader.android.tsx b/apps/mobile/src/features/home/HomeHeader.android.tsx
index 78e87431b47..0c15bcc09ce 100644
--- a/apps/mobile/src/features/home/HomeHeader.android.tsx
+++ b/apps/mobile/src/features/home/HomeHeader.android.tsx
@@ -1,13 +1,7 @@
import type { MenuAction } from "@react-native-menu/menu";
import { useCallback, useMemo } from "react";
import { NativeStackScreenOptions } from "../../native/StackHeader";
-import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
import { MaterialThreadListToolbar } from "./MaterialThreadListToolbar";
-import {
- hasCustomHomeListOptions,
- PROJECT_SORT_OPTIONS,
- THREAD_SORT_OPTIONS,
-} from "./home-list-options";
import type { HomeHeaderProps } from "./HomeHeader.types";
export type { HomeHeaderEnvironment } from "./HomeHeader.types";
@@ -17,13 +11,11 @@ function checkedMenuState(checked: boolean) {
}
export function HomeHeader(props: HomeHeaderProps) {
- // Thread List v2 lays the list out in fixed creation order, so the
- // sort/group filter controls would be silently ignored — hide them and
- // key the "customized" icon state off the environment filter alone.
- const threadListV2Enabled = useThreadListV2Enabled();
- const hasCustomListOptions = threadListV2Enabled
- ? props.selectedEnvironmentId !== null || props.selectedProjectKey !== null
- : hasCustomHomeListOptions(props);
+ // The list uses a fixed creation order and ignores sort/group options, so
+ // the filter menu only carries the filters and the "customized" icon state
+ // keys off those alone.
+ const hasCustomListOptions =
+ props.selectedEnvironmentId !== null || props.selectedProjectKey !== null;
const menuActions = useMemo<MenuAction[]>(
() => [
{
@@ -62,38 +54,8 @@ export function HomeHeader(props: HomeHeaderProps) {
],
},
] satisfies MenuAction[])),
- ...(threadListV2Enabled
- ? []
- : ([
- {
- id: "project-sort",
- title: "Sort projects",
- subactions: PROJECT_SORT_OPTIONS.map((option) => ({
- id: `project-sort:${option.value}`,
- title: option.label,
- state: checkedMenuState(props.projectSortOrder === option.value),
- })),
- },
- {
- id: "thread-sort",
- title: "Sort threads",
- subactions: THREAD_SORT_OPTIONS.map((option) => ({
- id: `thread-sort:${option.value}`,
- title: option.label,
- state: checkedMenuState(props.threadSortOrder === option.value),
- })),
- },
- ] satisfies MenuAction[])),
- ],
- [
- props.environments,
- props.projectSortOrder,
- props.projects,
- props.selectedEnvironmentId,
- props.selectedProjectKey,
- props.threadSortOrder,
- threadListV2Enabled,
],
+ [props.environments, props.projects, props.selectedEnvironmentId, props.selectedProjectKey],
);
const handleMenuAction = useCallback(
(event: { nativeEvent: { event: string } }) => {
@@ -126,20 +88,6 @@ export function HomeHeader(props: HomeHeaderProps) {
}
return;
}
-
- const projectSort = PROJECT_SORT_OPTIONS.find(
- (option) => id === `project-sort:${option.value}`,
- );
- if (projectSort) {
- props.onProjectSortOrderChange(projectSort.value);
- return;
- }
-
- const threadSort = THREAD_SORT_OPTIONS.find((option) => id === `thread-sort:${option.value}`);
- if (threadSort) {
- props.onThreadSortOrderChange(threadSort.value);
- return;
- }
},
[props],
);
diff --git a/apps/mobile/src/features/home/HomeHeader.tsx b/apps/mobile/src/features/home/HomeHeader.tsx
index 2f044862f70..e1cc7448eb5 100644
--- a/apps/mobile/src/features/home/HomeHeader.tsx
+++ b/apps/mobile/src/features/home/HomeHeader.tsx
@@ -2,7 +2,6 @@ import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/Stac
import { useCallback, useRef } from "react";
import type { SearchBarCommands } from "react-native-screens";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
-import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
import {
@@ -10,11 +9,6 @@ import {
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
} from "../layout/native-mail-search-toolbar";
import { buildHomeListFilterMenu } from "./home-list-filter-menu";
-import {
- hasCustomHomeListOptions,
- PROJECT_SORT_OPTIONS,
- THREAD_SORT_OPTIONS,
-} from "./home-list-options";
import type { HomeHeaderProps } from "./HomeHeader.types";
export type { HomeHeaderEnvironment } from "./HomeHeader.types";
@@ -22,22 +16,17 @@ export type { HomeHeaderEnvironment } from "./HomeHeader.types";
export function HomeHeader(props: HomeHeaderProps) {
const searchBarRef = useRef<SearchBarCommands>(null);
const iconColor = useUniwindTheme()["--color-icon"];
- // Thread List v2 lays the list out in fixed creation order, so the
- // sort/group filter controls would be silently ignored — hide them and
- // key the "customized" icon state off the environment filter alone.
- const threadListV2Enabled = useThreadListV2Enabled();
- const hasCustomListOptions = threadListV2Enabled
- ? props.selectedEnvironmentId !== null || props.selectedProjectKey !== null
- : hasCustomHomeListOptions(props);
+ // The list uses a fixed creation order and ignores sort/group options, so
+ // the filter menu only carries the filters and the "customized" icon state
+ // keys off those alone.
+ const hasCustomListOptions =
+ props.selectedEnvironmentId !== null || props.selectedProjectKey !== null;
const focusSearch = useCallback(() => {
searchBarRef.current?.focus();
return searchBarRef.current !== null;
}, []);
useHardwareKeyboardCommand("focusSearch", focusSearch);
- const filterMenu = buildHomeListFilterMenu({
- ...props,
- listOrganization: !threadListV2Enabled,
- });
+ const filterMenu = buildHomeListFilterMenu(props);
return (
<>
@@ -100,7 +89,7 @@ export function HomeHeader(props: HomeHeaderProps) {
{NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED ? null : (
<NativeHeaderToolbar placement="bottom">
<NativeHeaderToolbar.Menu
- accessibilityLabel="Filter and sort threads"
+ accessibilityLabel="Filter threads"
icon={
hasCustomListOptions
? "line.3.horizontal.decrease.circle.fill"
@@ -150,36 +139,6 @@ export function HomeHeader(props: HomeHeaderProps) {
))}
</NativeHeaderToolbar.Menu>
) : null}
-
- {threadListV2Enabled ? null : (
- <NativeHeaderToolbar.Menu title="Sort projects">
- <NativeHeaderToolbar.Label>Sort projects</NativeHeaderToolbar.Label>
- {PROJECT_SORT_OPTIONS.map((option) => (
- <NativeHeaderToolbar.MenuAction
- key={option.value}
- isOn={props.projectSortOrder === option.value}
- onPress={() => props.onProjectSortOrderChange(option.value)}
- >
- <NativeHeaderToolbar.Label>{option.label}</NativeHeaderToolbar.Label>
- </NativeHeaderToolbar.MenuAction>
- ))}
- </NativeHeaderToolbar.Menu>
- )}
-
- {threadListV2Enabled ? null : (
- <NativeHeaderToolbar.Menu title="Sort threads">
- <NativeHeaderToolbar.Label>Sort threads</NativeHeaderToolbar.Label>
- {THREAD_SORT_OPTIONS.map((option) => (
- <NativeHeaderToolbar.MenuAction
- key={option.value}
- isOn={props.threadSortOrder === option.value}
- onPress={() => props.onThreadSortOrderChange(option.value)}
- >
- <NativeHeaderToolbar.Label>{option.label}</NativeHeaderToolbar.Label>
- </NativeHeaderToolbar.MenuAction>
- ))}
- </NativeHeaderToolbar.Menu>
- )}
</NativeHeaderToolbar.Menu>
<NativeHeaderToolbar.Spacer flexible />
<NativeHeaderToolbar.Button
diff --git a/apps/mobile/src/features/home/HomeHeader.types.ts b/apps/mobile/src/features/home/HomeHeader.types.ts
index 0545db09281..3c5f580f9ee 100644
--- a/apps/mobile/src/features/home/HomeHeader.types.ts
+++ b/apps/mobile/src/features/home/HomeHeader.types.ts
@@ -1,5 +1,4 @@
-import type { EnvironmentId, SidebarThreadSortOrder } from "@t3tools/contracts";
-import type { HomeProjectSortOrder } from "./homeThreadList";
+import type { EnvironmentId } from "@t3tools/contracts";
import type {
HomeListFilterMenuEnvironment,
HomeListFilterMenuProject,
@@ -13,13 +12,9 @@ export interface HomeHeaderProps {
readonly searchQuery: string;
readonly selectedEnvironmentId: EnvironmentId | null;
readonly selectedProjectKey: string | null;
- readonly projectSortOrder: HomeProjectSortOrder;
- readonly threadSortOrder: SidebarThreadSortOrder;
readonly onSearchQueryChange: (query: string) => void;
readonly onEnvironmentChange: (environmentId: EnvironmentId | null) => void;
readonly onProjectChange: (projectKey: string | null) => void;
- readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
- readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
readonly onOpenEnvironments: () => void;
readonly onOpenSettings: () => void;
readonly onStartNewTask: () => void;
diff --git a/apps/mobile/src/features/home/HomeRouteScreen.tsx b/apps/mobile/src/features/home/HomeRouteScreen.tsx
index 1ef8ea7b286..c480d0be48f 100644
--- a/apps/mobile/src/features/home/HomeRouteScreen.tsx
+++ b/apps/mobile/src/features/home/HomeRouteScreen.tsx
@@ -76,12 +76,8 @@ export function HomeRouteScreen() {
() => new Set(environments.map((environment) => environment.environmentId)),
[environments],
);
- const {
- options: listOptions,
- setSelectedEnvironmentId,
- setProjectSortOrder,
- setThreadSortOrder,
- } = useHomeListOptions(availableEnvironmentIds);
+ const { options: listOptions, setSelectedEnvironmentId } =
+ useHomeListOptions(availableEnvironmentIds);
const selectedEnvironmentId = listOptions.selectedEnvironmentId;
const [selectedProjectKey, setSelectedProjectKey] = useState<string | null>(null);
const projectFilterOptions = useMemo(
@@ -175,8 +171,6 @@ export function HomeRouteScreen() {
searchQuery={searchQuery}
selectedEnvironmentId={selectedEnvironmentId}
selectedProjectKey={selectedProjectKey}
- projectSortOrder={listOptions.projectSortOrder}
- threadSortOrder={listOptions.threadSortOrder}
onEnvironmentChange={setSelectedEnvironmentId}
onProjectChange={setSelectedProjectKey}
onOpenEnvironments={() =>
@@ -191,10 +185,8 @@ export function HomeRouteScreen() {
params: { screen: "Settings" },
})
}
- onProjectSortOrderChange={setProjectSortOrder}
onSearchQueryChange={setSearchQuery}
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
- onThreadSortOrderChange={setThreadSortOrder}
/>
<HomeScreen
@@ -225,7 +217,6 @@ export function HomeRouteScreen() {
params: { screen: "Settings" },
})
}
- onProjectSortOrderChange={setProjectSortOrder}
onSearchQueryChange={setSearchQuery}
onSelectThread={handleSelectThread}
onSelectPendingTask={openPendingTask}
@@ -252,7 +243,6 @@ export function HomeRouteScreen() {
});
}}
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
- onThreadSortOrderChange={setThreadSortOrder}
pendingTasks={pendingTasks}
projectGroupingMode={listOptions.projectGroupingMode}
projects={projects}
@@ -262,7 +252,6 @@ export function HomeRouteScreen() {
selectedEnvironmentId={selectedEnvironmentId}
selectedProjectKey={selectedProjectKey}
threads={threads}
- threadSortOrder={listOptions.threadSortOrder}
/>
</>
</AndroidHomeFabLayout>
diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index 80e9f5cac6f..ed1eb2afdbe 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -1,10 +1,6 @@
import type { ThreadMoveDestination } from "../threads/threadOrder";
import { computeThreadMoveAvailability } from "../threads/threadOrder";
-import {
- LegendList,
- type LegendListRef,
- type LegendListRenderItemProps,
-} from "@legendapp/list/react-native";
+import { LegendList } from "@legendapp/list/react-native";
import {
type EnvironmentProject,
type EnvironmentThreadShell,
@@ -17,10 +13,8 @@ import {
type EnvironmentId,
resolveEnvironmentMachineKind,
type SidebarProjectGroupingMode,
- type SidebarThreadSortOrder,
} from "@t3tools/contracts";
-import { useAtomSet, useAtomValue } from "@effect/atom-react";
-import { AsyncResult } from "effect/unstable/reactivity";
+import { useAtomValue } from "@effect/atom-react";
import { useFocusEffect } from "@react-navigation/native";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { ActivityIndicator, Platform, View } from "react-native";
@@ -34,20 +28,12 @@ import type { WorkspaceEnvironment, WorkspaceState } from "../../state/workspace
import type { SavedRemoteConnection } from "../../lib/connection";
import { scopedProjectKey } from "../../lib/scopedEntities";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
-import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import { useThreadSearch } from "../../state/queries";
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
-import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
import { usePendingThreadOrder } from "../../state/thread-order";
import { environmentServerConfigsAtom } from "../../state/server";
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
-import {
- PendingTaskListRow,
- ThreadListGroupHeader,
- ThreadListRow,
- ThreadListShowMoreRow,
-} from "../threads/thread-list-items";
import {
ThreadListV2PendingRow,
ThreadListV2Row,
@@ -67,19 +53,8 @@ import {
} from "../threads/threadListV2";
import { useThreadListV2ShelfPreferences } from "../threads/use-thread-list-v2-shelf-preferences";
import type { HomeListFilterMenuEnvironment } from "./home-list-filter-menu";
-import {
- buildHomeListLayout,
- DEFAULT_GROUP_DISPLAY_STATE,
- EMPTY_HOME_LIST_LAYOUT,
- homeListItemsAreEqual,
- nextGroupDisplayState,
- type HomeGroupDisplayAction,
- type HomeGroupDisplayState,
- type HomeListItem,
-} from "./homeListItems";
import {
buildHomeProjectScopes,
- buildHomeThreadGroups,
sortHomeProjectScopes,
type HomeProjectSortOrder,
} from "./homeThreadList";
@@ -101,13 +76,10 @@ interface HomeScreenProps {
readonly selectedEnvironmentId: EnvironmentId | null;
readonly selectedProjectKey: string | null;
readonly projectSortOrder: HomeProjectSortOrder;
- readonly threadSortOrder: SidebarThreadSortOrder;
readonly projectGroupingMode: SidebarProjectGroupingMode;
readonly onSearchQueryChange: (query: string) => void;
readonly onEnvironmentChange: (environmentId: EnvironmentId | null) => void;
readonly onProjectChange: (projectKey: string | null) => void;
- readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
- readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
readonly onAddConnection: () => void;
readonly onOpenSettings: () => void;
readonly onStartNewTask: () => void;
@@ -138,7 +110,6 @@ interface HomeScreenProps {
/* ─── Layout constants ───────────────────────────────────────────────── */
-const ESTIMATED_THREAD_ROW_HEIGHT = 72;
// v2 rows are mixed-height: settled slim rows run ~60dp, single-line cards
// measured ~74dp on device (252px on the Pixel 10 Pro screenshot), two-line
// cards ~94dp. The estimate seeds the recycler's initial container count,
@@ -236,15 +207,8 @@ function HomeTopContentSpacer() {
/* ─── Main screen ────────────────────────────────────────────────────── */
export function HomeScreen(props: HomeScreenProps) {
- const [groupDisplayStates, setGroupDisplayStates] = useState<
- ReadonlyMap<string, HomeGroupDisplayState>
- >(() => new Map());
- const preferencesResult = useAtomValue(mobilePreferencesAtom);
- const threadListV2Enabled = useThreadListV2Enabled();
const queuedThreadKeys = useQueuedThreadKeys();
- const savePreferences = useAtomSet(updateMobilePreferencesAtom);
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
- const listRef = useRef<LegendListRef | null>(null);
const insets = useSafeAreaInsets();
const iosBottomToolbarClearance =
Platform.OS === "ios" && !NATIVE_LIQUID_GLASS_SUPPORTED
@@ -279,42 +243,6 @@ export function HomeScreen(props: HomeScreenProps) {
() => new Set(threadSearch.matches.map(threadSearchMatchKey)),
[threadSearch.matches],
);
- const effectiveGroupDisplayStates = useMemo(() => {
- const next = new Map(groupDisplayStates);
- if (!AsyncResult.isSuccess(preferencesResult)) {
- return next;
- }
- for (const key of preferencesResult.value.collapsedProjectGroups ?? []) {
- const existing = next.get(key);
- next.set(key, {
- ...(existing ?? DEFAULT_GROUP_DISPLAY_STATE),
- collapsed: true,
- });
- }
- return next;
- }, [groupDisplayStates, preferencesResult]);
- const effectiveGroupDisplayStatesRef = useRef(effectiveGroupDisplayStates);
- effectiveGroupDisplayStatesRef.current = effectiveGroupDisplayStates;
-
- const updateGroupDisplay = useCallback(
- (key: string, action: HomeGroupDisplayAction) => {
- const next = new Map(effectiveGroupDisplayStatesRef.current);
- next.set(key, nextGroupDisplayState(next.get(key) ?? DEFAULT_GROUP_DISPLAY_STATE, action));
- effectiveGroupDisplayStatesRef.current = next;
- setGroupDisplayStates(next);
- if (action === "toggle-collapsed") {
- const collapsedProjectGroups: string[] = [];
- for (const [groupKey, state] of next) {
- if (state.collapsed) {
- collapsedProjectGroups.push(groupKey);
- }
- }
- savePreferences({ collapsedProjectGroups });
- }
- },
- [savePreferences],
- );
-
const handleSwipeableWillOpen = useCallback((methods: SwipeableMethods) => {
if (openSwipeableRef.current !== methods) {
openSwipeableRef.current?.close();
@@ -346,112 +274,7 @@ export function HomeScreen(props: HomeScreenProps) {
}),
[props.projectGroupingMode, props.projects, props.selectedEnvironmentId],
);
- const selectedProjectScope = useMemo(
- () =>
- props.selectedProjectKey === null
- ? null
- : (projectScopes.find(
- (scope) =>
- scope.key === props.selectedProjectKey ||
- scope.projectRefs.some(
- (projectRef) =>
- scopedProjectKey(projectRef.environmentId, projectRef.projectId) ===
- props.selectedProjectKey,
- ),
- ) ?? null),
- [projectScopes, props.selectedProjectKey],
- );
- const selectedProjectRefKeys = useMemo(
- () =>
- selectedProjectScope === null
- ? null
- : new Set(
- selectedProjectScope.projectRefs.map((projectRef) =>
- scopedProjectKey(projectRef.environmentId, projectRef.projectId),
- ),
- ),
- [selectedProjectScope],
- );
- const scopedProjects = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : selectedProjectRefKeys === null
- ? props.projects
- : props.projects.filter((project) =>
- selectedProjectRefKeys.has(scopedProjectKey(project.environmentId, project.id)),
- ),
- [threadListV2Enabled, props.projects, selectedProjectRefKeys],
- );
- const scopedThreads = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : selectedProjectRefKeys === null
- ? props.threads
- : props.threads.filter((thread) =>
- selectedProjectRefKeys.has(scopedProjectKey(thread.environmentId, thread.projectId)),
- ),
- [threadListV2Enabled, props.threads, selectedProjectRefKeys],
- );
- const scopedPendingTasks = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : selectedProjectRefKeys === null
- ? props.pendingTasks
- : props.pendingTasks.filter((pendingTask) =>
- selectedProjectRefKeys.has(
- scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
- ),
- ),
- [threadListV2Enabled, props.pendingTasks, selectedProjectRefKeys],
- );
-
- const projectGroups = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : buildHomeThreadGroups({
- projects: scopedProjects,
- threads: scopedThreads,
- pendingTasks: scopedPendingTasks,
- queuedThreadKeys,
- environmentId: props.selectedEnvironmentId,
- searchQuery: props.searchQuery,
- matchedThreadKeys,
- projectSortOrder: props.projectSortOrder,
- threadSortOrder: props.threadSortOrder,
- projectGroupingMode: props.projectGroupingMode,
- }),
- [
- threadListV2Enabled,
- queuedThreadKeys,
- props.projectGroupingMode,
- props.projectSortOrder,
- props.searchQuery,
- props.selectedEnvironmentId,
- props.threadSortOrder,
- matchedThreadKeys,
- scopedPendingTasks,
- scopedProjects,
- scopedThreads,
- ],
- );
-
const hasSearchQuery = props.searchQuery.trim().length > 0;
- const listLayout = useMemo(
- () =>
- threadListV2Enabled
- ? EMPTY_HOME_LIST_LAYOUT
- : buildHomeListLayout({
- groups: projectGroups,
- displayStates: effectiveGroupDisplayStates,
- showAllThreads: hasSearchQuery,
- }),
- [threadListV2Enabled, projectGroups, effectiveGroupDisplayStates, hasSearchQuery],
- );
-
const projectByKey = useMemo(() => {
const map = new Map<string, EnvironmentProject>();
for (const project of props.projects) {
@@ -597,12 +420,11 @@ export function HomeScreen(props: HomeScreenProps) {
const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);
useFocusEffect(
useCallback(() => {
- if (!threadListV2Enabled) return;
// Refresh immediately on enable or focus because the previous value can be hours old.
setNowMinute(new Date().toISOString().slice(0, 16));
const id = setInterval(() => setNowMinute(new Date().toISOString().slice(0, 16)), 60_000);
return () => clearInterval(id);
- }, [threadListV2Enabled]),
+ }, []),
);
// Threads on servers without the settlement capability never classify as
// settled (the user could neither un-settle nor pin them).
@@ -715,16 +537,6 @@ export function HomeScreen(props: HomeScreenProps) {
snoozeWakeTick,
]);
const threadListV2Layout = useMemo(() => {
- if (!threadListV2Enabled)
- return {
- items: [],
- hiddenSettledCount: 0,
- snoozedCount: 0,
- snoozedShelfHeaderIndex: null,
- settledCount: 0,
- settledShelfHeaderIndex: null,
- nextSnoozeWakeAt: null,
- };
// Settled threads are live shells; archived threads keep their original
// "hidden from lists" meaning.
return buildThreadListV2Items({
@@ -757,7 +569,6 @@ export function HomeScreen(props: HomeScreenProps) {
props.selectedEnvironmentId,
props.threads,
matchedThreadKeys,
- threadListV2Enabled,
v2ScopedProjectGroup,
]);
// Re-partition the moment the earliest snooze expires (clamped to the
@@ -824,10 +635,7 @@ export function HomeScreen(props: HomeScreenProps) {
],
);
- useThreadJumpShortcuts(
- threadListV2Enabled ? threadListV2Items : listLayout.items,
- props.onSelectThread,
- );
+ useThreadJumpShortcuts(threadListV2Items, props.onSelectThread);
const renderV2Item = useCallback(
({ item }: { readonly item: ThreadListV2ListItem }) => {
@@ -996,126 +804,13 @@ export function HomeScreen(props: HomeScreenProps) {
],
);
- const extraData = useMemo(
- () => ({
- savedConnectionsById: props.savedConnectionsById,
- searchQuery: props.searchQuery,
- threadSearchMatchByKey,
- }),
- [props.savedConnectionsById, props.searchQuery, threadSearchMatchByKey],
- );
-
- const renderItem = useCallback(
- ({ item }: LegendListRenderItemProps<HomeListItem>) => {
- switch (item.type) {
- case "header":
- return (
- <ThreadListGroupHeader
- variant="compact"
- collapsed={item.collapsed}
- isFirst={item.isFirst}
- groupKey={item.group.key}
- onGroupAction={updateGroupDisplay}
- // Aggregated groups (same repo across machines) have no single
- // target project, and `pending-project:` groups hold a placeholder
- // built from queued-task metadata rather than a real project shell,
- // so the quick new-thread button is single-real-project only.
- newThreadTarget={item.group.newThreadTarget}
- onNewThread={props.onNewThreadInProject}
- project={item.group.representative}
- threadCount={item.group.threads.length + item.group.pendingTasks.length}
- title={item.group.title}
- />
- );
- case "pending-task":
- return (
- <PendingTaskListRow
- variant="compact"
- pendingTask={item.pendingTask}
- environmentLabel={
- props.savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ?? null
- }
- environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
- isLast={item.isLast}
- onSelectPendingTask={props.onSelectPendingTask}
- onDeletePendingTask={props.onDeletePendingTask}
- />
- );
- case "thread": {
- const thread = item.thread;
- return (
- <ThreadListRow
- onNewThreadOnBranch={props.onNewThreadOnBranch}
- variant="compact"
- thread={thread}
- hasQueuedMessages={queuedThreadKeys.has(`${thread.environmentId}:${thread.id}`)}
- environmentLabel={
- props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
- }
- environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
- isLast={item.isLast}
- searchMatch={threadSearchMatchByKey.get(
- threadSearchMatchKey({
- environmentId: thread.environmentId,
- threadId: thread.id,
- }),
- )}
- searchQuery={props.searchQuery}
- onArchiveThread={props.onArchiveThread}
- onDeleteThread={props.onDeleteThread}
- onRenameThread={handleRenameThread}
- onRegenerateThreadTitle={handleRegenerateThreadTitle}
- titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
- onSelectThread={props.onSelectThread}
- onSwipeableClose={handleSwipeableClose}
- onSwipeableWillOpen={handleSwipeableWillOpen}
- />
- );
- }
- case "show-more":
- return (
- <ThreadListShowMoreRow
- variant="compact"
- hiddenCount={item.hiddenCount}
- canShowLess={item.canShowLess}
- groupKey={item.groupKey}
- onGroupAction={updateGroupDisplay}
- />
- );
- }
- },
- [
- handleSwipeableClose,
- handleSwipeableWillOpen,
- handleRegenerateThreadTitle,
- handleRenameThread,
- machineByEnvironmentId,
- queuedThreadKeys,
- props.onArchiveThread,
- props.onDeletePendingTask,
- props.onDeleteThread,
- props.onNewThreadInProject,
- props.onSelectPendingTask,
- props.onSelectThread,
- props.onNewThreadOnBranch,
- props.searchQuery,
- props.savedConnectionsById,
- threadSearchMatchByKey,
- titleRegenerationEnvironmentIds,
- updateGroupDisplay,
- ],
- );
-
- const keyExtractor = useCallback((item: HomeListItem) => item.key, []);
-
/* Empty states */
// The signal must ignore the search/environment filters: an active query
// that matches nothing needs the in-list "No results" state, not the
// full-page "No threads yet". Settled threads are unarchived live shells,
- // so the v1 check already covers v2.
+ // so the archived-at check already covers the settled shelf.
const hasAnyThreads =
props.threads.some((thread) => thread.archivedAt === null) || props.pendingTasks.length > 0;
- const hasResults = threadListV2Enabled ? threadListV2Items.length > 0 : projectGroups.length > 0;
const selectedEnvironmentLabel =
props.selectedEnvironmentId === null
? null
@@ -1178,16 +873,18 @@ export function HomeScreen(props: HomeScreenProps) {
// mobile — the menu is the one filter surface).
const v2ListHeader = listHeader;
- const listEmpty = !hasResults ? (
+ // Use the v2 project scope for its empty state. Snoozed threads need no
+ // special empty state: their shelf header is a list row even while collapsed.
+ const v2ListEmpty =
hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
<EmptyState
title="No results"
detail={`No threads matching "${props.searchQuery}".`}
variant={Platform.OS === "android" ? "plain" : undefined}
/>
- ) : selectedProjectScope !== null ? (
+ ) : v2ScopedProjectGroup !== null ? (
<EmptyState
- title={`No threads in ${selectedProjectScope.title}`}
+ title={`No threads in ${v2ScopedProjectGroup.title}`}
detail="Choose another project or create a new task."
variant={Platform.OS === "android" ? "plain" : undefined}
/>
@@ -1203,93 +900,16 @@ export function HomeScreen(props: HomeScreenProps) {
detail="Create a task to start a new coding session."
variant={Platform.OS === "android" ? "plain" : undefined}
/>
- )
- ) : null;
- // Use the v2 project scope for its empty state. Snoozed threads need no
- // special empty state: their shelf header is a list row even while collapsed.
- const v2ListEmpty =
- hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
- <EmptyState
- title="No results"
- detail={`No threads matching "${props.searchQuery}".`}
- variant={Platform.OS === "android" ? "plain" : undefined}
- />
- ) : v2ScopedProjectGroup !== null ? (
- <EmptyState
- title={`No threads in ${v2ScopedProjectGroup.title}`}
- detail="Choose another project or create a new task."
- variant={Platform.OS === "android" ? "plain" : undefined}
- />
- ) : (
- listEmpty
);
- if (
- Platform.OS === "android" &&
- (threadListV2Enabled ? threadListV2Items.length === 0 : listLayout.items.length === 0)
- ) {
+ if (Platform.OS === "android" && threadListV2Items.length === 0) {
return (
<View className="flex-1 bg-header">
<View
className="flex-1 items-center justify-center overflow-hidden rounded-t-[28px] bg-screen px-4"
style={{ paddingBottom: insets.bottom }}
>
- {threadListV2Enabled ? v2ListEmpty : listEmpty}
- </View>
- </View>
- );
- }
-
- if (threadListV2Enabled) {
- return (
- <View className="flex-1 bg-screen android:bg-header">
- <View
- className={
- Platform.OS === "android"
- ? "flex-1 overflow-hidden rounded-t-[28px] bg-screen"
- : "flex-1 bg-screen"
- }
- >
- {/* Same recycler the iPad sidebar and the legacy list use: cells are
- reused across data rebuilds and `itemsAreEqual` keeps a minute tick
- (or an unrelated shell update) from re-rendering untouched rows. */}
- <SwipeableScrollGateProvider enabled={swipeEnabled}>
- <LegendList
- data={threadListV2Items}
- renderItem={renderV2Item}
- keyExtractor={v2KeyExtractor}
- getItemType={(item) => item.type}
- itemsAreEqual={threadListV2ListItemsAreEqual}
- estimatedItemSize={ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT}
- drawDistance={500}
- recycleItems
- extraData={v2ExtraData}
- ListHeaderComponent={v2ListHeader}
- ListFooterComponent={
- settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
- <ThreadListV2ShowMoreRow
- hiddenCount={threadListV2Layout.hiddenSettledCount}
- onPress={showMoreSettled}
- />
- ) : null
- }
- ListEmptyComponent={v2ListEmpty}
- style={{ flex: 1 }}
- automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
- showsVerticalScrollIndicator={false}
- keyboardDismissMode="on-drag"
- keyboardShouldPersistTaps="handled"
- {...scrollGateHandlers}
- scrollEventThrottle={16}
- contentContainerStyle={{
- paddingBottom:
- Platform.OS === "ios"
- ? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
- : Math.max(insets.bottom, 16) + (Platform.OS === "android" ? 148 : 88),
- }}
- />
- </SwipeableScrollGateProvider>
+ {v2ListEmpty}
</View>
</View>
);
@@ -1304,52 +924,44 @@ export function HomeScreen(props: HomeScreenProps) {
: "flex-1 bg-screen"
}
>
- {/* Sticky headers are deliberately not wired up: LegendList's JS sticky
- implementation mispositions pinned headers at mount under iOS
- automatic content insets (headers render one nav-inset too low until
- the first scroll event) and blanks non-pinned headers after
- collapse/expand data changes. The flattened layout still exposes
- `stickyHeaderIndices` if this gets revisited. */}
+ {/* Same recycler the iPad sidebar and the legacy list use: cells are
+ reused across data rebuilds and `itemsAreEqual` keeps a minute tick
+ (or an unrelated shell update) from re-rendering untouched rows. */}
<SwipeableScrollGateProvider enabled={swipeEnabled}>
<LegendList
- ref={listRef}
- data={listLayout.items}
- renderItem={renderItem}
- keyExtractor={keyExtractor}
- itemsAreEqual={homeListItemsAreEqual}
+ data={threadListV2Items}
+ renderItem={renderV2Item}
+ keyExtractor={v2KeyExtractor}
+ getItemType={(item) => item.type}
+ itemsAreEqual={threadListV2ListItemsAreEqual}
+ estimatedItemSize={ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT}
drawDistance={500}
- estimatedItemSize={ESTIMATED_THREAD_ROW_HEIGHT}
- extraData={extraData}
- ListHeaderComponent={listHeader}
- ListEmptyComponent={listEmpty}
+ recycleItems
+ extraData={v2ExtraData}
+ ListHeaderComponent={v2ListHeader}
+ ListFooterComponent={
+ settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
+ <ThreadListV2ShowMoreRow
+ hiddenCount={threadListV2Layout.hiddenSettledCount}
+ onPress={showMoreSettled}
+ />
+ ) : null
+ }
+ ListEmptyComponent={v2ListEmpty}
style={{ flex: 1 }}
- automaticallyAdjustsScrollIndicatorInsets={NATIVE_LIQUID_GLASS_SUPPORTED}
- contentInsetAdjustmentBehavior={NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"}
+ automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
+ contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
showsVerticalScrollIndicator={false}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
{...scrollGateHandlers}
- recycleItems
scrollEventThrottle={16}
contentContainerStyle={{
- // Android reserves room for the floating new-task FAB
- // (56 button + 16 gap + bottom inset). Pre-glass iOS shows a
- // standard 44pt bottom toolbar that overlays the list and is not
- // reflected in insets while contentInsetAdjustmentBehavior is
- // "never".
paddingBottom:
Platform.OS === "ios"
- ? Math.max(insets.bottom, 24) + 24 + iosBottomToolbarClearance
+ ? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
: Math.max(insets.bottom, 16) + (Platform.OS === "android" ? 148 : 88),
}}
- scrollIndicatorInsets={
- Platform.OS === "ios"
- ? {
- bottom: Math.max(insets.bottom, 16) + 24 + iosBottomToolbarClearance,
- top: 0,
- }
- : undefined
- }
/>
</SwipeableScrollGateProvider>
</View>
diff --git a/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx b/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx
index 72671bc046d..2d852f8f7be 100644
--- a/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx
+++ b/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx
@@ -130,7 +130,7 @@ export function MaterialThreadListToolbar(props: {
<AndroidAnchoredMenu actions={props.filterActions} onPressAction={props.onFilterAction}>
{(open) => (
<MaterialFloatingActionButton
- label="Filter and sort threads"
+ label="Filter threads"
icon={filterIcon}
onPress={open}
/>
diff --git a/apps/mobile/src/features/home/home-list-filter-menu.test.ts b/apps/mobile/src/features/home/home-list-filter-menu.test.ts
index 99e3cb36c07..0febe8e3103 100644
--- a/apps/mobile/src/features/home/home-list-filter-menu.test.ts
+++ b/apps/mobile/src/features/home/home-list-filter-menu.test.ts
@@ -13,12 +13,8 @@ describe("buildHomeListFilterMenu", () => {
],
selectedEnvironmentId: null,
selectedProjectKey: "environment-1:project-1",
- projectSortOrder: "updated_at",
- threadSortOrder: "updated_at",
onEnvironmentChange: vi.fn(),
onProjectChange,
- onProjectSortOrderChange: vi.fn(),
- onThreadSortOrderChange: vi.fn(),
});
const projectMenu = menu.items.find(
diff --git a/apps/mobile/src/features/home/home-list-filter-menu.ts b/apps/mobile/src/features/home/home-list-filter-menu.ts
index edd0176f862..ac53e427d21 100644
--- a/apps/mobile/src/features/home/home-list-filter-menu.ts
+++ b/apps/mobile/src/features/home/home-list-filter-menu.ts
@@ -1,7 +1,4 @@
-import type { EnvironmentId, SidebarThreadSortOrder } from "@t3tools/contracts";
-
-import type { HomeProjectSortOrder } from "./homeThreadList";
-import { PROJECT_SORT_OPTIONS, THREAD_SORT_OPTIONS } from "./home-list-options";
+import type { EnvironmentId } from "@t3tools/contracts";
export interface HomeListFilterMenuEnvironment {
readonly environmentId: EnvironmentId;
@@ -37,16 +34,8 @@ export function buildHomeListFilterMenu(props: {
readonly projects: ReadonlyArray<HomeListFilterMenuProject>;
readonly selectedEnvironmentId: EnvironmentId | null;
readonly selectedProjectKey: string | null;
- readonly projectSortOrder: HomeProjectSortOrder;
- readonly threadSortOrder: SidebarThreadSortOrder;
readonly onEnvironmentChange: (environmentId: EnvironmentId | null) => void;
readonly onProjectChange: (projectKey: string | null) => void;
- readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
- readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
- /** False hides the sort/group submenus. Thread List v2 uses a fixed
- creation-order layout, so offering those controls while it silently
- ignores them would be a lie; the environment filter still applies. */
- readonly listOrganization?: boolean;
}): HomeListFilterMenu {
const items: Array<HomeListFilterMenuAction | HomeListFilterMenuSubmenu> = [];
@@ -95,31 +84,6 @@ export function buildHomeListFilterMenu(props: {
});
}
- if (props.listOrganization !== false) {
- items.push(
- {
- type: "submenu",
- title: "Sort projects",
- items: PROJECT_SORT_OPTIONS.map((option) => ({
- type: "action",
- title: option.label,
- state: props.projectSortOrder === option.value ? "on" : "off",
- onPress: () => props.onProjectSortOrderChange(option.value),
- })),
- },
- {
- type: "submenu",
- title: "Sort threads",
- items: THREAD_SORT_OPTIONS.map((option) => ({
- type: "action",
- title: option.label,
- state: props.threadSortOrder === option.value ? "on" : "off",
- onPress: () => props.onThreadSortOrderChange(option.value),
- })),
- },
- );
- }
-
return {
title: "Thread list options",
items,
diff --git a/apps/mobile/src/features/home/home-list-options.test.ts b/apps/mobile/src/features/home/home-list-options.test.ts
deleted file mode 100644
index ac3893956ca..00000000000
--- a/apps/mobile/src/features/home/home-list-options.test.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import {
- DEFAULT_SIDEBAR_PROJECT_SORT_ORDER,
- DEFAULT_SIDEBAR_THREAD_SORT_ORDER,
-} from "@t3tools/contracts";
-import { describe, expect, it } from "vite-plus/test";
-
-import { hasCustomHomeListOptions, type HomeListOptions } from "./home-list-options";
-
-const defaults: HomeListOptions = {
- selectedEnvironmentId: null,
- projectSortOrder:
- DEFAULT_SIDEBAR_PROJECT_SORT_ORDER === "manual"
- ? "updated_at"
- : DEFAULT_SIDEBAR_PROJECT_SORT_ORDER,
- threadSortOrder: DEFAULT_SIDEBAR_THREAD_SORT_ORDER,
-};
-
-describe("home list options", () => {
- it("recognizes default options", () => {
- expect(hasCustomHomeListOptions(defaults)).toBe(false);
- });
-
- it("marks environment filters as customized", () => {
- expect(
- hasCustomHomeListOptions({ ...defaults, selectedEnvironmentId: "environment-1" as never }),
- ).toBe(true);
- expect(
- hasCustomHomeListOptions({ ...defaults, selectedProjectKey: "environment-1:project-1" }),
- ).toBe(true);
- });
-});
diff --git a/apps/mobile/src/features/home/home-list-options.ts b/apps/mobile/src/features/home/home-list-options.ts
index 14f842d73e2..849fbda369f 100644
--- a/apps/mobile/src/features/home/home-list-options.ts
+++ b/apps/mobile/src/features/home/home-list-options.ts
@@ -31,22 +31,6 @@ export interface ResolvedHomeListOptions extends HomeListOptions {
readonly projectGroupingMode: SidebarProjectGroupingMode;
}
-export const PROJECT_SORT_OPTIONS: ReadonlyArray<{
- readonly value: HomeProjectSortOrder;
- readonly label: string;
-}> = [
- { value: "updated_at", label: "Last user message" },
- { value: "created_at", label: "Created at" },
-];
-
-export const THREAD_SORT_OPTIONS: ReadonlyArray<{
- readonly value: SidebarThreadSortOrder;
- readonly label: string;
-}> = [
- { value: "updated_at", label: "Last user message" },
- { value: "created_at", label: "Created at" },
-];
-
function defaultHomeListOptions(): HomeListOptions {
return {
selectedEnvironmentId: null,
@@ -81,23 +65,6 @@ export function HomeListOptionsProvider({
return createElement(HomeListOptionsContext, { value }, children);
}
-export function hasCustomHomeListOptions(
- options: HomeListOptions & {
- readonly selectedProjectKey?: string | null;
- },
-): boolean {
- const defaultProjectSortOrder =
- DEFAULT_SIDEBAR_PROJECT_SORT_ORDER === "manual"
- ? "updated_at"
- : DEFAULT_SIDEBAR_PROJECT_SORT_ORDER;
- return (
- options.selectedEnvironmentId !== null ||
- (options.selectedProjectKey !== null && options.selectedProjectKey !== undefined) ||
- options.projectSortOrder !== defaultProjectSortOrder ||
- options.threadSortOrder !== DEFAULT_SIDEBAR_THREAD_SORT_ORDER
- );
-}
-
export function useHomeListOptions(availableEnvironmentIds: ReadonlySet<EnvironmentId>) {
const shared = useContext(HomeListOptionsContext);
const [localOptions, setLocalOptions] = useState<HomeListOptions>(defaultHomeListOptions);
diff --git a/apps/mobile/src/features/home/homeListItems.test.ts b/apps/mobile/src/features/home/homeListItems.test.ts
deleted file mode 100644
index d1e3315fd59..00000000000
--- a/apps/mobile/src/features/home/homeListItems.test.ts
+++ /dev/null
@@ -1,266 +0,0 @@
-import type {
- EnvironmentProject,
- EnvironmentThreadShell,
-} from "@t3tools/client-runtime/state/shell";
-import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";
-import { describe, expect, it } from "vite-plus/test";
-
-import {
- buildHomeListLayout,
- DEFAULT_GROUP_DISPLAY_STATE,
- HOME_INITIAL_VISIBLE_THREADS,
- HOME_SHOW_MORE_STEP,
- nextGroupDisplayState,
- type HomeGroupDisplayState,
- type HomeListItem,
-} from "./homeListItems";
-import type { HomeThreadGroup } from "./homeThreadList";
-import { threadJumpTarget } from "../keyboard/threadKeyboardShortcuts";
-
-const environmentId = EnvironmentId.make("environment-1");
-
-function makeProject(id: string, title: string): EnvironmentProject {
- return {
- environmentId,
- id: ProjectId.make(id),
- title,
- workspaceRoot: `/workspaces/${id}`,
- repositoryIdentity: null,
- defaultModelSelection: null,
- scripts: [],
- createdAt: "2026-06-01T00:00:00.000Z",
- updatedAt: "2026-06-01T00:00:00.000Z",
- };
-}
-
-function makeThread(id: string, projectId: ProjectId): EnvironmentThreadShell {
- return {
- environmentId,
- id: ThreadId.make(id),
- projectId,
- title: `Thread ${id}`,
- modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
- runtimeMode: "full-access",
- interactionMode: "default",
- branch: null,
- worktreePath: null,
- pullRequests: [],
- latestTurn: null,
- createdAt: "2026-06-01T00:00:00.000Z",
- updatedAt: "2026-06-01T00:00:00.000Z",
- archivedAt: null,
- settledOverride: null,
- settledAt: null,
- session: null,
- latestUserMessageAt: null,
- hasPendingApprovals: false,
- hasPendingUserInput: false,
- hasActionableProposedPlan: false,
- };
-}
-
-function makeGroup(key: string, threadCount: number): HomeThreadGroup {
- const project = makeProject(key, key);
- const threads = Array.from({ length: threadCount }, (_, index) =>
- makeThread(`${key}-thread-${index}`, project.id),
- );
- return {
- key,
- title: key,
- representative: project,
- projects: [project],
- pendingTasks: [],
- threads,
- // All threads inside the recency window, so the baseline stays at the
- // initial page size and the pagination expectations below hold.
- recentThreads: threads,
- newThreadTarget: project,
- };
-}
-
-function itemTypes(items: ReadonlyArray<HomeListItem>): string[] {
- return items.map((item) => item.type);
-}
-
-function displayStates(
- entries: Record<string, HomeGroupDisplayState>,
-): ReadonlyMap<string, HomeGroupDisplayState> {
- return new Map(Object.entries(entries));
-}
-
-describe("threadJumpTarget", () => {
- it("numbers only displayed threads across groups, skipping collapsed groups and pagination rows", () => {
- const layout = buildHomeListLayout({
- groups: [makeGroup("collapsed", 3), makeGroup("alpha", 8), makeGroup("beta", 3)],
- displayStates: displayStates({ collapsed: { collapsed: true, visibleCount: 6 } }),
- });
- expect(threadJumpTarget(layout.items, "thread.jump.1")?.id).toBe("alpha-thread-0");
- expect(threadJumpTarget(layout.items, "thread.jump.7")?.id).toBe("beta-thread-0");
- expect(threadJumpTarget(layout.items, "thread.jump.9")?.id).toBe("beta-thread-2");
- });
-
- it("ignores missing positions and unrelated commands", () => {
- const layout = buildHomeListLayout({
- groups: [makeGroup("alpha", 1)],
- displayStates: displayStates({}),
- });
- expect(threadJumpTarget(layout.items, "thread.jump.2")).toBeNull();
- expect(threadJumpTarget([], "thread.jump.1")).toBeNull();
- expect(threadJumpTarget(layout.items, "commandPalette")).toBeNull();
- });
-});
-
-describe("buildHomeListLayout", () => {
- it("renders a header plus all threads for a small group without a show-more row", () => {
- const layout = buildHomeListLayout({
- groups: [makeGroup("alpha", 3)],
- displayStates: displayStates({}),
- });
-
- expect(itemTypes(layout.items)).toEqual(["header", "thread", "thread", "thread"]);
- expect(layout.stickyHeaderIndices).toEqual([0]);
- expect(layout.items.at(-1)).toMatchObject({ type: "thread", isLast: true });
- });
-
- it("limits large groups to the initial visible count with a show-more row", () => {
- const layout = buildHomeListLayout({
- groups: [makeGroup("alpha", 133)],
- displayStates: displayStates({}),
- });
-
- const threadItems = layout.items.filter((item) => item.type === "thread");
- expect(threadItems).toHaveLength(HOME_INITIAL_VISIBLE_THREADS);
- expect(layout.items.at(-1)).toMatchObject({
- type: "show-more",
- groupKey: "alpha",
- hiddenCount: 133 - HOME_INITIAL_VISIBLE_THREADS,
- canShowLess: false,
- });
- // The show-more row takes over the last slot, so no thread is marked last.
- expect(threadItems.every((item) => item.type === "thread" && !item.isLast)).toBe(true);
- });
-
- it("reveals more threads per show-more step and offers show-less when exhausted", () => {
- const group = makeGroup("alpha", 20);
-
- const expandedOnce = buildHomeListLayout({
- groups: [group],
- displayStates: displayStates({
- alpha: nextGroupDisplayState(DEFAULT_GROUP_DISPLAY_STATE, "show-more"),
- }),
- });
- expect(expandedOnce.items.filter((item) => item.type === "thread")).toHaveLength(
- HOME_INITIAL_VISIBLE_THREADS + HOME_SHOW_MORE_STEP,
- );
- expect(expandedOnce.items.at(-1)).toMatchObject({
- type: "show-more",
- hiddenCount: 4,
- canShowLess: true,
- });
-
- const fullyExpanded = buildHomeListLayout({
- groups: [group],
- displayStates: displayStates({
- alpha: nextGroupDisplayState(
- nextGroupDisplayState(DEFAULT_GROUP_DISPLAY_STATE, "show-more"),
- "show-more",
- ),
- }),
- });
- expect(fullyExpanded.items.filter((item) => item.type === "thread")).toHaveLength(20);
- expect(fullyExpanded.items.at(-1)).toMatchObject({
- type: "show-more",
- hiddenCount: 0,
- canShowLess: true,
- });
-
- const reset = nextGroupDisplayState(
- nextGroupDisplayState(
- nextGroupDisplayState(DEFAULT_GROUP_DISPLAY_STATE, "show-more"),
- "show-more",
- ),
- "show-less",
- );
- expect(reset.visibleCount).toBe(HOME_INITIAL_VISIBLE_THREADS);
- });
-
- it("offers show-less after expanding a stale group whose baseline is below the page size", () => {
- // Stale project: 10 threads total but only 3 within the recency window.
- const project = makeProject("stale", "stale");
- const threads = Array.from({ length: 10 }, (_, index) =>
- makeThread(`stale-thread-${index}`, project.id),
- );
- const group: HomeThreadGroup = {
- key: "stale",
- title: "stale",
- representative: project,
- projects: [project],
- pendingTasks: [],
- threads,
- recentThreads: threads.slice(0, 3),
- newThreadTarget: project,
- };
-
- const collapsedToRecent = buildHomeListLayout({
- groups: [group],
- displayStates: displayStates({}),
- });
- expect(collapsedToRecent.items.filter((item) => item.type === "thread")).toHaveLength(3);
- expect(collapsedToRecent.items.at(-1)).toMatchObject({
- type: "show-more",
- hiddenCount: 7,
- canShowLess: false,
- });
-
- const expanded = buildHomeListLayout({
- groups: [group],
- displayStates: displayStates({
- stale: nextGroupDisplayState(DEFAULT_GROUP_DISPLAY_STATE, "show-more"),
- }),
- });
- expect(expanded.items.filter((item) => item.type === "thread")).toHaveLength(10);
- expect(expanded.items.at(-1)).toMatchObject({
- type: "show-more",
- hiddenCount: 0,
- canShowLess: true,
- });
- });
-
- it("hides threads and the show-more row for collapsed groups", () => {
- const layout = buildHomeListLayout({
- groups: [makeGroup("alpha", 12), makeGroup("beta", 2)],
- displayStates: displayStates({
- alpha: nextGroupDisplayState(DEFAULT_GROUP_DISPLAY_STATE, "toggle-collapsed"),
- }),
- });
-
- expect(itemTypes(layout.items)).toEqual(["header", "header", "thread", "thread"]);
- expect(layout.items[0]).toMatchObject({ type: "header", collapsed: true, isFirst: true });
- expect(layout.items[1]).toMatchObject({ type: "header", collapsed: false, isFirst: false });
- expect(layout.stickyHeaderIndices).toEqual([0, 1]);
- });
-
- it("suspends collapse and pagination while searching", () => {
- const layout = buildHomeListLayout({
- groups: [makeGroup("alpha", 12)],
- displayStates: displayStates({
- alpha: nextGroupDisplayState(DEFAULT_GROUP_DISPLAY_STATE, "toggle-collapsed"),
- }),
- showAllThreads: true,
- });
-
- expect(layout.items.filter((item) => item.type === "thread")).toHaveLength(12);
- expect(layout.items.some((item) => item.type === "show-more")).toBe(false);
- });
-
- it("keeps sticky indices aligned across multiple expanded groups", () => {
- const layout = buildHomeListLayout({
- groups: [makeGroup("alpha", 8), makeGroup("beta", 1)],
- displayStates: displayStates({}),
- });
-
- // header + 6 threads + show-more = 8 items, so beta's header is index 8.
- expect(layout.stickyHeaderIndices).toEqual([0, 8]);
- expect(layout.items[8]).toMatchObject({ type: "header", isFirst: false });
- });
-});
diff --git a/apps/mobile/src/features/home/homeListItems.ts b/apps/mobile/src/features/home/homeListItems.ts
deleted file mode 100644
index 910ddb5896b..00000000000
--- a/apps/mobile/src/features/home/homeListItems.ts
+++ /dev/null
@@ -1,209 +0,0 @@
-import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
-
-import type { PendingNewTask } from "../../state/use-pending-new-tasks";
-import type { HomeThreadGroup } from "./homeThreadList";
-
-/** Threads shown per project before the "Show more" affordance appears. */
-export const HOME_INITIAL_VISIBLE_THREADS = 6;
-/** Additional threads revealed per "Show more" tap. */
-export const HOME_SHOW_MORE_STEP = 10;
-
-export interface HomeGroupDisplayState {
- readonly collapsed: boolean;
- /** How many threads are currently revealed (clamped to the group size). */
- readonly visibleCount: number;
-}
-
-export const DEFAULT_GROUP_DISPLAY_STATE: HomeGroupDisplayState = {
- collapsed: false,
- visibleCount: HOME_INITIAL_VISIBLE_THREADS,
-};
-
-export interface HomeHeaderListItem {
- readonly type: "header";
- readonly key: string;
- readonly group: HomeThreadGroup;
- readonly collapsed: boolean;
- readonly isFirst: boolean;
-}
-
-export interface HomeThreadListItem {
- readonly type: "thread";
- readonly key: string;
- readonly thread: EnvironmentThreadShell;
- readonly isLast: boolean;
-}
-
-export interface HomePendingTaskListItem {
- readonly type: "pending-task";
- readonly key: string;
- readonly pendingTask: PendingNewTask;
- readonly isLast: boolean;
-}
-
-export interface HomeShowMoreListItem {
- readonly type: "show-more";
- readonly key: string;
- readonly groupKey: string;
- /** Threads still hidden. 0 means the group is fully expanded. */
- readonly hiddenCount: number;
- /** Whether more than the initial count is revealed, so "Show less" applies. */
- readonly canShowLess: boolean;
-}
-
-export type HomeListItem =
- | HomeHeaderListItem
- | HomePendingTaskListItem
- | HomeThreadListItem
- | HomeShowMoreListItem;
-
-export interface HomeListLayout {
- readonly items: ReadonlyArray<HomeListItem>;
- readonly stickyHeaderIndices: ReadonlyArray<number>;
-}
-
-export const EMPTY_HOME_LIST_LAYOUT: HomeListLayout = { items: [], stickyHeaderIndices: [] };
-
-export type HomeGroupDisplayAction = "toggle-collapsed" | "show-more" | "show-less";
-
-export function nextGroupDisplayState(
- current: HomeGroupDisplayState,
- action: HomeGroupDisplayAction,
-): HomeGroupDisplayState {
- switch (action) {
- case "toggle-collapsed":
- return { ...current, collapsed: !current.collapsed };
- case "show-more":
- return { ...current, visibleCount: current.visibleCount + HOME_SHOW_MORE_STEP };
- case "show-less":
- return { ...current, visibleCount: HOME_INITIAL_VISIBLE_THREADS };
- }
-}
-
-/**
- * Structural equality for list items. Item objects are rebuilt on every
- * collapse/show-more toggle; without this the lists would consider every
- * mounted row changed and re-render all of them (each carrying a swipeable +
- * a vcs-status subscription). Group/thread references are stable across
- * toggles.
- */
-export function homeListItemsAreEqual(previous: HomeListItem, item: HomeListItem): boolean {
- switch (item.type) {
- case "header":
- return (
- previous.type === "header" &&
- previous.group === item.group &&
- previous.collapsed === item.collapsed &&
- previous.isFirst === item.isFirst
- );
- case "pending-task":
- return (
- previous.type === "pending-task" &&
- previous.pendingTask === item.pendingTask &&
- previous.isLast === item.isLast
- );
- case "thread":
- return (
- previous.type === "thread" &&
- previous.thread === item.thread &&
- previous.isLast === item.isLast
- );
- case "show-more":
- return (
- previous.type === "show-more" &&
- previous.groupKey === item.groupKey &&
- previous.hiddenCount === item.hiddenCount &&
- previous.canShowLess === item.canShowLess
- );
- }
-}
-
-export function buildHomeListLayout(input: {
- readonly groups: ReadonlyArray<HomeThreadGroup>;
- readonly displayStates: ReadonlyMap<string, HomeGroupDisplayState>;
- /**
- * When searching, pagination is suspended so every match stays visible.
- */
- readonly showAllThreads?: boolean;
-}): HomeListLayout {
- const items: HomeListItem[] = [];
- const stickyHeaderIndices: number[] = [];
-
- for (const [groupIndex, group] of input.groups.entries()) {
- const display = input.displayStates.get(group.key) ?? DEFAULT_GROUP_DISPLAY_STATE;
- const collapsed = display.collapsed && input.showAllThreads !== true;
-
- stickyHeaderIndices.push(items.length);
- items.push({
- type: "header",
- key: `header:${group.key}`,
- group,
- collapsed,
- isFirst: groupIndex === 0,
- });
-
- if (collapsed) {
- continue;
- }
-
- const totalCount = group.threads.length;
- // Default to the group's recent-activity window (last few days, or a small
- // fallback for stale projects), capped at the initial page size. Until the
- // user taps "Show more", older threads stay hidden to save vertical space;
- // "Show less" resets visibleCount to the initial constant, which lands back
- // here at the recency baseline.
- const baselineCount = Math.min(
- group.recentThreads.length,
- HOME_INITIAL_VISIBLE_THREADS,
- totalCount,
- );
- const visibleCount = input.showAllThreads
- ? totalCount
- : Math.min(
- display.visibleCount > HOME_INITIAL_VISIBLE_THREADS
- ? display.visibleCount
- : baselineCount,
- totalCount,
- );
- const visibleThreads = group.threads.slice(0, visibleCount);
- const hiddenCount = totalCount - visibleCount;
- const hasShowMoreRow = !input.showAllThreads && totalCount > baselineCount;
-
- // Pending (unsent) tasks lead the group and are never paginated away.
- for (const [pendingIndex, pendingTask] of group.pendingTasks.entries()) {
- items.push({
- type: "pending-task",
- key: pendingTask.key,
- pendingTask,
- isLast:
- pendingIndex === group.pendingTasks.length - 1 &&
- visibleThreads.length === 0 &&
- !hasShowMoreRow,
- });
- }
-
- for (const [threadIndex, thread] of visibleThreads.entries()) {
- items.push({
- type: "thread",
- key: `thread:${thread.environmentId}:${thread.id}`,
- thread,
- isLast: threadIndex === visibleThreads.length - 1 && !hasShowMoreRow,
- });
- }
-
- if (hasShowMoreRow) {
- items.push({
- type: "show-more",
- key: `show-more:${group.key}`,
- groupKey: group.key,
- hiddenCount,
- // Compare against the group's own baseline, not the global page size:
- // stale projects start below HOME_INITIAL_VISIBLE_THREADS, and "Show
- // less" must be offered as soon as anything beyond the baseline shows.
- canShowLess: visibleCount > baselineCount,
- });
- }
- }
-
- return { items, stickyHeaderIndices };
-}
diff --git a/apps/mobile/src/features/home/homeThreadList.test.ts b/apps/mobile/src/features/home/homeThreadList.test.ts
index 0f7b14bf936..32a17312479 100644
--- a/apps/mobile/src/features/home/homeThreadList.test.ts
+++ b/apps/mobile/src/features/home/homeThreadList.test.ts
@@ -6,11 +6,7 @@ import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-searc
import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";
import { describe, expect, it } from "vite-plus/test";
-import {
- buildHomeProjectScopes,
- buildHomeThreadGroups,
- sortHomeProjectScopes,
-} from "./homeThreadList";
+import { buildHomeProjectScopes, sortHomeProjectScopes } from "./homeThreadList";
function makeProject(
input: Partial<EnvironmentProject> & Pick<EnvironmentProject, "environmentId" | "id" | "title">,
@@ -54,25 +50,7 @@ function makeThread(
const NOW = Date.parse("2026-06-29T00:00:00.000Z");
-function buildGroups(
- projects: ReadonlyArray<EnvironmentProject>,
- threads: ReadonlyArray<EnvironmentThreadShell>,
- overrides: Partial<Parameters<typeof buildHomeThreadGroups>[0]> = {},
-) {
- return buildHomeThreadGroups({
- projects,
- threads,
- environmentId: null,
- searchQuery: "",
- projectSortOrder: "updated_at",
- threadSortOrder: "updated_at",
- projectGroupingMode: "repository",
- now: NOW,
- ...overrides,
- });
-}
-
-describe("buildHomeThreadGroups", () => {
+describe("home project scopes", () => {
it("builds one v2 scope for the same repository across environments", () => {
const localEnvironmentId = EnvironmentId.make("environment-local");
const remoteEnvironmentId = EnvironmentId.make("environment-remote");
@@ -116,70 +94,6 @@ describe("buildHomeThreadGroups", () => {
);
});
- it("routes stale duplicate project refs through the canonical repository group", () => {
- const localEnvironmentId = EnvironmentId.make("environment-local");
- const remoteEnvironmentId = EnvironmentId.make("environment-remote");
- const repositoryIdentity = {
- canonicalKey: "github.com/pingdotgg/t3code",
- locator: {
- source: "git-remote" as const,
- remoteName: "origin",
- remoteUrl: "[email protected]:pingdotgg/t3code.git",
- },
- };
- const local = makeProject({
- id: ProjectId.make("project-local"),
- environmentId: localEnvironmentId,
- title: "t3code",
- workspaceRoot: "/workspaces/t3code",
- repositoryIdentity,
- });
- const stale = makeProject({
- environmentId: remoteEnvironmentId,
- id: ProjectId.make("project-stale"),
- title: "t3code",
- workspaceRoot: "/remote/t3code",
- updatedAt: "2026-06-01T00:00:00.000Z",
- });
- const canonicalRemote = makeProject({
- environmentId: remoteEnvironmentId,
- id: ProjectId.make("project-canonical-remote"),
- title: "t3code",
- workspaceRoot: "/remote/t3code/",
- repositoryIdentity,
- updatedAt: "2026-06-02T00:00:00.000Z",
- });
- const projects = [local, stale, canonicalRemote];
- const staleThread = makeThread({
- environmentId: remoteEnvironmentId,
- id: ThreadId.make("thread-stale-project-ref"),
- projectId: stale.id,
- title: "Still visible",
- updatedAt: "2026-06-03T00:00:00.000Z",
- });
-
- const scopes = buildHomeProjectScopes({
- projects,
- environmentId: null,
- projectGroupingMode: "repository",
- });
- const groups = buildGroups(projects, [staleThread]);
-
- expect(scopes).toHaveLength(1);
- expect(scopes[0]?.projects.map((project) => project.id)).toEqual([
- local.id,
- canonicalRemote.id,
- ]);
- expect(scopes[0]?.projectRefs.map((projectRef) => projectRef.projectId)).toEqual([
- local.id,
- stale.id,
- canonicalRemote.id,
- ]);
- expect(groups).toHaveLength(1);
- expect(groups[0]?.threads.map((thread) => thread.id)).toEqual([staleThread.id]);
- expect(groups[0]?.newThreadTarget?.id).toBe(canonicalRemote.id);
- });
-
it("keeps repository identity from an older duplicate when the freshness winner lacks it", () => {
const localEnvironmentId = EnvironmentId.make("environment-local");
const remoteEnvironmentId = EnvironmentId.make("environment-remote");
@@ -375,410 +289,4 @@ describe("buildHomeThreadGroups", () => {
}),
).toHaveLength(2);
});
-
- it("uses the physical project title for a singleton scope", () => {
- const project = makeProject({
- environmentId: EnvironmentId.make("environment-1"),
- id: ProjectId.make("project-1"),
- title: "local-worktree-name",
- repositoryIdentity: {
- canonicalKey: "github.com/pingdotgg/t3code",
- displayName: "codething-mvp",
- locator: {
- source: "git-remote" as const,
- remoteName: "origin",
- remoteUrl: "[email protected]:pingdotgg/t3code.git",
- },
- },
- });
-
- const scopes = buildHomeProjectScopes({
- projects: [project],
- environmentId: null,
- projectGroupingMode: "repository",
- });
- const groups = buildGroups(
- [project],
- [
- makeThread({
- environmentId: project.environmentId,
- id: ThreadId.make("thread-1"),
- projectId: project.id,
- title: "Thread",
- }),
- ],
- );
-
- expect(scopes[0]?.title).toBe("local-worktree-name");
- expect(groups[0]?.title).toBe("local-worktree-name");
- });
-
- it("sorts the newest thread first regardless of snapshot order", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const project = makeProject({
- environmentId,
- id: ProjectId.make("project-1"),
- title: "T3 Code",
- });
- const threads = [
- makeThread({
- environmentId,
- id: ThreadId.make("thread-old"),
- projectId: project.id,
- title: "Older thread",
- updatedAt: "2026-06-02T00:00:00.000Z",
- }),
- makeThread({
- environmentId,
- id: ThreadId.make("thread-new"),
- projectId: project.id,
- title: "Newer thread",
- updatedAt: "2026-06-03T00:00:00.000Z",
- }),
- ];
-
- expect(buildGroups([project], threads)[0]?.threads.map((thread) => thread.id)).toEqual([
- "thread-new",
- "thread-old",
- ]);
- });
-
- it("supports independent project and thread creation-time sorting", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const olderProject = makeProject({
- environmentId,
- id: ProjectId.make("project-older"),
- title: "Older project",
- });
- const newerProject = makeProject({
- environmentId,
- id: ProjectId.make("project-newer"),
- title: "Newer project",
- });
- const threads = [
- makeThread({
- environmentId,
- id: ThreadId.make("old-created"),
- projectId: olderProject.id,
- title: "Updated recently",
- createdAt: "2026-06-01T00:00:00.000Z",
- updatedAt: "2026-06-05T00:00:00.000Z",
- }),
- makeThread({
- environmentId,
- id: ThreadId.make("new-created"),
- projectId: olderProject.id,
- title: "Created recently",
- createdAt: "2026-06-04T00:00:00.000Z",
- updatedAt: "2026-06-04T00:00:00.000Z",
- }),
- makeThread({
- environmentId,
- id: ThreadId.make("newest-project-thread"),
- projectId: newerProject.id,
- title: "Newest project",
- createdAt: "2026-06-06T00:00:00.000Z",
- }),
- ];
-
- const groups = buildGroups([olderProject, newerProject], threads, {
- projectSortOrder: "created_at",
- threadSortOrder: "created_at",
- projectGroupingMode: "separate",
- });
-
- expect(groups.map((group) => group.representative.id)).toEqual([
- "project-newer",
- "project-older",
- ]);
- expect(groups[1]?.threads.map((thread) => thread.id)).toEqual(["new-created", "old-created"]);
- });
-
- it("filters both projects and threads to one environment", () => {
- const localEnvironmentId = EnvironmentId.make("environment-local");
- const remoteEnvironmentId = EnvironmentId.make("environment-remote");
- const projects = [
- makeProject({
- environmentId: localEnvironmentId,
- id: ProjectId.make("project-local"),
- title: "Local",
- }),
- makeProject({
- environmentId: remoteEnvironmentId,
- id: ProjectId.make("project-remote"),
- title: "Remote",
- }),
- ];
- const threads = projects.map((project) =>
- makeThread({
- environmentId: project.environmentId,
- id: ThreadId.make(`thread-${project.id}`),
- projectId: project.id,
- title: project.title,
- }),
- );
-
- const groups = buildGroups(projects, threads, { environmentId: remoteEnvironmentId });
-
- expect(groups).toHaveLength(1);
- expect(groups[0]?.representative.environmentId).toBe(remoteEnvironmentId);
- expect(groups[0]?.threads.map((thread) => thread.environmentId)).toEqual([remoteEnvironmentId]);
- });
-
- it("matches web repository, repository-path, and separate grouping modes", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const repositoryIdentity = {
- canonicalKey: "github.com/t3tools/t3code",
- locator: {
- source: "git-remote" as const,
- remoteName: "origin",
- remoteUrl: "[email protected]:t3tools/t3code.git",
- },
- provider: "github",
- owner: "t3tools",
- name: "t3code",
- displayName: "T3 Code",
- rootPath: "/workspaces/t3code",
- };
- const projects = [
- makeProject({
- environmentId,
- id: ProjectId.make("project-web"),
- title: "Web",
- workspaceRoot: "/workspaces/t3code/apps/web",
- repositoryIdentity,
- }),
- makeProject({
- environmentId,
- id: ProjectId.make("project-mobile"),
- title: "Mobile",
- workspaceRoot: "/workspaces/t3code/apps/mobile",
- repositoryIdentity,
- }),
- ];
- const threads = projects.map((project) =>
- makeThread({
- environmentId,
- id: ThreadId.make(`thread-${project.id}`),
- projectId: project.id,
- title: project.title,
- }),
- );
-
- expect(buildGroups(projects, threads, { projectGroupingMode: "repository" })).toHaveLength(1);
- expect(
- buildGroups(projects, threads, { projectGroupingMode: "repository_path" }).map(
- (group) => group.title,
- ),
- ).toEqual(["Mobile", "Web"]);
- expect(
- buildGroups(projects, threads, { projectGroupingMode: "separate" }).map(
- (group) => group.title,
- ),
- ).toEqual(["Mobile", "Web"]);
- });
-
- it("default view shows only threads from the last 5 days", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const project = makeProject({
- environmentId,
- id: ProjectId.make("project-1"),
- title: "T3 Code",
- });
- const threads = [
- makeThread({
- environmentId,
- id: ThreadId.make("recent-1"),
- projectId: project.id,
- title: "Today",
- updatedAt: "2026-06-28T00:00:00.000Z",
- }),
- makeThread({
- environmentId,
- id: ThreadId.make("recent-2"),
- projectId: project.id,
- title: "Within window",
- updatedAt: "2026-06-25T00:00:00.000Z",
- }),
- makeThread({
- environmentId,
- id: ThreadId.make("old"),
- projectId: project.id,
- title: "Two weeks ago",
- updatedAt: "2026-06-14T00:00:00.000Z",
- }),
- ];
-
- const group = buildGroups([project], threads)[0];
- // Default view trims to recent threads...
- expect(group?.recentThreads.map((thread) => thread.id)).toEqual(["recent-1", "recent-2"]);
- // ...while full history stays available for the expanded view.
- expect(group?.threads.map((thread) => thread.id)).toEqual(["recent-1", "recent-2", "old"]);
- });
-
- it("keeps an old thread in the default view while a message waits in its outbox", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const project = makeProject({
- environmentId,
- id: ProjectId.make("project-1"),
- title: "T3 Code",
- });
- const threads = [
- makeThread({
- environmentId,
- id: ThreadId.make("recent"),
- projectId: project.id,
- title: "Today",
- updatedAt: "2026-06-28T00:00:00.000Z",
- }),
- makeThread({
- environmentId,
- id: ThreadId.make("old-queued"),
- projectId: project.id,
- title: "Two weeks ago, follow-up queued offline",
- updatedAt: "2026-06-14T00:00:00.000Z",
- }),
- makeThread({
- environmentId,
- id: ThreadId.make("old"),
- projectId: project.id,
- title: "Two weeks ago",
- updatedAt: "2026-06-13T00:00:00.000Z",
- }),
- ];
-
- const group = buildGroups([project], threads, {
- queuedThreadKeys: new Set([`${environmentId}:old-queued`]),
- })[0];
- expect(group?.recentThreads.map((thread) => thread.id)).toEqual(["recent", "old-queued"]);
- });
-
- it("falls back to the most recent 3 threads when none are within 5 days", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const project = makeProject({
- environmentId,
- id: ProjectId.make("project-1"),
- title: "T3 Code",
- });
- const threads = ["2026-06-01", "2026-06-02", "2026-06-03", "2026-06-04", "2026-06-05"].map(
- (day, index) =>
- makeThread({
- environmentId,
- id: ThreadId.make(`thread-${index}`),
- projectId: project.id,
- title: `Thread ${index}`,
- updatedAt: `${day}T00:00:00.000Z`,
- }),
- );
-
- const group = buildGroups([project], threads)[0];
- expect(group?.recentThreads.map((thread) => thread.id)).toEqual([
- "thread-4",
- "thread-3",
- "thread-2",
- ]);
- expect(group?.threads).toHaveLength(5);
- });
-
- it("does not apply the recency window while searching", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const project = makeProject({
- environmentId,
- id: ProjectId.make("project-1"),
- title: "T3 Code",
- });
- const threads = ["2026-06-01", "2026-06-02", "2026-06-03", "2026-06-04", "2026-06-05"].map(
- (day, index) =>
- makeThread({
- environmentId,
- id: ThreadId.make(`thread-${index}`),
- projectId: project.id,
- title: `Thread ${index}`,
- updatedAt: `${day}T00:00:00.000Z`,
- }),
- );
-
- const group = buildGroups([project], threads, { searchQuery: "T3 Code" })[0];
- // Search reaches the full history rather than the 3-thread fallback.
- expect(group?.recentThreads).toHaveLength(5);
- expect(group?.recentThreads.map((thread) => thread.id)).toEqual(
- group?.threads.map((thread) => thread.id),
- );
- });
-
- it("includes a thread matched by message content", () => {
- const environmentId = EnvironmentId.make("environment-1");
- const project = makeProject({
- environmentId,
- id: ProjectId.make("project-1"),
- title: "T3 Code",
- });
- const thread = makeThread({
- environmentId,
- id: ThreadId.make("thread-content"),
- projectId: project.id,
- title: "Unrelated title",
- });
-
- const groups = buildGroups([project], [thread], {
- searchQuery: "relay reconnect",
- matchedThreadKeys: new Set([
- threadSearchMatchKey({
- environmentId,
- threadId: thread.id,
- }),
- ]),
- });
-
- expect(groups[0]?.threads.map((candidate) => candidate.id)).toEqual(["thread-content"]);
- });
-
- it("targets quick new threads at the group member with the newest thread", () => {
- const laptopEnv = EnvironmentId.make("environment-laptop");
- const desktopEnv = EnvironmentId.make("environment-desktop");
- const repositoryIdentity = {
- canonicalKey: "github.com/pingdotgg/t3code",
- locator: {
- source: "git-remote" as const,
- remoteName: "origin",
- remoteUrl: "[email protected]:pingdotgg/t3code.git",
- },
- };
- const laptopProject = makeProject({
- environmentId: laptopEnv,
- id: ProjectId.make("project-laptop"),
- title: "t3code",
- repositoryIdentity,
- });
- const desktopProject = makeProject({
- environmentId: desktopEnv,
- id: ProjectId.make("project-desktop"),
- title: "t3code",
- repositoryIdentity,
- });
- const threads = [
- makeThread({
- environmentId: laptopEnv,
- id: ThreadId.make("thread-laptop"),
- projectId: laptopProject.id,
- title: "Older laptop thread",
- updatedAt: "2026-06-27T00:00:00.000Z",
- }),
- makeThread({
- environmentId: desktopEnv,
- id: ThreadId.make("thread-desktop"),
- projectId: desktopProject.id,
- title: "Newest desktop thread",
- updatedAt: "2026-06-28T00:00:00.000Z",
- }),
- ];
-
- // Aggregated into one group by repository; the quick new-thread target
- // must follow the newest thread (desktop), not the arbitrary first member.
- const groups = buildGroups([laptopProject, desktopProject], threads);
- expect(groups).toHaveLength(1);
- expect(groups[0]?.projects).toHaveLength(2);
- expect(groups[0]?.newThreadTarget?.environmentId).toBe(desktopEnv);
- expect(groups[0]?.newThreadTarget?.id).toBe(desktopProject.id);
- });
});
diff --git a/apps/mobile/src/features/home/homeThreadList.ts b/apps/mobile/src/features/home/homeThreadList.ts
index 895c73bbe26..e50a1494498 100644
--- a/apps/mobile/src/features/home/homeThreadList.ts
+++ b/apps/mobile/src/features/home/homeThreadList.ts
@@ -141,252 +141,3 @@ export function sortHomeProjectScopes(input: {
const RECENT_THREAD_WINDOW_MS = 5 * 24 * 60 * 60 * 1000;
/** Fallback when a project has no threads inside the recency window. */
const RECENT_THREAD_FALLBACK_COUNT = 3;
-
-export interface HomeThreadGroup {
- readonly key: string;
- readonly title: string;
- readonly representative: EnvironmentProject;
- readonly projects: ReadonlyArray<EnvironmentProject>;
- readonly pendingTasks: ReadonlyArray<PendingNewTask>;
- /** Full sorted thread history for the group (revealed when expanded / searching). */
- readonly threads: ReadonlyArray<EnvironmentThreadShell>;
- /** Subset shown by default: threads from the last few days, or the most recent few. */
- readonly recentThreads: ReadonlyArray<EnvironmentThreadShell>;
- /**
- * Where a quick "new thread in this project" should land. For aggregated
- * groups (same repo on several machines) this is the member that owns the
- * group's most recent thread — the machine the user last worked on — rather
- * than the arbitrary first member; the draft's computer picker covers
- * switching from there. Null only for synthetic pending-project groups,
- * whose single "project" is a placeholder built from queued-task metadata.
- */
- readonly newThreadTarget: EnvironmentProject | null;
-}
-
-interface MutableHomeThreadGroup {
- readonly key: string;
- readonly projects: EnvironmentProject[];
- readonly pendingTasks: PendingNewTask[];
- readonly threads: EnvironmentThreadShell[];
-}
-
-function groupSortTimestamp(group: HomeThreadGroup, sortOrder: HomeProjectSortOrder): number {
- const latestThread = group.threads.reduce(
- (latest, thread) => Math.max(latest, getThreadSortTimestamp(thread, sortOrder)),
- Number.NEGATIVE_INFINITY,
- );
- return group.pendingTasks.reduce((latest, pendingTask) => {
- const timestamp = Date.parse(pendingTask.createdAt);
- return Number.isNaN(timestamp) ? latest : Math.max(latest, timestamp);
- }, latestThread);
-}
-
-/**
- * Trims a group's threads to recent activity for the default home view.
- * `sortedThreads` must already be ordered newest-first for `threadSortOrder`.
- * Keeps threads within {@link RECENT_THREAD_WINDOW_MS}; when none qualify, keeps
- * the most recent {@link RECENT_THREAD_FALLBACK_COUNT} so a project never vanishes.
- */
-function selectRecentThreads(
- sortedThreads: ReadonlyArray<EnvironmentThreadShell>,
- threadSortOrder: SidebarThreadSortOrder,
- now: number,
- queuedThreadKeys: ReadonlySet<string> | undefined,
-): ReadonlyArray<EnvironmentThreadShell> {
- const cutoff = now - RECENT_THREAD_WINDOW_MS;
- // A thread with a message waiting in the outbox has work the user is
- // waiting on, however old its last activity; it never trims away.
- const recent = sortedThreads.filter(
- (thread) =>
- getThreadSortTimestamp(thread, threadSortOrder) >= cutoff ||
- queuedThreadKeys?.has(scopedThreadKey(thread.environmentId, thread.id)) === true,
- );
- return recent.length > 0 ? recent : sortedThreads.slice(0, RECENT_THREAD_FALLBACK_COUNT);
-}
-
-export function buildHomeThreadGroups(input: {
- readonly projects: ReadonlyArray<EnvironmentProject>;
- readonly threads: ReadonlyArray<EnvironmentThreadShell>;
- readonly pendingTasks?: ReadonlyArray<PendingNewTask>;
- /** Thread keys with a message waiting in the outbox; kept in the default view. */
- readonly queuedThreadKeys?: ReadonlySet<string>;
- readonly environmentId: EnvironmentId | null;
- readonly searchQuery: string;
- readonly matchedThreadKeys?: ReadonlySet<string>;
- readonly projectSortOrder: HomeProjectSortOrder;
- readonly threadSortOrder: SidebarThreadSortOrder;
- readonly projectGroupingMode: SidebarProjectGroupingMode;
- /** Current time used for the recency window; defaults to now. Injectable for tests. */
- readonly now?: number;
-}): ReadonlyArray<HomeThreadGroup> {
- const now = input.now ?? Date.now();
- const groups = new Map<string, MutableHomeThreadGroup>();
- const groupTitleByKey = new Map<string, string>();
- const groupKeyByProjectKey = new Map<string, string>();
-
- for (const scope of buildHomeProjectScopes(input)) {
- groupTitleByKey.set(scope.key, scope.title);
- groups.set(scope.key, {
- key: scope.key,
- projects: [...scope.projects],
- pendingTasks: [],
- threads: [],
- });
- for (const projectRef of scope.projectRefs) {
- groupKeyByProjectKey.set(
- scopedProjectKey(projectRef.environmentId, projectRef.projectId),
- scope.key,
- );
- }
- }
-
- for (const pendingTask of input.pendingTasks ?? []) {
- if (input.environmentId !== null && pendingTask.environmentId !== input.environmentId) {
- continue;
- }
-
- const physicalKey = scopedProjectKey(pendingTask.environmentId, pendingTask.projectId);
- let groupKey = groupKeyByProjectKey.get(physicalKey);
- if (!groupKey) {
- // The project shell is not loaded (environment offline / project gone).
- // A queued task must stay visible and deletable regardless, so build a
- // standalone group from the metadata snapshotted at enqueue time.
- groupKey = `pending-project:${physicalKey}`;
- groupKeyByProjectKey.set(physicalKey, groupKey);
- groups.set(groupKey, {
- key: groupKey,
- projects: [
- {
- environmentId: pendingTask.environmentId,
- id: pendingTask.projectId,
- title: pendingTask.projectTitle ?? "Unknown project",
- workspaceRoot: pendingTask.projectCwd ?? String(pendingTask.projectId),
- repositoryIdentity: null,
- defaultModelSelection: null,
- scripts: [],
- createdAt: pendingTask.createdAt,
- updatedAt: pendingTask.createdAt,
- },
- ],
- pendingTasks: [],
- threads: [],
- });
- }
- groups.get(groupKey)?.pendingTasks.push(pendingTask);
- }
-
- for (const thread of input.threads) {
- if (thread.archivedAt !== null) {
- continue;
- }
- if (input.environmentId !== null && thread.environmentId !== input.environmentId) {
- continue;
- }
-
- const physicalKey = scopedProjectKey(thread.environmentId, thread.projectId);
- const groupKey = groupKeyByProjectKey.get(physicalKey);
- if (!groupKey) {
- continue;
- }
- groups.get(groupKey)?.threads.push(thread);
- }
-
- const query = input.searchQuery.trim().toLocaleLowerCase();
- const result: HomeThreadGroup[] = [];
-
- for (const group of groups.values()) {
- const representative = group.projects[0];
- if (!representative || (group.threads.length === 0 && group.pendingTasks.length === 0)) {
- continue;
- }
-
- const title =
- groupTitleByKey.get(group.key) ??
- deriveProjectGroupLabel({ representative, members: group.projects });
- const groupMatches =
- query.length === 0 ||
- title.toLocaleLowerCase().includes(query) ||
- group.projects.some((project) => project.title.toLocaleLowerCase().includes(query));
- const matchingThreads = groupMatches
- ? group.threads
- : group.threads.filter(
- (thread) =>
- thread.title.toLocaleLowerCase().includes(query) ||
- threadPullRequestSearchTerms(thread).some((term) =>
- term.toLocaleLowerCase().includes(query),
- ) ||
- input.matchedThreadKeys?.has(
- threadSearchMatchKey({
- environmentId: thread.environmentId,
- threadId: thread.id,
- }),
- ) === true,
- );
- const matchingPendingTasks = groupMatches
- ? group.pendingTasks
- : group.pendingTasks.filter((pendingTask) =>
- pendingTask.title.toLocaleLowerCase().includes(query),
- );
-
- if (matchingThreads.length === 0 && matchingPendingTasks.length === 0) {
- continue;
- }
-
- const sortedThreads = sortThreads(matchingThreads, input.threadSortOrder);
- // An active search should reach the full history, so the recency window
- // only trims the default (no-query) view.
- const recentThreads =
- query.length === 0
- ? selectRecentThreads(sortedThreads, input.threadSortOrder, now, input.queuedThreadKeys)
- : sortedThreads;
-
- // A stale project id still resolves to the canonical member with the same
- // environment/path, so quick creation follows the machine with the newest activity.
- const lastActiveProject = Arr.head(sortedThreads).pipe(
- Option.flatMap((thread) =>
- Arr.findFirst(
- input.projects,
- (project) =>
- project.environmentId === thread.environmentId && project.id === thread.projectId,
- ),
- ),
- Option.flatMap((threadProject) =>
- Arr.findFirst(
- group.projects,
- (project) =>
- derivePhysicalProjectKey(project) === derivePhysicalProjectKey(threadProject),
- ),
- ),
- Option.getOrNull,
- );
-
- result.push({
- key: group.key,
- title,
- representative,
- projects: group.projects,
- pendingTasks: matchingPendingTasks,
- threads: sortedThreads,
- recentThreads,
- newThreadTarget: group.key.startsWith("pending-project:")
- ? null
- : (lastActiveProject ?? representative),
- });
- }
-
- return Arr.sort(
- result,
- Order.mapInput(
- Order.Struct({
- timestamp: Order.flip(Order.Number),
- title: Order.String,
- key: Order.String,
- }),
- (group: HomeThreadGroup) => ({
- timestamp: groupSortTimestamp(group, input.projectSortOrder),
- title: group.title,
- key: group.key,
- }),
- ),
- );
-}
diff --git a/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts b/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts
index b76d2f8a90b..45b6ccb13d1 100644
--- a/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts
+++ b/apps/mobile/src/features/keyboard/threadKeyboardShortcuts.ts
@@ -2,23 +2,19 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell
import { THREAD_JUMP_KEYBINDING_COMMANDS } from "@t3tools/contracts";
import { useCallback } from "react";
-import type { HomeListItem } from "../home/homeListItems";
import type { ThreadListV2ListItem } from "../threads/threadListV2";
import {
useHardwareKeyboardCommand,
type HardwareKeyboardCommand,
} from "./hardwareKeyboardCommands";
-type ThreadShortcutListItem =
- | HomeListItem
- | ThreadListV2ListItem
- | { readonly type: "v2-show-more" };
+type ThreadShortcutListItem = ThreadListV2ListItem | { readonly type: "v2-show-more" };
export function threadJumpIndex(command: HardwareKeyboardCommand) {
return THREAD_JUMP_KEYBINDING_COMMANDS.findIndex((candidate) => candidate === command);
}
-/** Uses the rendered list so filters, collapsed groups and shelves keep their order. */
+/** Uses the rendered list so filters and shelves keep their order. */
export function threadJumpTarget(
items: ReadonlyArray<ThreadShortcutListItem>,
command: HardwareKeyboardCommand,
@@ -26,8 +22,7 @@ export function threadJumpTarget(
let index = threadJumpIndex(command);
if (index < 0) return null;
for (const item of items) {
- const thread =
- item.type === "thread" ? item.thread : item.type === "v2-thread" ? item.item.thread : null;
+ const thread = item.type === "v2-thread" ? item.item.thread : null;
if (thread !== null && index-- === 0) return thread;
}
return null;
diff --git a/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
index 9a98481d5be..e209ab0b6ce 100644
--- a/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsThreadsRouteScreen.tsx
@@ -12,7 +12,6 @@ import { AppText as Text } from "../../components/AppText";
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import { serverEnvironment } from "../../state/server";
import { useAtomCommand } from "../../state/use-atom-command";
-import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
import { SettingsSection } from "./components/SettingsSection";
import { SettingsProjectOverridesSection } from "./components/SettingsProjectOverridesSection";
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
@@ -224,19 +223,12 @@ function AutoSettleSettingsRows() {
function LegacySettingsSection() {
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
const preferences = useAtomValue(mobilePreferencesAtom);
- const threadListV2Enabled = useThreadListV2Enabled();
const planModeEnabled =
AsyncResult.isSuccess(preferences) && preferences.value.planModeEnabled === true;
return (
<View className="gap-3">
<SettingsSection title="Legacy">
- <SettingsSwitchRow
- icon="sidebar.left"
- label="Legacy Thread List"
- value={!threadListV2Enabled}
- onValueChange={(value) => savePreferences({ legacyThreadListEnabled: value })}
- />
<SettingsSwitchRow
icon="hammer"
label="Plan Mode"
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index 23cf2b22d70..160392fdd5d 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -29,7 +29,6 @@ import { NativeStackScreenOptions } from "../../native/StackHeader";
import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
import { useProjects, useThreadShells } from "../../state/entities";
import { useThreadSearch } from "../../state/queries";
-import { useThreadListV2Enabled } from "./use-thread-list-v2-enabled";
import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences";
import { usePendingThreadOrder } from "../../state/thread-order";
import { environmentServerConfigsAtom } from "../../state/server";
@@ -39,24 +38,9 @@ import { useWorkspaceState } from "../../state/workspace";
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
-import {
- hasCustomHomeListOptions,
- PROJECT_SORT_OPTIONS,
- THREAD_SORT_OPTIONS,
- useHomeListOptions,
-} from "../home/home-list-options";
+import { useHomeListOptions } from "../home/home-list-options";
import { buildHomeListFilterMenu } from "../home/home-list-filter-menu";
-import {
- buildHomeListLayout,
- DEFAULT_GROUP_DISPLAY_STATE,
- EMPTY_HOME_LIST_LAYOUT,
- homeListItemsAreEqual,
- nextGroupDisplayState,
- type HomeGroupDisplayAction,
- type HomeGroupDisplayState,
- type HomeListItem,
-} from "../home/homeListItems";
-import { buildHomeProjectScopes, buildHomeThreadGroups } from "../home/homeThreadList";
+import { buildHomeProjectScopes } from "../home/homeThreadList";
import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
import { useThreadListActions } from "../home/useThreadListActions";
@@ -71,12 +55,6 @@ import { useMaterialFabScroll } from "../home/MaterialFabScrollContext";
import { SidebarFilterButton } from "./sidebar-filter-button";
import { createSidebarHeaderItems } from "./sidebar-native-header-items";
import { SidebarNavigationShell } from "./sidebar-navigation-shell";
-import {
- PendingTaskListRow,
- ThreadListGroupHeader,
- ThreadListRow,
- ThreadListShowMoreRow,
-} from "./thread-list-items";
import {
ThreadListV2PendingRow,
ThreadListV2Row,
@@ -96,11 +74,9 @@ import {
type ThreadListV2ListItem,
} from "./threadListV2";
-/** The sidebar list serves both lists: v1 grouped items or, when the Thread
- List v2 beta is on, flat v2 rows with queued tasks spliced in, and a settled
- "Show more" pager. */
+/** The sidebar list: flat v2 rows with queued tasks spliced in, plus a
+ settled "Show more" pager row. */
type SidebarListItem =
- | HomeListItem
| ThreadListV2ListItem
| { readonly type: "v2-show-more"; readonly key: string; readonly hiddenCount: number };
@@ -178,7 +154,6 @@ function ThreadNavigationSidebarPane(
renameThread,
regenerateThreadTitle,
} = useThreadListActions();
- const threadListV2Enabled = useThreadListV2Enabled();
const pendingTasks = usePendingNewTasks();
const queuedThreadKeys = useQueuedThreadKeys();
const { openPendingTask, confirmDeletePendingTask } = usePendingTaskListActions();
@@ -196,8 +171,7 @@ function ThreadNavigationSidebarPane(
() => new Set(environments.map((environment) => environment.environmentId)),
[environments],
);
- const { options, setSelectedEnvironmentId, setProjectSortOrder, setThreadSortOrder } =
- useHomeListOptions(availableEnvironmentIds);
+ const { options, setSelectedEnvironmentId } = useHomeListOptions(availableEnvironmentIds);
const searchEnvironmentIds = useMemo(
() =>
options.selectedEnvironmentId === null
@@ -286,93 +260,6 @@ function ThreadNavigationSidebarPane(
),
[selectedProjectScope],
);
- const scopedProjects = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : selectedProjectRefs === null
- ? projects
- : projects.filter((project) =>
- selectedProjectRefs.has(scopedProjectKey(project.environmentId, project.id)),
- ),
- [threadListV2Enabled, projects, selectedProjectRefs],
- );
- const scopedThreads = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : selectedProjectRefs === null
- ? threads
- : threads.filter((thread) =>
- selectedProjectRefs.has(scopedProjectKey(thread.environmentId, thread.projectId)),
- ),
- [threadListV2Enabled, selectedProjectRefs, threads],
- );
- const scopedPendingTasks = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : selectedProjectRefs === null
- ? pendingTasks
- : pendingTasks.filter((pendingTask) =>
- selectedProjectRefs.has(
- scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
- ),
- ),
- [threadListV2Enabled, pendingTasks, selectedProjectRefs],
- );
- const groups = useMemo(
- () =>
- threadListV2Enabled
- ? []
- : buildHomeThreadGroups({
- projects: scopedProjects,
- threads: scopedThreads,
- pendingTasks: scopedPendingTasks,
- queuedThreadKeys,
- environmentId: options.selectedEnvironmentId,
- searchQuery: props.searchQuery,
- matchedThreadKeys,
- projectSortOrder: options.projectSortOrder,
- threadSortOrder: options.threadSortOrder,
- projectGroupingMode: options.projectGroupingMode,
- }),
- [
- threadListV2Enabled,
- queuedThreadKeys,
- matchedThreadKeys,
- options,
- props.searchQuery,
- scopedPendingTasks,
- scopedProjects,
- scopedThreads,
- ],
- );
- const [groupDisplayStates, setGroupDisplayStates] = useState<
- ReadonlyMap<string, HomeGroupDisplayState>
- >(() => new Map());
- const updateGroupDisplay = useCallback((key: string, action: HomeGroupDisplayAction) => {
- setGroupDisplayStates((previous) => {
- const next = new Map(previous);
- next.set(
- key,
- nextGroupDisplayState(previous.get(key) ?? DEFAULT_GROUP_DISPLAY_STATE, action),
- );
- return next;
- });
- }, []);
- const hasSearchQuery = props.searchQuery.trim().length > 0;
- const listLayout = useMemo(
- () =>
- threadListV2Enabled
- ? EMPTY_HOME_LIST_LAYOUT
- : buildHomeListLayout({
- groups,
- displayStates: groupDisplayStates,
- showAllThreads: hasSearchQuery,
- }),
- [threadListV2Enabled, groups, groupDisplayStates, hasSearchQuery],
- );
const projectByKey = useMemo(() => {
const map = new Map<string, EnvironmentProject>();
for (const project of projects) {
@@ -412,12 +299,11 @@ function ThreadNavigationSidebarPane(
// thread reappears immediately instead of on the next minute tick.
const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);
useEffect(() => {
- if (!threadListV2Enabled) return;
// Refresh immediately because the mount-time value can be hours old.
setNowMinute(new Date().toISOString().slice(0, 16));
const id = setInterval(() => setNowMinute(new Date().toISOString().slice(0, 16)), 60_000);
return () => clearInterval(id);
- }, [threadListV2Enabled]);
+ }, []);
// Threads on servers without the settlement capability never classify as
// settled (the user could neither un-settle nor pin them).
const serverConfigs = useAtomValue(environmentServerConfigsAtom);
@@ -529,16 +415,6 @@ function ThreadNavigationSidebarPane(
snoozeWakeTick,
]);
const threadListV2Layout = useMemo(() => {
- if (!threadListV2Enabled)
- return {
- items: [],
- hiddenSettledCount: 0,
- snoozedCount: 0,
- snoozedShelfHeaderIndex: null,
- settledCount: 0,
- settledShelfHeaderIndex: null,
- nextSnoozeWakeAt: null,
- };
return buildThreadListV2Items({
pendingOrder,
threads: threads.filter((thread) => thread.archivedAt === null),
@@ -569,7 +445,6 @@ function ThreadNavigationSidebarPane(
settledVisibleCount,
settlementEnvironmentIds,
snoozeEnvironmentIds,
- threadListV2Enabled,
threads,
selectedProjectScope,
]);
@@ -588,7 +463,6 @@ function ThreadNavigationSidebarPane(
// range) the boundary string is identical and the chain would die.
}, [nextSnoozeWakeAt, snoozeWakeTick]);
const listItems = useMemo<readonly SidebarListItem[]>(() => {
- if (!threadListV2Enabled) return listLayout.items;
// Queued offline tasks are not thread shells, so the v2 item builder
// never sees them; the shared splice puts them below the active block
// (mirrors the compact Home v2 list) where they stay visible and
@@ -630,7 +504,6 @@ function ThreadNavigationSidebarPane(
}
return items;
}, [
- listLayout.items,
nowMinute,
options.selectedEnvironmentId,
pendingTasks,
@@ -642,7 +515,6 @@ function ThreadNavigationSidebarPane(
shelfPreferencesLoaded,
snoozedShelfExpanded,
snoozeEnvironmentIds,
- threadListV2Enabled,
threadListV2Layout,
]);
const listMenuActions = useMemo<MenuAction[]>(
@@ -688,33 +560,8 @@ function ThreadNavigationSidebarPane(
],
},
] satisfies MenuAction[])),
- // v2 lays the list out in fixed creation order — offering sort/group
- // controls it silently ignores would be a lie. Environment still
- // scopes the v2 partition, so it stays.
- ...(threadListV2Enabled
- ? []
- : ([
- {
- id: "project-sort",
- title: "Sort projects",
- subactions: PROJECT_SORT_OPTIONS.map((option) => ({
- id: `project-sort:${option.value}`,
- title: option.label,
- state: options.projectSortOrder === option.value ? "on" : "off",
- })),
- },
- {
- id: "thread-sort",
- title: "Sort threads",
- subactions: THREAD_SORT_OPTIONS.map((option) => ({
- id: `thread-sort:${option.value}`,
- title: option.label,
- state: options.threadSortOrder === option.value ? "on" : "off",
- })),
- },
- ] satisfies MenuAction[])),
],
- [environments, options, projectFilterOptions, selectedProjectKey, threadListV2Enabled],
+ [environments, options, projectFilterOptions, selectedProjectKey],
);
const handleListMenuAction = useCallback(
({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
@@ -741,28 +588,8 @@ function ThreadNavigationSidebarPane(
}
return;
}
- const projectSort = PROJECT_SORT_OPTIONS.find(
- (option) => `project-sort:${option.value}` === event,
- );
- if (projectSort) {
- setProjectSortOrder(projectSort.value);
- return;
- }
- const threadSort = THREAD_SORT_OPTIONS.find(
- (option) => `thread-sort:${option.value}` === event,
- );
- if (threadSort) {
- setThreadSortOrder(threadSort.value);
- return;
- }
},
- [
- environments,
- projectFilterOptions,
- setProjectSortOrder,
- setSelectedEnvironmentId,
- setThreadSortOrder,
- ],
+ [environments, projectFilterOptions, setSelectedEnvironmentId],
);
const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
@@ -838,15 +665,7 @@ function ThreadNavigationSidebarPane(
if (previous.type === "v2-show-more" && item.type === "v2-show-more") {
return previous.hiddenCount === item.hiddenCount;
}
- if (
- isThreadListV2ListItem(previous) ||
- previous.type === "v2-show-more" ||
- isThreadListV2ListItem(item) ||
- item.type === "v2-show-more"
- ) {
- return false;
- }
- return homeListItemsAreEqual(previous, item);
+ return false;
},
[],
);
@@ -994,90 +813,11 @@ function ThreadNavigationSidebarPane(
onPress={showMoreSettled}
/>
);
- case "header":
- return (
- <ThreadListGroupHeader
- variant="sidebar"
- collapsed={item.collapsed}
- isFirst={item.isFirst}
- groupKey={item.group.key}
- onGroupAction={updateGroupDisplay}
- // Same gating as the compact Home list: aggregated groups have no
- // single target project, and pending-project groups hold a
- // placeholder shell rather than a real project.
- newThreadTarget={item.group.newThreadTarget}
- onNewThread={props.onNewThreadInProject}
- project={item.group.representative}
- threadCount={item.group.threads.length + item.group.pendingTasks.length}
- title={item.group.title}
- />
- );
- case "pending-task":
- return (
- <PendingTaskListRow
- variant="sidebar"
- pendingTask={item.pendingTask}
- environmentLabel={
- savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ?? null
- }
- environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
- isLast={item.isLast}
- onSelectPendingTask={openPendingTask}
- onDeletePendingTask={confirmDeletePendingTask}
- />
- );
- case "thread": {
- const thread = item.thread;
- return (
- <ThreadListRow
- onNewThreadOnBranch={props.onNewThreadOnBranch}
- variant="sidebar"
- thread={thread}
- hasQueuedMessages={queuedThreadKeys.has(`${thread.environmentId}:${thread.id}`)}
- environmentLabel={
- savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
- }
- environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
- isLast={item.isLast}
- searchMatch={threadSearchMatchByKey.get(
- threadSearchMatchKey({
- environmentId: thread.environmentId,
- threadId: thread.id,
- }),
- )}
- searchQuery={props.searchQuery}
- selected={
- scopedThreadKey(thread.environmentId, thread.id) === props.selectedThreadKey
- }
- fullSwipeWidth={props.width - 20}
- onArchiveThread={archiveThread}
- onDeleteThread={confirmDeleteThread}
- onRenameThread={renameThread}
- onRegenerateThreadTitle={regenerateThreadTitle}
- titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
- onSelectThread={handleSelectThread}
- onSwipeableClose={handleSwipeableClose}
- onSwipeableWillOpen={handleSwipeableWillOpen}
- simultaneousSwipeGesture={sidebarScrollGesture}
- />
- );
- }
- case "show-more":
- return (
- <ThreadListShowMoreRow
- variant="sidebar"
- hiddenCount={item.hiddenCount}
- canShowLess={item.canShowLess}
- groupKey={item.groupKey}
- onGroupAction={updateGroupDisplay}
- />
- );
}
},
[
archiveThread,
activeReorderEnvironmentIds,
- queuedThreadKeys,
confirmDeletePendingTask,
confirmDeleteThread,
handleSelectThread,
@@ -1093,13 +833,13 @@ function ThreadNavigationSidebarPane(
projectTitleByProjectKey,
regenerateThreadTitle,
renameThread,
+ threadSearchMatchByKey,
props.onNewThreadInProject,
props.onNewThreadOnBranch,
props.searchQuery,
props.selectedThreadKey,
props.width,
savedConnectionsById,
- threadSearchMatchByKey,
titleRegenerationEnvironmentIds,
settleThread,
settlementEnvironmentIds,
@@ -1113,14 +853,11 @@ function ThreadNavigationSidebarPane(
unpinThread,
unsettleThread,
unsnoozeThread,
- updateGroupDisplay,
],
);
- // v2 ignores the sort/group options, so only the environment filter can
- // light the "customized" state while the beta is on.
- const filterCustomized = threadListV2Enabled
- ? options.selectedEnvironmentId !== null || selectedProjectKey !== null
- : hasCustomHomeListOptions({ ...options, selectedProjectKey });
+ // The list ignores sort/group options, so only the environment and project
+ // filters can light the "customized" state.
+ const filterCustomized = options.selectedEnvironmentId !== null || selectedProjectKey !== null;
const filterIcon = filterCustomized
? "line.3.horizontal.decrease.circle.fill"
: "line.3.horizontal.decrease.circle";
@@ -1131,24 +868,10 @@ function ThreadNavigationSidebarPane(
projects: projectFilterOptions,
selectedEnvironmentId: options.selectedEnvironmentId,
selectedProjectKey,
- projectSortOrder: options.projectSortOrder,
- threadSortOrder: options.threadSortOrder,
onEnvironmentChange: setSelectedEnvironmentId,
onProjectChange: setSelectedProjectKey,
- onProjectSortOrderChange: setProjectSortOrder,
- onThreadSortOrderChange: setThreadSortOrder,
- listOrganization: !threadListV2Enabled,
}),
- [
- environments,
- options,
- projectFilterOptions,
- selectedProjectKey,
- setProjectSortOrder,
- setSelectedEnvironmentId,
- setThreadSortOrder,
- threadListV2Enabled,
- ],
+ [environments, options, projectFilterOptions, selectedProjectKey, setSelectedEnvironmentId],
);
const nativeHeaderItems = useMemo(
() =>
@@ -1358,10 +1081,7 @@ function ThreadNavigationSidebarPane(
/>
<View className="flex-row items-center gap-2.5">
<ControlPillMenu actions={listMenuActions} onPressAction={handleListMenuAction}>
- <SidebarFilterButton
- accessibilityLabel="Filter and sort threads"
- icon={filterIcon}
- />
+ <SidebarFilterButton accessibilityLabel="Filter threads" icon={filterIcon} />
</ControlPillMenu>
<SidebarHeaderActions onOpenSettings={props.onOpenSettings} />
</View>
diff --git a/apps/mobile/src/features/threads/sidebar-native-header-items.ts b/apps/mobile/src/features/threads/sidebar-native-header-items.ts
index b80fffda057..1f9297f4725 100644
--- a/apps/mobile/src/features/threads/sidebar-native-header-items.ts
+++ b/apps/mobile/src/features/threads/sidebar-native-header-items.ts
@@ -45,7 +45,7 @@ export function createSidebarHeaderItems(input: {
withNativeGlassHeaderItem({
type: "menu",
label: "",
- accessibilityLabel: "Filter and sort threads",
+ accessibilityLabel: "Filter threads",
icon: sfSymbolIcon(input.filterIcon),
menu: {
title: input.filterMenu.title,
diff --git a/apps/mobile/src/features/threads/thread-list-items.tsx b/apps/mobile/src/features/threads/thread-list-items.tsx
deleted file mode 100644
index 04d30a26a90..00000000000
--- a/apps/mobile/src/features/threads/thread-list-items.tsx
+++ /dev/null
@@ -1,849 +0,0 @@
-import type {
- EnvironmentProject,
- EnvironmentThreadShell,
-} from "@t3tools/client-runtime/state/shell";
-import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";
-import type { EnvironmentMachineKind } from "@t3tools/contracts";
-import type { MenuAction } from "@react-native-menu/menu";
-import { SymbolView } from "../../components/AppSymbol";
-import { memo, useCallback, useMemo, type ComponentProps } from "react";
-import { Platform, Pressable, useWindowDimensions, View } from "react-native";
-import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
-import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
-import Svg, { Circle, Path } from "react-native-svg";
-
-import { RowPressable } from "../../components/RowPressable";
-import { AppText as Text } from "../../components/AppText";
-import { ControlPillMenu } from "../../components/ControlPill";
-import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
-import { ProjectFavicon } from "../../components/ProjectFavicon";
-import { cn } from "../../lib/cn";
-import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
-import { HOME_HORIZONTAL_INSET } from "../../lib/layoutMetrics";
-import { relativeTime } from "../../lib/time";
-import { useUniwindTheme } from "../../lib/useUniwindTheme";
-import type { PendingNewTask } from "../../state/use-pending-new-tasks";
-import { useThreadPr, type ThreadPrPresentation } from "../../state/use-thread-pr";
-import type { HomeGroupDisplayAction } from "../home/homeListItems";
-import { ThreadSwipeable } from "../home/thread-swipe-actions";
-import { buildThreadTitleRegenerationMenuItems } from "./thread-title-regeneration-menu";
-import { QueuedMessageIcon } from "./queued-message-icon";
-import { resolveThreadStatus } from "./threadPresentation";
-import { ThreadSearchMatchExcerpt } from "./thread-search-match";
-
-/**
- * Shared presentation for the thread lists: the compact (phone) Home list and
- * the iPad sidebar render the SAME items — group headers with collapse,
- * thread rows with status/PR/subtitle, and show-more rows — differing only in
- * metrics and chrome via `variant`.
- */
-export type ThreadListVariant = "compact" | "sidebar";
-
-/** Left inset that aligns compact secondary rows with the title column. */
-export const THREAD_LIST_COMPACT_INSET = HOME_HORIZONTAL_INSET;
-const SIDEBAR_ROW_RADIUS = 12;
-
-function pullRequestTintColor(
- pr: Pick<ThreadPrPresentation, "state" | "isDraft" | "others" | "kind">,
- colorScheme: "light" | "dark",
-) {
- const dark = colorScheme === "dark";
- if (pr.state === "open" && pr.isDraft === true) {
- return dark ? "#a1a1aa" : "#71717a";
- }
- switch (pr.state) {
- case "open":
- return dark ? "#34d399" : "#059669";
- case "merged":
- return dark ? "#a78bfa" : "#7c3aed";
- case "closed":
- if (pr.kind === "stack" || pr.others > 0) {
- return dark ? "#fb7185" : "#e11d48";
- }
- return dark ? "#a1a1aa" : "#71717a";
- case null:
- return dark ? "#a1a1aa" : "#71717a";
- }
-}
-
-function PullRequestIcon(props: { readonly size: number; readonly color: string }) {
- return (
- <Svg
- width={props.size}
- height={props.size}
- viewBox="0 0 24 24"
- fill="none"
- stroke={props.color}
- strokeWidth={2}
- strokeLinecap="round"
- strokeLinejoin="round"
- >
- <Circle cx={18} cy={18} r={3} />
- <Circle cx={6} cy={6} r={3} />
- <Path d="M13 6h3a2 2 0 0 1 2 2v7" />
- <Path d="M6 9v12" />
- </Svg>
- );
-}
-
-/* ─── Project group header ───────────────────────────────────────────── */
-
-export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props: {
- readonly variant: ThreadListVariant;
- readonly project: EnvironmentProject;
- readonly title: string;
- readonly threadCount: number;
- readonly collapsed: boolean;
- readonly isFirst: boolean;
- readonly groupKey: string;
- readonly onGroupAction: (key: string, action: HomeGroupDisplayAction) => void;
- /** Project a quick new thread should target; null hides the button. */
- readonly newThreadTarget?: EnvironmentProject | null;
- readonly onNewThread?: (project: EnvironmentProject) => void;
-}) {
- const { groupKey, onGroupAction, onNewThread } = props;
- const newThreadTarget = props.newThreadTarget ?? null;
- const compact = props.variant === "compact";
- const handleToggle = useCallback(
- () => onGroupAction(groupKey, "toggle-collapsed"),
- [groupKey, onGroupAction],
- );
- const handleNewThread = useCallback(() => {
- if (newThreadTarget) {
- onNewThread?.(newThreadTarget);
- }
- }, [newThreadTarget, onNewThread]);
- const showNewThreadButton = onNewThread !== undefined && newThreadTarget !== null;
-
- // The new-thread button is a SIBLING of the collapse toggle, not a child:
- // nested touchables are unreachable to VoiceOver/TalkBack (the parent
- // swallows focus). Row padding lives on the container (explicit styles —
- // dynamic padding classes on Pressable did not apply reliably) so both
- // children share one centerline; hitSlop restores the padded tap area.
- const verticalHitSlop = { top: props.isFirst ? 8 : 24, bottom: 12 };
- return (
- <View
- className={compact ? "flex-row items-center bg-screen" : "flex-row items-center"}
- style={{
- minHeight: compact ? 44 : 36,
- paddingLeft: compact ? 20 : 12,
- // Compact right padding centers the 20pt plus glyph on the thread
- // rows' trailing chevron column (18 + 13/2 ≈ 24.5 from the edge).
- paddingRight: compact ? 14 : 12,
- paddingBottom: compact ? 12 : 8,
- paddingTop: props.isFirst ? (compact ? 8 : 4) : compact ? 24 : 20,
- }}
- >
- <Pressable
- accessibilityRole="button"
- accessibilityState={{ expanded: !props.collapsed }}
- accessibilityLabel={`${props.title}, ${props.threadCount} threads`}
- accessibilityHint={props.collapsed ? "Expands the project" : "Collapses the project"}
- className={
- compact ? "flex-1 flex-row items-center gap-2.5" : "flex-1 flex-row items-center gap-2"
- }
- hitSlop={{ ...verticalHitSlop, left: compact ? 20 : 12 }}
- onPress={handleToggle}
- >
- <ProjectFavicon
- environmentId={props.project.environmentId}
- faviconPath={props.project.faviconPath}
- open={!props.collapsed}
- size={compact ? 22 : 18}
- projectTitle={props.project.title}
- workspaceRoot={props.project.workspaceRoot}
- />
- <Text
- className={
- compact
- ? "flex-shrink text-base font-t3-bold tracking-[0.2px] text-foreground-muted"
- : "flex-shrink text-sm font-t3-bold tracking-[0.2px] text-drawer-foreground-muted"
- }
- numberOfLines={1}
- >
- {props.title}
- </Text>
- <Text
- className={
- compact
- ? "flex-1 text-sm font-t3-medium text-foreground-tertiary"
- : "flex-1 text-xs font-t3-medium text-drawer-foreground-muted"
- }
- >
- {props.threadCount}
- </Text>
- </Pressable>
- {showNewThreadButton ? (
- <Pressable
- accessibilityLabel={`Create new thread in ${props.title}`}
- accessibilityRole="button"
- hitSlop={{ ...verticalHitSlop, left: 10, right: 14 }}
- onPress={handleNewThread}
- style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1, paddingLeft: 12 })}
- >
- <SymbolView
- name="plus"
- size={compact ? 20 : 16}
- tintColorClassName="accent-icon-muted"
- type="monochrome"
- weight="medium"
- />
- </Pressable>
- ) : null}
- </View>
- );
-});
-
-/* ─── Show more / show less row ──────────────────────────────────────── */
-
-export const ThreadListShowMoreRow = memo(function ThreadListShowMoreRow(props: {
- readonly variant: ThreadListVariant;
- readonly hiddenCount: number;
- readonly canShowLess: boolean;
- readonly groupKey: string;
- readonly onGroupAction: (key: string, action: HomeGroupDisplayAction) => void;
-}) {
- const showsMore = props.hiddenCount > 0;
- const compact = props.variant === "compact";
- const { groupKey, onGroupAction } = props;
- const handleShowMore = useCallback(
- () => onGroupAction(groupKey, "show-more"),
- [groupKey, onGroupAction],
- );
- const handleShowLess = useCallback(
- () => onGroupAction(groupKey, "show-less"),
- [groupKey, onGroupAction],
- );
-
- const button = (label: string, icon: "chevron.down" | "chevron.up", onPress: () => void) => (
- <Pressable
- accessibilityRole="button"
- accessibilityLabel={label === "Show more" ? "Show more threads" : "Show fewer threads"}
- className="rounded-full bg-subtle"
- hitSlop={6}
- onPress={onPress}
- style={({ pressed }) => ({
- opacity: pressed ? 0.6 : 1,
- paddingHorizontal: compact ? 14 : 12,
- paddingVertical: compact ? 7 : 6,
- borderCurve: "continuous",
- })}
- >
- <View className="flex-row items-center gap-1.5">
- <SymbolView
- name={icon}
- size={10}
- tintColorClassName="accent-icon-subtle"
- type="monochrome"
- weight="semibold"
- />
- <Text
- className={
- compact
- ? "text-sm font-t3-medium text-foreground-muted"
- : "text-xs font-t3-medium text-drawer-foreground-muted"
- }
- >
- {label}
- </Text>
- </View>
- </Pressable>
- );
-
- return (
- <View
- className={
- compact ? "flex-row items-center gap-2.5 bg-screen" : "flex-row items-center gap-2"
- }
- style={{
- paddingLeft: compact ? THREAD_LIST_COMPACT_INSET : 12,
- paddingRight: compact ? 18 : 12,
- paddingVertical: compact ? 12 : 8,
- }}
- >
- {showsMore ? button("Show more", "chevron.down", handleShowMore) : null}
- {props.canShowLess ? button("Show less", "chevron.up", handleShowLess) : null}
- </View>
- );
-});
-
-/* ─── Pending task row ───────────────────────────────────────────────── */
-
-const PENDING_TASK_MENU_ACTIONS: MenuAction[] = [
- { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
-];
-
-const DRAFT_TASK_MENU_ACTIONS: MenuAction[] = [
- { id: "delete", title: "Discard", image: "trash", attributes: { destructive: true } },
-];
-
-/**
- * Unsent work: a task queued in the outbox for its environment to reconnect,
- * or a draft still sitting in the project's new-task composer. Tapping
- * reopens the composer with everything prefilled; the row disappears once
- * the work is sent and the real thread arrives. The two kinds differ in what
- * happens next, so the pill and icon say which one this is: a queued task
- * sends itself, a draft waits for the user.
- */
-export const PendingTaskListRow = memo(function PendingTaskListRow(props: {
- readonly variant: ThreadListVariant;
- readonly pendingTask: PendingNewTask;
- readonly environmentLabel: string | null;
- readonly environmentMachine?: EnvironmentMachineKind;
- readonly isLast: boolean;
- readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
- readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
-}) {
- const compact = props.variant === "compact";
-
- const { pendingTask, onSelectPendingTask, onDeletePendingTask } = props;
- const isDraft = pendingTask.kind === "draft";
- const timestamp = isDraft ? null : relativeTime(pendingTask.createdAt);
- // The pill only has room for one word, so what happens next goes in the
- // subtitle: a queued task sends itself, a draft waits for the user.
- const subtitleParts = [
- isDraft ? null : "Sends on reconnect",
- props.environmentLabel,
- pendingTask.branch,
- ].filter((part): part is string => Boolean(part));
-
- const handleMenuAction = useCallback(
- ({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
- if (nativeEvent.event === "delete") onDeletePendingTask(pendingTask);
- },
- [onDeletePendingTask, pendingTask],
- );
-
- const statusPill = isDraft ? (
- <View className="rounded-full bg-adaptive-amber-500-a12-a16 px-1.5 py-0.5">
- <Text className="text-3xs font-t3-bold text-adaptive-amber-700-300">Draft</Text>
- </View>
- ) : (
- <View className="rounded-full bg-subtle px-1.5 py-0.5">
- <Text
- className={cn(
- "text-3xs font-t3-bold text-foreground-muted",
- !compact && "text-drawer-foreground-muted",
- )}
- >
- Pending
- </Text>
- </View>
- );
-
- const subtitleRow =
- subtitleParts.length > 0 ? (
- <View className="mt-px flex-row items-center gap-1.5">
- <SymbolView
- name={isDraft ? "square.and.pencil" : "tray.and.arrow.up"}
- size={10}
- tintColorClassName={compact ? "accent-icon-subtle" : "accent-drawer-foreground-muted"}
- type="monochrome"
- />
- {props.environmentLabel && props.environmentMachine ? (
- <EnvironmentMachineSymbol
- kind={props.environmentMachine}
- size={compact ? 12 : 10}
- tintColorClassName={compact ? "accent-icon-subtle" : "accent-drawer-foreground-muted"}
- />
- ) : null}
- <Text
- className={
- compact
- ? "shrink text-sm text-foreground-muted"
- : "shrink text-xs text-drawer-foreground-muted"
- }
- numberOfLines={1}
- >
- {subtitleParts.join(" · ")}
- </Text>
- </View>
- ) : null;
-
- const accessibilityHint = isDraft
- ? "Opens the draft in the new task composer"
- : "Sends when the environment reconnects. Opens the task for editing";
-
- const rowContent = compact ? (
- <RowPressable
- key={pendingTask.key}
- accessibilityHint={accessibilityHint}
- accessibilityLabel={pendingTask.title}
- accessibilityRole="button"
- className="bg-screen"
- onPress={() => onSelectPendingTask(pendingTask)}
- >
- <View className="pr-[18px] pt-[10px]" style={{ paddingLeft: THREAD_LIST_COMPACT_INSET }}>
- <View className={cn("gap-[3px] pb-[10px]", !props.isLast && "border-b border-separator")}>
- <View className="flex-row items-center justify-between gap-2">
- <Text
- className={cn(
- "flex-1 text-lg font-t3-bold text-foreground",
- !compact && "text-drawer-foreground",
- )}
- numberOfLines={1}
- >
- {pendingTask.title}
- </Text>
- <View className="flex-row items-center gap-2">
- {statusPill}
- {timestamp !== null ? (
- <Text
- className={cn(
- "text-base tabular-nums text-foreground-tertiary",
- !compact && "text-drawer-foreground-muted",
- )}
- >
- {timestamp}
- </Text>
- ) : null}
- <SymbolView
- name="chevron.right"
- size={13}
- tintColorClassName="accent-icon-subtle"
- type="monochrome"
- />
- </View>
- </View>
- {subtitleRow}
- </View>
- </View>
- </RowPressable>
- ) : (
- <RowPressable
- key={pendingTask.key}
- accessibilityHint={accessibilityHint}
- accessibilityLabel={pendingTask.title}
- accessibilityRole="button"
- interactionClassName="bg-thread-hover"
- onPress={() => onSelectPendingTask(pendingTask)}
- style={{
- borderRadius: SIDEBAR_ROW_RADIUS,
- minHeight: 64,
- justifyContent: "center",
- paddingHorizontal: 12,
- paddingVertical: 10,
- }}
- >
- <View className="gap-[3px]">
- <View className="flex-row items-center justify-between gap-2">
- <Text
- className="flex-1 text-base font-t3-medium text-drawer-foreground"
- numberOfLines={1}
- >
- {pendingTask.title}
- </Text>
- <View className="flex-row items-center gap-2">
- {statusPill}
- {timestamp !== null ? (
- <Text
- className={cn(
- "text-xs tabular-nums text-foreground-muted",
- !compact && "text-drawer-foreground-muted",
- )}
- numberOfLines={1}
- >
- {timestamp}
- </Text>
- ) : null}
- </View>
- </View>
- {subtitleRow}
- </View>
- </RowPressable>
- );
-
- return (
- <ControlPillMenu
- actions={isDraft ? DRAFT_TASK_MENU_ACTIONS : PENDING_TASK_MENU_ACTIONS}
- onPressAction={handleMenuAction}
- shouldOpenOnLongPress
- >
- {rowContent}
- </ControlPillMenu>
- );
-});
-
-/* ─── Thread row ─────────────────────────────────────────────────────── */
-
-const THREAD_ROW_MENU_ACTIONS: MenuAction[] = [
- { id: "archive", title: "Archive", image: "archivebox" },
- { id: "rename", title: "Rename", image: "square.and.pencil" },
- { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
-];
-
-export const ThreadListRow = memo(function ThreadListRow(props: {
- readonly variant: ThreadListVariant;
- readonly thread: EnvironmentThreadShell;
- readonly environmentLabel: string | null;
- readonly environmentMachine?: EnvironmentMachineKind;
- /** A message for this thread is waiting in the outbox. */
- readonly hasQueuedMessages?: boolean;
- readonly searchMatch?: EnvironmentThreadSearchMatch;
- readonly searchQuery?: string;
- readonly isLast: boolean;
- /** Sidebar only: the thread currently open in the detail pane. */
- readonly selected?: boolean;
- /** Defaults to window width minus compact margins. */
- readonly fullSwipeWidth?: number;
- readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
- readonly onArchiveThread: (thread: EnvironmentThreadShell) => void;
- readonly onDeleteThread: (thread: EnvironmentThreadShell) => void;
- readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
- readonly onRenameThread: (thread: EnvironmentThreadShell) => void;
- readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => void;
- readonly titleRegenerationSupported: boolean;
- readonly onSwipeableWillOpen: (methods: SwipeableMethods) => void;
- readonly onSwipeableClose: (methods: SwipeableMethods) => void;
- readonly simultaneousSwipeGesture?: ComponentProps<
- typeof ThreadSwipeable
- >["simultaneousWithExternalGesture"];
-}) {
- const { width: windowWidth } = useWindowDimensions();
- const { themeAppearance: colorScheme } = useAppearancePreferences();
- const compact = props.variant === "compact";
- const selected = props.selected === true;
- const visuallySelected = selected && (!compact || Platform.OS === "android");
- const theme = useUniwindTheme();
- const screenColor = theme["--color-screen"];
- const drawerColor = theme["--color-drawer"];
- const selectedBackgroundColor = theme["--color-thread-selected"];
-
- const {
- thread,
- onSelectThread,
- onArchiveThread,
- onDeleteThread,
- onRenameThread,
- onRegenerateThreadTitle,
- onNewThreadOnBranch,
- } = props;
- const status = resolveThreadStatus(thread);
- const pr = useThreadPr(thread);
- const timestamp = relativeTime(
- thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt,
- );
- const threadAccessibilityLabel = [
- thread.title,
- pr?.accessibilityLabel,
- props.hasQueuedMessages ? "messages queued to send" : null,
- ]
- .filter(Boolean)
- .join(", ");
- const subtitleParts = [props.environmentLabel, thread.branch].filter((part): part is string =>
- Boolean(part),
- );
-
- const backgroundColor = compact ? screenColor : drawerColor;
-
- const handleDelete = useCallback(() => onDeleteThread(thread), [onDeleteThread, thread]);
- const handleArchive = useCallback(() => onArchiveThread(thread), [onArchiveThread, thread]);
- const handleRename = useCallback(() => onRenameThread(thread), [onRenameThread, thread]);
- const handleRegenerateTitle = useCallback(
- () => onRegenerateThreadTitle(thread),
- [onRegenerateThreadTitle, thread],
- );
- const menuActions = useMemo<MenuAction[]>(
- () => [
- ...(thread.branch
- ? [
- {
- id: "new-thread-on-branch",
- title:
- Platform.OS === "ios" ? "New thread on branch" : `New thread on ${thread.branch}`,
- image: "square.and.pencil",
- },
- ]
- : []),
- THREAD_ROW_MENU_ACTIONS[0]!,
- THREAD_ROW_MENU_ACTIONS[1]!,
- { id: "copy-thread-id", title: "Copy thread ID", image: "doc.on.doc" },
- ...buildThreadTitleRegenerationMenuItems({
- supported: props.titleRegenerationSupported,
- isRegenerating: thread.titleRegeneration != null,
- }),
- THREAD_ROW_MENU_ACTIONS[2]!,
- ],
- [props.titleRegenerationSupported, thread.branch, thread.titleRegeneration],
- );
- const primaryAction = useMemo(
- () => ({
- accessibilityLabel: `Archive ${thread.title}`,
- icon: "archivebox" as const,
- label: "Archive",
- onPress: handleArchive,
- }),
- [handleArchive, thread.title],
- );
- const handleMenuAction = useCallback(
- ({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
- if (nativeEvent.event === "new-thread-on-branch") onNewThreadOnBranch(thread);
- if (nativeEvent.event === "archive") handleArchive();
- if (nativeEvent.event === "rename") handleRename();
- if (nativeEvent.event === "copy-thread-id") {
- copyTextWithHaptic(thread.id, { target: "thread-id" });
- }
- if (nativeEvent.event === "regenerate-title") handleRegenerateTitle();
- if (nativeEvent.event === "delete") handleDelete();
- },
- [handleArchive, handleDelete, handleRegenerateTitle, handleRename, onNewThreadOnBranch, thread],
- );
-
- const statusPill = status ? (
- <View className={`${status.pillClassName} rounded-full px-1.5 py-0.5`}>
- <Text className={`text-3xs font-t3-bold ${status.textClassName}`}>{status.label}</Text>
- </View>
- ) : null;
-
- const subtitleRow =
- subtitleParts.length > 0 || pr !== null ? (
- <View className="mt-px flex-row items-center gap-1.5">
- {subtitleParts.length > 0 ? (
- <>
- {props.environmentLabel && props.environmentMachine ? (
- <EnvironmentMachineSymbol
- kind={props.environmentMachine}
- size={compact ? 12 : 10}
- tintColorClassName={
- compact
- ? "accent-icon-subtle"
- : selected
- ? "accent-thread-selected-foreground-muted"
- : "accent-drawer-foreground-muted"
- }
- />
- ) : null}
- <Text
- className={cn(
- "shrink",
- compact ? "text-sm" : "text-xs",
- visuallySelected
- ? "text-thread-selected-foreground-muted"
- : compact
- ? "text-foreground-muted"
- : "text-drawer-foreground-muted",
- )}
- numberOfLines={1}
- >
- {subtitleParts.join(" · ")}
- </Text>
- </>
- ) : null}
- {pr !== null ? (
- <View
- className="flex-row items-center gap-0.5"
- accessibilityLabel={pr.accessibilityLabel}
- >
- {pr.kind === "stack" ? (
- <SymbolView
- name="square.3.layers.3d"
- size={compact ? 13 : 11}
- tintColor={pullRequestTintColor(pr, colorScheme)}
- />
- ) : (
- <PullRequestIcon
- size={compact ? 13 : 11}
- color={pullRequestTintColor(pr, colorScheme)}
- />
- )}
- <Text
- className={`${compact ? "text-sm" : "text-xs"} font-t3-medium ${pr.textClassName}`}
- >
- {pr.label}
- </Text>
- </View>
- ) : null}
- </View>
- ) : null;
-
- const rowContent = (close: () => void) =>
- compact ? (
- <RowPressable
- key={`${thread.environmentId}:${thread.id}`}
- interactionClassName="bg-row-hover"
- interactionOpacity={visuallySelected ? 0 : 1}
- accessibilityHint="Swipe left for archive and delete actions"
- accessibilityLabel={threadAccessibilityLabel}
- accessibilityRole="button"
- className="bg-screen"
- style={
- Platform.OS === "android"
- ? {
- backgroundColor: visuallySelected ? selectedBackgroundColor : backgroundColor,
- borderRadius: 20,
- }
- : undefined
- }
- onPress={() => {
- close();
- onSelectThread(thread);
- }}
- >
- <View className="pr-[18px] pt-[10px]" style={{ paddingLeft: THREAD_LIST_COMPACT_INSET }}>
- <View
- className={cn(
- "gap-[3px] pb-[10px]",
- Platform.OS !== "android" && !props.isLast && "border-b border-separator",
- )}
- >
- <View className="flex-row items-center justify-between gap-2">
- <Text
- className={cn(
- "flex-1 text-lg font-t3-bold",
- visuallySelected
- ? "text-thread-selected-foreground"
- : compact
- ? "text-foreground"
- : "text-drawer-foreground",
- )}
- numberOfLines={1}
- >
- {thread.title}
- </Text>
- <View className="flex-row items-center gap-2">
- {props.hasQueuedMessages ? (
- <QueuedMessageIcon selected={visuallySelected && Platform.OS !== "android"} />
- ) : null}
- {statusPill}
- <Text
- className={cn(
- "text-base tabular-nums",
- visuallySelected
- ? "text-thread-selected-foreground-muted"
- : "text-drawer-foreground-muted",
- )}
- >
- {timestamp}
- </Text>
- <SymbolView
- name="chevron.right"
- size={13}
- tintColorClassName="accent-icon-subtle"
- type="monochrome"
- />
- </View>
- </View>
- {props.searchMatch ? (
- <ThreadSearchMatchExcerpt
- compact
- sidebar={!compact}
- match={props.searchMatch}
- query={props.searchQuery ?? ""}
- selected={visuallySelected}
- />
- ) : null}
- {subtitleRow}
- </View>
- </View>
- </RowPressable>
- ) : (
- <RowPressable
- key={`${thread.environmentId}:${thread.id}`}
- interactionClassName="bg-thread-hover"
- interactionOpacity={visuallySelected ? 0 : 1}
- accessibilityHint="Opens the thread"
- accessibilityLabel={threadAccessibilityLabel}
- accessibilityRole="button"
- accessibilityState={{ selected }}
- onPress={() => {
- close();
- onSelectThread(thread);
- }}
- style={{
- backgroundColor: visuallySelected ? selectedBackgroundColor : backgroundColor,
- borderRadius: Platform.OS === "android" ? 20 : SIDEBAR_ROW_RADIUS,
- minHeight: 64,
- justifyContent: "center",
- paddingHorizontal: 12,
- paddingVertical: 10,
- }}
- >
- <View className="gap-[3px]">
- <View className="flex-row items-center justify-between gap-2">
- <Text
- className={cn(
- "flex-1 text-base font-t3-medium",
- visuallySelected
- ? "text-thread-selected-foreground"
- : compact
- ? "text-foreground"
- : "text-drawer-foreground",
- )}
- numberOfLines={1}
- >
- {thread.title}
- </Text>
- <View className="flex-row items-center gap-2">
- {props.hasQueuedMessages ? (
- <QueuedMessageIcon selected={visuallySelected && Platform.OS !== "android"} />
- ) : null}
- {statusPill}
- <Text
- className={cn(
- "text-xs tabular-nums",
- visuallySelected
- ? "text-thread-selected-foreground-muted"
- : compact
- ? "text-foreground-muted"
- : "text-drawer-foreground-muted",
- )}
- numberOfLines={1}
- >
- {timestamp}
- </Text>
- </View>
- </View>
- {props.searchMatch ? (
- <ThreadSearchMatchExcerpt
- sidebar={!compact}
- match={props.searchMatch}
- query={props.searchQuery ?? ""}
- selected={visuallySelected}
- />
- ) : null}
- {subtitleRow}
- </View>
- </RowPressable>
- );
-
- return (
- <ThreadSwipeable
- threadKey={`${thread.environmentId}:${thread.id}`}
- backgroundColor={backgroundColor}
- containerStyle={
- Platform.OS === "android"
- ? { borderRadius: 20, overflow: "hidden", marginHorizontal: 8, marginVertical: 2 }
- : compact
- ? undefined
- : { borderRadius: SIDEBAR_ROW_RADIUS, overflow: "hidden" }
- }
- enableTrackpadSwipe
- fullSwipeWidth={props.fullSwipeWidth ?? windowWidth - 32}
- onDelete={handleDelete}
- onSwipeableClose={props.onSwipeableClose}
- onSwipeableWillOpen={props.onSwipeableWillOpen}
- primaryAction={primaryAction}
- resetKey={`${thread.environmentId}:${thread.id}`}
- simultaneousWithExternalGesture={props.simultaneousSwipeGesture}
- threadTitle={thread.title}
- >
- {(close) => (
- // Messages-style row actions on long-press. iOS: a real
- // UIContextMenuInteraction with the row as the zoom preview (needs the
- // patched @react-native-menu, see
- // patches/@[email protected] — in long-press mode the
- // interaction is hosted by the component view and the underlying
- // UIButton passes touches through, so row taps keep working). Android:
- // ControlPillMenu injects onLongPress into the row and anchors the
- // token-styled dropdown to it; taps and swipes are untouched.
- <ControlPillMenu
- actions={menuActions}
- onPressAction={handleMenuAction}
- shouldOpenOnLongPress
- >
- {rowContent(close)}
- </ControlPillMenu>
- )}
- </ThreadSwipeable>
- );
-});
diff --git a/apps/mobile/src/features/threads/threadListV2.test.ts b/apps/mobile/src/features/threads/threadListV2.test.ts
index 15f875d7225..3c010315515 100644
--- a/apps/mobile/src/features/threads/threadListV2.test.ts
+++ b/apps/mobile/src/features/threads/threadListV2.test.ts
@@ -30,7 +30,6 @@ import {
buildThreadListV2ListItems,
getThreadListV2OrderedSection,
isThreadListV2ListItem,
- resolveThreadListV2Enabled,
resolveThreadListV2SnoozeMenuSelection,
resolveThreadListV2SnoozeGateExpiryMs,
resolveThreadListV2Status,
@@ -125,29 +124,6 @@ describe("resolveThreadListV2SnoozeMenuSelection", () => {
});
});
-describe("resolveThreadListV2Enabled", () => {
- it("defaults on when the device has never chosen", () => {
- expect(
- resolveThreadListV2Enabled({ legacyPreference: undefined, preferencesLoaded: true }),
- ).toBe(true);
- });
-
- it("honors an explicit legacy opt-in", () => {
- expect(resolveThreadListV2Enabled({ legacyPreference: true, preferencesLoaded: true })).toBe(
- false,
- );
- expect(resolveThreadListV2Enabled({ legacyPreference: false, preferencesLoaded: true })).toBe(
- true,
- );
- });
-
- it("holds the default while preferences are still loading so the list does not remount", () => {
- expect(
- resolveThreadListV2Enabled({ legacyPreference: undefined, preferencesLoaded: false }),
- ).toBe(true);
- });
-});
-
describe("resolveThreadListV2Status", () => {
it("prioritizes approval over a running session", () => {
const thread = makeThread({
diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.ts
index d2f2d453905..9a876c899ac 100644
--- a/apps/mobile/src/features/threads/threadListV2.ts
+++ b/apps/mobile/src/features/threads/threadListV2.ts
@@ -116,26 +116,6 @@ export function resolveThreadListV2SnoozeGateExpiryMs(
export const THREAD_LIST_V2_SETTLED_INITIAL_COUNT = 10;
export const THREAD_LIST_V2_SETTLED_PAGE_COUNT = 25;
-/**
- * The flat Thread List v2 is the default on every app variant; the Settings →
- * Legacy toggle opts a device back into the grouped legacy list. Preferences
- * persist as sparse patches, so `undefined` genuinely means "never chosen".
- *
- * `preferencesLoaded` guards the startup window: preferences load
- * asynchronously, and rendering one list before the stored choice arrives would
- * remount the whole thing a tick later. While loading, hold the default — that
- * is where every device without an explicit legacy opt-in lands anyway.
- */
-export function resolveThreadListV2Enabled(input: {
- readonly legacyPreference: boolean | undefined;
- readonly preferencesLoaded: boolean;
-}): boolean {
- if (!input.preferencesLoaded) {
- return true;
- }
- return input.legacyPreference !== true;
-}
-
export function resolveThreadListV2Status(
thread: Pick<EnvironmentThreadShell, "hasPendingApprovals" | "hasPendingUserInput" | "session">,
): ThreadListV2Status {
diff --git a/apps/mobile/src/features/threads/threadPresentation.ts b/apps/mobile/src/features/threads/threadPresentation.ts
deleted file mode 100644
index b5f286937e0..00000000000
--- a/apps/mobile/src/features/threads/threadPresentation.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-import type { StatusTone } from "../../components/StatusPill";
-import type { OrchestrationLatestTurn, OrchestrationSession } from "@t3tools/contracts";
-import { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
-
-export type ThreadStatusKind =
- | "pending-approval"
- | "awaiting-input"
- | "working"
- | "connecting"
- | "error"
- | "plan-ready";
-
-export interface ThreadStatusPresentation extends StatusTone {
- readonly kind: ThreadStatusKind;
- /** Whether the indicator represents in-flight activity. */
- readonly pulse: boolean;
-}
-
-function isLatestTurnSettled(
- latestTurn: OrchestrationLatestTurn | null,
- session: OrchestrationSession | null,
-): boolean {
- if (!latestTurn?.startedAt) return false;
- if (!latestTurn.completedAt) return false;
- if (!session) return true;
- return session.status !== "running";
-}
-
-/**
- * Resolves the user-facing status of a thread, in priority order. Returns
- * `null` for quiescent threads so rows stay free of "Idle"-style noise.
- * Mirrors `resolveThreadStatusPill` in apps/web/src/components/Sidebar.logic.ts.
- */
-export function resolveThreadStatus(
- thread: EnvironmentThreadShell,
-): ThreadStatusPresentation | null {
- if (thread.hasPendingApprovals) {
- return {
- kind: "pending-approval",
- label: "Needs Approval",
- pillClassName: "bg-warning",
- textClassName: "text-warning-foreground",
- pulse: false,
- };
- }
-
- if (thread.hasPendingUserInput) {
- return {
- kind: "awaiting-input",
- label: "Awaiting Input",
- pillClassName: "bg-adaptive-indigo-500-a12-a16",
- textClassName: "text-adaptive-indigo-600-300",
- pulse: false,
- };
- }
-
- if (thread.session?.status === "running") {
- return {
- kind: "working",
- label: "Working",
- pillClassName: "bg-adaptive-sky-500-a12-a16",
- textClassName: "text-adaptive-sky-600-400",
- pulse: true,
- };
- }
-
- if (thread.session?.status === "starting") {
- return {
- kind: "connecting",
- label: "Connecting",
- pillClassName: "bg-adaptive-sky-500-a12-a16",
- textClassName: "text-adaptive-sky-600-400",
- pulse: true,
- };
- }
-
- if (thread.session?.status === "error" || thread.latestTurn?.state === "error") {
- return {
- kind: "error",
- label: "Error",
- pillClassName: "bg-danger",
- textClassName: "text-danger-foreground",
- pulse: false,
- };
- }
-
- const hasPlanReadyPrompt =
- thread.interactionMode === "plan" &&
- isLatestTurnSettled(thread.latestTurn, thread.session) &&
- thread.hasActionableProposedPlan;
- if (hasPlanReadyPrompt) {
- return {
- kind: "plan-ready",
- label: "Plan Ready",
- pillClassName: "bg-adaptive-violet-500-a12-a16",
- textClassName: "text-adaptive-violet-600-400",
- pulse: false,
- };
- }
-
- return null;
-}
diff --git a/apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts b/apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts
deleted file mode 100644
index 2672942c2d3..00000000000
--- a/apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { useAtomValue } from "@effect/atom-react";
-import { AsyncResult } from "effect/unstable/reactivity";
-
-import { mobilePreferencesAtom } from "../../state/preferences";
-import { resolveThreadListV2Enabled } from "./threadListV2";
-
-/**
- * Resolved Thread List v2 state: on unless the device opted into the legacy
- * grouped list (Settings → Legacy). Every consumer must read through this
- * rather than the raw preference, which is undefined until explicitly chosen.
- */
-export function useThreadListV2Enabled(): boolean {
- const preferencesResult = useAtomValue(mobilePreferencesAtom);
- const loaded = AsyncResult.isSuccess(preferencesResult);
- return resolveThreadListV2Enabled({
- legacyPreference: loaded ? preferencesResult.value.legacyThreadListEnabled : undefined,
- preferencesLoaded: loaded,
- });
-}
diff --git a/apps/mobile/src/persistence/mobile-preferences.ts b/apps/mobile/src/persistence/mobile-preferences.ts
index 508630b1e58..9514efdff42 100644
--- a/apps/mobile/src/persistence/mobile-preferences.ts
+++ b/apps/mobile/src/persistence/mobile-preferences.ts
@@ -33,14 +33,6 @@ export interface Preferences {
/** @deprecated Kept temporarily so older OTA bundles retain the selected mode. */
readonly projectGroupingEnabled?: boolean;
readonly projectGroupingMode?: SidebarProjectGroupingMode;
- /**
- * Device-local mirror of the web `legacySidebarEnabled` setting. Mobile has
- * no client-settings sync, so the legacy grouped thread list is opted into
- * per device. Deliberately a fresh key (was `threadListV2Enabled`, an
- * opt-out): sanitizing drops the old key, so every device resets to the
- * default flat list — see `resolveThreadListV2Enabled`.
- */
- readonly legacyThreadListEnabled?: boolean;
/** Device-local counterpart of desktop's `planModeEnabled` legacy flag. */
readonly planModeEnabled?: boolean;
/** Model favorites belong to this device, like the web client setting. */
@@ -107,7 +99,6 @@ function sanitizePreferences(parsed: Preferences): Preferences {
composerEnterBehavior?: ComposerEnterBehavior;
projectGroupingEnabled?: boolean;
projectGroupingMode?: SidebarProjectGroupingMode;
- legacyThreadListEnabled?: boolean;
planModeEnabled?: boolean;
modelFavorites?: Preferences["modelFavorites"];
threadListSettledShelfExpanded?: boolean;
@@ -176,9 +167,6 @@ function sanitizePreferences(parsed: Preferences): Preferences {
) {
preferences.projectGroupingMode = parsed.projectGroupingMode;
}
- if (typeof parsed.legacyThreadListEnabled === "boolean") {
- preferences.legacyThreadListEnabled = parsed.legacyThreadListEnabled;
- }
if (typeof parsed.planModeEnabled === "boolean") {
preferences.planModeEnabled = parsed.planModeEnabled;
}