Repository navigation
feat(console): Manage views restores the factory version of a customized package view - #36342
Conversation
…ew from Manage views (WIP) Claude-Session: https://claude.ai/code/session_01FEkQ5oY5WCqqqBMtn9qt7m Co-authored-by: Claude <noreply@anthropic.com>
…ter and the list row Claude-Session: https://claude.ai/code/session_01FEkQ5oY5WCqqqBMtn9qt7m Co-authored-by: Claude <noreply@anthropic.com>
…t the two new de quote pairs Claude-Session: https://claude.ai/code/session_01FEkQ5oY5WCqqqBMtn9qt7m Co-authored-by: Claude <noreply@anthropic.com>
…store-factory-view
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jUc3qp6bHKSWijbjds Final head (area f7-list, 2026-11-22T07:33Z): |
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC Contract-review-claim: session_01QsR2jTeURPvEm465RcoYEC · head 767c872 · 2026-11-22T07:36Z |
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jS7jCv5PH4ytECQWqf L1 ACCEPT · head 维护者速读
席位核对
|
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC Contract reviewServed-tier: Face: declaration ( ① Derived judgmentsEvery public-surface change the diff implies, against what the PR body and changeset name:
② Semver level
③ Boundary flags
Findings: No must-fix, no should-fix. N1 (nit) — The PR body's Readings say the targeted UI run and the data-objectstack type-check are NOT MEASURED on 767c872, while report 7075365451 says 72 files / 799 tests passed and data-objectstack type-check exit 0 on that same head; the two records of one head disagree. CI's green N2 (nit) — Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jUc3qp6bHKSWijbjds Landing (area f7-list, 2026-11-22T07:45Z): head |
… and the pinned list view per organization (objectstack-ai#36341) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbUq2j5tRRVo3TVY3wcS1Fdg)_ Fixes objectstack-ai#36244 Clause-②: no Metadata-protocol: none ## 维护者速读 - 同时属于两个组织的用户,用同一个浏览器切换组织后,不再在新组织里先看到旧组织的收藏、最近访问、上次应用和固定视图;单组织与无组织部署的用户原有内容保留。 - 为个人设置清点中您接受的建议(p2):浏览器里的副本跟服务器一样按组织分开保存。 - 出错时最坏是某个组织里的收藏或固定视图首次显示为空、等服务器读回后恢复;不涉及他人数据,撤回本改动即回到原行为。 - 无。 ## What changes - `scopedKey(base, userId, orgId?)` (`UserStateAdapters`) spells `BASE:u:USER:o:ORG` when an organization is active; without one (no organization feature, a preview, the boot before an organization is known) it is the user-only key as before. - The organization is `ActiveOrganizationStorage`'s id, read synchronously (`useOrganizationScope`): the same id the console stamps on the `sys_user_preference` reads as `X-Tenant-ID`, and the one `switchOrganization` stores before the switch reloads the console, so the first paint after a switch reads the new organization's copy. - `FavoritesProvider`, `RecentItemsProvider`, `LastAppProvider`, `FlowPaletteRecentsProvider` read and write their browser copy under that key, and re-load when the organization changes. `FavoritesProvider`'s hydrate push-back now reads this organization's local copy, so it can only carry this organization's own nav-pin extras into its row. - The pinned list view (`list.view.pinned`) is read through `usePinnedListView` (new, `views/pinnedListView.ts`), whose slot is `os:pref:list.view.pinned@object:OBJECT@org:ORG`. Only this preference is keyed this way; the `os:pref` mechanism and every other workspace preference are unchanged. - **Carry-over rule (Done-when 4):** an organization that finds no copy of its own adopts the copy kept before the organization was part of the key (the user-only `ui.*` copy, and the per-object pin slot): the value moves under that organization's key and the old key is removed, so exactly one organization, the first to read it, inherits it. A single-organization person keeps everything; a deployment with no organization keeps the user-only key unchanged. The first reader is in practice the organization the old copy mirrors: every hydrate rewrote it with the active organization's row, and the first page-load on this code boots into the organization the browser last held. - Sign-out and change-of-user purges are keep-list sweeps (`purgeSignedOutUserClientState`, `@object-ui/auth`); the new keys are not on the keep list, so they are swept exactly as today's are. A pin in `signOutPurge.test.tsx` holds that for all five new spellings. - Round 2 (this head): the red `Type Check UI` / `Lint UI` (build) / `Test UI (8/16)` on `f957b6e1` had two causes, both read from the job logs before the fix. (1) `pinnedListView.ts(35,18): error TS2322` — the org slot was built from `objectPreferenceScope()`'s union and could spell `user@org:…`; it is now spelled `object:OBJECT@org:ORG` directly. (2) `FavoritesProvider.test.tsx` "favorites and a nav pin set in A …" read 21 ids — the suite above it leaves its last list under the user-only key, which org A then adopted as designed; the new suite's `beforeEach` now clears storage and resets the mocked user. No production behaviour changed in round 2. `origin/main` was merged once (`b3bcfefc`); it touched only one comment line in `workspacePreference.ts` among this diff's files. ## Tests Reach measured once, before the fix, by the round-1 dev with a unit harness (no running console with two memberships in this container): real `ActiveOrganizationStorage`, a fake server answering one `ui.favorites` row per stamped organization, favorite + nav pin in A, switch (remount) to B. On base `c30ce97c`: B's first paint `["object:a_obj","nav:a_menu"]` (A's list); B's server row after hydrate `["nav:a_menu"]` (A's nav pin pushed into B); pinned view read in B `"pv_in_org_a"`, back in A after pinning in B `"pv_in_org_b"`, one key `os:pref:list.view.pinned@object:crm_lead`. Both mechanisms reproduce. All readings below are on head `af1438fd`, under `scripts/pm/os-verify-lock.sh`. <details><summary>Committed pins — 6 files, 67 tests, green</summary> `cd ui && pnpm exec vitest run --maxWorkers=2` FavoritesProvider, RecentItemsProvider, FlowPaletteRecentsProvider, LastAppProvider, signOutPurge (context/__tests__) and views/pinnedListView-36244: `Test Files 6 passed (6)` · `Tests 67 passed (67)` · `VERDICT command-exit 0`. Neighbours that read the pin or the preference store (ObjectView.personalViews-29635, ObjectView.titleViewSwitcher-27594, consoleListStateWall-12418, consoleUserPreferenceBudget): `Test Files 4 passed (4)` · `Tests 45 passed (45)` · `VERDICT command-exit 0`. `ui/packages/app-shell` `pnpm run type-check` (both `tsc --noEmit` and `tsc -p tsconfig.test.json`): `VERDICT command-exit 0`, no `error TS`. </details> <details><summary>Four ablations — each red on its own pins, each restored to the HEAD blob</summary> Mutations through `scripts/ablation-replace.mjs` (WRAP mode: anchor must hit once, blob must change, restore proven by blob == HEAD and empty `git diff HEAD`). Same 6-file run each time; tests import `src` relatively, so no `dist/` leg applies. - A1 `scopedKey` ignores the organization (`UserStateAdapters.tsx`, blob `94bba20a → 67dd65bb`): `Tests 8 failed | 59 passed` — the per-organization and the adoption pins of all four providers. - A2 no adoption (`if (own !== null || !userId || !orgId) return own;` → unconditional return; blob `94bba20a → e9c51a34`): `Tests 4 failed | 63 passed` — the four "a single organization keeps the copy …" pins. The first A2 attempt was refused by the tool before anything ran (its replacement text already occurred in the anchor line, so the count did not rise); retried with a distinct replacement. - A3 pin slot ignores the organization (`pinnedListView.ts`, blob `b49631f8 → af9680b7`): `Tests 2 failed | 65 passed` — the round-trip pin and the single-organization pin. - A4 no pin adoption (blob `b49631f8 → 6f653efc`): `Tests 1 failed | 66 passed` — the single-organization pin. After the script: both files' blob equals `HEAD`'s (`94bba20a…`, `b49631f8…`), `git status` clean on both. </details> ## Acceptance notes - The `os:pref:*` pin slot carries no user. The organization in the slot does not change that, but a different account signing in on the same browser runs the change-of-user purge, which sweeps every key not on its keep list (all `os:pref:*` included), so a second account does not read the first's pin. - On a browser that holds no active organization yet (first boot, or after the server answered none), the copy is the user-only one until the organization resolves, then the organization adopts it; that boot window also costs one extra preference read when the organization arrives. - Quiet hours (`notificationPreferences`) still use the user-only key: out of this card. ## Verification Two-minute check: `cd ui && pnpm exec vitest run packages/app-shell/src/views/pinnedListView-36244.test.tsx` — 3 passing tests expected. Files to read first: `ui/packages/app-shell/src/context/UserStateAdapters.tsx` (`readScopedCopy`, `useOrganizationScope` — the adoption move), `ui/packages/app-shell/src/views/pinnedListView.ts` (slot spelling and pin adoption), `ui/packages/app-shell/src/context/FavoritesProvider.tsx` (hydrate push-back). <details><summary>Gates</summary> Local, `dispatch-gates --commands --repo objectstack-ai/objectstack` at `af1438fd`: 38 commands; 36 of the 37 non-vitest families exit 0 (exit captured before any pipe). `pnpm check:type-check-debt` exit 3 — its closure build queued past the lock budget (`VERDICT queue-timeout`), NOT MEASURED locally; CI's `Type Check · debt ledger` is success on this head. `pnpm --dir ui exec vitest run scripts/`: `Test Files 172 passed | 2 skipped (174)` · `Tests 5127 passed | 2 skipped`, `VERDICT command-exit 0`. `--ran` (with `:: exit` codes): `38 derived famil(ies) accounted for — 37 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)`. `overlap-check` before push: `VERDICT clean exit 0` (main and objectstack-ai#36343, objectstack-ai#36342 merge cleanly). CI on `af1438fd`: 52 check-runs, 39 success, 13 skipped, 0 failed — among them `Lint & Repo Gates`, `TypeScript Type Check`, `Test Core`, `Governed Surface Queue Guard`, `Lint UI`, `Type Check UI`, `Test UI`, `Build & E2E UI`, `Live E2E UI`, `Dogfood Regression Gate`, `Check Changeset`. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jV3scu6UYPb42n5okQ <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Leehom · project thread
Fixes #36011
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
On a view a read-only package ships, a pin, a rename or a set-default writes the whole view into the package's customization pair (
PACKAGE.custom, ruling record 7058654416 keeps those three). Manage views now:overridesnaming the package it is served under);Pieces:
@object-ui/data-objectstack:ObjectStackAdapter.restoreFactoryView(objectName, viewName)reads the served view, refuses (sending nothing) when it is no override of its package, takes the pair from the ensure door for that package (the same homeupdateViewwrites into), and deletes the view's draft then its row there: the existing doorDELETE /meta/view/NAME?package=PAIR, the one Studio's "Restore package original" uses. A pair that held no row throws.listViews()now carries a record'soverridesonto the flattened row.@object-ui/plugin-view:ViewTabItem.customized,ManageViewsDialogProps.onRestoreFactory, the mark and the menu entry.@object-ui/app-shell: thecustomizedverdict in the title switcher's Manage views items, andhandleRestoreFactoryView(confirm, restore, re-read, toast; a refusal is said with the door's message).@object-ui/i18n: 8 keys in every locale pack (zh-Hant regenerated bygen:zh-hant); the de quote-pairing pin counts the two new pairs.No server, protocol or
packages/specchange.Server door, measured (scratch test, not committed)
Real engine, SQL store, protocol,
HttpDispatcherreads andRestServerdelete, both topologies, at 446de0e / f35f7f3:PUT /meta/view/NAME?package=APP.customwith the declaration):GET /meta/view?object=OBJserves the row with_packageId= the base andoverrides: { package: BASE, basedOn }, in the canonicalconfigshape (hence thelistViewschange).DELETE ?package=APP.custom&state=draft200reset:false;DELETE ?package=APP.custom200reset:true; the list then serves the base's view with nooverrides.manage_metadata: 403FORBIDDEN("Resetting a metadata item requires themanage_metadatacapability"), the same gate as the pin's write; Manage views is the admin's, as for pin.created: false, so it keeps blocking uninstall (ADR-0146 D3). This PR adds no package deletion.Tests
New files:
ManageViewsDialog.restoreFactory-36011.test.tsx(plugin-view),restoreFactoryView-36011.test.ts(data-objectstack),ObjectView.restoreFactoryView-36011.test.tsx(app-shell: pin then restore under the real English I18nProvider, the confirm text, a cancelled confirm, a refused restore).Readings
updateView.draft,deleteView.homes, the 35974 and 11583 ObjectView files); i18n package 105 files / 1962 passed.git diff HEADempty after): restore entry dropped, customized verdict forced false,overridescopy dropped fromlistViews, the nothing-removed guard and the not-an-override guard disabled: each turned its pins red.dispatch-gates --commands, 767c872): the local run was in progress at hand-over; every command read so far exited 0.Acceptance notes
os-verify-lock.shlost a waiter's slot twice when the budget ran out while that waiter was at the head of the queue; the next call with the same slot name started at the back.