Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): fix thread jumping after reorder (#7103)
Illia Panasenko1afe5545b7d0
diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.tsindex c6e113a44..ba75f2eaa 100644--- a/apps/web/src/components/Sidebar.logic.test.ts+++ b/apps/web/src/components/Sidebar.logic.test.ts@@ -1,5 +1,7 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";+import { defaultAnimateLayoutChanges, type AnimateLayoutChanges } from "@dnd-kit/sortable";import {+ animatePinnedLayoutChanges,archiveSelectedThreadEntries,buildBulkTitleRegenerationContextMenuItem,buildMultiSelectThreadContextMenuItems,@@ -53,6 +55,32 @@ import {const localEnvironmentId = EnvironmentId.make("environment-local");+describe("animatePinnedLayoutChanges", () => {+ const baseArgs: Parameters<AnimateLayoutChanges>[0] = {+ active: null,+ containerId: "pinned-threads",+ isDragging: false,+ isSorting: false,+ id: "thread-a",+ index: 1,+ items: ["thread-b", "thread-a"],+ newIndex: 0,+ previousItems: ["thread-a", "thread-b"],+ previousContainerId: "pinned-threads",+ transition: { duration: 200, easing: "ease" },+ wasDragging: true,+ };++ it("does not replay layout movement after the pointer is released", () => {+ expect(defaultAnimateLayoutChanges(baseArgs)).toBe(true);+ expect(animatePinnedLayoutChanges(baseArgs)).toBe(false);+ });++ it("keeps layout movement while the user is sorting", () => {+ expect(animatePinnedLayoutChanges({ ...baseArgs, isSorting: true })).toBe(true);+ });+});+describe("shouldNavigateAfterProjectRemoval", () => {const projectThreads = [{ environmentId: "environment-local", id: "thread-1" }];diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.tsindex 9cb09219d..747fc07d3 100644--- a/apps/web/src/components/Sidebar.logic.ts+++ b/apps/web/src/components/Sidebar.logic.ts@@ -1,4 +1,5 @@import * as React from "react";+import { defaultAnimateLayoutChanges, type AnimateLayoutChanges } from "@dnd-kit/sortable";import type { ContextMenuItem } from "@t3tools/contracts";import type { SidebarProjectSortOrder, SidebarThreadSortOrder } from "@t3tools/contracts/settings";import {@@ -23,6 +24,12 @@ export const THREAD_JUMP_HINT_SHOW_DELAY_MS = 100;// it small; cold opens still render instantly from the cached snapshot.export const SIDEBAR_THREAD_PREWARM_LIMIT = 3;+// The list already reaches its destination through sortable transforms while+// the pointer is down. dnd-kit's default also animates the committed DOM order+// after release, replaying the same movement across every affected row.+export const animatePinnedLayoutChanges: AnimateLayoutChanges = (args) =>+ args.isSorting ? defaultAnimateLayoutChanges(args) : false;+type SidebarProject = {id: string;title: string;diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex cabb4db4c..0c30a5b6b 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -121,6 +121,7 @@ import type { SidebarThreadSummary } from "../types";import { cn } from "~/lib/utils";import { buildThreadActionMenuItems } from "./threadActionMenu.logic";import {+ animatePinnedLayoutChanges,buildBulkTitleRegenerationContextMenuItem,formatWorkingDurationLabel,firstValidTimestampMs,@@ -448,6 +449,7 @@ function SortablePinnedThreadRow(props: {}) {const { listeners, setNodeRef, transform, transition, isDragging } = useSortable({id: props.id,+ animateLayoutChanges: animatePinnedLayoutChanges,});return props.children({ listeners, setNodeRef, transform, transition, isDragging });}