Skip to content

Commit 5e8e243

Browse files
feat(console): a footer calculation is a part of the list draft; a package view's refused save says why in the reader's words (#36212)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu3R6vTvrF8uP9Z2MFVbqmJV)_ repo:objectstack#1 · os-sales · session_01L6bhgX7ez5A7JDsmzTy9Ks Fixes #36194 Fixes #36195 Clause-②: yes (widening) — two new keys in every `@object-ui/i18n` locale pack (`console.objectView.personalizedParts.summaries`, `console.objectView.saveRefused.packaged`); zh-Hant regenerated; nothing removed or renamed. `ListView` / `ObjectGrid` props unchanged (doc comments only). Metadata-protocol: none ## 维护者速读 - 列表底部选、换、去掉一列的统计:马上显示结果,不再写进视图或个人视图;和筛选排序一样算草稿,出现「放弃」「保存」,「保存」菜单的未保存列表多一项「统计」。「放弃」还原;「保存到这个视图」(自己的视图)和「另存为我的视图」把统计一起存进去。 - 包里带的视图(比如 HotCRM「全部客户」)、没有权限改的共享视图:照样能选统计,进草稿,「保存」里只有「另存为我的视图」。任何时候都不会再出现卡上那段英文报错。 - 服务端拒绝保存包里带的视图时,提示改成一句中文(11 种语言都有):「这个视图来自应用包,不能直接修改,可以另存为我的视图。」其它拒绝照旧显示服务端那句话(那些是写给人看的,已有测试钉着)。 - 卡上那段报错的来历:包可写的判断要等包列表读回来,列表为了不和页面抢网络,要等页面请求安静下来(最多 8 秒)才读;这之前判断按设计放行,底部入口就直接写了视图。统计改成草稿后,这段时间里底部不再写任何东西。 ## What changes **A footer calculation is a draft part** (`objectViewListRenderer.tsx`, `listDraftStore.ts`, `columnSummaryWrite.ts`, `ObjectView.tsx`) - `ListDraft` gains `summaries` (column → calculation, `null` = None over a column the view sums); an emptied part is no part. It lives exactly as the other parts (#35955 item 4: kept on a record round trip, dropped on another view or object and on a reload). - The renderer lays the draft's calculations over the columns it hands `ListView` (`columnsWithSummaries`), so the grid draws them at once, and `onColumnSummaryPick` only patches the draft and answers `true`. A pick equal to the column's own calculation (`columnSummaryOf`) drops the column from the draft. - The menu is offered (`columnSummaryPickFields`) on the columns the list draws, the reader's added fields included: the columns a saved body carries. Where the list holds no draft (an environment list, no open view) nothing is offered (`listViewActions.draftsSummaries`). - Removed: `handlePickPersonalViewSummary` (wrote the reader's own view at once) and `handlePickSharedViewSummary` (wrote the shared view's draft, `PUT /meta/view/<name>?mode=draft`). No footer pick writes anything now. - The Save menu's unsaved list names it: host-side part `summaries` (`ListDraftActions`' `ListPersonalizationPart` gains it; `ListView`'s own vocabulary is untouched), pushed in `objectViewListUrlState.ts` like `columns`. - Saves carry it: `PersonalViewListState.summaries`, laid by `buildPersonalViewConfig` on the columns it keeps (after added fields, order and hidden columns). Callers: Save to this view (own view), Save as my view, the switcher's create card with "include current". **A view the reader cannot change in place** — the same "can save in place" reading as the filter and the Save menu, no second rule: the Save menu offers Save to this view on the reader's own view only (on `main`), so a package's view and a non-admin's shared view get Save as my view alone. With #36123 merged in, its shared-view Save to this view keeps its own test (`canSaveToSharedView`, now waiting for the package list: small call 5) and stores the calculations too. **A refused save of a package's view** (`viewSaveRefusal.ts`, `objectViewViewCrud.tsx`, `ObjectView.tsx`) - `viewSaveRefusalText(err, t)`: `code === 'NOT_OVERRIDABLE'` (the door's close on an item a package ships, `protocol-packaged-base-refusal.ts`) → `console.objectView.saveRefused.packaged`; anything else → `formatMetadataError` as before. Used at every view-write toast on the object page except delete (view settings save, create, rename, pin, set default, personal create / save / save as). **Docs**: `content/docs/ui/views.mdx` § "A user's list state never writes the view". Changeset `36194-footer-calculation-draft.md`. ## Small calls made in this thread (Sales 22:19:27Z rule; seat agreed 22:51Z) 1. The menu is offered on every column the list draws, not only the ones the view declares: the draft can carry a calculation on any column the saved body keeps (#35702's declared-only limit existed because the pick wrote the view). 2. A reader who is no admin gets the menu on a shared view too (their pick is their draft; Save as my view keeps it). The card's "no entry for a reader without permission" acceptance line predates the fold; the brief settles it as "into the draft, Save as my view alone". 3. Only `NOT_OVERRIDABLE` is reworded. Other refusals (403 permission, 422 field issues, pin / default / rename) keep the door's message, which objectui#11583 / #12417 pin as worded for the person saving. 4. The switcher's create card carries the calculations only with "include current", as it does the filter and sort. 5. **Done after #36123 merged:** its 「保存到这个视图」 on a shared view stays hidden while the package list is unread, and for a package listed read-only (`usePackageSaveRead`: the same session-held read as `usePackageRefusesSaves`, with the in-flight state told apart; a failed read or an unlisted package still offers it, as today). Reason measured below: the unread window is where the card's error came from. ## Root cause of the card's error (measured, client-side) HotCRM 6.5.0 on `main` (`fa304140`), console from this tree's `ui/` against it: the server's package list reports `app.objectstack.hotcrm` `writable: false`, and `crm_account.all_accounts`'s row carries `_packageId: app.objectstack.hotcrm`. The reading is right once read; but `fetchSessionPackages` waits for the page's own requests to go quiet (up to 8 s) before it reads, and until then `usePackageRefusesSaves` fails open by design. Measured at 1440: the list drew with 「+ 添加统计」 at 7.2 s, the package list answered at 8.0 s, and the entry went. A pick inside that window sent the `PUT ?mode=draft` the card shows. With this PR the pick writes nothing in any window. ## Tests - `ObjectView.footerCalculationDraft-36194.test.tsx` (7, renamed from `ObjectView.readOnlyPackageView-35933.test.tsx`; real `ObjectView`, `ListView` stand-in that draws the condition row's end, every non-GET `fetch` recorded): a pick is drawn, writes nothing, Save names it, picking None again drops it; Discard takes it off; the reader's own view stores it only on Save to this view; a view that declares no columns gets the menu on the drawn columns and Save as my view stores it; a package's view: drawn, no write, Save offers Save as my view alone, which stores it; the package list unread: still a draft; a non-admin on a shared view: a draft, Save as my view alone. - `__tests__/footerCalculationDraft-36194.test.ts` (9): `columnsWithSummaries` / `columnSummaryOf`; the draft store's empty part; `buildPersonalViewConfig` stores calculations on kept columns (added kept, hidden dropped) in a body `ListViewSchema` accepts; `viewSaveRefusalText` (package refusal reworded, a 403 keeps the door's words, issues keep the list). - `AppContent.draftSaveKeepsList-35932.test.tsx` (8, adapted): the pick no longer writes, so the refresh pulse a draft save announces is announced by the test (`emitMetadataRefresh`); no skeleton, no remount, picks drawn through it; a reader's pick is offered (their draft). ## Verification Local at head (`claude/project-thread-8r2qm4`): - `pnpm --dir ui exec vitest run packages/app-shell/src/views/ObjectView packages/app-shell/src/views/__tests__ packages/app-shell/src/views/ListDraftActions packages/app-shell/src/views/personalViews packages/app-shell/src/console/__tests__/AppContent packages/i18n packages/plugin-list/src packages/plugin-grid/src/__tests__` → 797 files, 8404 passed / 13 skipped; the 7 failures of that run were the first version of the refusal helper (it also reworded every 403) and a stale zh-Hant; both fixed, and the three files re-run green (`ObjectView.viewWriteRefusal-11583`, `ObjectView.createViewRefusal-11578`, `packages/i18n` 106 files). - `@object-ui/app-shell` `type-check` (both `tsc --noEmit` and `tsconfig.test.json`): exit 0. - `eslint` on every changed file: 0 errors. - The whole app-shell package is left to CI's shards. ## Since the first L1-b read (`ef54913f` → `efa7c4f0`) - Merged `main` twice (#36128, then #36123). Resolutions: the renderer's memo deps take #36128's `openReferencedRecord` and keep this PR's drop of `summaryPickKey`; `ObjectView`, `personalViews`, `listDraftStore` and `views.mdx` keep both sides (calculations beside #36123's layout and row colour). - The shared-view Save to this view passes `summaries` to `layListStateOverView`, which lays them after the added, ordered and hidden columns; it still writes neither the reader's row height nor column widths. - Small call 5: `usePackageSaveRead` in `useStudioDesignGate.ts` (`unread` / `refuses` / `takes`); `canSaveToSharedView` asks for `takes`. - L1-b N1: `viewSaveRefusalText` reads the code with `errorCodeIs`. - Tests: three new cases in `ObjectView.sharedViewSave-35955.test.tsx` (a pick on a shared view writes nothing and Save to this view stores it with the view's own row height; unread package list hides the save, the answer offers it; a failed read offers it). Local: 203 files / 1769 tests green (ObjectView*, the gate hook, `views/__tests__`, the console draft test); app-shell type-check 0; eslint 0 errors. ## Evidence (HotCRM 6.5.0, 1440×900, `/mnt/project-files/build-seat1/36194-36195/`) - Before: `before-1440-{light,dark}-hotcrm-pick-refused.png` — 「全部客户」, the package list held 15 s to show the window, a 「去重」 pick: `PUT …/crm_account.all_accounts?mode=draft`, the English refusal toast. - After (same hold): `after-1440-{light,dark}-hotcrm-pick-in-draft.png` (「去重 9」 drawn, 「放弃」「保存」, no write), `after-1440-{light,dark}-hotcrm-save-menu.png` (「未保存的改动: 统计」, 「另存为我的视图」 alone), `after-1440-light-hotcrm-discarded.png`, `after-1440-light-saved-as-my-view.png` (「全部客户 副本」 keeps 「去重 9」), `after-1440-light-my-view-save-menu.png` (own view: 「保存到这个视图」 offered), `after-1440-light-my-view-after-reload.png` (saved 「非空 9」 survives a reload; the only write of the run: `PATCH /api/v1/data/sys_personal_view/<id>`). ## Overlap `overlap-check.mjs` @ `efa7c4f0`: merges cleanly with `main` (`af2361ee`, #36123 and #36128 in); textual conflict with #36133 only (`listDraftStore.ts`, `objectViewListRenderer.tsx`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgX7ez5A7JDsmzTy9Ks <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgX7ez5A7JDsmzTy9Ks --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent af2361e commit 5e8e243

30 files changed

Lines changed: 839 additions & 385 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): a footer calculation is a part of the list's draft; a refused save of a package's view says why in the reader's words
7+
8+
Clause-②: yes (widening) — new keys in every `@object-ui/i18n` locale pack: `console.objectView.personalizedParts.summaries` and `console.objectView.saveRefused.packaged`; nothing removed or renamed
9+
Metadata-protocol: none
10+
11+
On a Console object list, picking, changing or removing a column's footer calculation (「+ 添加统计」) applies at once and writes nothing. It used to be saved at once: on the reader's own view straight into it, on a shared view as a draft of the view (`PUT /api/v1/meta/view/<name>?mode=draft`), which the server refuses on a view an app package ships.
12+
13+
- The calculation is a part of the list's draft, like the sort and the filter: **Discard** and **Save** appear, Save's menu names it (「统计」), and Discard takes it off. The draft lives as long as the others: kept on opening a record and coming back, dropped on another view, object or a reload.
14+
- **Save to this view** (on the reader's own view, or on a shared view an admin may edit) and **Save as my view** store it on the columns the saved view keeps.
15+
- **Save to this view** on a shared view is offered only once the Console has read that the view's package takes saves: not while that read is in flight (on a slow start the list draws seconds before it lands) nor for a package it lists read-only. A failed read, or a package the list leaves out, still offers it as before.
16+
- On a view the reader cannot change in place (one an app package ships, or a shared view of a reader who is no admin), the pick goes into the draft too and Save offers **Save as my view** alone.
17+
- The menu is offered on every column the saved view would carry: the columns the list draws and the fields the reader added.
18+
- When the server refuses to save a view an app package ships (`NOT_OVERRIDABLE`), the toast says in the reader's language that the view comes with an app package, cannot be changed directly and can be saved as the reader's own view. The server's text goes to the console only. Every other refusal is said as before.

‎content/docs/ui/views.mdx‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -620,25 +620,34 @@ reader's right-column and panel choices on it, are described in
620620
### A user's list state never writes the view
621621
622622
A header sort, a filter change, grouping, the search, Hide Fields, an added field, a
623-
column drag and the Display panel's layout and row color apply at once and are a **draft**:
624-
they are kept nowhere and never write the view metadata, so they work even where the
625-
tenant's metadata is read-only. While the list holds a draft, **Discard** and **Save** sit at
626-
the end of the condition row (one **Save** whose menu also holds Discard on a narrow list or
627-
a phone).
628-
629-
- **Save** names what is unsaved and keeps the sort, filters, columns, hidden fields, layout
630-
and row color: **Save to this view**, or **Save as my view**, which asks a name first (the
631-
view's name with "copy") and then opens the new view. Either says "Saved", and the buttons
632-
go while the conditions stay.
623+
column drag, a footer calculation picked under a column, and the Display panel's layout and
624+
row color apply at once and are a **draft**: they are kept nowhere and never write the view
625+
metadata, so they work even where the tenant's metadata is read-only. While the list holds a
626+
draft, **Discard** and **Save** sit at the end of the condition row (one **Save** whose menu
627+
also holds Discard on a narrow list or a phone).
628+
629+
- **Save** names what is unsaved and keeps the sort, filters, columns, hidden fields, footer
630+
calculations, layout and row color: **Save to this view**, or **Save as my view**, which
631+
asks a name first (the view's name with "copy") and then opens the new view. Either says
632+
"Saved", and the buttons go while the conditions stay. A view the user cannot change in
633+
place (one an app package ships, or a shared view they may not edit) offers **Save as my
634+
view** alone.
633635
- **Save to this view** on a view of the user's own saves it at once. On a shared view it is
634636
offered to a user who may edit the view (an administrator, on a stored view whose package
635-
takes saves). It asks once ("everyone who uses this view will see these changes"), then
637+
takes saves; while the Console has not yet read which packages take saves, it is not
638+
offered). It asks once ("everyone who uses this view will see these changes"), then
636639
saves the view and publishes it in the same step, so every user sees it on their next read,
637640
and says "Saved, visible to everyone". It never writes the user's row height or column
638641
widths into the view. When the view already has unpublished changes (a draft saved from
639642
the view settings, by anyone), nothing is saved: the Console says so and points to the view
640643
settings to publish or discard that draft first. Every other change to a shared view still
641644
goes to a draft that the view settings publish.
645+
- A footer calculation is offered on every column the saved view would carry: the columns
646+
the list draws and the fields the user added. Picking the view's own calculation again
647+
takes that column out of the draft.
648+
- When the server refuses to save a view an app package ships, the list says so in the
649+
user's language (it cannot be changed directly; save it as your own view), never the
650+
server's own text.
642651
- **Discard** puts the list back as its view declares it, the Display panel's layout and row
643652
color included, and removes the list's `uf_*` parameters from the address bar.
644653
- The draft survives opening a record and coming back. Opening another view or object,

‎ui/packages/app-shell/src/console/__tests__/AppContent.draftSaveKeepsList-35932.test.tsx‎

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
* mounts, so a remount of the route is read as a second mount.
2222
*
2323
* Pinned:
24-
* - an admin's footer pick on a shared view: no skeleton, no remount, the
25-
* list keeps the picked calculation while the refresh is on the wire and
26-
* after it lands;
27-
* - two successive picks: the second draft carries both;
28-
* - the writes are draft saves; a reader (not an admin) served the published
29-
* view draws it, without the admin's calculations.
24+
* - an admin's footer pick on a shared view, then the refresh pulse a draft
25+
* save announces: no skeleton, no remount, the list keeps the picked
26+
* calculation while the refresh is on the wire and after it lands. Since
27+
* objectstack#36194 the pick itself is a part of the list's draft and
28+
* writes nothing, so the pulse is announced here as a save announces it;
29+
* - two successive picks: the list draws both, and nothing is written;
30+
* - a reader (not an admin) served the published view draws it, without the
31+
* admin's calculations.
3032
* CONTROL: a whole-type invalidation of `view` (the provider dropping its
3133
* items, not refetching in place) still sends the route back to waiting.
3234
*
@@ -199,6 +201,7 @@ import '../../views/ObjectView.js';
199201
import { AppContent } from '../AppContent';
200202
import { MetadataProvider, useMetadata } from '../../providers/MetadataProvider';
201203
import { publishRuntimeMetadata } from '../../views/runtime-metadata-persistence.js';
204+
import { emitMetadataRefresh } from '../../assistant/assistantBus.js';
202205

203206
interface Server {
204207
/** Hold every `/meta/view` list read until `releaseViews`, as a request on the wire. */
@@ -362,12 +365,8 @@ const pick = (field: string, summary: string) =>
362365
act(async () => {
363366
await list.props!.onColumnSummaryPick(field, summary);
364367
});
365-
const storedSummaries = (body: any) =>
366-
Object.fromEntries(
367-
((body?.config?.columns ?? body?.columns ?? []) as Array<string | { field: string; summary?: unknown }>)
368-
.filter((c): c is { field: string; summary?: unknown } => typeof c === 'object' && c.summary !== undefined)
369-
.map((c) => [c.field, c.summary]),
370-
);
368+
/** The refresh pulse every write of the persistence seam announces (`emitMetadataRefresh`). */
369+
const announceSave = () => act(() => emitMetadataRefresh());
371370

372371
beforeEach(() => {
373372
server.holdViews = false;
@@ -400,7 +399,9 @@ describe('objectstack#35932 — a shared view\'s draft save keeps the list on sc
400399
// The refresh the save announces re-reads `/meta/view`; held, as a request on the wire.
401400
server.holdViews = true;
402401
await pick('amount', 'sum');
403-
expect(saves).toHaveLength(1);
402+
// objectstack#36194 — the pick is the list's draft: nothing is written.
403+
expect(saves).toHaveLength(0);
404+
announceSave();
404405
await act(async () => {
405406
await new Promise((resolve) => setTimeout(resolve, 50));
406407
});
@@ -417,28 +418,25 @@ describe('objectstack#35932 — a shared view\'s draft save keeps the list on sc
417418
expect(summaryOf('amount')).toBe('sum');
418419
});
419420

420-
it('two successive picks: the second draft carries both', async () => {
421+
it('two successive picks: the list draws both, nothing is written', async () => {
421422
boot(true);
422423
await waitFor(() => expect(typeof list.props?.onColumnSummaryPick).toBe('function'), { timeout: 5000 });
423424

424425
server.holdViews = true;
425426
await pick('amount', 'sum');
427+
announceSave();
426428
await act(async () => {
427429
await new Promise((resolve) => setTimeout(resolve, 50));
428430
});
429431
await pick('closed_at', 'latest');
432+
announceSave();
430433
server.holdViews = false;
431434
act(() => server.releaseViews());
432435
await act(async () => {
433436
await new Promise((resolve) => setTimeout(resolve, 50));
434437
});
435438

436-
expect(saves.map((s) => [s.type, s.name, s.options?.mode])).toEqual([
437-
['view', VIEW, 'draft'],
438-
['view', VIEW, 'draft'],
439-
]);
440-
expect(storedSummaries(saves[0].body)).toEqual({ amount: 'sum' });
441-
expect(storedSummaries(saves[1].body)).toEqual({ amount: 'sum', closed_at: 'latest' });
439+
expect(saves).toEqual([]);
442440
expect(list.mounts).toBe(1);
443441
expect(summaryOf('amount')).toBe('sum');
444442
expect(summaryOf('closed_at')).toBe('latest');
@@ -448,15 +446,15 @@ describe('objectstack#35932 — a shared view\'s draft save keeps the list on sc
448446
boot(true);
449447
await waitFor(() => expect(typeof list.props?.onColumnSummaryPick).toBe('function'), { timeout: 5000 });
450448
await pick('amount', 'sum');
451-
expect(saves.map((s) => s.options?.mode)).toEqual(['draft']);
449+
expect(saves).toEqual([]);
452450
cleanup();
453451

454452
forgetList();
455453
boot(false);
456454
await waitFor(() => expect(list.props?.schema?.columns).toBeDefined(), { timeout: 5000 });
457455
expect(summaryOf('amount')).toBeUndefined();
458-
// Offered to an admin only.
459-
expect(list.props?.onColumnSummaryPick).toBeUndefined();
456+
// objectstack#36194 — a reader's pick is their own draft too.
457+
expect(typeof list.props?.onColumnSummaryPick).toBe('function');
460458
});
461459

462460
it('CONTROL: a whole-type invalidation of `view` still sends the route back to waiting', async () => {
@@ -486,6 +484,7 @@ describe('objectstack#35932 — the same, on an app with a bundle', () => {
486484

487485
appBundle.hold = true;
488486
await pick('amount', 'sum');
487+
announceSave();
489488
await settle();
490489
// The pulse dropped the bundle and its reload is on the wire.
491490
expect(appBundle.items).toBeNull();
@@ -502,18 +501,21 @@ describe('objectstack#35932 — the same, on an app with a bundle', () => {
502501
expect(summaryOf('amount')).toBe('sum');
503502
});
504503

505-
it('two successive picks, then Publish: both picks in the second draft, one mount throughout', async () => {
504+
it('two successive picks, then Publish: both picks drawn, one mount throughout', async () => {
506505
boot(true, { bundle: true });
507506
await waitFor(() => expect(typeof list.props?.onColumnSummaryPick).toBe('function'), { timeout: 5000 });
508507

509508
appBundle.hold = true;
510509
await pick('amount', 'sum');
510+
announceSave();
511511
await settle();
512512
await pick('closed_at', 'latest');
513+
announceSave();
513514
await settle();
514515
expect(skeletonUp()).toBe(false);
515-
expect(storedSummaries(saves[0].body)).toEqual({ amount: 'sum' });
516-
expect(storedSummaries(saves[1].body)).toEqual({ amount: 'sum', closed_at: 'latest' });
516+
expect(saves).toEqual([]);
517+
expect(summaryOf('amount')).toBe('sum');
518+
expect(summaryOf('closed_at')).toBe('latest');
517519

518520
appBundle.hold = false;
519521
act(() => releaseBundle());

‎ui/packages/app-shell/src/hooks/useStudioDesignGate.ts‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ function usePackageListSession(): string {
142142
* previous organization) is never read as this one's.
143143
*/
144144
function usePackagePosture(packageId: string | null): StudioPosture | null {
145+
return usePackagePostureRead(packageId)?.posture ?? null;
146+
}
147+
148+
/**
149+
* {@link usePackagePosture} with the read itself: `undefined` while the
150+
* package list for `packageId` is not answered yet (or `packageId` is `null`),
151+
* else the answer, `posture: null` for a failed read and a package the list
152+
* leaves out.
153+
*/
154+
function usePackagePostureRead(packageId: string | null): { posture: StudioPosture | null } | undefined {
145155
const session = usePackageListSession();
146156
const [verdict, setVerdict] = useState<{
147157
packageId: string;
@@ -164,8 +174,8 @@ function usePackagePosture(packageId: string | null): StudioPosture | null {
164174
};
165175
}, [packageId, session]);
166176
return packageId !== null && verdict?.packageId === packageId && verdict.session === session
167-
? verdict.posture
168-
: null;
177+
? { posture: verdict.posture }
178+
: undefined;
169179
}
170180

171181
/**
@@ -208,6 +218,23 @@ export function usePackageRefusesSaves(packageId: string | null): boolean {
208218
return usePackagePosture(packageId) === 'view';
209219
}
210220

221+
/**
222+
* objectstack#36195 — {@link usePackageRefusesSaves} for a save that is not
223+
* offered on a guess: `unread` while the package list for `packageId` is still
224+
* being read, `refuses` when it carries the package read-only, else `takes`
225+
* (`null`, a failed read and a package the list leaves out keep the fail-open
226+
* answer, so the server's write gate refuses what it refuses). A list's
227+
* 「Save to this view」 on a shared view waits for the answer: on a slow boot
228+
* the list draws seconds before the package list lands, and a save offered in
229+
* that window is a save into a package's view the server refuses.
230+
*/
231+
export function usePackageSaveRead(packageId: string | null): 'unread' | 'refuses' | 'takes' {
232+
const read = usePackagePostureRead(packageId);
233+
if (packageId === null) return 'takes';
234+
if (read === undefined) return 'unread';
235+
return read.posture === 'view' ? 'refuses' : 'takes';
236+
}
237+
211238
const NO_REFUSING_PACKAGES: ReadonlySet<string> = new Set();
212239

213240
/**

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ import { useObjectTranslation } from '@object-ui/i18n';
3434
import { ConditionDiscardButton, type ListViewProps } from '@object-ui/plugin-list';
3535
import { ChevronDown, CopyPlus, RotateCcw, Save } from 'lucide-react';
3636

37-
/** One part of a list that can differ from its view (`ListView`'s vocabulary). */
38-
export type ListPersonalizationPart = Parameters<NonNullable<ListViewProps['onPersonalizationChange']>>[0][number];
37+
/**
38+
* One part of a list that can differ from its view: `ListView`'s vocabulary,
39+
* plus the footer's calculations (objectstack#36194), a part only this page's
40+
* draft knows (the grid hands the pick to the host, which holds it).
41+
*/
42+
export type ListPersonalizationPart =
43+
| Parameters<NonNullable<ListViewProps['onPersonalizationChange']>>[0][number]
44+
| 'summaries';
3945

4046
/** The order the menu names the unsaved parts in: the toolbar's, then the Display panel's. */
4147
const LIST_DRAFT_PART_ORDER: readonly ListPersonalizationPart[] = [
@@ -44,6 +50,7 @@ const LIST_DRAFT_PART_ORDER: readonly ListPersonalizationPart[] = [
4450
'grouping',
4551
'columns',
4652
'hiddenFields',
53+
'summaries',
4754
'layout',
4855
'rowColor',
4956
'inlineEdit',
@@ -76,6 +83,7 @@ export function ListDraftActions({
7683
grouping: t('console.objectView.personalizedParts.grouping'),
7784
columns: t('console.objectView.personalizedParts.columns'),
7885
hiddenFields: t('console.objectView.personalizedParts.hiddenFields'),
86+
summaries: t('console.objectView.personalizedParts.summaries'),
7987
density: t('console.objectView.personalizedParts.density'),
8088
layout: t('console.objectView.personalizedParts.layout'),
8189
rowColor: t('console.objectView.personalizedParts.rowColor'),

0 commit comments

Comments
 (0)