Skip to content
This repository was archived by the owner on Oct 10, 2026. It is now read-only.

Commit c13a021

Browse files
t3dotggclaude
andauthored
feat: default sidebar v2 on for nightly and dev builds (pingdotgg#4491)
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent 476d69c commit c13a021

17 files changed

Lines changed: 312 additions & 36 deletions

‎apps/desktop/src/settings/DesktopClientSettings.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const clientSettings: ClientSettings = {
3030
sidebarThreadSortOrder: "created_at",
3131
sidebarThreadPreviewCount: 6,
3232
sidebarV2Enabled: false,
33+
sidebarV2ConfiguredByUser: false,
3334
timestampFormat: "24-hour",
3435
wordWrap: true,
3536
};

‎apps/mobile/src/features/home/HomeHeader.tsx‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { EnvironmentId, SidebarThreadSortOrder } from "@t3tools/contracts";
22
import type { MenuAction } from "@react-native-menu/menu";
3-
import { useAtomValue } from "@effect/atom-react";
4-
import { AsyncResult } from "effect/unstable/reactivity";
53
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
64
import { useCallback, useMemo, useRef } from "react";
75
import { Platform, Pressable, Text as RNText, TextInput, View } from "react-native";
@@ -12,7 +10,7 @@ import { ControlPillMenu } from "../../components/ControlPill";
1210
import { SymbolView } from "../../components/AppSymbol";
1311
import { T3Wordmark } from "../../components/T3Wordmark";
1412
import { useThemeColor } from "../../lib/useThemeColor";
15-
import { mobilePreferencesAtom } from "../../state/preferences";
13+
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
1614
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
1715
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
1816
import { createNativeMailSearchToolbarItem } from "../layout/native-mail-search-toolbar";
@@ -59,21 +57,14 @@ function checkedMenuState(checked: boolean) {
5957
return checked ? ("on" as const) : undefined;
6058
}
6159

62-
/** Thread List v2 lays the list out in fixed creation order, so the
63-
sort/group filter controls would be silently ignored — hide them and
64-
key the "customized" icon state off the environment filter alone. */
65-
function useThreadListV2FilterGate() {
66-
const preferencesResult = useAtomValue(mobilePreferencesAtom);
67-
return (
68-
AsyncResult.isSuccess(preferencesResult) && preferencesResult.value.threadListV2Enabled === true
69-
);
70-
}
71-
7260
function AndroidHomeHeader(props: HomeHeaderProps) {
7361
const insets = useSafeAreaInsets();
7462
const iconColor = useThemeColor("--color-icon");
7563
const mutedColor = useThemeColor("--color-foreground-muted");
76-
const threadListV2Enabled = useThreadListV2FilterGate();
64+
// Thread List v2 lays the list out in fixed creation order, so the
65+
// sort/group filter controls would be silently ignored — hide them and
66+
// key the "customized" icon state off the environment filter alone.
67+
const threadListV2Enabled = useThreadListV2Enabled();
7768
const hasCustomListOptions = threadListV2Enabled
7869
? props.selectedEnvironmentId !== null || props.selectedProjectKey !== null
7970
: hasCustomHomeListOptions(props);
@@ -291,7 +282,10 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
291282
function IosHomeHeader(props: HomeHeaderProps) {
292283
const searchBarRef = useRef<SearchBarCommands>(null);
293284
const iconColor = useThemeColor("--color-icon");
294-
const threadListV2Enabled = useThreadListV2FilterGate();
285+
// Thread List v2 lays the list out in fixed creation order, so the
286+
// sort/group filter controls would be silently ignored — hide them and
287+
// key the "customized" icon state off the environment filter alone.
288+
const threadListV2Enabled = useThreadListV2Enabled();
295289
const hasCustomListOptions = threadListV2Enabled
296290
? props.selectedEnvironmentId !== null || props.selectedProjectKey !== null
297291
: hasCustomHomeListOptions(props);

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import type { SavedRemoteConnection } from "../../lib/connection";
2727
import { scopedProjectKey } from "../../lib/scopedEntities";
2828
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
2929
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
30+
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
3031
import { environmentServerConfigsAtom } from "../../state/server";
3132
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
3233
import {
@@ -181,9 +182,7 @@ export function HomeScreen(props: HomeScreenProps) {
181182
ReadonlyMap<string, HomeGroupDisplayState>
182183
>(() => new Map());
183184
const preferencesResult = useAtomValue(mobilePreferencesAtom);
184-
const threadListV2Enabled =
185-
AsyncResult.isSuccess(preferencesResult) &&
186-
preferencesResult.value.threadListV2Enabled === true;
185+
const threadListV2Enabled = useThreadListV2Enabled();
187186
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
188187
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
189188
const listRef = useRef<LegendListRef | null>(null);

‎apps/mobile/src/features/settings/SettingsRouteScreen.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
4646
import { runtime } from "../../lib/runtime";
4747
import { useThemeColor } from "../../lib/useThemeColor";
4848
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
49+
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
4950
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
5051
import { SettingsRow } from "./components/SettingsRow";
5152
import { SettingsSection } from "./components/SettingsSection";
@@ -555,11 +556,8 @@ function GeneralSettingsSection() {
555556
* the counterpart of web's Settings → Beta backed by mobile preferences.
556557
*/
557558
function BetaSettingsSection() {
558-
const preferencesResult = useAtomValue(mobilePreferencesAtom);
559559
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
560-
const threadListV2Enabled = AsyncResult.isSuccess(preferencesResult)
561-
? preferencesResult.value.threadListV2Enabled === true
562-
: false;
560+
const threadListV2Enabled = useThreadListV2Enabled();
563561

564562
return (
565563
<View className="gap-3">

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
import { LegendList } from "@legendapp/list/react-native";
77
import type { MenuAction } from "@react-native-menu/menu";
88
import { useAtomValue } from "@effect/atom-react";
9-
import { AsyncResult } from "effect/unstable/reactivity";
109
import type { EnvironmentId } from "@t3tools/contracts";
1110
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
1211
import type { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent } from "react-native";
@@ -25,7 +24,7 @@ import { NativeStackScreenOptions } from "../../native/StackHeader";
2524
import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
2625
import { useThemeColor } from "../../lib/useThemeColor";
2726
import { useProjects, useThreadShells } from "../../state/entities";
28-
import { mobilePreferencesAtom } from "../../state/preferences";
27+
import { useThreadListV2Enabled } from "./use-thread-list-v2-enabled";
2928
import { environmentServerConfigsAtom } from "../../state/server";
3029
import { usePendingNewTasks, type PendingNewTask } from "../../state/use-pending-new-tasks";
3130
import { useWorkspaceState } from "../../state/workspace";
@@ -196,10 +195,7 @@ function ThreadNavigationSidebarPane(
196195
const sidebarScrollGesture = useMemo(() => Gesture.Native(), []);
197196
const { archiveThread, confirmDeleteThread, settleThread, unsettleThread } =
198197
useThreadListActions();
199-
const preferencesResult = useAtomValue(mobilePreferencesAtom);
200-
const threadListV2Enabled =
201-
AsyncResult.isSuccess(preferencesResult) &&
202-
preferencesResult.value.threadListV2Enabled === true;
198+
const threadListV2Enabled = useThreadListV2Enabled();
203199
const pendingTasks = usePendingNewTasks();
204200
const { openPendingTask, confirmDeletePendingTask } = usePendingTaskListActions();
205201
const environments = useMemo(

‎apps/mobile/src/features/threads/threadListV2.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { describe, expect, it } from "vite-plus/test";
44

55
import {
66
buildThreadListV2Items,
7+
resolveThreadListV2Enabled,
78
resolveThreadListV2Status,
89
sortThreadsForListV2,
910
} from "./threadListV2";
@@ -38,6 +39,47 @@ function makeThread(
3839

3940
const NOW = "2026-06-02T00:00:00.000Z";
4041

42+
describe("resolveThreadListV2Enabled", () => {
43+
it.each(["development", "preview"])("defaults on for the %s variant", (appVariant) => {
44+
expect(
45+
resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: true, appVariant }),
46+
).toBe(true);
47+
});
48+
49+
it.each(["production", undefined])("defaults off for the %s variant", (appVariant) => {
50+
expect(
51+
resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: true, appVariant }),
52+
).toBe(false);
53+
});
54+
55+
it("prefers an explicit device choice over the variant default", () => {
56+
expect(
57+
resolveThreadListV2Enabled({
58+
preference: false,
59+
preferencesLoaded: true,
60+
appVariant: "preview",
61+
}),
62+
).toBe(false);
63+
expect(
64+
resolveThreadListV2Enabled({
65+
preference: true,
66+
preferencesLoaded: true,
67+
appVariant: "production",
68+
}),
69+
).toBe(true);
70+
});
71+
72+
it("holds v1 while preferences are still loading so the list does not remount", () => {
73+
expect(
74+
resolveThreadListV2Enabled({
75+
preference: undefined,
76+
preferencesLoaded: false,
77+
appVariant: "development",
78+
}),
79+
).toBe(false);
80+
});
81+
});
82+
4183
describe("resolveThreadListV2Status", () => {
4284
it("prioritizes approval over a running session", () => {
4385
const thread = makeThread({

‎apps/mobile/src/features/threads/threadListV2.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,37 @@ export type ThreadListV2Status = "approval" | "input" | "working" | "failed" | "
1818
export const THREAD_LIST_V2_SETTLED_INITIAL_COUNT = 10;
1919
export const THREAD_LIST_V2_SETTLED_PAGE_COUNT = 25;
2020

21+
/**
22+
* Whether Thread List v2 is on by default for an app variant. The `development`
23+
* and `preview` variants are mobile's nightly equivalents and opt in;
24+
* `production` stays on v1. Counterpart of web's `resolveSidebarV2Default`.
25+
*/
26+
export function resolveThreadListV2Default(appVariant: unknown): boolean {
27+
return appVariant === "development" || appVariant === "preview";
28+
}
29+
30+
/**
31+
* Resolved Thread List v2 state: the device-local preference if the user has
32+
* set one, otherwise the default for this app variant. Preferences persist as
33+
* sparse patches, so `undefined` genuinely means "never chosen".
34+
*
35+
* `preferencesLoaded` guards the startup window: preferences load
36+
* asynchronously, and treating "still loading" as "never chosen" would mount
37+
* v2 on a development build and then flip to v1 once a stored opt-out arrives,
38+
* remounting the whole list. While loading, hold v1 — the state both variants
39+
* already start from.
40+
*/
41+
export function resolveThreadListV2Enabled(input: {
42+
readonly preference: boolean | undefined;
43+
readonly preferencesLoaded: boolean;
44+
readonly appVariant: unknown;
45+
}): boolean {
46+
if (!input.preferencesLoaded) {
47+
return false;
48+
}
49+
return input.preference ?? resolveThreadListV2Default(input.appVariant);
50+
}
51+
2152
export function resolveThreadListV2Status(
2253
thread: Pick<EnvironmentThreadShell, "hasPendingApprovals" | "hasPendingUserInput" | "session">,
2354
): ThreadListV2Status {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useAtomValue } from "@effect/atom-react";
2+
import { AsyncResult } from "effect/unstable/reactivity";
3+
import Constants from "expo-constants";
4+
5+
import { mobilePreferencesAtom } from "../../state/preferences";
6+
import { resolveThreadListV2Enabled } from "./threadListV2";
7+
8+
/**
9+
* Resolved Thread List v2 state: the device-local preference if the user has
10+
* set one, otherwise the default for this app variant (on for development and
11+
* preview, off for production). Every consumer must read through this rather
12+
* than the raw preference, which is undefined until explicitly chosen.
13+
*
14+
* Kept out of `state/preferences.ts` so that module stays importable from node
15+
* test environments, which have no `__DEV__` for expo-constants.
16+
*/
17+
export function useThreadListV2Enabled(): boolean {
18+
const preferencesResult = useAtomValue(mobilePreferencesAtom);
19+
const loaded = AsyncResult.isSuccess(preferencesResult);
20+
return resolveThreadListV2Enabled({
21+
preference: loaded ? preferencesResult.value.threadListV2Enabled : undefined,
22+
preferencesLoaded: loaded,
23+
appVariant: Constants.expoConfig?.extra?.appVariant,
24+
});
25+
}

‎apps/mobile/src/persistence/mobile-preferences.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export interface Preferences {
2626
/**
2727
* Device-local mirror of the web beta's `sidebarV2Enabled`. Mobile has no
2828
* client-settings sync, so the flat v2 thread list is opted into per
29-
* device.
29+
* device. Undefined means the user has never chosen, in which case the app
30+
* variant decides — see `resolveThreadListV2Enabled`.
3031
*/
3132
readonly threadListV2Enabled?: boolean;
3233
}

‎apps/web/src/branding.logic.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,51 @@ export function formatAppDisplayName(input: {
1111
return `${input.baseName} (${input.stageLabel})`;
1212
}
1313

14+
/**
15+
* Whether the sidebar v2 beta is on by default for a build stage.
16+
*
17+
* Nightly and local dev opt in; Alpha and Latest stay on v1. This is resolved
18+
* from the client's own stage label rather than the connected server's version:
19+
* v2 only exists in the client, so a stable client on a nightly server has
20+
* nothing to turn on.
21+
*/
22+
export function resolveSidebarV2Default(stageLabel: string): boolean {
23+
const stage = stageLabel.trim().toLowerCase();
24+
return stage === "nightly" || stage === "dev";
25+
}
26+
27+
/**
28+
* Resolved sidebar v2 state: an explicit choice if the user has made one,
29+
* otherwise the default for this build stage.
30+
*
31+
* A stored `enabled: true` counts as an explicit choice even without the
32+
* companion flag. `true` was never the schema default, so it can only have come
33+
* from the Settings → Beta toggle — settings written before that flag existed
34+
* would otherwise lose the opt-in and drop such users back to v1 on production.
35+
* Mirrors how `normalizeDesktopSettingsDocument` treats a legacy stored
36+
* `updateChannel: "nightly"` as user-configured.
37+
*
38+
* `settingsHydrated` guards the startup window: client settings load
39+
* asynchronously and the pre-hydration snapshot is just the schema defaults, so
40+
* resolving against it would mount one sidebar and swap it out a tick later,
41+
* remounting the tree. While hydrating, hold v1 — where both paths already
42+
* start.
43+
*/
44+
export function resolveSidebarV2Enabled(input: {
45+
readonly enabled: boolean;
46+
readonly configuredByUser: boolean;
47+
readonly settingsHydrated: boolean;
48+
readonly stageLabel: string;
49+
}): boolean {
50+
if (!input.settingsHydrated) {
51+
return false;
52+
}
53+
54+
return input.configuredByUser || input.enabled
55+
? input.enabled
56+
: resolveSidebarV2Default(input.stageLabel);
57+
}
58+
1459
export function resolveServerBackedAppStageLabel(input: {
1560
readonly primaryServerVersion: string | null | undefined;
1661
readonly fallbackStageLabel: string;

0 commit comments

Comments
 (0)