Skip to content

Commit 27c2f1e

Browse files
fix(console): a list with no declared primary action keeps its header actions as buttons beside a long description (#34045)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JXjA9EsAjn7YUmjuHNUrgC)_ Fixes #33988 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么:** 列表页(和 `/data` 页)页头没有「声明的主操作」时(没有 New,也没有工具栏动作写 `variant: 'primary'`),不再把按钮折叠进「⋯」;按钮一直保留,长描述被截断。 - **为什么改:** objectui#12705 的折叠只保留声明的主操作。hotclm 的 `Launch Contract` 没声明为 primary,读者也没有 New,于是折叠后只剩「⋯」,英文长描述一占满就把唯一的按钮藏进菜单(卡里截图的菜单正是 `Launch Contract`、`Add to favorites`)。 - **风险与回滚:** 只动 `@object-ui/app-shell` 三个文件的条件与注释,PageHeader 的折叠算法不变;有声明主操作的页面行为不变(objectui#12705 的测试原样通过)。没有主操作的页面在窄屏也不再折叠,按钮照常显示、标题和描述先截断。回滚 = revert。 - **先看:** `objectViewHeaderChrome.tsx` 里 `foldedHeaderActions` 的新条件;`ObjectDataPage.tsx` 的 `foldedActions`;测试 `ObjectView.headerFold-12705.test.tsx` 新增的 objectstack#33988 describe。 - **两分钟验证:** `pnpm --dir ui exec vitest run packages/app-shell/src/views/ObjectView.headerFold-12705.test.tsx packages/app-shell/src/views/ObjectDataPage.createAffordances.test.tsx`,预期全部通过;在没有 New、只有一个非 primary 工具栏动作、描述很长的列表页上,1440 宽下该动作仍是按钮。 - **需要你做的:** 无,席位落地。 ## What changes - **The list page offers its header a folded face only when it has a primary to keep.** `useObjectViewHeaderChrome` builds `foldedHeaderActions` only when the list draws New or has a list-toolbar action authored `variant: 'primary'` (`declaredPrimaryToolbarAction`). Otherwise it passes none, and `PageHeader` keeps `actions` at every width (its documented behaviour for a page with no `foldedActions`); the description truncates instead. - **`/data` (`ObjectDataPage`) follows the same rule:** its folded face (New labelled, Save as view in a `⋯`) is offered only when New is drawn. An admin who cannot create keeps Save as view as a button. - **`PageHeader`:** no code change; the `foldedActions` docblock now says a page with no primary to keep labelled passes none. - A list that declares a primary folds exactly as before; the objectui#12705 pins are unchanged. ## Why `PageHeader` folds when `actions` would clip the title or the description, and the description counts at its full content width. The list's folded face keeps one labelled action only when that action is DECLARED primary; with none, the face is the `⋯` alone. So on hotclm's `clm_contract` list (reader without create, one toolbar action `Launch Contract` not authored primary, a 122-character English description), the header folded at desktop width and moved the page's only action into the menu, exactly the card's menu (`Launch Contract`, `Add to favorites`). The PM hypothesis (the action bar measures what the title block leaves) did not hold: the fold decision is `PageHeader`'s, and it worked as designed; the gap was a folded face with nothing labelled in it. **Between phone and desktop widths** a list with no declared primary now never folds: its actions stay labelled buttons, the description truncates first and the title truncates inside its 60 % cap. The schema-driven toolbar keeps its own `action:bar` overflow (`maxVisible`), so many undeclared actions still collapse into that bar's own menu, as before objectui#12705. Below `sm` the Console list draws its phone header, which this change does not touch. To keep a toolbar action labelled AND fold the others on a narrow header, author it `variant: 'primary'`. ## Tests - `ObjectView.headerFold-12705.test.tsx`, new top-level `describe` in the existing harness (the same layout model as the objectui#12705 pins: 10 px per title character, 7 px per description character, 100 px per labelled button): the card's object (no New for the reader, one undeclared `Launch Contract`, the card's description) at a 1110 px, 1184 px (a 1440 px viewport less the 256 px sidebar) and 700 px header keeps `Launch Contract` labelled, the `⋯` holds only `Add to favorites`, and `data-folded` is absent. **CONTROL:** the same list with `Launch Contract` authored `variant: 'primary'` still folds at 600 px and keeps it labelled. - `ObjectDataPage.createAffordances.test.tsx`, new top-level `describe`: an admin who cannot create keeps Save as view as a button with no fold offered; **CONTROL:** with New drawn the fold is offered (`data-folded="false"`). - **Forced test edits:** the `/data` harness's `useWorkspaceAdminStatus` mock now reads a `workspaceAdmin` variable (default `false`, reset in `beforeEach`), so the existing cases see the same value as before. The `ObjectView` fold harness gains the module-top `import '@objectstack/lint'` that `check:test-source-alias` asks of an edited test file reaching `ObjectView`. <details><summary>Runs, ablation and the wider suite (head 2daa61d)</summary> - The two fold harnesses plus the `/data` harness: `Test Files 3 passed (3)`, `Tests 48 passed (48)` (lock VERDICT command-exit 0). - Ablation through `scripts/ablation-replace.mjs`, both fixes mutated together (`objectViewHeaderChrome.tsx` anchor `!isEnvironmentList && (showCreate || primaryToolbarAction) ?` 1 → 0, replaced by `!isEnvironmentList /* ablated */ ?`; `ObjectDataPage.tsx` anchor `newButton && <>` 1 → 0, replaced by `(true as boolean) && <>`; both restored, blob equal to HEAD, `git diff HEAD` empty): all four no-primary pins red, both controls green, `Tests 4 failed | 37 passed (41)`. With the assertions reordered to read the action first, the list-page leg reads `AssertionError: expected [] to deeply equal [ 'Launch Contract' ]` at 1110, 1184 and 700 px: the action was in the `⋯`. ui vitest resolves `@object-ui/*` to `src/`, so no build sits between mutation and run. A first `/data` leg replaced the anchor with `<>`, which the tool refused (the replacement already occurred in the file); it did not run. - Every test file under `ui/packages/app-shell/src` and `ui/apps/console/src` naming `PageHeader`, `ObjectDataPage`, `ObjectView` or `objectViewHeaderChrome` (191 files, selected by `grep -rlE`): `Test Files 191 passed (191)`, `Tests 2246 passed (2246)` (lock VERDICT command-exit 0), at 1eba7d1; the final head adds only the harness's module-top import, and the three pin files were re-run on it. The rest of Test UI is CI's. - `pnpm --filter @object-ui/app-shell type-check` (`tsc --noEmit` and `tsc -p tsconfig.test.json`) after `turbo run build --filter='@object-ui/app-shell^...'`: VERDICT command-exit 0. - `pnpm exec eslint` on the five touched files from `ui/`: 0 errors (21 pre-existing warnings, none on added lines). `pnpm run check:new-line-citations` (ui): `0 new citation(s)`. </details> ## Acceptance notes - **Real browser: NOT MEASURED** (no hotclm stack in this container). The pins use the objectui#12705 harnesses' layout model; in it the base code folds the card's list at 1110, 1184 and 700 px, matching the card's 1440 px reading. - **Same class elsewhere:** `PackagesPage` always draws New Package, so its folded face always keeps a labelled action; no change there. - **hotclm (carrier: hotclm):** authoring `Launch Contract` as `variant: 'primary'` would also keep it labelled on a narrow header while the other actions fold; not required for this fix. ## Verification Gates from `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` on 2daa61d (change set: 6 paths vs merge base bc6b7ff): **37 derived, 37 run, all exit 0**; `dispatch-gates --ran`: "37 derived famil(ies) accounted for — 37 run, 0 NOT-MEASURED (a DERIVED zero …)". Among them `check:test-source-alias`, `check:type-check-debt`, `check:type-check-coverage`, `check:cross-package-test-inputs`, `check:published-files`, `check:nul-bytes`, `check-sdui-manifest` (and `--self-test`), `check-changeset-no-major --base origin/main`, `check-empty-changeset --base origin/main`, `check-adr-0087-registration --base origin/main`, `pnpm --dir ui exec vitest run scripts/`. The first round on 1eba7d1 had `check:test-source-alias` red (the edited fold harness lacked the module-top lint import); fixed in 2daa61d and the whole list re-run there. Dogfood: n/a (no `!` in the title, no `(narrowing)` arm). Changeset: `.changeset/33988-header-fold-needs-primary.md`, `@object-ui/app-shell` and `@object-ui/console` patch. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmRPuiKPqavVVdijcAp)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 39fa82b commit 27c2f1e

6 files changed

Lines changed: 101 additions & 5 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
---
5+
6+
fix(console): a list page with no declared primary action keeps its header actions as buttons, whatever the length of the object's description
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
On a list page the header folds its actions when they do not fit beside the title and the object's description: the primary action stays a labelled button and the others move into the `⋯` menu. The primary is declared: the page's New, else the list-toolbar action authored `variant: 'primary'`. A list with neither had nothing to keep labelled, so the folded header was the `⋯` alone, and a long description by itself moved the page's one action (for example a reader without create rights and a single `Launch Contract` toolbar action) into the menu at desktop width. Such a list is now offered no folded header: its actions stay buttons at every width and the description is truncated instead. The `/data` page follows the same rule: with no New to keep, Save as view stays a button. A list that declares a primary folds exactly as before. To keep a toolbar action labelled on a narrow header as well, author it `variant: 'primary'`.

‎ui/packages/app-shell/src/layout/PageHeader.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ export interface ConsolePageHeaderProps {
135135
* The header measures its own width, not the viewport's. The page declares
136136
* which action is primary by being the one that names it here; the header
137137
* never guesses it from `actions`. A page that passes no `foldedActions`
138-
* keeps `actions` at every width.
138+
* keeps `actions` at every width, and a page with no primary to keep
139+
* labelled passes none (objectstack#33988): a face of only the `⋯` would
140+
* trade the page's actions for its description.
139141
*/
140142
foldedActions?: React.ReactNode;
141143
/**

‎ui/packages/app-shell/src/views/ObjectDataPage.createAffordances.test.tsx‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ import { MemoryRouter, Routes, Route } from 'react-router-dom';
6161
let principal: Record<string, boolean> = {};
6262
/** Controllable server-resolved effective API operations (#3391); `undefined` = unrestricted. */
6363
let apiOperations: string[] | undefined;
64+
/** Whether the reader is a workspace admin (draws "Save as view"); off by default. */
65+
let workspaceAdmin = false;
6466

6567
vi.mock('@object-ui/permissions', async (importOriginal) => {
6668
const actual = await importOriginal<typeof import('@object-ui/permissions')>();
@@ -85,7 +87,7 @@ vi.mock('@object-ui/permissions', async (importOriginal) => {
8587
vi.mock('@object-ui/auth', async (importOriginal) => ({
8688
...(await importOriginal<Record<string, unknown>>()),
8789
useAuth: () => ({ user: { id: 'u1', name: 'Ada' }, activeOrganization: null }),
88-
useWorkspaceAdminStatus: () => ({ isAdmin: false, isResolved: true }),
90+
useWorkspaceAdminStatus: () => ({ isAdmin: workspaceAdmin, isResolved: true }),
8991
createAuthenticatedFetch: () => vi.fn(),
9092
}));
9193

@@ -182,6 +184,7 @@ function expectCreateEntry(expected: { rendered: boolean; disabled?: boolean })
182184
beforeEach(() => {
183185
principal = {};
184186
apiOperations = undefined;
187+
workspaceAdmin = false;
185188
cleanup();
186189
vi.stubGlobal(
187190
'fetch',
@@ -373,3 +376,31 @@ describe('#5164 — /data and the object-list page agree on one declaration', ()
373376
expect(newButton()).toBeTruthy();
374377
});
375378
});
379+
380+
/**
381+
* objectstack#33988 — the header's folded face (objectui#12705) keeps New
382+
* labelled and puts Save as view in a `⋯`. With no New there is nothing to keep
383+
* labelled, so the page offers no folded face: a long description must never
384+
* send the page's one action into the `⋯`. The header marks a page that offers
385+
* the fold with `data-folded`; one that does not keeps `actions` at every
386+
* width, so the attribute is absent.
387+
*/
388+
describe('objectstack#33988 — /data offers the fold only with a New to keep labelled', () => {
389+
const cluster = () => document.querySelector('[data-testid="page-header-actions"]') as HTMLElement | null;
390+
391+
it('an admin who cannot create keeps "Save as view" as a button: no folded face is offered', () => {
392+
workspaceAdmin = true;
393+
principal = { create: false };
394+
renderDataPage(objects());
395+
expect(newButton()).toBeNull();
396+
expect(cluster()?.querySelector('[data-testid="object-data-save-as-view"]')).toBeTruthy();
397+
expect(cluster()?.hasAttribute('data-folded')).toBe(false);
398+
});
399+
400+
it('CONTROL: with New drawn, the folded face is still offered', () => {
401+
workspaceAdmin = true;
402+
renderDataPage(objects());
403+
expect(newButton()).toBeTruthy();
404+
expect(cluster()?.getAttribute('data-folded')).toBe('false');
405+
});
406+
});

‎ui/packages/app-shell/src/views/ObjectDataPage.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,11 @@ export function ObjectDataPage({ dataSource, objects }: any) {
629629
</>
630630
}
631631
// objectui#12705 — too narrow for both actions and the description:
632-
// New stays labelled and Save as view goes into a `⋯`.
632+
// New stays labelled and Save as view goes into a `⋯`. With no New
633+
// to keep labelled there is no folded face (objectstack#33988): it
634+
// would send the page's one action into the `⋯` for the description.
633635
foldedActions={
634-
<>
636+
newButton && <>
635637
{newButton}
636638
{isAdmin && (
637639
<DropdownMenu>

‎ui/packages/app-shell/src/views/ObjectView.headerFold-12705.test.tsx‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ vi.mock('@object-ui/plugin-grid', async (importOriginal) => ({
9999
ImportWizard: ({ open }: { open: boolean }) => (open ? <div data-testid="import-wizard" /> : null),
100100
}));
101101

102+
// `ObjectView` reaches a dynamic `import('@objectstack/lint')`: pay its load at
103+
// collection, never inside a case's clocked window (`check:test-source-alias`).
104+
import '@objectstack/lint';
102105
import { ObjectView, declaredPrimaryToolbarAction } from './ObjectView';
103106
import { ExpressionProvider } from '../providers/ExpressionProvider';
104107

@@ -282,6 +285,47 @@ describe('the object list’s header folds its actions (objectui#12705)', () =>
282285
});
283286
});
284287

288+
/**
289+
* objectstack#33988 — a list that declares no primary (no New, no toolbar
290+
* action authored `variant: 'primary'`) is offered no folded face: that face
291+
* would keep no labelled action, so a long description alone sent the page's
292+
* one action into the `⋯` at desktop width (hotclm's 「Launch Contract」). The
293+
* header keeps `actions` at every width and the description truncates instead.
294+
*/
295+
describe('a list with no declared primary keeps its actions labelled (objectstack#33988)', () => {
296+
const LAUNCH = { name: 'launch_contract', label: 'Launch Contract', type: 'script', locations: ['list_toolbar'] };
297+
/** The card's object: no New for the reader, one undeclared toolbar action, its English description. */
298+
const CONTRACTS = {
299+
name: 'demo_contract',
300+
label: 'Contract',
301+
pluralLabel: 'Contracts',
302+
description:
303+
'A contract from intake to archive: parties, commercial and legal terms, lifecycle status and the stamps each stage leaves.',
304+
fields: { id: { type: 'text', label: 'Id' }, name: { type: 'text', label: 'Name' } },
305+
actions: [LAUNCH],
306+
};
307+
308+
// A 1366 px laptop and a 1440 px desktop, each less the 256 px sidebar, and
309+
// a tablet-wide header between the phone header and the desktop.
310+
it.each([1110, 1184, 700])('at a %i px header the action stays a button and the header does not fold', (width) => {
311+
headerWidth = width;
312+
principal = { create: false };
313+
const { cluster, labelled, openMenu } = renderList(CONTRACTS);
314+
expect(labelled()).toEqual(['Launch Contract']);
315+
expect(openMenu()).toEqual(['Add to favorites']);
316+
expect(cluster.hasAttribute('data-folded')).toBe(false);
317+
});
318+
319+
it('CONTROL: authored `variant: primary`, the same list still folds at a 600 px header, keeping it labelled', () => {
320+
headerWidth = 600;
321+
principal = { create: false };
322+
const { cluster, labelled, openMenu } = renderList({ ...CONTRACTS, actions: [{ ...LAUNCH, variant: 'primary' }] });
323+
expect(cluster.getAttribute('data-folded')).toBe('true');
324+
expect(labelled()).toEqual(['Launch Contract']);
325+
expect(openMenu()).toEqual(['Add to favorites']);
326+
});
327+
});
328+
285329
describe('declaredPrimaryToolbarAction (objectui#12705)', () => {
286330
it('is the `variant: primary` list-toolbar action with the lowest order, never the first by position', () => {
287331
const late = { ...INVITE, name: 'late', order: 5 };

‎ui/packages/app-shell/src/views/objectViewHeaderChrome.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ export function useObjectViewHeaderChrome({
9797
// it before the header can fold, so no action in the folded face carries
9898
// `autoTrigger`. Not offered on the environment list, whose toolbar is
9999
// `EnvironmentListToolbar`, not this bar.
100+
//
101+
// objectstack#33988 — not offered either when the list declares no
102+
// primary (no New, no toolbar action authored `variant: 'primary'`): that
103+
// face would keep no labelled action, so a long description alone would
104+
// send the page's one action into the `⋯`. Without a folded face the
105+
// header keeps `actions` at every width and the description truncates.
100106
const toolbarRowActions: UIActionSchema[] = listActions?.some((a: { locations?: readonly string[] }) => a.locations?.includes('list_toolbar'))
101107
? toolbarActionsWithDeepLink
102108
: [];
@@ -133,7 +139,7 @@ export function useObjectViewHeaderChrome({
133139
maxVisible: 0,
134140
mobileMaxVisible: 0,
135141
};
136-
const foldedHeaderActions = !isEnvironmentList ? (
142+
const foldedHeaderActions = !isEnvironmentList && (showCreate || primaryToolbarAction) ? (
137143
<>
138144
{createButton}
139145
{/* One inline slot at every width: `toolbarBar` keeps none below

0 commit comments

Comments
 (0)