Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

test(work-panel): cover tab close reachability after resize

vastsa55dac23e44b5
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 39af82dd5..f4962985c 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -16326,24 +16326,24 @@ plugin-form fixtures in an isolated temporary directory at runtime.
### E2E-WORK-PANEL-active-tab-close-visibility
-- **Preconditions**: Open a desktop session on Windows with the work panel at
- its narrow supported width and create a long-named file or plugin tab so the
- tab wrapper is wider than the visible horizontal strip.
-- **Steps**: Activate the overflowing tab, then inspect the tab wrapper and
- its `.work-panel-tab-close` rectangle against the strip's client viewport.
- Repeat after switching between two overflowing tabs and after scrolling the
- strip toward either end.
-- **Expected**: Activating a tab scrolls the whole tab wrapper and then its
- close button into the visible strip. The close button is visible and hit
- testable without requiring a middle click, keyboard shortcut, or widening
- the panel.
+- **Preconditions**: Render the work panel with enough long-named tabs to
+ overflow the horizontal strip.
+- **Steps**: Activate an overflowing tab in the narrow layout and inspect its
+ close-button rectangle and `elementFromPoint` hit target. Resize the layout
+ while keeping the same tab active and repeat. Then partially scroll the strip
+ to an inactive tab, hover it, and inspect its close button the same way.
+- **Expected**: The active close button stays fully inside the strip after
+ activation and resize. Hovering a partially visible inactive tab scrolls its
+ close button into the viewport too. In all three states the button is visible
+ and hit testable without requiring a middle click, keyboard shortcut, or
+ widening the panel.
- **Specs linked**: `04-ux/07-ui-design-system.md` §10, issue #1762
- **Acceptance**: Quality
- **Milestone**: Post-M6 desktop shell maintenance
-- **Status**: Renderer source-contract regression covered by
- `apps/desktop/test/work-panel.test.mjs`; the Windows probe in
- `scripts/e2e-work-panel-drag.mjs` also checks the active close-button
- rectangle before its native hit-test stages.
+- **Status**: Electron geometry and hit-target coverage runs in
+ `scripts/e2e-work-panel-tab-close.mjs`; `apps/desktop/test/work-panel.test.mjs`
+ also covers the reveal contract. The Windows probe in
+ `scripts/e2e-work-panel-drag.mjs` checks native hit testing separately.
#### E2E-LAYOUT-sidebar-project-group-fold
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.md
index 45136145b..eb3ff8fa9 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
@@ -8560,13 +8560,13 @@ runner 会在运行时的隔离临时目录中生成六个插件形态 fixture
### E2E-WORK-PANEL-active-tab-close-visibility
-- **前提条件**:在 Windows 上打开桌面会话,将工作面板调整到支持的窄宽度,并创建一个名称较长的文件或插件标签,使标签容器宽于可见的横向标签栏。
-- **步骤**:激活发生溢出的标签,读取标签容器及其 `.work-panel-tab-close` 矩形与标签栏 client 视口的关系。在两个溢出标签之间切换,并分别将标签栏滚向两端后重复检查。
-- **预期**:激活标签时,整个标签容器及其关闭按钮都会滚动到可见标签栏内。关闭按钮无需中键、键盘快捷键或扩大面板即可看见并命中。
+- **前提条件**:渲染工作面板,并创建足够多的长标题标签使横向标签栏溢出。
+- **步骤**:在窄布局中激活溢出标签,检查关闭按钮矩形是否落入标签栏视口,并确认 `elementFromPoint` 命中关闭按钮。保持同一标签激活并缩窄布局后重复检查。随后将标签栏滚到一半,对部分可见的非激活标签执行悬停,再检查其关闭按钮。
+- **预期**:激活标签及布局缩窄后,关闭按钮都完整位于标签栏内;悬停部分可见的非激活标签时,其关闭按钮也会滚入视口。三个状态下按钮都可见且可命中,无需中键、键盘快捷键或扩大面板。
- **链接规格**:`04-ux/07-ui-design-system.md` §10,issue #1762
- **验收**:品质
- **里程碑**:M6 之后桌面壳维护
-- **状态**:渲染器源契约回归由 `apps/desktop/test/work-panel.test.mjs` 覆盖;`scripts/e2e-work-panel-drag.mjs` 的 Windows 探针也会在原生命中测试阶段前检查激活标签关闭按钮的矩形。
+- **状态**:`scripts/e2e-work-panel-tab-close.mjs` 在 Electron 中覆盖真实几何位置和命中目标;`apps/desktop/test/work-panel.test.mjs` 也覆盖滚动契约。Windows 原生命中测试由 `scripts/e2e-work-panel-drag.mjs` 单独覆盖。
#### E2E-LAYOUT-sidebar-project-group-fold
diff --git a/scripts/e2e-work-panel-tab-close.mjs b/scripts/e2e-work-panel-tab-close.mjs
index 14905423a..6f55c71d3 100644
--- a/scripts/e2e-work-panel-tab-close.mjs
+++ b/scripts/e2e-work-panel-tab-close.mjs
@@ -104,6 +104,7 @@ app.whenReady().then(async () => {
for (const result of results) {
console.log(
`${result.stage}: strip [${result.stripLeft.toFixed(1)}, ${result.stripRight.toFixed(1)}] ` +
+ `clientWidth=${result.stripClientWidth} ` +
`close [${result.closeLeft.toFixed(1)}, ${result.closeRight.toFixed(1)}] ` +
`inside=${result.insideStrip} hit=${result.hitIsClose || result.hitIsDescendant}`,
);
diff --git a/scripts/e2e/work-panel-tab-close.tsx b/scripts/e2e/work-panel-tab-close.tsx
index 5abf5b384..87608b27d 100644
--- a/scripts/e2e/work-panel-tab-close.tsx
+++ b/scripts/e2e/work-panel-tab-close.tsx
@@ -22,6 +22,7 @@ type CloseGeometry = {
tabId: string;
stripLeft: number;
stripRight: number;
+ stripClientWidth: number;
closeLeft: number;
closeRight: number;
insideStrip: boolean;
@@ -62,7 +63,11 @@ async function rendered() {
function renderPanel(containerWidth: number) {
// The panel's own width comes from the store; `containerWidth` is the shell
- // budget. Resize the host so the strip's box actually changes.
+ // budget. Resize the host so the strip's box actually changes. Each probe
+ // stage starts from the stylesheet width, even when React reuses the strip.
+ const existingStrip = host.querySelector<HTMLElement>(".work-panel-tab-strip");
+ existingStrip?.style.removeProperty("flex");
+ existingStrip?.style.removeProperty("width");
host.style.width = `${containerWidth}px`;
flushSync(() => {
useAppStore.setState({
@@ -114,6 +119,7 @@ function measure(stage: string): CloseGeometry {
tabId,
stripLeft: stripRect.left,
stripRight: stripRect.right,
+ stripClientWidth: strip.clientWidth,
closeLeft: closeRect.left,
closeRight: closeRect.right,
// The control must be fully inside the strip's client box. A sub-pixel
@@ -147,11 +153,19 @@ globalThis.tabCloseProbe = async (stage) => {
const before = measure("before-resize");
assert(before.insideStrip, "fixture invalid: close control clipped before the resize");
- // Narrow enough to clip the strip but wide enough that the panel is not
- // auto-collapsed: MAIN_PANE_MIN_WIDTH is 450 and the panel floor is 244.
- renderPanel(760);
+ // Resize the strip's actual scrollport while leaving the active tab and tab
+ // count untouched. The wide fixture above confirms that the close control
+ // fits before this resize; 80px forces it out of view until the observer
+ // reveals the same active tab again.
+ const strip = element(".work-panel-tab-strip");
+ strip.style.flex = "0 0 80px";
+ strip.style.width = "80px";
await rendered();
const after = measure(stage);
+ assert(
+ after.stripClientWidth < before.stripClientWidth,
+ "fixture invalid: the tab strip scrollport did not narrow",
+ );
return after;
}
@@ -205,6 +219,7 @@ globalThis.tabCloseProbe = async (stage) => {
tabId: firstId!,
stripLeft: stripRect.left,
stripRight: stripRect.right,
+ stripClientWidth: strip.clientWidth,
closeLeft: rect.left,
closeRight: rect.right,
insideStrip: rect.left >= stripRect.left - 0.5 && rect.right <= stripRect.right + 0.5,