Skip to content

Commit d139c7a

Browse files
fix(studio): 流程页头信息条按顺序逐个让位,不再整排缩成单字 (#36745) (#36781)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8CSSa72mrtYoeegnZzNftqp)_ Fixes #36745 Clause-②: no Metadata-protocol: none ## 维护者速读 - 在 Studio 自动化里打开一个流程,标题旁那排「触发 · 状态 · 运行身份 · 版本 · 出错时」在右侧属性面板打开、位置变窄时,不再整排挤成一个字一个省略号;放不下的从后往前整项收起,鼠标悬停这一排能看到收起的内容。 - 来自你 11-23 的 Studio 评审(第 r07 项),属于界面体验缺陷修复。 - 出错的话最多是这一排显示的项目多一个或少一个,不影响流程本身和任何数据,可直接撤回。 - 无。 ## What changes `FlowMetaPills`' header variant laid its items on a one-row grid whose columns could all shrink to zero (objectui#13135), so a short meta slot (about 80 px with the property panel open) shrank every item at once, to one character each. - `ui/packages/app-shell/src/views/metadata-admin/previews/FlowPreview.tsx` - New `FlowMetaHeaderRow`: every item is laid out whole (`shrink-0`, `whitespace-nowrap`), each after its `·` separator, in a row that takes the slot's width and clips. After each render and on resize (`ResizeObserver` on the row) it measures each item's width and the row's, keeps the first N whole items, and makes the rest `invisible` + `aria-hidden` (still laid out, so still measured: they come back when the row widens). The row's `title` names each hidden item's whole `Label: value`, one per line, in row order; with nothing hidden there is no `title`. - New `fitFlowMetaItems(widths, available, floor = 2)`: as many whole items from the front as fit (half-pixel slack). Fewer than the floor (Trigger + Status) ⇒ 0: the row shows nothing. - Drop order is the row order from the end: On error, then version, then Run as. Trigger and Status are the floor. - The header `Pill` no longer truncates (`min-w-0 truncate` → `whitespace-nowrap`), and the per-pill cut measurement (`useCutText`, objectui#13135) is removed: nothing in the header can be cut any more. A shown pill keeps its own hover text (Status: the run status's reason; Trigger: the object's API name). - The designer's info bar (`variant="bar"`) is unchanged. - `ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx`: the `auto-flow-meta` wrapper goes `inline-flex` → `flex` (plus a comment line), so the row reads the meta slot's whole width rather than its own content width. - Tests: `FlowPreview.headerMetaTruncate-13135.test.tsx` is deleted (it pinned the `truncate` class this card replaces); `FlowPreview.headerMetaGiveWay-36745.test.tsx` is added. - Changeset: `@object-ui/app-shell` patch. `fitFlowMetaItems` is a module export, not on the package index. Reading taken on the card: "Keep Status and Trigger whole … hide the slot when not even one item fits". The card names On error, version and Run as as the items that drop, so Trigger + Status are read as the floor: when those two do not both fit whole, the row hides. (The other reading, dropping Status and then Trigger one by one, would drop an item the card says stays.) ## Tests - `FlowPreview.headerMetaGiveWay-36745.test.tsx`, 11 tests, widths stubbed per element (each item 120/110/80/30/60 px): - 400 px: all five shown, no row title; - 320 px: version and On error hidden, title = `v3` + `On error: …`; - 240 px: Run as hidden too, Trigger and Status stay; - 200 px (below the floor): every item hidden and `aria-hidden`, title names all five; - re-render wider: items come back; no header item carries `truncate`; - CONTROLS: a shown Status keeps its run-status hover text; the `bar` variant has no give-way row; - `fitFlowMetaItems` at the boundaries (399/400, 229/230) and fractional widths. - Ablation (`fitFlowMetaItems` returning every item regardless of width): 6 of 11 red; restored, `git diff HEAD` empty. - The test file imports `@objectstack/lint` at module top (`check:test-source-alias`: the source under test reaches its dynamic import; the load is paid at collection, not inside a clocked case). - Also run: `AutomationsPillar.tabs-12454.test.tsx`, `StudioItemHeader.statusPlace-12524.test.tsx` (they read `auto-flow-meta`): 20/20 with the new file. `pnpm --filter @object-ui/app-shell type-check`: exit 0. ## Acceptance notes Browser run on the showcase app (Studio › Automations › "Notify on Task Completed", zh-CN, 1440×900 unless named; its meta has four items, no On error). Shots are attached on the project thread (GitHub image upload is browser-only). Readings are the row's own `data-shown`, item widths and `title`: | Frame | Slot width | Items shown | Row hover text | |---|---|---|---| | Property panel open (the r07 case) | 81 px | none (Trigger 123 + Status 82 = 205 px do not fit) | 触发 / 状态 / 运行身份 / v1, one per line | | Panel closed | 441 px | all four, whole | none | | Panel closed, 1300 px viewport | 301 px | Trigger, Status, Run as | `v1` | | Panel closed, 1220 px viewport | 221 px | Trigger, Status | 运行身份: 用户 / v1 | | Panel closed, 1150 px viewport | 151 px | none | all four | No frame shows a cut or single-character item. Native `title` tooltips do not render headless, so the hover text is evidenced by the attribute. ## Verification - Two-minute check: in Studio › Automations, open a flow with the property panel closed (wide header: every item shows whole), then open the property panel: the row keeps Trigger and Status whole or hides, never single characters; hover the row to read what was dropped. <details><summary>Local gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands`: 38 derived families, all run; 37 exit 0 at `9f6fc4fa`. `check:test-source-alias` exited 1 there (the module-top lint import above), fixed and re-run at `d37f9470`: exit 0. `--ran` reconciliation: `38 run, 0 NOT-MEASURED (a DERIVED zero — all 38 recorded an exit code and none of them is 3)`. Results: project file `issue-36745/gate-results-d37f9470.tsv`. - `node scripts/pm/overlap-check.mjs` at `d37f9470`: `VERDICT clean exit 0` against `origin/main`, #36774 and #36784 (both share `StudioDesignSurface.tsx`, merge cleanly). - Every other family is CI's: read from this PR's check-runs, not re-run locally. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01JQwxbXxhLfnaEFoHNkAeGh)_ <!-- signed: repo:objectstack#1 · os-warren · session_01JQwxbXxhLfnaEFoHNkAeGh --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 368deee commit d139c7a

5 files changed

Lines changed: 294 additions & 177 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(studio): the flow header's meta gives way item by item instead of shrinking every item to one character
6+
7+
In Studio's Automations pillar, the open flow's header shows its meta beside the title: Trigger, Status, Run as, version and, when set, On error. When the row was short of room — with the property panel open, about 80 px were left — every item shrank at once, so the row read as single characters with ellipses.
8+
9+
Each item now keeps its whole text. When the row cannot hold them all, they drop from the end (On error, then version, then Run as), and hovering the row names each dropped item in full. Trigger and Status always show together: when the row cannot hold those two whole, the meta hides and the hover text names every item. Widen the row and the dropped items come back. The designer's info bar is unchanged.
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#36745 — with the property panel open, the Studio flow header's
5+
* meta ("Trigger: … · Status: … · Run as: … · v3 · On error: …") shrank every
6+
* item at once, to one character each (objectui#13135's shrinking grid). The
7+
* row now gives way item by item:
8+
*
9+
* - every item keeps its whole text (no item truncates);
10+
* - items drop from the end — On error, then version, then Run as — and the
11+
* row's hover text names each dropped item's whole text, in row order;
12+
* - Trigger and Status are the floor: when the row cannot hold those two
13+
* whole, every item hides and the hover text names all of them;
14+
* - an item that fits again comes back when the row widens;
15+
* - CONTROL: the designer's info bar (`bar`) has no such row.
16+
*
17+
* jsdom lays nothing out, so widths are the elements' own readings, stubbed
18+
* here per element: the row reads the width under test, each item its width.
19+
*/
20+
21+
import * as React from 'react';
22+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
23+
import { cleanup, render, screen, within } from '@testing-library/react';
24+
// The source under test reaches `import('@objectstack/lint')` inside a function
25+
// body; pay that load during collection, never inside a clocked case.
26+
import '@objectstack/lint';
27+
28+
vi.stubGlobal(
29+
'fetch',
30+
vi.fn(async () => new Response('not found', { status: 404 })),
31+
);
32+
33+
import { FlowMetaPills, fitFlowMetaItems } from './FlowPreview';
34+
import { t, translateFlowMeta } from '../i18n';
35+
36+
const LOCALE = 'en-US';
37+
const en = (key: string): string => t(key, LOCALE);
38+
39+
const DRAFT: Record<string, unknown> = {
40+
name: 'f1',
41+
label: 'F1',
42+
type: 'autolaunched',
43+
version: 3,
44+
runAs: 'system',
45+
errorHandling: { strategy: 'continue' },
46+
nodes: [
47+
{ id: 'start', type: 'start', label: 'Start', config: {} },
48+
{ id: 'end', type: 'end', label: 'End' },
49+
],
50+
edges: [{ id: 'e1', source: 'start', target: 'end' }],
51+
};
52+
53+
/** Each item's whole width with its leading separator; the five sum to 400. */
54+
const WIDTH: Record<string, number> = { trigger: 120, status: 110, runAs: 80, version: 30, onError: 60 };
55+
56+
let rowWidth = 0;
57+
const original = HTMLElement.prototype.getBoundingClientRect;
58+
59+
beforeEach(() => {
60+
HTMLElement.prototype.getBoundingClientRect = function (this: HTMLElement) {
61+
const key = this.dataset.metaItem;
62+
const width = this.dataset.testid === 'flow-meta-row' ? rowWidth : key ? (WIDTH[key] ?? 0) : 0;
63+
return { x: 0, y: 0, top: 0, left: 0, bottom: 16, right: width, width, height: 16, toJSON: () => ({}) } as DOMRect;
64+
};
65+
});
66+
67+
afterEach(() => {
68+
cleanup();
69+
HTMLElement.prototype.getBoundingClientRect = original;
70+
});
71+
72+
const whole = {
73+
trigger: () => `${en('engine.flowPreview.pill.trigger')}: autolaunched`,
74+
status: () => `${en('engine.flowPreview.pill.status')}: ${en('engine.studio.unpublishedDraft')}`,
75+
runAs: () => `${en('engine.flowPreview.pill.runAs')}: ${translateFlowMeta('runAs', 'system', LOCALE)}`,
76+
version: () => 'v3',
77+
onError: () => `${en('engine.flowPreview.pill.onError')}: ${translateFlowMeta('onError', 'continue', LOCALE)}`,
78+
};
79+
80+
function renderHeaderAt(width: number, variant: 'header' | 'bar' = 'header') {
81+
rowWidth = width;
82+
return render(<FlowMetaPills draft={DRAFT} runStatus={{ kind: 'unpublished' }} locale={LOCALE} variant={variant} />);
83+
}
84+
85+
function row(): HTMLElement {
86+
return screen.getByTestId('flow-meta-row');
87+
}
88+
89+
/** The items the row shows, in order: the ones not made invisible. */
90+
function shownKeys(): string[] {
91+
return Array.from(row().querySelectorAll<HTMLElement>('[data-meta-item]'))
92+
.filter((el) => !el.classList.contains('invisible'))
93+
.map((el) => el.dataset.metaItem!);
94+
}
95+
96+
describe('the flow header meta gives way item by item (objectstack#36745)', () => {
97+
it('wide row (400 px): every item shows whole, and the row has no hover text', () => {
98+
renderHeaderAt(400);
99+
expect(shownKeys()).toEqual(['trigger', 'status', 'runAs', 'version', 'onError']);
100+
expect(row()).not.toHaveAttribute('title');
101+
});
102+
103+
it('middle row (320 px): On error, then version, drop; the hover text names both whole', () => {
104+
renderHeaderAt(320);
105+
expect(shownKeys()).toEqual(['trigger', 'status', 'runAs']);
106+
expect(row()).toHaveAttribute('title', [whole.version(), whole.onError()].join('\n'));
107+
});
108+
109+
it('narrow row (240 px): Run as drops too; Trigger and Status stay whole', () => {
110+
renderHeaderAt(240);
111+
expect(shownKeys()).toEqual(['trigger', 'status']);
112+
expect(row()).toHaveAttribute('title', [whole.runAs(), whole.version(), whole.onError()].join('\n'));
113+
});
114+
115+
it('a row too narrow for Trigger and Status (200 px, the panel-open case) hides every item', () => {
116+
renderHeaderAt(200);
117+
expect(shownKeys()).toEqual([]);
118+
expect(row()).toHaveAttribute(
119+
'title',
120+
[whole.trigger(), whole.status(), whole.runAs(), whole.version(), whole.onError()].join('\n'),
121+
);
122+
// Hidden items are out of the accessibility tree, not half-drawn.
123+
for (const el of row().querySelectorAll('[data-meta-item]')) expect(el).toHaveAttribute('aria-hidden', 'true');
124+
});
125+
126+
it('an item that fits again comes back when the row re-renders wider', () => {
127+
const view = renderHeaderAt(200);
128+
expect(shownKeys()).toEqual([]);
129+
rowWidth = 400;
130+
view.rerender(<FlowMetaPills draft={{ ...DRAFT }} runStatus={{ kind: 'unpublished' }} locale={LOCALE} variant="header" />);
131+
expect(shownKeys()).toEqual(['trigger', 'status', 'runAs', 'version', 'onError']);
132+
});
133+
134+
it('no header item truncates: each keeps its whole text on one line', () => {
135+
renderHeaderAt(240);
136+
for (const el of row().querySelectorAll('[data-meta-item], [data-meta-item] *')) {
137+
expect(el).not.toHaveClass('truncate');
138+
}
139+
expect(within(row()).getByText(`${en('engine.flowPreview.pill.status')}:`).parentElement).toHaveClass('whitespace-nowrap');
140+
});
141+
142+
it("CONTROL: a shown Status keeps its own hover text (the run status's reason)", () => {
143+
renderHeaderAt(400);
144+
expect(within(row()).getByText(`${en('engine.flowPreview.pill.status')}:`).parentElement).toHaveAttribute(
145+
'title',
146+
en('engine.studio.auto.unpublishedTitle'),
147+
);
148+
});
149+
150+
it("CONTROL: the designer's info bar has no give-way row and shows every item", () => {
151+
renderHeaderAt(0, 'bar');
152+
expect(screen.queryByTestId('flow-meta-row')).toBeNull();
153+
expect(screen.getByText(`${en('engine.flowPreview.pill.onError')}:`)).toBeVisible();
154+
});
155+
});
156+
157+
describe('fitFlowMetaItems', () => {
158+
const widths = [120, 110, 80, 30, 60];
159+
it('keeps as many whole items from the front as fit', () => {
160+
expect(fitFlowMetaItems(widths, 400)).toBe(5);
161+
expect(fitFlowMetaItems(widths, 399)).toBe(4);
162+
expect(fitFlowMetaItems(widths, 310)).toBe(3);
163+
expect(fitFlowMetaItems(widths, 230)).toBe(2);
164+
});
165+
it('shows nothing below the Trigger + Status floor', () => {
166+
expect(fitFlowMetaItems(widths, 229)).toBe(0);
167+
expect(fitFlowMetaItems(widths, 0)).toBe(0);
168+
});
169+
it('absorbs a half-pixel of fractional width', () => {
170+
expect(fitFlowMetaItems([120.4, 110.3], 230.5)).toBe(2);
171+
});
172+
});

‎ui/packages/app-shell/src/views/metadata-admin/previews/FlowPreview.headerMetaTruncate-13135.test.tsx‎

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)