@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 36 lines 1.17 KB
Raw
1 import type { ScopedThreadRef } from "@t3tools/contracts";
2 import { flushSync } from "react-dom";
3 import { dispatchCommandPalette } from "../commandPaletteStore";
4 import { SidebarPointerSensor } from "./Sidebar.pointer";
5 import {
6 dropThreadContext,
7 endThreadContextDrag,
8 moveThreadContextDrag,
9 } from "./chat/threadContextDrag";
10
11 export function startPaletteThreadDrag(
12 event: PointerEvent,
13 thread: ScopedThreadRef,
14 title: string,
15 ) {
16 if (!event.isPrimary || event.button !== 0 || event.pointerType === "touch") return;
17 // The document-owned sensor must survive closing and unmounting the palette on activation.
18 return new SidebarPointerSensor({
19 event,
20 active: `${thread.environmentId}:${thread.threadId}`,
21 options: {
22 distance: 6,
23 onAttach: () => {},
24 onFinish: endThreadContextDrag,
25 onDrop: (point) => dropThreadContext(point, [{ ...thread, title }]),
26 },
27 onStart: () => {
28 flushSync(() => dispatchCommandPalette({ _tag: "SetOpen", open: false }));
29 },
30 onMove: (point) => moveThreadContextDrag(point, { title, count: 1 }),
31 onPending: () => {},
32 onAbort: () => {},
33 onCancel: () => {},
34 onEnd: () => {},
35 });
36 }