Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .changeset/35955-list-layout-in-browser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@object-ui/app-shell': patch
'@object-ui/data-objectstack': patch
'@object-ui/react': patch
'@objectstack/platform-objects': patch
---

feat(console): a list's column widths, row height and tab order are kept in this browser only

Clause-②: no
Metadata-protocol: none

On a Console object list, the column widths a reader drags, the row height they pick and the order they give the view tabs are now kept in their own browser only, per signed-in user and object (localStorage `list-layout:<user id>:<object>`). Nothing is sent to the server: the Console no longer reads or writes the per-user list preference row `sys_user_preference` `ui.list.<object>`, and its boot read of the reader's preferences no longer asks for that key family. A list opens at once, without waiting for that read.

- Another browser or device opens the list on its view's own widths, row height and tab order until the reader changes them there.
- Signing out clears these entries with the rest of this browser's Console state, as before.
- With nobody signed in, nothing is kept.
- The record page's "show empty fields" choice (`ui.record.<object>`) is unchanged and still follows the reader.

Upgrade note: what an earlier Console kept for a reader's lists is not carried over. The `ui.list.<object>` rows are no longer read, so every reader's lists open on their views' own widths, row height and tab order until they change them again. This browser's old copies (`list-state:*`, `list-filters:*` and `viewOrder:*` in localStorage) are removed on the first list the Console opens. The server rows stay where they are, unread; leaving them does no harm.

`@object-ui/data-objectstack`, `@object-ui/react` and `@objectstack/platform-objects` change only comments and a README example that named the retired key. No metadata key, value or default changes.
7 changes: 5 additions & 2 deletions content/docs/ui/views.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,11 @@ also holds Discard on a narrow list or a phone).
- The draft survives opening a record and coming back. Opening another view or object,
or reloading the list's page, drops it, so that reload opens the view as it is declared.
- Column widths, the row height (density) and the views' order are not a draft: they are
remembered for the user (`sys_user_preference`, key `ui.list.<object>`). A sort, filter,
column order or hidden column an earlier Console stored there no longer applies.
remembered in this browser only, per signed-in user and object (localStorage
`list-layout:<user id>:<object>`). Nothing is sent to the server, another browser or device
opens the view's own layout, and signing out clears them with the rest of this browser's
Console state. Earlier Consoles kept them, with a stored sort and filters, in the user's
`sys_user_preference` row `ui.list.<object>`; nothing reads that row now.
- A link carrying list state (`uf_*` parameters) applies it as a draft, whether it opens in a
new tab or in-app (an AI answer's list link, after a reload of the chat page too).
- When a session ends, the sign-in page's return link keeps the list's path but never its
Expand Down
36 changes: 24 additions & 12 deletions docs/qa/platform-checklist/areas/records-forms.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/platform-objects/src/pages/sys-user.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ export const SysUserDetailPage: Page = {
},
// ── Preferences ───────────────────────────────────────────
// [#23803] This user's `sys_user_preference` rows — the console's
// per-user UI state (`ui.recent`, `ui.favorites`, `ui.list.<object>`
// per-user UI state (`ui.recent`, `ui.favorites`, `ui.record.<object>`
// …). Setup's "User Preferences" menu entry, which listed every
// user's rows, left the menu; this tab is where an administrator
// reaches them now, from the user they belong to.
Expand Down
23 changes: 3 additions & 20 deletions ui/packages/app-shell/src/console/ConsoleShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ import { FlowPaletteRecentsProvider } from '../context/FlowPaletteRecentsProvide
import { LastAppProvider, LAST_APP_PREFERENCE_KEY } from '../context/LastAppProvider.js';
import {
UserStateAdaptersProvider,
useAttachListStateFamily,
useAttachRecordStateFamily,
useAttachUserStateAdapters,
} from '../context/UserStateAdapters.js';
import {
LIST_PREFERENCE_PREFIX,
ListPreferencesProvider,
} from '../context/ListPreferencesProvider.js';
import {
RECORD_PREFERENCE_PREFIX,
RecordPreferencesProvider,
Expand Down Expand Up @@ -203,7 +198,6 @@ function ConsoleShellProviders({ children }: { children: ReactNode }) {
<RecentItemsProvider>
<FlowPaletteRecentsProvider>
<LastAppProvider>
<ListPreferencesProvider>
<RecordPreferencesProvider>
{/* objectstack#36112 — inside an app from 768 px up the three
are drawn at the top of the content area instead
Expand Down Expand Up @@ -241,7 +235,6 @@ function ConsoleShellProviders({ children }: { children: ReactNode }) {
<NotificationSnackbar />
<NotificationAlerts />
</RecordPreferencesProvider>
</ListPreferencesProvider>
</LastAppProvider>
</FlowPaletteRecentsProvider>
</RecentItemsProvider>
Expand Down Expand Up @@ -388,7 +381,6 @@ function UserStateBridge() {
const { user } = useAuth();
const dataSource = useAdapter();
const attach = useAttachUserStateAdapters();
const attachListState = useAttachListStateFamily();
const attachRecordState = useAttachRecordStateFamily();

useEffect(() => {
Expand All @@ -397,7 +389,6 @@ function UserStateBridge() {
attach('recent', null);
attach('flowPaletteRecents', null);
attach('lastApp', null);
attachListState(null);
attachRecordState(null);
return;
}
Expand All @@ -422,35 +413,27 @@ function UserStateBridge() {
userId: user.id,
key: LAST_APP_PREFERENCE_KEY,
});
// objectui#12418 — every object's list state, `ui.list.<object>`: a key
// family, loaded by prefix in the same one read as the three slots above.
const listState = createObjectStackUserPreferenceFamily({
dataSource,
userId: user.id,
prefix: LIST_PREFERENCE_PREFIX,
});
attach('favorites', favorites);
attach('recent', recent);
attach('flowPaletteRecents', flowPaletteRecents);
attach('lastApp', lastApp);
// objectstack#25883 — every object's record-page state, `ui.record.<object>`
// ("show empty fields"): a second key family in the same one read.
// ("show empty fields"): a key family loaded by prefix in the same one
// read as the slots above.
const recordState = createObjectStackUserPreferenceFamily({
dataSource,
userId: user.id,
prefix: RECORD_PREFERENCE_PREFIX,
});
attachListState(listState);
attachRecordState(recordState);
return () => {
attach('favorites', null);
attach('recent', null);
attach('flowPaletteRecents', null);
attach('lastApp', null);
attachListState(null);
attachRecordState(null);
};
}, [user?.id, dataSource, attach, attachListState, attachRecordState]);
}, [user?.id, dataSource, attach, attachRecordState]);

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
* `walledCatalogWriteVerdict`). A header sort and a Manage Views drag used to
* be such writes: the sort PUT the view, the drag PATCHed a `sortOrder` onto
* every saved view, so a workspace admin who is not the operator got an error
* for a personal preference. They are the user's own list state now, a
* `sys_user_preference` row: an organization row the tenant's user may write
* under every posture.
* for a personal preference. They are the user's own list state now. Since
* objectstack#35955 the sort is the list's draft and the tab order and the
* density are the reader's layout in this browser
* (`list-layout:<user id>:<object>`, `../../views/listLayoutStore.ts`), so
* neither reaches the server at all: no metadata write, and no
* `sys_user_preference` write either.
*
* ## The tree
*
* The real `ConsoleShell` providers, the real `ConnectedShell` (its real
* `ObjectStackAdapter`, its `UserStateBridge` and the list-state family), and
* `ObjectStackAdapter` and its `UserStateBridge`), and
* the real object page inside it, over the fake framework the preference
* budget pin uses (`preferenceFramework.ts`), here WALLED: every metadata
* write is answered 403. The session reports the `group` posture and a
Expand All @@ -23,13 +26,12 @@
*
* ## The pins
*
* 1. A header sort and a drag-reorder put NO metadata write on the wire
* and raise no error. The drag lands as ONE preference write of the
* object's row; the sort is the list's draft (objectstack#35955) and
* writes nothing.
* 1. A header sort and a drag-reorder put NO write on the wire and raise no
* error. The drag is kept in this browser's layout entry; the sort is
* the list's draft and is kept nowhere.
* 2. objectui#12474 — the density toggle and a Hide Fields change put NO
* metadata write on the wire and raise no error. The density lands as
* ONE preference write of the same row; the hide is the draft's.
* write on the wire and raise no error. The density is kept in the same
* layout entry; the hide is the draft's.
* 3. CONTROL — the wall is live: a metadata write made in this same tree
* (the real adapter's own view write, `createView`) is answered 403.
* Since objectui#12474 no list toolbar control makes one, so the control
Expand Down Expand Up @@ -126,7 +128,8 @@ import { useAdapter } from '../../providers/AdapterProvider';
import '@objectstack/lint';
import { ObjectView } from '../../views/ObjectView';
import { resetListDraftStoreForTests } from '../../views/listDraftStore';
import { createPreferenceFramework, preferenceRowId, type PreferenceFramework } from './preferenceFramework';
import { listLayoutStorageKey, resetListLayoutStoreForTests } from '../../views/listLayoutStore';
import { createPreferenceFramework, type PreferenceFramework } from './preferenceFramework';

const FIELDS = {
id: { type: 'text', label: 'Id' },
Expand All @@ -142,7 +145,7 @@ const OBJECT = {
},
};

/** The user already has a list-state row for the object (from another device). */
/** A list-state row an earlier Console stored for the user: no longer read or written (objectstack#35955). */
const STORE = { u1: { 'ui.list.account': { viewOrder: [ALL_ID, MINE_ID] } } };

let fake: PreferenceFramework;
Expand Down Expand Up @@ -174,10 +177,14 @@ function boot() {
);
}

/** The reader's layout entry for the object in this browser. */
const storedLayout = () => JSON.parse(localStorage.getItem(listLayoutStorageKey('u1', OBJECT_NAME)!) ?? 'null');

const wait = (ms: number) => act(() => new Promise<void>((resolve) => setTimeout(resolve, ms)));

beforeEach(() => {
resetListDraftStoreForTests();
resetListLayoutStoreForTests();
listProps = null;
pageAdapter = null;
localStorage.clear();
Expand All @@ -195,7 +202,7 @@ afterEach(() => {
});

describe('a user\'s list state under a walled posture (objectui#12418)', () => {
it('a header sort and a drag-reorder write no metadata and raise no error; the drag lands as one preference write, the sort as the draft', async () => {
it('a header sort and a drag-reorder write nothing to the server and raise no error; the drag is kept in this browser, the sort as the draft', async () => {
boot();
await waitFor(() => expect(typeof listProps?.onSortChange).toBe('function'), { timeout: 5000 });
await screen.findByTestId('stub-reorder');
Expand All @@ -208,22 +215,18 @@ describe('a user\'s list state under a walled posture (objectui#12418)', () => {
await act(async () => {
fireEvent.click(screen.getByTestId('stub-reorder'));
});
// Past the preference debounce (500 ms) and the round trip.
await waitFor(() => expect(fake.wire.writes).toHaveLength(1), { timeout: 3000 });
await wait(400);
// Past the old preference debounce (500 ms) and a round trip.
await wait(900);

expect(fake.wire.metaWrites).toEqual([]);
expect(fake.wire.writes).toEqual([]);
expect(toast.error).not.toHaveBeenCalled();
expect(fake.wire.writes).toHaveLength(1);
const [write] = fake.wire.writes;
// An update of the row the boot read found: no second read, no insert.
expect(write.id).toBe(preferenceRowId('u1', 'ui.list.account'));
expect(fake.wire.gets.length).toBe(readsBefore);
// objectstack#35955 — the sort is the list's draft: it is stored nowhere.
expect(write.value).toEqual({ viewOrder: [MINE_ID, ALL_ID] });
// objectstack#35955 — the order is this browser's; the sort is the list's draft, stored nowhere.
expect(storedLayout()).toEqual({ viewOrder: [MINE_ID, ALL_ID] });
});

it('a density toggle and a Hide Fields change write no metadata and raise no error; the density lands as one preference write, the hide as the draft (objectui#12474)', async () => {
it('a density toggle and a Hide Fields change write nothing to the server and raise no error; the density is kept in this browser, the hide as the draft (objectui#12474)', async () => {
boot();
await waitFor(() => expect(typeof listProps?.schema?.onDensityChange).toBe('function'), { timeout: 5000 });
await wait(100);
Expand All @@ -232,30 +235,21 @@ describe('a user\'s list state under a walled posture (objectui#12418)', () => {
act(() => {
listProps.schema.onDensityChange('comfortable');
});
// Past the preference debounce (500 ms) and the round trip.
await waitFor(() => expect(fake.wire.writes).toHaveLength(1), { timeout: 3000 });
await wait(400);
expect(fake.wire.metaWrites).toEqual([]);
expect(toast.error).not.toHaveBeenCalled();
expect(fake.wire.writes).toHaveLength(1);
expect(fake.wire.writes[0].id).toBe(preferenceRowId('u1', 'ui.list.account'));
expect(fake.wire.writes[0].value).toEqual({
viewOrder: [ALL_ID, MINE_ID],
perView: { [ALL_ID]: { rowHeight: 'medium' } },
});
await wait(100);
expect(storedLayout()).toEqual({ perView: { [ALL_ID]: { rowHeight: 'medium' } } });
// The list is handed the user's density back.
expect(listProps.schema.rowHeight).toBe('medium');

act(() => {
listProps.onHiddenFieldsChange(['name']);
});
// Past the preference debounce (500 ms) and a round trip: nothing more is written.
// Past the old preference debounce (500 ms) and a round trip: nothing is written.
await wait(900);
expect(fake.wire.metaWrites).toEqual([]);
expect(fake.wire.writes).toEqual([]);
expect(toast.error).not.toHaveBeenCalled();
expect(fake.wire.writes).toHaveLength(1);
expect(listProps.schema.hiddenFields).toEqual(['name']);
// No second read: each write updates the row the boot read found.
expect(storedLayout()).toEqual({ perView: { [ALL_ID]: { rowHeight: 'medium' } } });
expect(fake.wire.gets.length).toBe(readsBefore);
});

Expand Down
Loading
Loading