From 788c5149c03dfa5bdedfe69cff9cb818f34b73d2 Mon Sep 17 00:00:00 2001 From: WinterXMQ Date: Sun, 25 Oct 2026 01:31:21 +0800 Subject: [PATCH 1/2] fix(sidebar): keep the bottom workbench toggle while the right panel is open The header toggle bailed out whenever the host's right sidebar was expanded, so opening that panel first left the bottom workbench unreachable until it was collapsed again. The session header's utilities seat and the panel's own Split / Fullscreen / Collapse cluster sit in two different columns, so they never overlap. The blank-session fixed fallback keeps its guard: that entry anchors to the left of the panel controls and would cover panel content while expanded. tests/bottom-toggle.spec.tsx pins both behaviours. --- src/client/Sidebar.tsx | 7 ++- src/client/sidebar/dock-fallback.tsx | 5 +- tests/bottom-toggle.spec.tsx | 69 ++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 tests/bottom-toggle.spec.tsx diff --git a/src/client/Sidebar.tsx b/src/client/Sidebar.tsx index ae6b41b7..ca0154fb 100644 --- a/src/client/Sidebar.tsx +++ b/src/client/Sidebar.tsx @@ -48,7 +48,6 @@ import { createOpenInApp } from './open-in-app.ts' import { useCenterColumn } from './sidebar/use-center-column.ts' import { useHostFeeds } from './sidebar/use-host-feeds.ts' import { mountedSessions } from './native/surface.ts' -import { useRightPanelOpen } from './sidebar/right-panel-open.ts' import type { TabDragPayload } from './TabBar.tsx' import { t } from './locales.ts' import { useSessionRoot } from './use-session-root.ts' @@ -784,9 +783,9 @@ export function BottomDockToggle(props: { store: SidebarStore }) { useCallback((callback: () => void) => store.subscribe(callback), [store]), useCallback(() => store.getSnapshot(), [store]), ) - // 宿主右侧面板展开时不出现:那个状态下它右上角是一簇自己的控件 - // (Split / Fullscreen / Collapse right sidebar),入口挤进去只会跟它们打架。 - if (useRightPanelOpen()) return null + // 宿主右侧面板展开时**照常渲染**:本入口在会话头 utilities,位于右栏控件簇 + // (Split / Fullscreen / Collapse right sidebar)左侧的独立一列,不会被它们盖住。 + // 早先这里在右栏展开时早退,结果「先开右栏就再也打不开工作台」。 const open = snapshot.state?.bottomOpen === true const label = open ? t('collapseBottomPanel') : t('expandBottomPanel') return ( diff --git a/src/client/sidebar/dock-fallback.tsx b/src/client/sidebar/dock-fallback.tsx index 1009b994..1363f003 100644 --- a/src/client/sidebar/dock-fallback.tsx +++ b/src/client/sidebar/dock-fallback.tsx @@ -197,8 +197,9 @@ export function DockFallback({ store }: { store: SidebarStore }): ReactNode { if (phase === undefined || !phase.blank) return null // 兜底:相位说 blank、但会话头的入口确实在 DOM 里 —— 让位,绝不叠出第二套。 if (headerEntry) return null - // 宿主右侧面板展开时不渲染(里面那个按钮本身也会返回 null,这里连空壳一起省掉): - // 那个状态下右上角是宿主自己的一簇控件,没有本入口的容身之处。 + // 宿主右侧面板展开时不渲染:兜底入口是 fixed 定位、锚在那簇控件左侧,展开时锚点 + // 落在面板内部,放过去会盖住面板内容。正常会话的顶部入口不受此限(见 Sidebar.tsx + // 的 BottomDockToggle:它在会话头 utilities 里,与旧栏控件分属两列)。 if (rightOpen) return null // portal 到 body:面板宿主(z 20-30)的层叠上下文压不过会话头,按钮会被 titleRow // 拦截点击。40 高于 AppFrame(20) 与会话头、低于 DSH 浮层(100+)。 diff --git a/tests/bottom-toggle.spec.tsx b/tests/bottom-toggle.spec.tsx new file mode 100644 index 00000000..668ffa34 --- /dev/null +++ b/tests/bottom-toggle.spec.tsx @@ -0,0 +1,69 @@ +/** + * 会话头里的底部工作台开关(`Sidebar.tsx` 的 `BottomDockToggle`)。 + * + * 钉住一条行为:**宿主右侧面板展开时入口照常渲染**。早先这里在 `useRightPanelOpen()` + * 为真时早退,结果「先开右栏就再也打不开工作台」——右栏那簇控件 + * (Split / Fullscreen / Collapse right sidebar)在右栏列内,本入口在会话头 utilities + * (中间列),两列不重叠,没有隐藏的理由。 + * + * 空白会话的 fixed 兜底入口是另一件事(见 `dock-fallback.spec.tsx`),它在右栏展开时 + * 仍然不渲染:那个入口锚在右栏控件左侧,展开时锚点落在面板内部。 + */ +// @vitest-environment jsdom +import { afterEach, describe, expect, it } from 'vitest' +import { createElement } from 'react' +import { act } from 'react-dom/test-utils' +// First import: browser globals before the primitive-carrying sidebar graph loads. +import './browser-globals.ts' +import { renderRoot, setupReactAct } from './test-utils.ts' +import { BottomDockToggle } from '../src/client/Sidebar.tsx' +import { createSidebarStore } from '../src/client/state.ts' + +setupReactAct() + +function renderToggle(): { unmount: () => void; store: ReturnType } { + const store = createSidebarStore() + store.setSession('s1') + const view = renderRoot(createElement(BottomDockToggle, { store })) + return { unmount: view.unmount, store } +} + +/** 宿主右侧面板**展开**态的控件:可见的 `[data-sidebar-right-toggle]`。 */ +function appendExpandedRightPanelControl(): void { + const element = document.createElement('button') + element.setAttribute('data-sidebar-right-toggle', 'true') + element.getBoundingClientRect = () => ({ + x: 900, y: 10, left: 900, top: 10, width: 28, height: 28, right: 928, bottom: 38, + toJSON: () => ({}), + }) as DOMRect + document.body.append(element) +} + +afterEach(() => { + for (const element of document.querySelectorAll('[data-sidebar-right-toggle]')) element.remove() +}) + +describe('会话头底部开关', () => { + it('宿主右侧面板展开时仍然渲染入口', () => { + appendExpandedRightPanelControl() + const { unmount } = renderToggle() + try { + expect(document.querySelector('[data-dsh-bottom-toggle]'), '右栏展开也要有底部入口').not.toBeNull() + } finally { + unmount() + } + }) + + it('点击翻转 store 的 bottomOpen', () => { + const { unmount, store } = renderToggle() + try { + const element = document.querySelector('[data-dsh-bottom-toggle]') + if (element === null) throw new Error('missing element: bottom toggle') + expect(store.getSnapshot().state?.bottomOpen).toBe(false) + act(() => { element.dispatchEvent(new MouseEvent('click', { bubbles: true })) }) + expect(store.getSnapshot().state?.bottomOpen).toBe(true) + } finally { + unmount() + } + }) +}) From a3630a4bd29a6f223ef28725f8eaf4933419c677 Mon Sep 17 00:00:00 2001 From: WinterXMQ Date: Sun, 25 Oct 2026 02:19:37 +0800 Subject: [PATCH 2/2] docs(changelog): note the bottom workbench toggle staying visible The header toggle no longer hides while the host's right panel is expanded. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e487b4f3..0e220ad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### 未发布 +- **右栏展开时仍可开关底部工作台**:会话头的底部工作台开关此前在宿主右侧面板展开时整枚隐藏,导致「先开右栏就再也打不开工作台」,必须先收起右栏。现在照常显示(它在会话头 utilities,与右栏那簇控件分属两列,不会重叠)。空白会话的 fixed 兜底入口保持原行为:那个入口锚在右栏控件左侧,展开时锚点落在面板内部。`tests/bottom-toggle.spec.tsx` 守护。 - **任务图展开修复**:平移画布后,聚合卡和 Agent 卡的下一次点击不再被误判为拖动;展开聚合与查看详情恢复正常。 - **任务图性能**:卡片内容使用独立 memo 边界,平移与布局补间不再重复渲染内容;布局用索引和显式栈替代逐边查找与深递归,同次宽度适配复用相同列数的布局。2000 个非根 Agent 的纯布局对照及 200/500 Agent 真浏览器证据见[验证记录](docs/plans/2026-10-23-tasks-folding-performance-validation.md),布局加速不外推为整页加速。 - **任务页拖拽改为每帧一次更新**:图模式背景平移、后台任务浮窗标题拖动、锚定弹层拖动不再按鼠标事件频率重绘(高回报率鼠标下此前每个 pointermove 都提交整块画布);松手同步落位,点击判定与最终位置不变。实测同一帧内 100 次移动的画布提交由 98 次降到 1 次。