diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index e5b23a2627d9c..64b13f65edbb6 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -379,12 +379,6 @@ export function HomeScreen(props: HomeScreenProps) {
const [settledVisibleCount, setSettledVisibleCount] = useState(
THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
);
- const settledResetKey = `${props.selectedEnvironmentId ?? "all"}:${v2ProjectScopeKey ?? "all"}:${props.searchQuery.trim()}`;
- const [lastSettledResetKey, setLastSettledResetKey] = useState(settledResetKey);
- if (lastSettledResetKey !== settledResetKey) {
- setLastSettledResetKey(settledResetKey);
- setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
- }
const showMoreSettled = () =>
setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT);
const {
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index 681f5d3c6fa0a..da680c463f32d 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -237,12 +237,6 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
const [settledVisibleCount, setSettledVisibleCount] = useState(
THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
);
- const settledResetKey = `${options.selectedEnvironmentId ?? "all"}:${selectedProjectKey ?? "all"}:${props.searchQuery.trim()}`;
- const [lastSettledResetKey, setLastSettledResetKey] = useState(settledResetKey);
- if (lastSettledResetKey !== settledResetKey) {
- setLastSettledResetKey(settledResetKey);
- setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
- }
const showMoreSettled = () =>
setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT);
const {
diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx
index 1a0b4c588d64c..929dac08c8e07 100644
--- a/apps/web/src/components/Sidebar.browser.test.tsx
+++ b/apps/web/src/components/Sidebar.browser.test.tsx
@@ -132,6 +132,57 @@ describe("sidebar header new thread", () => {
});
});
+describe("sidebar settled shelf", () => {
+ // regression: #34291 changing the project filter collapsed an expanded Settled shelf back to 10
+ it("keeps its expanded length when the project filter changes", async () => {
+ using stack = new DisposableStack();
+ localStorage.setItem("t3code:sidebar:settled-expanded", "true");
+ stack.defer(() => localStorage.removeItem("t3code:sidebar:settled-expanded"));
+ const projectA = project("a");
+ const projectB = project("b");
+ const settled = (projectId: ProjectId, index: number) => ({
+ ...threadShell(projectId, index),
+ settledOverride: "settled" as const,
+ });
+ const threads = [
+ ...Array.from({ length: 14 }, (_, index) => settled(projectA.id, index)),
+ ...Array.from({ length: 2 }, (_, index) => settled(projectB.id, 14 + index)),
+ ];
+ vi.mocked(useProjects).mockReturnValue([projectA, projectB]);
+ vi.mocked(useQuietThreadShells).mockReturnValue(threads);
+ // Threads only count as settled once their environment's config has loaded.
+ vi.mocked(useServerConfigs).mockReturnValue(
+ new Map([[projectA.environmentId, { environment: { capabilities: {} } } as never]]),
+ );
+ vi.mocked(useThreadRouteTarget).mockReturnValue(null);
+ vi.mocked(useHandleNewThread).mockReturnValue({
+ activeDraftThread: null,
+ activeThread: null,
+ defaultProjectRef: { environmentId: projectA.environmentId, projectId: projectA.id },
+ defaultProjectFallbackReady: true,
+ handleNewThread: vi.fn().mockResolvedValue(null),
+ routeDraftId: null,
+ routeThreadRef: null,
+ });
+ await using screen = await render(
+
+
+ ,
+ );
+
+ await userEvent.click(screen.getByRole("button", { name: "Show 6 more" }));
+ await expect.element(screen.getByText("Thread 15").first()).toBeInTheDocument();
+
+ await userEvent.click(screen.getByRole("combobox", { name: "Filter threads by project" }));
+ await userEvent.click(screen.getByRole("option", { name: "a" }));
+ await expect.element(screen.getByRole("button", { name: "Settled14" })).toBeInTheDocument();
+ expect(
+ screen.getByRole("button", { name: /^Thread \d+, a$/ }).elements(),
+ "the Settled shelf fell back to its first page",
+ ).toHaveLength(14);
+ });
+});
+
// regression: #38623 unsent drafts are listed above threads but mod+1..9 skipped them
describe("sidebar numbered jumps", () => {
it("numbers the unsent draft at the top before the threads below it", async () => {
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 98ed2224169cd..d3091671f48f6 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -422,7 +422,6 @@ function routeThreadOnly(
// Separate hooks cache maps independently of later Sidebar hooks and preserve dnd-kit inputs.
function useSidebarThreads(input: {
- readonly projectScopeKey: string | null;
readonly scopedProjectKeys: ReadonlySet | null;
readonly serverConfigs: ReadonlyMap;
readonly connectedEnvironmentIds: readonly EnvironmentId[];
@@ -436,7 +435,6 @@ function useSidebarThreads(input: {
readonly keepEmptyFolders: (group: SidebarProjectSnapshot) => boolean;
}) {
const {
- projectScopeKey,
scopedProjectKeys,
serverConfigs,
connectedEnvironmentIds,
@@ -475,15 +473,7 @@ function useSidebarThreads(input: {
// Shared with the old per-project sidebar, so folders keep their open state.
const projectExpandedById = useUiStateStore((store) => store.projectExpandedById);
const setProjectExpanded = useUiStateStore((store) => store.setProjectExpanded);
- const [settledTail, setSettledTail] = useState({
- scopeKey: projectScopeKey,
- count: SETTLED_TAIL_INITIAL_COUNT,
- });
- if (settledTail.scopeKey !== projectScopeKey) {
- setSettledTail({ scopeKey: projectScopeKey, count: SETTLED_TAIL_INITIAL_COUNT });
- }
- const settledVisibleCount =
- settledTail.scopeKey === projectScopeKey ? settledTail.count : SETTLED_TAIL_INITIAL_COUNT;
+ const [settledVisibleCount, setSettledVisibleCount] = useState(SETTLED_TAIL_INITIAL_COUNT);
const partition = partitionSidebarThreads({
threads,
@@ -585,11 +575,7 @@ function useSidebarThreads(input: {
settledCount,
olderSettledShelf,
hiddenSettledCount: Math.max(0, settledCount - visibleSettledThreads.length),
- showMoreSettled: () =>
- setSettledTail((current) => ({
- scopeKey: current.scopeKey,
- count: current.count + SETTLED_TAIL_PAGE_COUNT,
- })),
+ showMoreSettled: () => setSettledVisibleCount((count) => count + SETTLED_TAIL_PAGE_COUNT),
settledShelfExpanded,
toggleSettledShelf: () => setSettledShelfExpanded((value) => !value),
snoozedShelfExpanded,
@@ -1142,7 +1128,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
findThread: (key) => threads.find((candidate) => threadShellKey(candidate) === key),
});
const projectScopeKeys = revealWidensScope ? [] : chosenProjectScopeKeys;
- const projectScopeKey = projectScopeKeys.length === 0 ? null : projectScopeKeys.join("\n");
const toggleProjectScopeKey = (key: string) =>
setProjectScopeKeys(
projectScopeKeys.includes(key)
@@ -1332,7 +1317,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
pinnedKeysById,
activeKeysById,
} = useSidebarThreads({
- projectScopeKey,
scopedProjectKeys,
serverConfigs,
connectedEnvironmentIds,