TypeScript
fix(web): Working threads can be dragged into chat as references again (#19697)
Theo Browne8f026485df09
diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.tsindex e8149ae0026..15acf606e8a 100644--- a/apps/web/src/components/Sidebar.logic.test.ts+++ b/apps/web/src/components/Sidebar.logic.test.ts@@ -2242,6 +2242,33 @@ describe("Working shelf (beta)", () => {expect(resolveSidebarDropVerb("active", "working")).toBeNull();});+ it.each([+ ["pinned", "p1"],+ ["active", "a2"],+ ["settled", "s1"],+ ] as const)(+ "does not move a Working thread into %s when its reference drag ends in the sidebar",+ (section, overKey) => {+ const target = resolveSidebarDropTarget(items, "w1", overKey);+ expect(target?.section).toBe(section);+ expect(+ planSidebarThreadDrop({+ activeKey: "w1",+ activeSection: "working",+ target: target!,+ pinnedOrder: ["p1"],+ pinnedKeysById: new Map([["p1", "m"]]),+ activeOrder: ["a1", "a2"],+ activeKeysById: new Map([+ ["a1", "f"],+ ["a2", "t"],+ ]),+ activeTimeOrdered: true,+ }),+ ).toEqual({ kind: "none" });+ },+ );+it("arranges the rows it can write when another row's server cannot store an order", () => {const plan = planSidebarThreadDrop({activeKey: "a2",diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.tsindex 94db97c388a..d44bc6854e5 100644--- a/apps/web/src/components/Sidebar.logic.ts+++ b/apps/web/src/components/Sidebar.logic.ts@@ -115,7 +115,8 @@ export const animateSidebarLayoutChanges: AnimateLayoutChanges = (args) =>// Snoozed rows can leave the shelf, but dropping into it is not supported// because snoozing requires a wake time. The Working shelf (beta) follows live-// status, so it is neither a drag source nor a destination.+// status, so its rows only drag out as chat context, never between sidebar+// sections.export type SidebarSection = "pinned" | "active" | "working" | "snoozed" | "settled";@@ -290,6 +291,7 @@ export function planSidebarThreadDrop(input: {activeKeysById,activeReorderableKeys,} = input;+ if (activeSection === "working") return { kind: "none" };if (input.supportsSettlement === false && (target.section === "settled" || activeSettled)) {return { kind: "none" };}diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex d097eba3ae5..b955323c9a0 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -3314,7 +3314,8 @@ export default function Sidebar() {listMotionRef.current?.update(false);};- const isContextDrag = dragState?.contextDrag === true;+ // Working rows can supply chat context, but never preview sidebar movement.+ const isContextDrag = dragState?.contextDrag === true || dragState?.activeSection === "working";const dragTargetSection = isContextDrag ? null : (dragState?.targetSection ?? null);const finishThreadDrag = (started: boolean) => {dragSensorRef.current = null;@@ -4799,7 +4800,6 @@ export default function Sidebar() {contextDrag={isContextDrag}sortableDisabled={renamingThreadKey === threadKey ||- section === "working" ||!draggableThreadKeys.has(threadKey) ||optimisticDrop !== null}