Skip to content
TypeScript

fix(sidebar): collapse settled and snoozed shelves by default (#9314)

maria31eeb443305a
diff --git a/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts b/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts
index d4599336472..8ffab4e045b 100644
--- a/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts
+++ b/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts
@@ -14,9 +14,9 @@ export function useThreadListV2ShelfPreferences() {
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
const loaded = AsyncResult.isSuccess(preferencesResult);
const snoozedShelfExpanded =
- loaded && preferencesResult.value.threadListV2SnoozedShelfExpanded === true;
+ loaded && preferencesResult.value.threadListSnoozedShelfExpanded === true;
const settledShelfExpanded =
- !loaded || preferencesResult.value.threadListV2SettledShelfExpanded !== false;
+ loaded && preferencesResult.value.threadListSettledShelfExpanded === true;
const snoozedShelfExpandedRef = useRef(snoozedShelfExpanded);
const settledShelfExpandedRef = useRef(settledShelfExpanded);
snoozedShelfExpandedRef.current = snoozedShelfExpanded;
@@ -26,13 +26,13 @@ export function useThreadListV2ShelfPreferences() {
if (!loaded) return;
const expanded = !snoozedShelfExpandedRef.current;
snoozedShelfExpandedRef.current = expanded;
- savePreferences({ threadListV2SnoozedShelfExpanded: expanded });
+ savePreferences({ threadListSnoozedShelfExpanded: expanded });
}, [loaded, savePreferences]);
const toggleSettledShelf = useCallback(() => {
if (!loaded) return;
const expanded = !settledShelfExpandedRef.current;
settledShelfExpandedRef.current = expanded;
- savePreferences({ threadListV2SettledShelfExpanded: expanded });
+ savePreferences({ threadListSettledShelfExpanded: expanded });
}, [loaded, savePreferences]);
return {
diff --git a/apps/mobile/src/lib/storage.test.ts b/apps/mobile/src/lib/storage.test.ts
index a1c7960a570..15e385067dc 100644
--- a/apps/mobile/src/lib/storage.test.ts
+++ b/apps/mobile/src/lib/storage.test.ts
@@ -213,33 +213,35 @@ describe("mobile connection storage", () => {
expect(fallback.updatedAt).toEqual(expect.any(Number));
});
- it("persists Thread List v2 shelf expansion preferences", async () => {
+ it("persists thread list shelf expansion preferences", async () => {
await expect(
savePreferencesPatch({
- threadListV2SettledShelfExpanded: false,
- threadListV2SnoozedShelfExpanded: true,
+ threadListSettledShelfExpanded: false,
+ threadListSnoozedShelfExpanded: true,
}),
).resolves.toEqual({
- threadListV2SettledShelfExpanded: false,
- threadListV2SnoozedShelfExpanded: true,
+ threadListSettledShelfExpanded: false,
+ threadListSnoozedShelfExpanded: true,
});
await expect(loadPreferences()).resolves.toEqual({
- threadListV2SettledShelfExpanded: false,
- threadListV2SnoozedShelfExpanded: true,
+ threadListSettledShelfExpanded: false,
+ threadListSnoozedShelfExpanded: true,
});
expect(JSON.parse(mocks.getPreferencesJson() ?? "")).toEqual({
- threadListV2SettledShelfExpanded: false,
- threadListV2SnoozedShelfExpanded: true,
+ threadListSettledShelfExpanded: false,
+ threadListSnoozedShelfExpanded: true,
});
});
- it("ignores invalid Thread List v2 shelf expansion preference types", async () => {
+ it("drops legacy and invalid thread list shelf expansion preferences", async () => {
mocks.setPreferencesJson(
JSON.stringify({
baseFontSize: 17,
- threadListV2SettledShelfExpanded: "false",
- threadListV2SnoozedShelfExpanded: 1,
+ threadListV2SettledShelfExpanded: true,
+ threadListV2SnoozedShelfExpanded: true,
+ threadListSettledShelfExpanded: "false",
+ threadListSnoozedShelfExpanded: 1,
}),
10,
);
diff --git a/apps/mobile/src/persistence/mobile-preferences.ts b/apps/mobile/src/persistence/mobile-preferences.ts
index cf4c29c6041..f14a73f15cb 100644
--- a/apps/mobile/src/persistence/mobile-preferences.ts
+++ b/apps/mobile/src/persistence/mobile-preferences.ts
@@ -41,10 +41,9 @@ export interface Preferences {
readonly legacyThreadListEnabled?: boolean;
/** Device-local counterpart of desktop's `planModeEnabled` legacy flag. */
readonly planModeEnabled?: boolean;
- /** Undefined preserves the default expanded Settled shelf. */
- readonly threadListV2SettledShelfExpanded?: boolean;
- /** Undefined preserves the default collapsed Snoozed shelf. */
- readonly threadListV2SnoozedShelfExpanded?: boolean;
+ /** Fresh keys reset both shelves to collapsed when users update. */
+ readonly threadListSettledShelfExpanded?: boolean;
+ readonly threadListSnoozedShelfExpanded?: boolean;
}
export class MobilePreferencesLoadError extends Schema.TaggedErrorClass<MobilePreferencesLoadError>()(
@@ -102,8 +101,8 @@ function sanitizePreferences(parsed: Preferences): Preferences {
projectGroupingMode?: SidebarProjectGroupingMode;
legacyThreadListEnabled?: boolean;
planModeEnabled?: boolean;
- threadListV2SettledShelfExpanded?: boolean;
- threadListV2SnoozedShelfExpanded?: boolean;
+ threadListSettledShelfExpanded?: boolean;
+ threadListSnoozedShelfExpanded?: boolean;
} = {};
if (typeof parsed.liveActivitiesEnabled === "boolean") {
@@ -171,11 +170,11 @@ function sanitizePreferences(parsed: Preferences): Preferences {
if (typeof parsed.planModeEnabled === "boolean") {
preferences.planModeEnabled = parsed.planModeEnabled;
}
- if (typeof parsed.threadListV2SettledShelfExpanded === "boolean") {
- preferences.threadListV2SettledShelfExpanded = parsed.threadListV2SettledShelfExpanded;
+ if (typeof parsed.threadListSettledShelfExpanded === "boolean") {
+ preferences.threadListSettledShelfExpanded = parsed.threadListSettledShelfExpanded;
}
- if (typeof parsed.threadListV2SnoozedShelfExpanded === "boolean") {
- preferences.threadListV2SnoozedShelfExpanded = parsed.threadListV2SnoozedShelfExpanded;
+ if (typeof parsed.threadListSnoozedShelfExpanded === "boolean") {
+ preferences.threadListSnoozedShelfExpanded = parsed.threadListSnoozedShelfExpanded;
}
return preferences;
}
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 69f9ea2f30c..0c18c42c8db 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -211,9 +211,9 @@ import {
// stays behind an explicit Show more.
const SETTLED_TAIL_INITIAL_COUNT = 10;
const SETTLED_TAIL_PAGE_COUNT = 25;
-// Keep the v2 key so existing preferences survive the v2-to-default rename.
-const SETTLED_SHELF_EXPANDED_KEY = "t3code:sidebar-v2:settled-expanded";
-const SNOOZED_SHELF_EXPANDED_KEY = "t3code:sidebar-v2:snoozed-expanded";
+// Fresh keys deliberately reset both shelves to collapsed for existing users.
+const SETTLED_SHELF_EXPANDED_KEY = "t3code:sidebar:settled-expanded";
+const SNOOZED_SHELF_EXPANDED_KEY = "t3code:sidebar:snoozed-expanded";
function compactSidebarTimeLabel(label: string): string {
if (label === "just now") return "now";
@@ -2274,7 +2274,7 @@ export default function Sidebar() {
);
const [settledShelfExpanded, setSettledShelfExpanded] = useLocalStorage(
SETTLED_SHELF_EXPANDED_KEY,
- true,
+ false,
Schema.Boolean,
);
const toggleSettledShelf = useCallback(