Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(work-panel): support reorderable tabs with edge scrolling
Gargantua5da1683a7311
diff --git a/apps/desktop/src/components/workpanel/WorkPanel.tsx b/apps/desktop/src/components/workpanel/WorkPanel.tsxindex 7f328c6e7..a8fbe3212 100644--- a/apps/desktop/src/components/workpanel/WorkPanel.tsx+++ b/apps/desktop/src/components/workpanel/WorkPanel.tsx@@ -10,6 +10,11 @@ import {} from "react";import { useTranslation } from "react-i18next";import { useBlockingOverlayActive } from "../../lib/blocking-overlay";+import {+ workPanelTabReorderScrollDelta,+ workPanelTabReorderInsertAfter,+ workPanelTabReorderShouldArm,+} from "../../lib/work-panel-tab-reorder";import type { PluginViewMeta } from "@pi-desktop/shared";import {isKnownWorkPanelTab,@@ -65,6 +70,22 @@ type WorkPanelResizeState = {frame: number;};+type WorkPanelTabReorderState = {+ pointerId: number;+ sourceTabId: string;+ startClientX: number;+ startClientY: number;+ lastClientX: number;+ lastClientY: number;+ targetTabId: string | null;+ insertAfter: boolean;+ armed: boolean;+ autoScrollFrame: number | null;+ onMove: (event: PointerEvent) => void;+ onUp: (event: PointerEvent) => void;+ onCancel: (event: PointerEvent) => void;+};+type WorkPanelTool = {id: string;tab: WorkPanelTab;@@ -177,6 +198,7 @@ export function WorkPanel({const pluginViews = useAppStore((s) => s.pluginViews);const width = useAppStore((s) => s.workPanelWidth);const activateTab = useAppStore((s) => s.activateWorkPanelTab);+ const reorderTabs = useAppStore((s) => s.reorderWorkPanelTabs);const closeTab = useAppStore((s) => s.closeWorkPanelTab);const openWorkPanelTab = useAppStore((s) => s.openWorkPanelTab);const openNewWorkPanelTab = useAppStore((s) => s.openNewWorkPanelTab);@@ -187,8 +209,16 @@ export function WorkPanel({const [panelDragWidth, setPanelDragWidth] = useState<number | null>(null);const panelResizeState = useRef<WorkPanelResizeState | null>(null);+ const tabReorderState = useRef<WorkPanelTabReorderState | null>(null);+ const tabStripRef = useRef<HTMLDivElement | null>(null);+ const suppressTabClickRef = useRef(false);const tabButtonRefs = useRef<Record<string, HTMLButtonElement | null>>({});const newTabButtonRef = useRef<HTMLButtonElement | null>(null);+ const [draggingTabId, setDraggingTabId] = useState<string | null>(null);+ const [dropIndicator, setDropIndicator] = useState<{+ tabId: string;+ insertAfter: boolean;+ } | null>(null);const [nativeSurfaceReadyForExit, setNativeSurfaceReadyForExit] =useState(false);@@ -250,6 +280,214 @@ export function WorkPanel({});}, [activeTabId, tabs.length]);+ const finishTabReorder = useCallback(+ (keepClickSuppressed = false) => {+ const state = tabReorderState.current;+ if (state) {+ window.removeEventListener("pointermove", state.onMove, true);+ window.removeEventListener("pointerup", state.onUp, true);+ window.removeEventListener("pointercancel", state.onCancel, true);+ if (state.autoScrollFrame !== null) {+ cancelAnimationFrame(state.autoScrollFrame);+ state.autoScrollFrame = null;+ }+ tabReorderState.current = null;+ }+ if (!keepClickSuppressed) suppressTabClickRef.current = false;+ setDraggingTabId(null);+ setDropIndicator(null);+ document.documentElement.removeAttribute("data-work-panel-tab-reordering");+ },+ [],+ );++ useEffect(() => {+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.key !== "Escape" || !tabReorderState.current) return;+ event.preventDefault();+ finishTabReorder();+ };+ window.addEventListener("keydown", onKeyDown);+ return () => {+ window.removeEventListener("keydown", onKeyDown);+ finishTabReorder();+ };+ }, [finishTabReorder]);++ const reorderTab = useCallback(+ (sourceTabId: string, targetTabId: string, insertAfter: boolean) => {+ if (sourceTabId === targetTabId) return;+ reorderTabs(sourceTabId, targetTabId, insertAfter);+ requestAnimationFrame(() => {+ tabButtonRefs.current[sourceTabId]?.focus({ preventScroll: true });+ });+ },+ [reorderTabs],+ );++ const beginTabReorder = useCallback(+ (event: React.PointerEvent<HTMLButtonElement>, sourceTabId: string) => {+ if (+ event.button !== 0 ||+ event.pointerType === "touch" ||+ tabReorderState.current+ ) {+ return;+ }+ // A completed drag may not produce a click when released outside the+ // strip. Clear the one-shot suppression before the next gesture so that+ // later ordinary clicks are never swallowed.+ suppressTabClickRef.current = false;++ const updateDropTarget = (state: WorkPanelTabReorderState) => {+ const strip = tabStripRef.current;+ const target = strip+ ? document+ .elementFromPoint(state.lastClientX, state.lastClientY)+ ?.closest<HTMLElement>("[data-work-panel-tab-id]")+ : null;+ if (!target || !strip?.contains(target)) {+ state.targetTabId = null;+ setDropIndicator(null);+ return;+ }++ const targetTabId = target.dataset.workPanelTabId;+ if (!targetTabId || targetTabId === state.sourceTabId) {+ state.targetTabId = null;+ setDropIndicator(null);+ return;+ }+ const rect = target.getBoundingClientRect();+ const insertAfter = workPanelTabReorderInsertAfter(+ state.lastClientX,+ rect.left,+ rect.width,+ );+ state.targetTabId = targetTabId;+ state.insertAfter = insertAfter;+ setDropIndicator({ tabId: targetTabId, insertAfter });+ };++ const startAutoScroll = (state: WorkPanelTabReorderState) => {+ if (state.autoScrollFrame !== null) return;++ const tick = () => {+ const current = tabReorderState.current;+ const strip = tabStripRef.current;+ if (!current || current !== state || !current.armed || !strip) {+ state.autoScrollFrame = null;+ return;+ }++ const stripRect = strip.getBoundingClientRect();+ if (+ current.lastClientY < stripRect.top ||+ current.lastClientY > stripRect.bottom ||+ strip.scrollWidth <= strip.clientWidth+ ) {+ current.autoScrollFrame = null;+ return;+ }++ const delta = workPanelTabReorderScrollDelta(+ current.lastClientX,+ stripRect.left,+ stripRect.right,+ );+ if (!delta) {+ current.autoScrollFrame = null;+ return;+ }++ const maxScrollLeft = strip.scrollWidth - strip.clientWidth;+ const nextScrollLeft = Math.min(+ maxScrollLeft,+ Math.max(0, strip.scrollLeft + delta),+ );+ if (nextScrollLeft === strip.scrollLeft) {+ current.autoScrollFrame = null;+ return;+ }++ strip.scrollLeft = nextScrollLeft;+ updateDropTarget(current);+ current.autoScrollFrame = requestAnimationFrame(tick);+ };++ state.autoScrollFrame = requestAnimationFrame(tick);+ };++ const onMove = (moveEvent: PointerEvent) => {+ const state = tabReorderState.current;+ if (!state || state.pointerId !== moveEvent.pointerId) return;+ state.lastClientX = moveEvent.clientX;+ state.lastClientY = moveEvent.clientY;+ if (!state.armed) {+ if (+ !workPanelTabReorderShouldArm(+ moveEvent.clientX - state.startClientX,+ moveEvent.clientY - state.startClientY,+ )+ ) {+ return;+ }+ state.armed = true;+ suppressTabClickRef.current = true;+ document.documentElement.setAttribute(+ "data-work-panel-tab-reordering",+ "true",+ );+ setDraggingTabId(state.sourceTabId);+ }++ moveEvent.preventDefault();+ updateDropTarget(state);+ startAutoScroll(state);+ };++ const onUp = (upEvent: PointerEvent) => {+ const state = tabReorderState.current;+ if (!state || state.pointerId !== upEvent.pointerId) return;+ if (state.armed) {+ upEvent.preventDefault();+ if (state.targetTabId) {+ reorderTab(state.sourceTabId, state.targetTabId, state.insertAfter);+ }+ finishTabReorder(true);+ return;+ }+ finishTabReorder();+ };++ const onCancel = (cancelEvent: PointerEvent) => {+ if (tabReorderState.current?.pointerId !== cancelEvent.pointerId) return;+ finishTabReorder();+ };++ const state: WorkPanelTabReorderState = {+ pointerId: event.pointerId,+ sourceTabId,+ startClientX: event.clientX,+ startClientY: event.clientY,+ lastClientX: event.clientX,+ lastClientY: event.clientY,+ targetTabId: null,+ insertAfter: false,+ armed: false,+ autoScrollFrame: null,+ onMove,+ onUp,+ onCancel,+ };+ tabReorderState.current = state;+ window.addEventListener("pointermove", onMove, true);+ window.addEventListener("pointerup", onUp, true);+ window.addEventListener("pointercancel", onCancel, true);+ },+ [finishTabReorder, reorderTab],+ );+const selectTool = useCallback((item: WorkPanelTool, sourceTabId?: string) => {if (sourceTabId) {@@ -296,6 +534,13 @@ export function WorkPanel({closeTabAndFocus(tabId);return;}+ if (event.altKey && ["ArrowLeft", "ArrowRight"].includes(event.key)) {+ event.preventDefault();+ const target = tabs[index + (event.key === "ArrowLeft" ? -1 : 1)];+ if (!target) return;+ reorderTab(tabId, target.id, event.key === "ArrowRight");+ return;+ }if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;event.preventDefault();const nextIndex =@@ -311,7 +556,7 @@ export function WorkPanel({activateTab(nextTab.id);requestAnimationFrame(() => tabButtonRefs.current[nextTab.id]?.focus());},- [activateTab, closeTabAndFocus, tabs],+ [activateTab, closeTabAndFocus, reorderTab, tabs],);const onTabStripWheel = (event: React.WheelEvent<HTMLDivElement>) => {@@ -513,6 +758,7 @@ export function WorkPanel({</div>) : (<div+ ref={tabStripRef}className="work-panel-tab-strip"role="tablist"aria-label={t("panel.tabsLabel")}@@ -528,7 +774,17 @@ export function WorkPanel({) ?? TAB_ICONS.plugin: TAB_ICONS[tab.kind];return (- <div className={cx("work-panel-tab", selected && "active")} key={tab.id}>+ <div+ className={cx(+ "work-panel-tab",+ selected && "active",+ draggingTabId === tab.id && "is-dragging",+ dropIndicator?.tabId === tab.id &&+ (dropIndicator.insertAfter ? "is-drop-after" : "is-drop-before"),+ )}+ data-work-panel-tab-id={tab.id}+ key={tab.id}+ ><buttonref={(node) => {tabButtonRefs.current[tab.id] = node;@@ -539,9 +795,19 @@ export function WorkPanel({aria-selected={selected}aria-controls={`work-panel-surface-${tab.id}`}tabIndex={selected ? 0 : -1}+ aria-grabbed={draggingTabId === tab.id}+ aria-keyshortcuts="Alt+ArrowLeft Alt+ArrowRight"className="work-panel-tab-button"title={tab.resource ?? label}- onClick={() => activateTab(tab.id)}+ onPointerDown={(event) => beginTabReorder(event, tab.id)}+ onDragStart={(event) => event.preventDefault()}+ onClick={() => {+ if (suppressTabClickRef.current) {+ suppressTabClickRef.current = false;+ return;+ }+ activateTab(tab.id);+ }}onAuxClick={(event) => {if (event.button !== 1) return;event.preventDefault();diff --git a/apps/desktop/src/lib/work-panel-tab-reorder.ts b/apps/desktop/src/lib/work-panel-tab-reorder.tsnew file mode 100644index 000000000..803b45a7f--- /dev/null+++ b/apps/desktop/src/lib/work-panel-tab-reorder.ts@@ -0,0 +1,40 @@+export const WORK_PANEL_TAB_REORDER_ARM_PX = 8;+export const WORK_PANEL_TAB_REORDER_EDGE_PX = 32;+export const WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX = 12;++export function workPanelTabReorderShouldArm(+ dx: number,+ dy: number,+ thresholdPx = WORK_PANEL_TAB_REORDER_ARM_PX,+): boolean {+ return dx * dx + dy * dy > thresholdPx * thresholdPx;+}++export function workPanelTabReorderInsertAfter(+ clientX: number,+ targetLeft: number,+ targetWidth: number,+): boolean {+ return clientX > targetLeft + targetWidth / 2;+}++/** Return the per-frame horizontal scroll speed for a pointer near either edge. */+export function workPanelTabReorderScrollDelta(+ clientX: number,+ stripLeft: number,+ stripRight: number,+ edgePx = WORK_PANEL_TAB_REORDER_EDGE_PX,+ maxScrollPx = WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX,+): number {+ const leftProgress = (stripLeft + edgePx - clientX) / edgePx;+ if (leftProgress > 0) {+ return -Math.ceil(Math.min(1, leftProgress) * maxScrollPx);+ }++ const rightProgress = (clientX - (stripRight - edgePx)) / edgePx;+ if (rightProgress > 0) {+ return Math.ceil(Math.min(1, rightProgress) * maxScrollPx);+ }++ return 0;+}diff --git a/apps/desktop/src/lib/work-panel-tabs.ts b/apps/desktop/src/lib/work-panel-tabs.tsindex d38e56d26..5ae9c299d 100644--- a/apps/desktop/src/lib/work-panel-tabs.ts+++ b/apps/desktop/src/lib/work-panel-tabs.ts@@ -296,6 +296,31 @@ export function activateWorkPanelTabState(: state;}+/** Move one tab before or after another without changing the active tab. */+export function reorderWorkPanelTabsState(+ state: WorkPanelTabsState,+ sourceTabId: string,+ targetTabId: string,+ insertAfter: boolean,+): WorkPanelTabsState {+ const sourceIndex = state.tabs.findIndex((tab) => tab.id === sourceTabId);+ const targetIndex = state.tabs.findIndex((tab) => tab.id === targetTabId);+ if (+ sourceIndex < 0 ||+ targetIndex < 0 ||+ sourceTabId === targetTabId+ ) {+ return state;+ }++ const tabs = [...state.tabs];+ const [source] = tabs.splice(sourceIndex, 1);+ const nextTargetIndex = tabs.findIndex((tab) => tab.id === targetTabId);+ if (!source || nextTargetIndex < 0) return state;+ tabs.splice(nextTargetIndex + (insertAfter ? 1 : 0), 0, source);+ return { tabs, activeTabId: state.activeTabId };+}+export function closeWorkPanelTabState(state: WorkPanelTabsState,tabId: string,diff --git a/apps/desktop/src/stores/app-state.ts b/apps/desktop/src/stores/app-state.tsindex 3cf9e08e0..66d68c388 100644--- a/apps/desktop/src/stores/app-state.ts+++ b/apps/desktop/src/stores/app-state.ts@@ -368,6 +368,11 @@ export type AppState = {replaceWorkPanelTab: (sourceTabId: string, tab: WorkPanelTab) => void;openWorkPanelTabForSession: (sessionId: string, tab: WorkPanelTab) => void;activateWorkPanelTab: (tabId: string) => void;+ reorderWorkPanelTabs: (+ sourceTabId: string,+ targetTabId: string,+ insertAfter: boolean,+ ) => void;closeWorkPanelTab: (tabId: string) => void;collapseWorkPanel: () => void;/** Hide the visible panel while retaining its session-owned context. */diff --git a/apps/desktop/src/stores/slices/work-panel-slice.ts b/apps/desktop/src/stores/slices/work-panel-slice.tsindex 2fc5ae354..2b3b607b9 100644--- a/apps/desktop/src/stores/slices/work-panel-slice.ts+++ b/apps/desktop/src/stores/slices/work-panel-slice.ts@@ -7,6 +7,7 @@ import {fileWorkPanelTab,newWorkPanelTab,openWorkPanelTabState,+ reorderWorkPanelTabsState,replaceWorkPanelTabState,sanitizeWorkPanelTabsState,switchWorkPanelContextState,@@ -105,6 +106,7 @@ export function createWorkPanelSlice({| "replaceWorkPanelTab"| "openWorkPanelTabForSession"| "activateWorkPanelTab"+ | "reorderWorkPanelTabs"| "closeWorkPanelTab"| "collapseWorkPanel"| "resetWorkPanelContext"@@ -290,6 +292,36 @@ export function createWorkPanelSlice({};});},+ reorderWorkPanelTabs: (sourceTabId, targetTabId, insertAfter) => {+ set((state) => {+ const sessionId = state.activeSessionId;+ if (!sessionId) return {};+ const next = reorderWorkPanelTabsState(+ {+ tabs: state.workPanelTabs,+ activeTabId: state.activeWorkPanelTabId,+ },+ sourceTabId,+ targetTabId,+ insertAfter,+ );+ if (next.tabs === state.workPanelTabs) return {};+ const nextContext: WorkPanelContext = {+ open: state.workPanelOpen,+ tabs: next.tabs,+ activeTabId: next.activeTabId,+ fileRequest: state.workPanelFileRequest,+ };+ return {+ workPanelTabs: next.tabs,+ activeWorkPanelTabId: next.activeTabId,+ workPanelContexts: {+ ...state.workPanelContexts,+ [sessionId]: nextContext,+ },+ };+ });+ },closeWorkPanelTab: (tabId) => {set((state) => {const sessionId = state.activeSessionId;diff --git a/apps/desktop/src/styles/work-panel.css b/apps/desktop/src/styles/work-panel.cssindex 95fb2f88c..3281891d8 100644--- a/apps/desktop/src/styles/work-panel.css+++ b/apps/desktop/src/styles/work-panel.css@@ -200,6 +200,7 @@}.work-panel-tab {+ position: relative;display: inline-flex;min-width: 92px;max-width: 180px;@@ -213,6 +214,35 @@color var(--motion-duration-fast) var(--motion-ease-out);}+.work-panel-tab.is-dragging {+ opacity: 0.5;+}++.work-panel-tab.is-dragging .work-panel-tab-button {+ cursor: grabbing;+}++.work-panel-tab.is-drop-before::before,+.work-panel-tab.is-drop-after::after {+ position: absolute;+ top: 4px;+ bottom: 4px;+ z-index: 1;+ width: 2px;+ border-radius: var(--radius-round);+ background: var(--ds-accent);+ content: "";+ pointer-events: none;+}++.work-panel-tab.is-drop-before::before {+ left: -4px;+}++.work-panel-tab.is-drop-after::after {+ right: -4px;+}+.work-panel-tab:hover,.work-panel-tab.active {background: var(--ds-bg-hover);@@ -227,6 +257,7 @@align-items: center;gap: 6px;padding: 0 2px 0 10px;+ cursor: grab;color: inherit;text-align: left;}@@ -278,6 +309,12 @@color: var(--ds-text-primary);}+:root[data-work-panel-tab-reordering="true"],+:root[data-work-panel-tab-reordering="true"] * {+ cursor: grabbing !important;+ user-select: none !important;+}+/* One button group with the viewport-fixed collapse toggle: the same controlgap the header reserves for it, and no divider, inset, or margin of its own.The rule owns spacing only — `+` and maximize take the shared chrome-controldiff --git a/apps/desktop/test/work-panel-tab-reorder.test.mjs b/apps/desktop/test/work-panel-tab-reorder.test.mjsnew file mode 100644index 000000000..a40b7d7a3--- /dev/null+++ b/apps/desktop/test/work-panel-tab-reorder.test.mjs@@ -0,0 +1,46 @@+import assert from "node:assert/strict";+import test from "node:test";++const {+ WORK_PANEL_TAB_REORDER_EDGE_PX,+ WORK_PANEL_TAB_REORDER_ARM_PX,+ WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX,+ workPanelTabReorderInsertAfter,+ workPanelTabReorderShouldArm,+ workPanelTabReorderScrollDelta,+} = await import("../src/lib/work-panel-tab-reorder.ts");++test("tab reorder arms only after the pointer crosses the movement threshold", () => {+ assert.equal(workPanelTabReorderShouldArm(4, 5), false);+ assert.equal(+ workPanelTabReorderShouldArm(WORK_PANEL_TAB_REORDER_ARM_PX + 1, 0),+ true,+ );+});++test("tab reorder inserts after the target's horizontal midpoint", () => {+ assert.equal(workPanelTabReorderInsertAfter(99, 50, 100), false);+ assert.equal(workPanelTabReorderInsertAfter(101, 50, 100), true);+});++test("tab reorder scrolls toward the edge with a bounded speed", () => {+ assert.equal(workPanelTabReorderScrollDelta(200, 100, 300), 0);+ assert.equal(+ workPanelTabReorderScrollDelta(100, 100, 300),+ -WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX,+ );+ assert.equal(+ workPanelTabReorderScrollDelta(300, 100, 300),+ WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX,+ );+ assert.equal(+ workPanelTabReorderScrollDelta(+ 100 + WORK_PANEL_TAB_REORDER_EDGE_PX / 2,+ 100,+ 300,+ ),+ -WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX / 2,+ );+ assert.equal(workPanelTabReorderScrollDelta(0, 100, 300), -WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX);+ assert.equal(workPanelTabReorderScrollDelta(400, 100, 300), WORK_PANEL_TAB_REORDER_MAX_SCROLL_PX);+});diff --git a/apps/desktop/test/work-panel-tabs.test.mjs b/apps/desktop/test/work-panel-tabs.test.mjsindex a2313d920..1b0b9de63 100644--- a/apps/desktop/test/work-panel-tabs.test.mjs+++ b/apps/desktop/test/work-panel-tabs.test.mjs@@ -17,6 +17,7 @@ const {pluginWorkPanelTab,preferredFileWorkPanelTab,replaceWorkPanelTabState,+ reorderWorkPanelTabsState,sanitizeWorkPanelTabsState,switchWorkPanelContextState,toolWorkPanelTab,@@ -113,6 +114,40 @@ test("activation ignores stale tab ids", () => {assert.equal(activateWorkPanelTabState(state, "missing"), state);});+test("reordering tabs inserts before or after a target and preserves selection", () => {+ const review = toolWorkPanelTab("review");+ const file = fileWorkPanelTab("src/App.tsx");+ const browser = browserPluginTab();+ const state = {+ tabs: [review, file, browser],+ activeTabId: file.id,+ };++ const movedAfter = reorderWorkPanelTabsState(state, review.id, browser.id, true);+ assert.deepEqual(movedAfter.tabs.map((tab) => tab.id), [file.id, browser.id, review.id]);+ assert.equal(movedAfter.activeTabId, file.id);++ const movedBefore = reorderWorkPanelTabsState(movedAfter, review.id, file.id, false);+ assert.deepEqual(movedBefore.tabs.map((tab) => tab.id), [review.id, file.id, browser.id]);+ assert.equal(movedBefore.activeTabId, file.id);+});++test("reordering an unknown or identical tab is a no-op", () => {+ const state = {+ tabs: [toolWorkPanelTab("review"), browserPluginTab()],+ activeTabId: "review",+ };++ assert.equal(+ reorderWorkPanelTabsState(state, "missing", "review", false),+ state,+ );+ assert.equal(+ reorderWorkPanelTabsState(state, "review", "review", false),+ state,+ );+});+test("unknown retained tabs are discarded without losing a known selection", () => {const stale = { id: "removed", kind: "removed" };const selected = sanitizeWorkPanelTabsState({diff --git a/apps/desktop/test/work-panel.test.mjs b/apps/desktop/test/work-panel.test.mjsindex 9fb125837..d6e2c571b 100644--- a/apps/desktop/test/work-panel.test.mjs+++ b/apps/desktop/test/work-panel.test.mjs@@ -295,6 +295,22 @@ test("plus creates a blank page and launcher rows open tools in that page", () =assert.doesNotMatch(panelSource, /setMenuOpen|menuOpen|newTabMenuRef|createPortal/);});+test("work panel tabs support pointer and keyboard reordering", () => {+ assert.match(panelSource, /beginTabReorder/);+ assert.match(panelSource, /data-work-panel-tab-id/);+ assert.match(panelSource, /workPanelTabReorderShouldArm/);+ assert.match(panelSource, /workPanelTabReorderInsertAfter/);+ assert.match(panelSource, /workPanelTabReorderScrollDelta/);+ assert.match(panelSource, /autoScrollFrame/);+ assert.match(panelSource, /requestAnimationFrame\(tick\)/);+ assert.match(panelSource, /data-work-panel-tab-reordering/);+ assert.match(panelSource, /event\.altKey/);+ assert.match(panelSource, /reorderWorkPanelTabs/);+ assert.match(storeSource, /reorderWorkPanelTabs: \(sourceTabId, targetTabId, insertAfter\)/);+ assert.match(storeSource, /reorderWorkPanelTabsState/);+ assert.match(globalStyles, /\.work-panel-tab\.is-drop-before::before/);+});+test("work panel starts closed with no tabs and persists width only", () => {assert.match(storeSource, /workPanelOpen:\s*false/);assert.match(storeSource, /workPanelTabs:\s*\[\]/);diff --git a/docs/adr/0224-right-panel-tab-strip.md b/docs/adr/0224-right-panel-tab-strip.mdindex 11bfdbdba..c9b0daede 100644--- a/docs/adr/0224-right-panel-tab-strip.md+++ b/docs/adr/0224-right-panel-tab-strip.md@@ -19,9 +19,13 @@ The work-panel header is a horizontally scrollable tab strip followed by afixed, tight `+` trigger. The strip is the only horizontally scrolling region;the `+` remains visible. Every open Review, file, or plugin view is representedby one ARIA tab. Tabs activate on click, close on their hover/focus close-button or middle-click, and support ArrowLeft/ArrowRight/Home/End plus-Delete/Backspace. Closing the final tab keeps the panel open and shows a New-launcher in the body.+button or middle-click, support press-and-move pointer reordering and+`Alt+ArrowLeft`/`Alt+ArrowRight` reordering, and retain+ArrowLeft/ArrowRight/Home/End plus Delete/Backspace for navigation and closing.+A drag drops before or after the target tab and keeps the active tab unchanged.+While dragging near either edge, the strip auto-scrolls so off-screen tabs can+be reached without releasing the pointer.+Closing the final tab keeps the panel open and shows a New launcher in the body.The `+` menu has one **Tools & panels** group. Review is the only host-ownedentry; all other entries come from the current plugin-view metadata returned bydiff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 9c5436797..e5dba31a1 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -1110,7 +1110,11 @@ entirely inside the plugin's isolated page:Review, file, or plugin view. Clicking a tab activates it; the active tab isscrolled into view. Its close button and middle-click close it, selecting theright neighbor and then the left. ArrowLeft/ArrowRight/Home/End move between- tabs and Delete/Backspace closes the focused tab. The `+` trigger remains+ tabs and Delete/Backspace closes the focused tab. Pressing and moving a tab+ by 8px starts reordering; dropping on either half of another tab inserts the+ source before or after it. Holding the pointer near either edge auto-scrolls+ the strip toward off-screen tabs. `Alt+ArrowLeft`/`Alt+ArrowRight` reorders+ the focused tab without changing its active state. The `+` trigger remainsfixed beside the strip and creates a new launcher tab.- New launcher: each `+` click creates a unique, active New tab. Its body usesthe Review-plus-plugin tool list as buttons. Selecting a row replaces thediff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 9f651d6e4..51328ab41 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -500,11 +500,16 @@ may be retained while exactly one workspace supplies the visible shell context.unique New launcher tab; its data-driven Review, Files, Browser, and pluginview rows are ordinary buttons in the page body.- Tab focus uses roving `tabIndex`: ArrowLeft/ArrowRight/Home/End move across- tabs and Delete/Backspace closes the focused tab. Middle-click closes a tab;- closing an active tab selects the right neighbor, then the left. Selecting a- launcher row replaces that New tab with the destination or activates its- existing singleton. Shortcut labels appear only for bindings that actually- exist.+ tabs and Delete/Backspace closes the focused tab. Pressing and moving a tab+ by 8px starts pointer reordering; dropping on the target's left or right half+ inserts before or after it, and `Alt+ArrowLeft`/`Alt+ArrowRight` provides the+ keyboard equivalent. Holding the pointer near the tab strip's edge scrolls+ toward off-screen tabs and keeps the drop indicator synchronized. The active+ tab remains active after reordering.+ Middle-click closes a tab; closing an active tab selects the right neighbor,+ then the left. Selecting a launcher row replaces that New tab with the+ destination or activates its existing singleton. Shortcut labels appear only+ for bindings that actually exist.- Activating a tool that is already open activates its existing resource insteadof replacing it, so Browser keeps its URL and Files its selection (D173).- Every resource can be closed from its tab. Closing the active resource selectsdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 44249df78..fb0e4d750 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -3451,7 +3451,11 @@ identify the platform validation still needed.a URL preview, and a completed Bash row. 3) Verify the header is a tablist:open enough tabs to overflow it, confirm only the strip scrolls and the `+`trigger stays visible, activate the scrolled-away tab, and close tabs with- hover/focus `×` and middle-click. 4) Click `+` twice and verify each click+ hover/focus `×` and middle-click. Drag a tab across another tab and verify+ the before/after drop indicator, resulting order, and unchanged active tab;+ hold a drag at each strip edge until hidden tabs scroll into view, then verify+ the indicator follows the newly visible targets. Repeat with+ `Alt+ArrowLeft`/`Alt+ArrowRight`. 4) Click `+` twice and verify each clickcreates and activates a separate New launcher tab. Confirm the launcher bodycontains Review plus each in-scope plugin view exactly once as clickable rows;there is no work-panel dropdown or popup. Click Browser from one New tab and@@ -3499,9 +3503,13 @@ identify the platform validation still needed.fixed `+`; labels stay readable instead of shrinking into one cluster, thestrip alone scrolls, active tabs scroll into view, and close selects theright neighbor then left. New launcher tabs expose Review and in-scope plugin- views as body buttons, with no popup to overlap or shift the panel. Clicking a- launcher row replaces that New tab with the destination or activates its- existing singleton. Closing the last tab leaves the panel open on New. Collapse+ views as body buttons, with no popup to overlap or shift the panel. Dragging a+ tab shows a before/after insertion indicator, edge-holding scrolls the strip+ toward hidden tabs, and reorders only the tab array; the active resource stays+ active. `Alt+ArrowLeft`/`Alt+ArrowRight` provides the same reorder path from+ the focused tab. Clicking a launcher row replaces+ that New tab with the destination or activates its existing singleton.+ Closing the last tab leaves the panel open on New. Collapseretains runtime tabs but hides the panel until another artifact reopens it.Width follows the shared three-column budget with no fixed pixel cap andpreviews its current/minimum/maximum values through the panel separator. Thediff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.mdindex 1082a9ace..1c1a8d4aa 100644--- a/docs/zh-CN/spec/04-ux/08-component-spec.md+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md@@ -820,7 +820,10 @@ vendor 进来的 `pi.file-manager` 视图在插件自己的隔离页面内完成后工具哈希和返回冲突而不覆盖以后的工作。- 标题栏标签:标签条是包含所有打开的 Review、文件和插件视图的 `tablist`。- 点击标签激活它,活动标签会滚动到可见范围;关闭按钮和中键都会关闭它,+ 点击标签激活它,活动标签会滚动到可见范围;按住标签移动 8px 后开始重排,+ 放到另一个标签的左半部或右半部时插入到其前后;`Alt+ArrowLeft`/+ `Alt+ArrowRight` 可重排聚焦标签且不改变激活状态。关闭按钮和中键都会关闭它,+ 拖拽指针靠近标签条边缘时会自动滚动,以便访问屏幕外的标签;并按右邻居、左邻居的顺序选择下一个。Arrow/Home/End 在标签之间移动,Delete/Backspace 关闭聚焦标签。固定 `+` 打开唯一的 Tools & panels 菜单。- New 启动器:没有活动标签时,主体使用与 `+` 菜单相同的 Review 加插件工具列表。diff --git a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md b/docs/zh-CN/spec/04-ux/09-interaction-patterns.mdindex 4d4c92d22..b1e1d1537 100644--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md@@ -403,9 +403,12 @@Tools & panels 分组,包含宿主 Review 以及当前范围内所有插件视图,Files和 Browser 保持数据驱动(D173)。- 标签焦点使用 roving `tabIndex`:ArrowLeft/ArrowRight/Home/End 在标签间移动,- Delete/Backspace 关闭聚焦标签,中键关闭标签;关闭活动标签后按右邻居、左邻居- 选择下一个。`+` 菜单使用 Arrow/Home/End、Escape 和 Tab,并在关闭时把焦点- 返回 `+`。只有真实存在的绑定才显示快捷键标签。+ Delete/Backspace 关闭聚焦标签,中键关闭标签。按住标签移动 8px 后开始拖拽排序,+ 放到目标标签左半部或右半部时分别插入到目标之前或之后;`Alt+ArrowLeft`/+ `Alt+ArrowRight` 提供键盘排序方式,排序后仍保持当前标签激活。拖拽指针靠近标签条边缘时+ 自动滚动并同步插入指示器。关闭活动标签后按右邻居、左邻居选择下一个。`+` 菜单使用+ Arrow/Home/End、Escape 和 Tab,并在关闭时+ 把焦点返回 `+`。只有真实存在的绑定才显示快捷键标签。- 激活已打开的工具会激活其现有资源替换它,因此浏览器保留其 URL 和文件的选择 (D173)。- 每个资源都可以从对应标签中关闭。关闭活动资源选择右邻居,再选择左邻居;关闭diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 194cd60cb..5a74013f8 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -2020,7 +2020,9 @@ hover/focus 不带移位标签,项目标题 hover/focus 路径显示并且没有创建任何选项卡。 2)打开两个不同的文件工件,再次打开相同的第一个文件,URL 预览,并准备一条已完成的 Bash 行。 3)验证 header 是可横向滚动的tablist:打开足够多的标签,确认只有标签条滚动且 `+` 始终可见,并使用- hover/focus `×` 与中键关闭。 4)打开 `+` 的 Tools & panels 菜单,验证+ hover/focus `×` 与中键关闭。将一个标签拖到另一个标签的前后,确认显示插入指示器、+ 顺序更新且当前激活标签不变;在标签条左右边缘保持拖拽,确认隐藏标签自动滚动到可见,+ 插入指示器跟随目标更新;再使用 `Alt+ArrowLeft`/`Alt+ArrowRight` 重复验证。 4)打开 `+` 的 Tools & panels 菜单,验证浏览器和当前范围内的插件视图各出现一次,并处于活动状态,打开-非活动和关闭状态,并且出现转录打开的资源仅在第二部分。使用指针和键盘打开/选择每个可用视图,@@ -2066,7 +2068,9 @@ hover/focus 不带移位标签,项目标题 hover/focus 路径显示更改操作系统窗口大小 - 仅 MainChat 在内部回流固定客户区 (ADR 0033)。一旦面板打开,标题栏显示可滚动的标签条和固定 `+`;`+` 菜单只列出 Review 与当前范围内的插件视图,不重复已打开的标签。标签- 溢出时只有标签条滚动,活动标签滚动到可见范围;菜单淡入超过 ≤4px,并在+ 溢出时只有标签条滚动,活动标签滚动到可见范围;拖拽标签显示前后插入指示器,+ 靠近边缘保持拖拽会自动滚动到隐藏标签,松开后只更新标签顺序且保持当前资源激活;`Alt+ArrowLeft`/`Alt+ArrowRight` 提供相同的+ 键盘重排路径。菜单淡入超过 ≤4px,并在reduced motion 下保持静态。Arrow/Home/End 在标签或菜单项目间移动,Delete/Backspace 与中键关闭标签,Escape/Tab/选择将菜单焦点恢复到 `+`。重新打开已存在的工具会激活它并保留浏览器 URL。打开菜单时原生插件表面