diff --git a/packages/desktop/src/pages/session.tsx b/packages/desktop/src/pages/session.tsx index 08e5f4f01..890401723 100644 --- a/packages/desktop/src/pages/session.tsx +++ b/packages/desktop/src/pages/session.tsx @@ -28,7 +28,7 @@ import { import type { DragEvent, Transformer } from "@thisbeyond/solid-dnd" import type { JSX } from "solid-js" import { useSync } from "@/context/sync" -import { useSession } from "@/context/session" +import { useSession, type LocalPTY } from "@/context/session" import { useLayout } from "@/context/layout" import { getDirectory, getFilename } from "@opencode-ai/util/path" import { Terminal } from "@/components/terminal" @@ -43,6 +43,7 @@ export default function Page() { clickTimer: undefined as number | undefined, fileSelectOpen: false, activeDraggable: undefined as string | undefined, + activeTerminalDraggable: undefined as string | undefined, }) let inputRef!: HTMLDivElement @@ -178,6 +179,49 @@ export default function Page() { setStore("activeDraggable", undefined) } + const handleTerminalDragStart = (event: unknown) => { + const id = getDraggableId(event) + if (!id) return + setStore("activeTerminalDraggable", id) + } + + const handleTerminalDragOver = (event: DragEvent) => { + const { draggable, droppable } = event + if (draggable && droppable) { + const terminals = session.terminal.all() + const fromIndex = terminals.findIndex((t) => t.id === draggable.id.toString()) + const toIndex = terminals.findIndex((t) => t.id === droppable.id.toString()) + if (fromIndex !== -1 && toIndex !== -1 && fromIndex !== toIndex) { + session.terminal.move(draggable.id.toString(), toIndex) + } + } + } + + const handleTerminalDragEnd = () => { + setStore("activeTerminalDraggable", undefined) + } + + const SortableTerminalTab = (props: { terminal: LocalPTY }): JSX.Element => { + const sortable = createSortable(props.terminal.id) + return ( + // @ts-ignore +
+
+ 1 && ( + session.terminal.close(props.terminal.id)} /> + ) + } + > + {props.terminal.title} + +
+
+ ) + } + const FileVisual = (props: { file: LocalFile; active?: boolean }): JSX.Element => { return (
@@ -618,40 +662,54 @@ export default function Page() { onResize={layout.terminal.resize} onCollapse={layout.terminal.close} /> - - + + + + + + t.id)}> + {(terminal) => } + +
+ + + +
+
{(terminal) => ( - 1 && ( - session.terminal.close(terminal.id)} /> - ) - } - > - {terminal.title} - + + session.terminal.clone(terminal.id)} + /> + )} -
- - - -
-
- - {(terminal) => ( - - session.terminal.clone(terminal.id)} - /> - - )} - -
+ + + + {(draggedId) => { + const terminal = createMemo(() => session.terminal.all().find((t) => t.id === draggedId())) + return ( + + {(t) => ( +
+ {t().title} +
+ )} +
+ ) + }} +
+
+