From 4b399e44aa2d551fb61a5b55b060b82dea2f6821 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 25 Nov 2026 23:34:16 +1100 Subject: [PATCH] fix(ui/chat): fix dock drag/resize bounds and dynamic slash command loader --- ui/src/chat/ChatComposer.vue | 20 +++++++++++------ ui/src/chat/ChatDock.vue | 31 ++++++++++++++++++--------- ui/src/chat/ChatDockLayout.ts | 14 +++++++----- ui/test/chat-dock-float.test.ts | 11 ++++++++-- ui/test/chat-more-menu.test.ts | 38 +++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 23 deletions(-) diff --git a/ui/src/chat/ChatComposer.vue b/ui/src/chat/ChatComposer.vue index bad346c83..ea8ab074a 100644 --- a/ui/src/chat/ChatComposer.vue +++ b/ui/src/chat/ChatComposer.vue @@ -164,17 +164,25 @@ async function searchWorkflows(query: string): Promise { })); } +function searchCommands(query: string): MenuEntry[] { + const q = query.trim().toLowerCase(); + return commandSpecs.value + .filter((spec) => `${spec.command} ${spec.description ?? ""}`.toLowerCase().includes(q)) + .slice(0, 8) + .map((spec) => ({ + value: spec.command, + label: spec.command, + keywords: spec.description ? [spec.description] : [], + detail: spec.description || spec.usage || "", + })); +} + const triggers = computed(() => [ { char: "/", boundary: "start", type: "command", - items: commandSpecs.value.map((spec) => ({ - value: spec.command, - label: spec.command, - keywords: spec.description ? [spec.description] : [], - detail: spec.description || spec.usage || "", - })), + items: searchCommands, }, { char: "@", diff --git a/ui/src/chat/ChatDock.vue b/ui/src/chat/ChatDock.vue index c53825c3c..19b10b25e 100644 --- a/ui/src/chat/ChatDock.vue +++ b/ui/src/chat/ChatDock.vue @@ -28,7 +28,6 @@ import { SWIPE, barPlacement, fitRect, - BAR_W, INSET, handleOrientation, handleValue, @@ -120,9 +119,7 @@ const winRect = computed(() => { if (pinned.value) { return { x: mode.value === "left" ? 0 : vw.value - pinW.value, y: 0, w: pinW.value, h: vh.value }; } - // Opening the window never narrows it below the minimised bar. - const minW = Math.min(BAR_W, vw.value - INSET * 2); - return fitRect({ ...layout.value, w: Math.max(layout.value.w, minW) }, vw.value, vh.value); + return fitRect(layout.value, vw.value, vh.value); }); // The part of the layout viewport the on-screen keyboard covers, and the height @@ -254,7 +251,16 @@ const bar = ref(null); function onDragSurface(target: HTMLElement): boolean { const surface = expanded.value ? header.value : bar.value; if (!surface?.contains(target)) return false; - return !target.closest("button, a, input, select, textarea, [role=combobox], [role=separator]") || !!target.closest("[data-move-handle]"); + return ( + !target.closest('button, a, input, select, textarea, [role="combobox"], [role="separator"], [role="textbox"], [contenteditable="true"], [contenteditable=""]') || + !!target.closest("[data-move-handle]") + ); +} + +function onBarFocusIn(event: FocusEvent): void { + const target = event.target as HTMLElement | null; + if (target?.closest("[data-move-handle]")) return; + expanded.value = true; } // Pointer travel before a press becomes a drag, so a click or a double-click @@ -264,7 +270,7 @@ useDraggable(dock, { disabled: () => !desktop.value, onStart: (_, e) => { if (!e.isPrimary || !onDragSurface(e.target as HTMLElement)) return false; - drag = { origin: { ...winRect.value }, x0: e.clientX, y0: e.clientY, moved: false, snap: null }; + drag = { origin: resizeOrigin(), x0: e.clientX, y0: e.clientY, moved: false, snap: null }; }, onMove: (_, e) => { if (!drag) return; @@ -273,9 +279,14 @@ useDraggable(dock, { if (!drag.moved && Math.hypot(dx, dy) < DRAG_START) return; drag.moved = true; dragging.value = true; + if (!expanded.value) { + const nextX = Math.min(Math.max(drag.origin.x + dx, INSET), Math.max(INSET, vw.value - drag.origin.w - INSET)); + layout.value = { ...layout.value, mode: "float", x: nextX }; + return; + } const next = fitRect({ ...drag.origin, x: drag.origin.x + dx, y: drag.origin.y + dy }, vw.value, vh.value); layout.value = { ...layout.value, mode: "float", x: next.x, y: next.y, w: next.w, h: next.h }; - drag.snap = expanded.value ? snapEdge(e.clientX, vw.value) : null; + drag.snap = snapEdge(e.clientX, vw.value); snapTarget.value = drag.snap; }, onEnd: (_, e) => { @@ -368,8 +379,8 @@ const DIR_LABEL: Record = { se: "bottom right", sw: "bottom left", }; -// The minimised bar keeps its height, so only its width edges resize it. -const visibleDirs = computed(() => (expanded.value ? [...RESIZE_DIRS] : ["e", "w"])); +// Only the expanded floating window resizes; the minimised bar is move-only. +const visibleDirs = computed(() => (expanded.value ? [...RESIZE_DIRS] : [])); // The rectangle a resize starts from. Minimised, the bar can sit at an edge // rather than at the stored x, so its rendered x and width are the origin, or @@ -534,7 +545,7 @@ function onPinKey(event: KeyboardEvent): void { > -
+