From 7aec2ad3a85420b40a45d783d6a88ac465a77910 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Sat, 7 Nov 2026 09:14:40 +0800 Subject: [PATCH 1/2] fix(chat): simplify queue dragging and balance row spacing --- design-system/AGENTS.md | 2 +- design-system/packages/ui/README.md | 8 +++++--- .../composer/ChatComposerQueue.module.css | 7 +++++-- .../src/flow-chat/composer/useQueueReorder.ts | 11 ++--------- .../packages/ui/tests/chat-composer.test.mjs | 3 +++ src/mobile-web/README.md | 4 ++-- .../src/components/MobileHostQueue.tsx | 2 +- src/mobile-web/src/i18n/messages.ts | 6 +++--- .../tests/host-dialog-queue-browser.test.mjs | 5 +++-- .../components/HostPendingQueuePanel.test.tsx | 6 +++++- .../components/HostPendingQueuePanel.tsx | 2 +- .../components/PendingQueuePanel.test.tsx | 1 + .../components/PendingQueuePanel.tsx | 2 +- .../components/useQueueReorder.test.tsx | 19 +++++++++++++------ src/web-ui/src/locales/en-US/flow-chat.json | 2 +- src/web-ui/src/locales/zh-CN/flow-chat.json | 2 +- src/web-ui/src/locales/zh-TW/flow-chat.json | 2 +- 17 files changed, 49 insertions(+), 35 deletions(-) diff --git a/design-system/AGENTS.md b/design-system/AGENTS.md index 7c4f63f4ed..080c3ba0bf 100644 --- a/design-system/AGENTS.md +++ b/design-system/AGENTS.md @@ -107,7 +107,7 @@ Use a pre-change reference commit when testing an already committed change. The native fixture runs outside performance windows. Geometry equivalence does not establish pixel-identical rasterization or coverage on other WebView engines. -For shared queue pointer/keyboard interaction, cancellation and focus retention: +For shared queue dragging, arrow-key pass-through, cancellation and focus retention: ```bash pnpm --dir src/web-ui exec vitest run src/flow_chat/components/useQueueReorder.test.tsx diff --git a/design-system/packages/ui/README.md b/design-system/packages/ui/README.md index cfcf3e242e..daaf4956af 100644 --- a/design-system/packages/ui/README.md +++ b/design-system/packages/ui/README.md @@ -1041,11 +1041,13 @@ consume those references through intervening wrappers. A control's explicit name or own label takes precedence; descriptions are combined. Give each child in a composite field its own name. Nested `Field` controls retain their own labels. -`ChatComposerQueue` has no outer border. Each row starts with an inset hairline; +`ChatComposerQueue` has no outer border. Each row has equal block padding and starts with an inset hairline; the final row has no bottom hairline and meets the composer without an extra gap. `ChatComposerQueueItem.leadingControl` accepts an accessible interactive control; `leadingIcon` remains decorative. `useQueueReorder` supplies pointer -capture, keyboard moves, edge scrolling and cancellation when the authoritative +capture, edge scrolling and cancellation when the authoritative revision changes. Pass only reorderable IDs and keep the actual order in the -product owner until its mutation succeeds. Disabled or legacy hosts must expose +product owner until its mutation succeeds. Arrow keys do not reorder the queue; +product action menus provide explicit move-up/down commands. Drag handles carry +an accessible label without a hover tooltip. Disabled or legacy hosts must expose a clear reason in their product surface. diff --git a/design-system/packages/ui/src/flow-chat/composer/ChatComposerQueue.module.css b/design-system/packages/ui/src/flow-chat/composer/ChatComposerQueue.module.css index 9ca741bb74..db948dd74f 100644 --- a/design-system/packages/ui/src/flow-chat/composer/ChatComposerQueue.module.css +++ b/design-system/packages/ui/src/flow-chat/composer/ChatComposerQueue.module.css @@ -69,7 +69,8 @@ var(--openbitfun-control-height-sm) + var(--openbitfun-control-height-sm) + var(--openbitfun-control-height-sm) + - var(--openbitfun-control-height-sm) + var(--openbitfun-control-height-sm) + + var(--openbitfun-space-1) * 8 ); flex-direction: column; gap: 0; @@ -99,6 +100,9 @@ min-block-size: var(--openbitfun-control-height-sm); align-items: flex-start; gap: var(--openbitfun-space-2); + /* Own both sides of the divider; document li margins must not leak in. */ + margin: 0; + padding-block: var(--openbitfun-space-1); padding-inline: var(--openbitfun-space-2) var(--openbitfun-space-1); border-radius: var(--openbitfun-radius-md); color: var(--openbitfun-color-content-primary); @@ -190,7 +194,6 @@ font-size: var(--openbitfun-type-meta-font-size); line-height: var(--openbitfun-type-body-sm-line-height); overflow-wrap: anywhere; - padding-block-end: var(--openbitfun-space-1); } .status[data-openbitfun-tone="warning"] { diff --git a/design-system/packages/ui/src/flow-chat/composer/useQueueReorder.ts b/design-system/packages/ui/src/flow-chat/composer/useQueueReorder.ts index 18844d0b4b..7c0f447cba 100644 --- a/design-system/packages/ui/src/flow-chat/composer/useQueueReorder.ts +++ b/design-system/packages/ui/src/flow-chat/composer/useQueueReorder.ts @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent } from 'react'; +import { useEffect, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react'; type Drag = { id: string; @@ -14,7 +14,7 @@ type Drag = { moved: boolean; }; -/** Pointer/keyboard presentation only. The caller owns authoritative ordering. */ +/** Pointer drag presentation only. The caller owns authoritative ordering. */ export function useQueueReorder(ids: string[], enabled: boolean, revision: string | number, onMove: (id: string, beforeId: string | null) => void) { const rows = useRef(new Map()); @@ -133,13 +133,6 @@ export function useQueueReorder(ids: string[], enabled: boolean, revision: strin onPointerUp: (event: ReactPointerEvent) => { if (drag.current?.pointerId === event.pointerId) finish(true); }, onPointerCancel: () => finish(false), onLostPointerCapture: () => finish(false), - onKeyDown(event: ReactKeyboardEvent) { - if (!enabled || drag.current || !['ArrowUp', 'ArrowDown'].includes(event.key)) return; - event.preventDefault(); - const index = ids.indexOf(id); - if (event.key === 'ArrowUp' && index > 0) requestMove(id, ids[index - 1]!); - if (event.key === 'ArrowDown' && index >= 0 && index < ids.length - 1) requestMove(id, ids[index + 2] ?? null); - }, }; }, }; diff --git a/design-system/packages/ui/tests/chat-composer.test.mjs b/design-system/packages/ui/tests/chat-composer.test.mjs index a00797492e..99137e887c 100644 --- a/design-system/packages/ui/tests/chat-composer.test.mjs +++ b/design-system/packages/ui/tests/chat-composer.test.mjs @@ -197,8 +197,11 @@ test("ChatComposer queue keeps four message rows visible before scrolling", asyn (maxBlockSize.match(/--openbitfun-control-height-sm/g) ?? []).length, 4, ); + assert.match(maxBlockSize, /var\(--openbitfun-space-1\)\s*\*\s*8/); assert.match(listRule, /gap:\s*0;/); assert.match(styles, /\.item\s*\{[^}]*min-block-size:\s*var\(--openbitfun-control-height-sm\)/s); + assert.match(styles, /\.item\s*\{[^}]*margin:\s*0;[^}]*padding-block:\s*var\(--openbitfun-space-1\);/s); + assert.doesNotMatch(styles, /\.status\s*\{[^}]*padding-block-end:/s); assert.match(listRule, /overflow-y:\s*auto/); assert.match(listRule, /overscroll-behavior-y:\s*contain/); }); diff --git a/src/mobile-web/README.md b/src/mobile-web/README.md index 858a0f3be4..bd3fb287a8 100644 --- a/src/mobile-web/README.md +++ b/src/mobile-web/README.md @@ -92,8 +92,8 @@ the phone, or leaving the session does not stop host-side dispatch. still render steering inline within the active turn. The turn-scoped SDK steering API used by CLI/Dispatch retains its inline contract; this handoff belongs to host queue promotion. -- **Reorder** uses the drag handle, Up/Down while the handle is focused, or - Move up/down in **More**. The host confirms the new execution order before +- **Reorder** uses the drag handle or Move up/down in **More**. + Arrow keys do not change the queue order. The host confirms the new execution order before the list changes. A concurrent update cancels a drag and asks you to retry against the refreshed list. Older queue hosts without `supportsReorder` retain Send now and Remove, with a clear sorting-unavailable message. diff --git a/src/mobile-web/src/components/MobileHostQueue.tsx b/src/mobile-web/src/components/MobileHostQueue.tsx index a16352c4bc..89191d52ed 100644 --- a/src/mobile-web/src/components/MobileHostQueue.tsx +++ b/src/mobile-web/src/components/MobileHostQueue.tsx @@ -51,7 +51,7 @@ export function MobileHostQueue({ queue, onRestore }: { queue: HostDialogQueue;