Skip to content

Commit 6cac280

Browse files
NikitaMGrimmclaude
authored andcommitted
fix(web): allow Working threads to be dragged into chat as references
Imported from #15269 by @NikitaMGrimm. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ab3a3cd commit 6cac280

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

‎apps/web/src/components/Sidebar.logic.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,33 @@ describe("Working shelf (beta)", () => {
22572257
expect(resolveSidebarDropVerb("active", "working")).toBeNull();
22582258
});
22592259

2260+
it.each([
2261+
["pinned", "p1"],
2262+
["active", "a2"],
2263+
["settled", "s1"],
2264+
] as const)(
2265+
"does not move a Working thread into %s when its reference drag ends in the sidebar",
2266+
(section, overKey) => {
2267+
const target = resolveSidebarDropTarget(items, "w1", overKey);
2268+
expect(target?.section).toBe(section);
2269+
expect(
2270+
planSidebarThreadDrop({
2271+
activeKey: "w1",
2272+
activeSection: "working",
2273+
target: target!,
2274+
pinnedOrder: ["p1"],
2275+
pinnedKeysById: new Map([["p1", "m"]]),
2276+
activeOrder: ["a1", "a2"],
2277+
activeKeysById: new Map([
2278+
["a1", "f"],
2279+
["a2", "t"],
2280+
]),
2281+
activeTimeOrdered: true,
2282+
}),
2283+
).toEqual({ kind: "none" });
2284+
},
2285+
);
2286+
22602287
it("arranges the rows it can write when another row's server cannot store an order", () => {
22612288
// None of the rows has a key yet, so the drop needs keys for its
22622289
// neighbors too. "offline" sits on a server that cannot take them.

‎apps/web/src/components/Sidebar.logic.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export const animateSidebarLayoutChanges: AnimateLayoutChanges = (args) =>
129129
// and active threads keep the dragged position; settled threads use time
130130
// order. Snoozed rows can leave the shelf, but dropping into it is not
131131
// supported because snoozing requires a wake time. The Working shelf (beta)
132-
// follows live status, so it is neither a drag source nor a destination.
132+
// follows live status, so its rows only drag out as chat context, never
133+
// between sidebar sections.
133134

134135
export type SidebarSection = "pinned" | "active" | "working" | "snoozed" | "settled";
135136

@@ -333,6 +334,7 @@ export function planSidebarThreadDrop(input: {
333334
activeKeysById,
334335
activeReorderableKeys,
335336
} = input;
337+
if (activeSection === "working") return { kind: "none" };
336338
if (input.supportsSettlement === false && (target.section === "settled" || activeSettled)) {
337339
return { kind: "none" };
338340
}

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,7 +3497,8 @@ export default function Sidebar() {
34973497
readonly targetSection: SidebarSection | null;
34983498
readonly contextDrag: boolean;
34993499
} | null>(null);
3500-
const isContextDrag = dragState?.contextDrag === true;
3500+
// Working rows can supply chat context, but never preview sidebar movement.
3501+
const isContextDrag = dragState?.contextDrag === true || dragState?.activeSection === "working";
35013502
const dragTargetSection = isContextDrag ? null : (dragState?.targetSection ?? null);
35023503
const dragSensorRef = useRef<SidebarPointerSensor | null>(null);
35033504
const contextDragKeyRef = useRef<string | null>(null);
@@ -5422,7 +5423,6 @@ export default function Sidebar() {
54225423
environmentId={thread.environmentId}
54235424
disabled={
54245425
renamingThreadKey === threadKey ||
5425-
section === "working" ||
54265426
!draggableThreadKeys.has(threadKey) ||
54275427
optimisticDrop !== null
54285428
}

0 commit comments

Comments
 (0)