The best way to control Claude Code, Codex and more from any computer or phone
fix(web): drag command palette threads into the composer (#33990)
Yash Singh committed
Nov 10, 2026 at 11:49 UTC
f06bfa69c7c4142de28e9c55a92d3dc52d9c8636
7 files changed
+106
-5
apps/web/src/components/CommandPalette.browser.test.tsx
+51
-1
@@ -2,7 +2,7 @@ import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
2
import { describe, expect, it, vi } from "vite-plus/test";
3
import { page, userEvent } from "vite-plus/test/browser";
4
5
-import { render } from "../../test/render";
5
+import { act, render } from "../../test/render";
6
import { openCommandPalette } from "../commandPaletteBus";
7
import { useCommandPaletteStore } from "../commandPaletteStore";
8
import { makeThreadFixture } from "../test-fixtures";
@@ -26,6 +26,56 @@ function setup(state: { projects?: ReadonlyArray<Project>; threads?: ReadonlyArr
26
}
27
28
describe("CommandPalette open intents", () => {
29
+ it("drags a searched thread into the current composer without navigating", async () => {
30
+ const environmentId = EnvironmentId.make("remote");
31
+ const threadId = ThreadId.make("dragged-thread");
32
+ setup({
33
+ threads: [makeThreadFixture({ environmentId, id: threadId, title: "Drag this thread" })],
34
+ });
35
+ const onDrop = vi.fn();
36
+ await using screen = await render(
37
+ <CommandPalette>
38
+ <div
39
+ data-thread-context-drop="true"
40
+ ref={(node) => {
41
+ node?.addEventListener("t3-thread-context-drop", onDrop);
42
+ }}
43
+ style={{ position: "fixed", bottom: 0, width: 300, height: 100 }}
44
+ >
45
+ Composer
46
+ </div>
47
+ </CommandPalette>,
48
+ );
49
+ const pathname = screen.router?.state.location.pathname;
50
+ openCommandPalette({ query: "Drag this thread" });
51
+ const row = page.getByRole("option", { name: /Drag this thread/ });
52
+ await expect.element(row).toBeVisible();
53
+ const bounds = row.element().getBoundingClientRect();
54
+ const pointer = (type: string, x: number, y: number) =>
55
+ new PointerEvent(type, {
56
+ bubbles: true,
57
+ cancelable: true,
58
+ pointerId: 1,
59
+ isPrimary: true,
60
+ button: 0,
61
+ buttons: type === "pointerup" ? 0 : 1,
62
+ clientX: x,
63
+ clientY: y,
64
+ });
65
+ await act(() => {
66
+ row.element().dispatchEvent(pointer("pointerdown", bounds.x + 20, bounds.y + 10));
67
+ document.dispatchEvent(pointer("pointermove", bounds.x + 30, bounds.y + 20));
68
+ });
69
+ expect(useCommandPaletteStore.getState().open).toBe(false);
70
+ await act(() => {
71
+ document.dispatchEvent(pointer("pointermove", 50, window.innerHeight - 30));
72
+ document.dispatchEvent(pointer("pointerup", 50, window.innerHeight - 30));
73
+ });
74
+ expect(onDrop).toHaveBeenCalledOnce();
75
+ expect((onDrop.mock.calls[0]![0] as CustomEvent).detail).toEqual([{ environmentId, threadId }]);
76
+ expect(screen.router?.state.location.pathname).toBe(pathname);
77
+ });
78
+
79
it("opens New thread in... with focus in the search input, not the Back button", async () => {
80
setup();
81
await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
apps/web/src/components/CommandPalette.drag.ts
new
+36
@@ -0,0 +1,36 @@
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]),
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
+}
apps/web/src/components/CommandPalette.logic.ts
+4
@@ -19,6 +19,7 @@ import {
19
type AddProjectRemoteSourceReadiness,
20
} from "@t3tools/client-runtime/operations/projects";
21
import {
22
+ type ScopedThreadRef,
23
type EnvironmentId,
24
type ProjectId,
25
type EnvironmentMachineKind,
@@ -48,6 +49,7 @@ export function buildLinkedThreadActionItems(
49
return input.threads.map((thread) => ({
50
kind: "action",
51
value: `thread:${input.environmentId}:${thread.id}`,
52
+ threadRef: { environmentId: input.environmentId, threadId: thread.id },
53
title: thread.title || "Untitled thread",
54
description: thread.archivedAt === null ? "Linked thread" : "Archived thread",
55
searchTerms: [input.query, thread.title],
@@ -194,6 +196,7 @@ export interface CommandPaletteItem {
196
readonly timestamp?: string;
197
/** Thread rows rank by this, with use history, instead of by `searchTerms`. */
198
readonly threadSearch?: ThreadSearchSubject;
199
+ readonly threadRef?: ScopedThreadRef;
200
/** Shown in place of the description when the match is not in the title. */
201
readonly matchHint?: SearchMatchHint;
202
readonly icon: ReactNode;
@@ -466,6 +469,7 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThr
469
{
470
kind: "action" as const,
471
value: `thread:${thread.environmentId}:${thread.id}`,
472
+ threadRef: { environmentId: thread.environmentId, threadId: thread.id },
473
searchTerms: [thread.title],
474
threadSearch: threadSearchSubject(
475
{
apps/web/src/components/CommandPalette.tsx
+2
@@ -1,3 +1,4 @@
1
+import { ThreadContextDragGhost } from "./chat/ThreadContextDragGhost";
2
import { threadPullRequestLinkMode } from "@t3tools/client-runtime/thread-pull-request-compatibility";
3
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
4
@@ -308,6 +309,7 @@ export function CommandPalette({ children }: { children: ReactNode }) {
309
310
return (
311
<ComposerHandleContext value={composerHandleRef}>
312
+ <ThreadContextDragGhost />
313
<CommandDialog
314
open={state.open}
315
onOpenChange={(open, eventDetails) => {
apps/web/src/components/CommandPaletteResults.tsx
+11
@@ -1,3 +1,4 @@
1
+import { startPaletteThreadDrag } from "./CommandPalette.drag";
2
import { useLegendListRef } from "~/hooks/useLegendListRef";
3
import { type ResolvedKeybindingsConfig } from "@t3tools/contracts";
4
import { LegendList, type LegendListRef } from "@legendapp/list/react";
@@ -241,6 +242,16 @@ function CommandPaletteResultRow(props: {
242
{...(props.index === undefined ? {} : { index: props.index })}
243
value={props.item.value}
244
active={props.isActive}
245
+ onPointerDown={(event) => {
246
+ if (props.item.threadRef) {
247
+ startPaletteThreadDrag(
248
+ event.nativeEvent,
249
+ props.item.threadRef,
250
+ props.item.searchTitle ??
251
+ (typeof props.item.title === "string" ? props.item.title : "Thread"),
252
+ );
253
+ }
254
+ }}
255
onMouseDown={(event) => {
256
event.preventDefault();
257
}}
apps/web/src/components/Sidebar.tsx
-2
@@ -1,7 +1,6 @@
1
import { attachSidebarTree } from "../lib/sidebarTree";
2
import { type EnvironmentId, type ScopedProjectRef } from "@t3tools/contracts";
3
import type { EnvironmentServerConfig } from "@t3tools/client-runtime/connection";
4
-import { ThreadContextDragGhost } from "./chat/ThreadContextDragGhost";
4
import {
5
dropThreadContext,
6
endThreadContextDrag,
@@ -2992,7 +2991,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2991
const newThreadInProjectShortcutLabel = shortcutLabelForCommand(keybindings, "chat.newLocal");
2992
return (
2993
<>
2995
- <ThreadContextDragGhost />
2994
<SidebarChromeHeader isElectron={isElectron} />
2995
<SidebarContent
2996
ref={sidebarContentRef}
apps/web/src/components/ui/command.tsx
+2
-2
@@ -29,7 +29,7 @@ function CommandDialogTrigger(props: CommandDialogPrimitive.Trigger.Props) {
29
function CommandDialogBackdrop({ className, ...props }: CommandDialogPrimitive.Backdrop.Props) {
30
return (
31
<CommandDialogPrimitive.Backdrop
32
- className={cn(DIALOG_BACKDROP_CLASS, className)}
32
+ className={cn(DIALOG_BACKDROP_CLASS, "data-ending-style:pointer-events-none", className)}
33
data-slot="command-dialog-backdrop"
34
{...props}
35
/>
@@ -74,7 +74,7 @@ function CommandDialogPopup({
74
ref={popupRef}
75
className={cn(
76
DIALOG_POPUP_CLASS,
77
- "pointer-events-auto max-h-105 max-w-xl text-foreground",
77
+ "pointer-events-auto max-h-105 max-w-xl text-foreground data-ending-style:pointer-events-none",
78
className,
79
)}
80
data-slot="command-dialog-popup"