Skip to content
Merged
20 changes: 20 additions & 0 deletions .changeset/35955-save-into-shared-view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
'@object-ui/plugin-list': patch
---

feat(console): Save to this view on a shared view asks once, then saves and publishes it; the layout and row colour are part of a list's draft

Clause-②: yes (widening) — new `console.objectView.draft.*` keys in every `@object-ui/i18n` locale pack (`saveToViewConfirmTitle`, `saveToViewConfirm`, `saveToViewConfirmButton`, `savedForEveryone`, `pendingDraft`); `@object-ui/plugin-list` `ListView` gains the optional host prop `onRowColorChange` and two optional `viewDefaults` members, `viewType` and `rowColor`; nothing removed or renamed
Metadata-protocol: none

On a Console object list, **Save to this view** is now offered on a shared view to a reader who may edit it (an administrator, on a stored view whose package takes saves). It asks once ("everyone who uses this view will see these changes"), then saves the view and publishes it in the same step, so other readers see it on their next read, and says "Saved, visible to everyone". The options menu's Save does the same.

- When the view already has unpublished changes (a draft saved from the view settings, by anyone), nothing is written: the Console says so and points to the view settings to publish or discard that draft first. The draft write is sent with the first-write pin (`If-None-Match: *`), so the server refuses it when a draft is pending; that draft is never published on someone else's behalf. A publish the server refuses discards the draft the save wrote.
- The reader's row height and column widths are never written into a shared view: it keeps its own.
- The Display panel's layout and row colour are part of the list's draft: they survive opening a record and coming back, and both Save to this view and Save as my view keep them (a layout switch retypes the saved view). Discard puts back the view's own.

`@object-ui/plugin-list`: `ListView` reports a pick in its row colour panel through the new optional host prop `onRowColorChange` (the rule in force, or `null` for none), never at mount or for a reset. A host that lays the reader's layout or row colour into `schema` passes the view's own in `viewDefaults.viewType` / `viewDefaults.rowColor`, and the `layout` / `rowColor` parts and the Display count are judged against them; each is read only when its key is present. Without them nothing changes.

No metadata key, value or default changes. The view settings panel and the footer calculation still save a shared view as a draft that the view settings publish.
30 changes: 20 additions & 10 deletions content/docs/ui/views.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,26 @@ reader's right-column and panel choices on it, are described in

### A user's list state never writes the view

A header sort, a filter change, grouping, the search, Hide Fields, an added field and a
column drag apply at once and are a **draft**: they are kept nowhere and never write the
view metadata, so they work even where the tenant's metadata is read-only. While the list
holds a draft, **Discard** and **Save** sit at the end of the condition row (one **Save**
whose menu also holds Discard on a narrow list or a phone).

- **Save** names what is unsaved and keeps the sort, filters, columns and hidden fields:
**Save to this view** on a view of the user's own, or **Save as my view**, which asks a
name first (the view's name with "copy") and then opens the new view. Either says
"Saved", and the buttons go while the conditions stay.
A header sort, a filter change, grouping, the search, Hide Fields, an added field, a
column drag and the Display panel's layout and row color apply at once and are a **draft**:
they are kept nowhere and never write the view metadata, so they work even where the
tenant's metadata is read-only. While the list holds a draft, **Discard** and **Save** sit at
the end of the condition row (one **Save** whose menu also holds Discard on a narrow list or
a phone).

- **Save** names what is unsaved and keeps the sort, filters, columns, hidden fields, layout
and row color: **Save to this view**, or **Save as my view**, which asks a name first (the
view's name with "copy") and then opens the new view. Either says "Saved", and the buttons
go while the conditions stay.
- **Save to this view** on a view of the user's own saves it at once. On a shared view it is
offered to a user who may edit the view (an administrator, on a stored view whose package
takes saves). It asks once ("everyone who uses this view will see these changes"), then
saves the view and publishes it in the same step, so every user sees it on their next read,
and says "Saved, visible to everyone". It never writes the user's row height or column
widths into the view. When the view already has unpublished changes (a draft saved from
the view settings, by anyone), nothing is saved: the Console says so and points to the view
settings to publish or discard that draft first. Every other change to a shared view still
goes to a draft that the view settings publish.
- **Discard** puts the list back as its view declares it, the Display panel's layout and row
color included, and removes the list's `uf_*` parameters from the address bar.
- The draft survives opening a record and coming back. Opening another view or object,
Expand Down
20 changes: 17 additions & 3 deletions docs/qa/platform-checklist/areas/records-forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,7 @@
"title": "User-built FilterBuilder/SortBuilder toolbar merges with the view filter, restores across nav, and reproduces rows from the URL",
"since": "v16",
"status": "active",
"revision": 13,
"revision": 14,
"priority": "P1",
"surface": "browser",
"personas": [
Expand All @@ -2958,7 +2958,8 @@
"read where the toolbar filter and sort are kept: nowhere durable. Since objectstack#35955 they are the list's DRAFT, held in this tab's memory (ui/packages/app-shell/src/views/listDraftStore.ts): the signed-in user's sys_user_preference row keyed ui.list.showcase_task (GET /api/v1/data/sys_user_preference filtered to that key) gains no filters, sort or search from the change — it holds only what is remembered for the reader (perView.<view>.columnState.widths, rowHeight, viewOrder) — and localStorage gains no list-filters:<userId>:showcase_task:<viewId> key. Reload the page: the list opens as the view declares it",
"sign out through the account menu (the avatar menu's Log out, user.logout in ui/packages/app-shell/src/layout/AppHeader.tsx; never by clearing storage). That Log out itself removes the signed-out user's list-state:* and list-filters:* keys from localStorage (purgeSignedOutUserClientState, ui/packages/auth/src/ActiveOrganizationStorage.ts, run by AuthProvider's sign-out), so the first account's keys are gone by the time the second signs in; the clause holds by that wipe AND by the user-keyed row. Sign in as the SECOND account; open the same object+view; confirm the first account's cached toolbar filter does NOT appear",
"userFilters/URL: where UserFilters are hosted (an interface page or the userFilters surface — NOT a bare object list, ADR-0053), apply a quick-filter; copy the URL; open it in a fresh tab; confirm the uf_<field> params (comma-joined, URI-encoded) reproduce the same rows and uf__tab carries the active preset (ADR-0047)",
"negative sweep: confirm tabs-element userFilters (preset chips, uf__tab) do NOT leak onto the bare object list view — dropdown chips the object view itself declares are allowed there (ADR-0047 amendment) and their uf_<field> params are not a leak"
"negative sweep: confirm tabs-element userFilters (preset chips, uf__tab) do NOT leak onto the bare object list view — dropdown chips the object view itself declares are allowed there (ADR-0047 amendment) and their uf_<field> params are not a leak",
"shared-view save (objectstack#35955): as the seeded admin on the in_progress saved view (a stored view the showcase package takes saves into), change the sort, pick Kanban in the Display panel's layout and a row colour, open a record and come back with Back (the layout and the row colour are part of the draft and are still there), then set the row height to Spacious on the options menu's Row height level. Press 「Save」 at the condition row's end (Save to this view): it asks once, 「Save to this view?」, saying everyone who uses the view will see the changes. Confirm; capture the two writes: PUT /api/v1/meta/view/<view> as a draft carrying If-None-Match: *, then POST /api/v1/meta/view/<view>/publish. The console toasts 「Saved, visible to everyone」 and the condition row's 「Discard」/「Save」 go away. Sign in as the second account and open the same view: it shows the saved sort and the Kanban layout, with the second account's own row height. Back as the admin, change something in the view settings and save it there as a draft without publishing it; change the sort and press 「Save」 again: the console says the view has unpublished changes, to publish or discard them in the view settings first, and writes nothing. Discard that settings draft afterwards"
],
"acceptance": [
{
Expand Down Expand Up @@ -2990,13 +2991,20 @@
"oracle": "network",
"verify": "opening the copied URL fresh issues the same filtered data request and returns the same rows (app-shell/src/views/userFilterUrlState.ts parseUserFilterParams/applyUserFilterParams)",
"evidence": "the shared URL + the reproduced rows"
},
{
"clause": "Save to this view on a shared view (objectstack#35955) is offered only to a reader who may edit the view, asks once, then saves the draft and publishes it in one step so every reader sees it on their next read; it never writes the saver's row height into the view, and it never publishes a draft someone else left pending: with one pending it writes nothing and says so",
"oracle": "network",
"verify": "the confirmed save issues PUT /api/v1/meta/view/<view> (a draft, If-None-Match: *) then POST /api/v1/meta/view/<view>/publish, and the published view carries the new sort, the kanban type and the row colour but not rowHeight tall; the second account's read of the view shows them; with a settings draft pending the second Save issues no PUT and no publish (or only a PUT the server refuses 409 METADATA_CONFLICT) and the pending draft is still there, unpublished (ui/packages/app-shell/src/views/runtime-metadata-persistence.ts saveAndPublishRuntimeMetadata)",
"evidence": "the two captured writes + the published view body + the second account's screenshot + the refused second save"
}
],
"negative": [
"a toolbar filter that REPLACES the view's stored filter (rows appear that the view filter should exclude) is a FAIL — buildEffectiveFilter merges, it does not overwrite the base",
"tabs-element userFilters (preset chips, the uf__tab preset) leaking onto a bare OBJECT list view is a FAIL — ADR-0053 suppresses them there by design, as amended by ADR-0047: on an object list view only `element: 'tabs'` userFilters (and quickFilters) are ignored — objectui app-shell warnSuppressedListNav.ts, which logs the suppression — while `element: 'dropdown'` value chips ARE allowed there (examples/app-showcase/src/ui/views/project.view.ts ships them on All Projects, QA run #24616) (the list-view-capabilities item flags the same regression). The reserved list-state params an object list writes for ITSELF — uf__filter, uf__search, uf__sort, uf__group (objectui#11860, userFilterUrlState.ts), e.g. uf__sort after a toolbar sort — are the list's own state mirrored into the URL, not userFilters, and do not count",
"a cached toolbar filter from account A visible to account B on the same browser (A signed out through the account menu's Log out, never by clearing storage) is a FAIL — the key embeds the user id precisely to prevent that leak",
"an incomplete FilterBuilder row emitted as [field, op, ''] (which matches only empty and silently excludes everything) instead of being dropped is a FAIL — convertFilterGroupToAST skips valueless rows (#1964)"
"an incomplete FilterBuilder row emitted as [field, op, ''] (which matches only empty and silently excludes everything) instead of being dropped is a FAIL — convertFilterGroupToAST skips valueless rows (#1964)",
"a Save to this view that publishes a view draft which was already pending before the save (saved from the view settings, by anyone) is a FAIL — the draft write carries the first-write pin, so a pending draft refuses it; a shared save that writes the saver's row height into the view is a FAIL too"
],
"traps": [
"hydration-race",
Expand Down Expand Up @@ -3092,6 +3100,12 @@
"date": "2026-11-21",
"change": "steps[3], steps[4], acceptance[2] (clause, verify, evidence), acceptance[3] (clause, verify, evidence) and source[1] re-pointed to the list draft (objectstack#35955): a toolbar filter, sort and search are a draft held in the tab's memory, kept on opening a record and coming back and dropped on opening another object or view or on a reload; they are no longer stored in the user's ui.list.<object> row. The in-app-navigation restore of revision 3 is replaced by the record round trip, and the user-scope clause now reads that nothing is stored at all. Not loosened: a second account must still see none of the first account's filters",
"ref": "#35955"
},
{
"revision": 14,
"date": "2026-11-21",
"change": "steps[8], acceptance[5] and negative[4] added for the shared-view save (objectstack#35955 PR 2): Save to this view on a stored view an administrator may edit asks once, then saves the draft and publishes it; the saver's row height stays theirs; a pending view draft is never published on anyone's behalf. steps[8] also reads the Display panel's layout and row colour back across a record round trip, since they are now part of the draft. Not loosened: every earlier clause is unchanged",
"ref": "#35955"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,32 @@ describe('objectstack#35955 — a reload drops a list\'s address state only when
await mountHost([address]);
expect(filterOf(lastQuery())).toContain('"priority","=","urgent"');
});

// The two edges of the address match (objectstack#35955, PR 2's known
// edges): each is pinned as it behaves, not changed.
it('edge: a reload whose address is rewritten before the list seeds counts as no reload of the list, so the address state applies', async () => {
// The reload asked for one address; the list opens on another (a landing
// redirect, a view segment filled in) that carries the same `uf_*` state.
const reloaded = link(VIEW, { filter: URGENT });
const address = link(`${VIEW}/all`, { filter: URGENT });
stubNavigation('reload', new URL(reloaded, window.location.origin).href);
window.history.replaceState(null, '', address);
const host = await mountHost([address]);
expect(filterOf(lastQuery())).toContain('"priority","=","urgent"');
expect(new URLSearchParams(host.search()).has(LIST_FILTER_PARAM)).toBe(true);
});

it('edge: a reload of a record page, then Back to the list: the list\'s history entry applies its `uf_*` state', async () => {
const record = `${VIEW}/all/record/1`;
const address = link(`${VIEW}/all`, { filter: URGENT });
window.history.replaceState(null, '', record);
stubNavigation('reload', new URL(record, window.location.origin).href);
const host = await mountHost([record]);
window.history.replaceState(null, '', address);
await host.go(address);
expect(filterOf(lastQuery())).toContain('"priority","=","urgent"');
expect(new URLSearchParams(host.search()).has(LIST_FILTER_PARAM)).toBe(true);
});
});

describe('a malformed or stale param is dropped — the list opens and nothing throws (objectui#11860)', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,4 +789,48 @@ describe('objectstack#30073 — a personal view\'s conditions are Filter panel r
await waitFor(() => expect(screen.queryByTestId('list-draft')).toBeNull());
expect(draftOf('v1')).toEqual({});
});

it.each([
['no label', undefined, 'Leads copy'],
['a label given as a locale map', { en: 'Hot list', 'zh-CN': '热门' }, 'Hot list copy'],
])('objectstack#35955 L1-b S1 — 「Save as my view」 names the copy by the view\'s tab label when it has %s', async (_case, label, expected) => {
const v1 = LEAD.listViews.v1 as Record<string, unknown>;
const authored = v1.label;
if (label === undefined) delete v1.label;
else v1.label = label;
try {
mountLeads(romeLink('/apps/crm/crm_lead/view/v1'));
await listToolbar();
fireEvent.pointerDown(await screen.findByTestId('list-draft-save'), { button: 0, ctrlKey: false, pointerType: 'mouse' });
fireEvent.click(await screen.findByTestId('list-draft-save-as'));
// Never 「 copy」 or 「[object Object] copy」: the name the tab draws.
expect(await screen.findByDisplayValue(expected)).toBeInTheDocument();
} finally {
v1.label = authored;
}
});

it('objectstack#35955 — the draft\'s row colour is saved too: into the reader\'s own view, and into a view of their own', async () => {
const RED = { field: 'status', colors: { open: 'red' } };
storeListState({ perView: { pv_mine: { sort: [{ field: 'name', order: 'desc' }], rowColor: RED } } });
const { dataSource } = mountLeads('/apps/crm/crm_lead/view/pv_mine');
await listToolbar();
await saveToThisView();
await waitFor(() => expect(dataSource.update).toHaveBeenCalledTimes(1));
const patch = dataSource.update.mock.calls[0][2];
expect(patch.config.rowColor).toEqual(RED);
expect(patch.config.sort).toEqual([{ field: 'name', order: 'desc' }]);
expect(ListViewSchema.safeParse(patch.config).success).toBe(true);
cleanup();

storeListState({ perView: { v1: { sort: [{ field: 'name', order: 'desc' }], rowColor: RED } } });
const second = mountLeads('/apps/crm/crm_lead/view/v1');
await listToolbar();
fireEvent.pointerDown(await screen.findByTestId('list-draft-save'), { button: 0, ctrlKey: false, pointerType: 'mouse' });
fireEvent.click(await screen.findByTestId('list-draft-save-as'));
await screen.findByDisplayValue('View 1 copy');
fireEvent.click(screen.getByTestId('personal-view-name-submit'));
await waitFor(() => expect(second.dataSource.create).toHaveBeenCalledTimes(1));
expect(second.dataSource.create.mock.calls[0][1].config.rowColor).toEqual(RED);
});
});
Loading
Loading