Skip to content

fix(console): keep the browser copies of favorites, recents, last app and the pinned list view per organization - #36341

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-36244-org-scoped-browser-state
Nov 22, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-36244-org-scoped-browser-state

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread
Fixes #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.

Committed pins — 6 files, 67 tests, green

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.

Four ablations — each red on its own pins, each restored to the HEAD blob

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.

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).

Gates

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 #36343, #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.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QsR2jV3scu6UYPb42n5okQ

… and the pinned list view per organization (WIP)

Claude-Session: https://claude.ai/code/session_01FEkQ5oY5WCqqqBMtn9qt7m
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5oY5WCqqqBMtn9qt7m

Stop point · area a4-F · 2026-11-22T06:38Z · seat handover (maintainer 06:31Z: no rework this shift; the successor continues)
Head-sha: f957b6e
CI: red. Lint UI (check-run 137121117199) and Type Check UI (check-run 137121117159) fail on this PR's own change: the app-shell build's type-check reports a scope of type `user@org:${string}` | `object:${string}@org:${string}` as not assignable to WorkspacePreferenceScope.
Owed next: fix that type (without a packages/spec change, per the card), then run the suites and the four ablations that never ran locally (dev report 7075363715), then head declaration and L1. No review has been requested on this PR.

…orites pins

The pinned-view scope is spelled as an object scope so it type-checks
against WorkspacePreferenceScope, and the per-organization favorites
suite clears the copy the suite above leaves under the user-only key.

Claude-Session: https://claude.ai/code/session_01QsR2jV3scu6UYPb42n5okQ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ

Final head for L1 · area f7-shell · 2026-11-22T09:05Z
Head-sha: af1438fdd9340946c7478bb2c10b6747f9e6e0f3

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jS7jCv5PH4ytECQWqf

L1 ACCEPT · head af1438fdd9340946c7478bb2c10b6747f9e6e0f3 · 2026-11-22T09:08Z

维护者速读

  • 用户能看到什么变化:同一个人在两个组织里时,收藏、最近访问、上次打开的应用、流程画板最近用过的节点,以及列表页钉住的视图,现在每个组织各存一份浏览器副本,切换组织后不会再看到或写进另一个组织的那份。
  • 为什么做:卡 Console: the browser copies of favorites, recent items and last app, and the pinned list view, are not kept per organization — one person in two organizations sees and saves one organization's choices in the other #36244。服务器那一行(sys_user_preference)本来就按组织分开存,浏览器副本却只按用户存,于是切组织后会先闪出另一个组织的收藏,还可能被写回到错误的组织。
  • 出错会怎样:旧的、只按用户存的副本由第一个读到它的组织接手(搬到该组织的键下,旧键删掉),东西不会丢。最坏情况是某一份副本被另一个组织接手,下一次从服务器加载时会被那个组织的服务器行覆盖。只改 @object-ui/app-shell,可以整体撤回。
  • 要你做什么:无。
  • 席位意见:ACCEPT。Clause-②: no,Metadata-protocol: none,不欠 L2;非受管,由外壳区落地。

席位核对

  • 形态:l1-face --pr 36341 CLEAN;draft、base main、Fixes #36244。卡的完成标准逐条对上:按组织分开的键 BASE:u:USER:o:ORG、旧副本由第一个组织接手、钉住视图的槽位 object:OBJECT@org:ORG、退出登录时的清除覆盖新键。所以 Fixes 正确。15 个文件 +613 −71;check-governed-merges NOT governed,684 行。
  • 实现读法:scopedKey 在没有用户时退回原键,没有组织时退回只按用户的键,行为和以前一样。readScopedCopy 只有在本组织没有副本、且用户和组织都已知时才去接手旧键;搬动失败时仍然返回旧值。useOrganizationScope 读的是 ActiveOrganizationStorage.get(),也就是 createAuthenticatedFetch 作为 X-Tenant-ID 发给服务器的那个 id(createAuthenticatedFetch.ts:134),所以浏览器副本和它所镜像的服务器行总是同一个组织。AuthProvider 在切换时写入或清除它(AuthProvider.tsx:817/1002),并让 context 重新渲染。四个 provider 的读、写、hydrate、跨标签页同步键,以及依赖数组里都加了 orgId,我逐个核过,没有漏掉的路径。ObjectView 改用 usePinnedListView。LIST_PINNED_VIEW_PREFERENCE 的 TSDoc 已补上按组织的说明;scopedKey 的 TSDoc 随签名更新。在 app-shell 和 docs 里搜过,没有别处还写着"只按用户"的键形。
  • changeset 逐句核:@object-ui/app-shell patch,和 diff 相符。
  • 测试证据:6 个文件共 67 条用例。四处消融(A1 键里不放组织、A2 不接手旧副本、A3 钉住槽位不分组织、A4 退出清除不覆盖新键)各自让对应用例变红;退出清除的钉在 signOutPurge.test.tsx。这些单测我没有在本地重跑,读的是 CI。
  • 门禁 check-runs @ af1438fd:41 success · 15 expected skip · 0 failed · 0 pending;mergeable_state clean。
  • 接受的偏差(nit,不改本 head):① adoptPerObjectPin 在 useMemo 里做了搬动这个副作用。它是幂等的,StrictMode 下重复执行也无害,但放进 useMemo 不是惯用写法。② 启动时组织还没确定的那一刻,读写的是只按用户的键,组织确定后再被接手。正文写明了这一点,会不会闪一下取决于 AuthProvider 恢复组织的时序。③ 免打扰时段仍然只按用户存,不在本卡范围内。
  • 范围外去向:无新卡。
  • 落地条款:非受管,684 行 ≤ 3000,无 L2 ⇒ 由 f7-shell ready + auto-merge。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ

Landing · area f7-shell · 2026-11-22T09:42Z
Head-sha: 640d83340bf36ccf2f211c78839a96b7ceb9c89d

Probe Reading
L1 ACCEPT 7076969228 at af1438f; 640d833 is a clean git merge origin/main (ed33f8a) on top, PR delta unchanged (15 files, +613 / −71), so the ACCEPT holds
Landing K 19 first-parent commits behind at af1438f (≥ 15) ⇒ main merged; 2 at 640d833
Checks at head 52 check-runs: 39 success, 13 skipped, 0 failed; mergeable_state clean
Governed check-governed-merges --pr 36341: NOT governed, 684 changed lines

State: ready + auto-merge into the merge queue. Fixes #36244 closes the card on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 22, 2026 09:43
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit a57efde Nov 22, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36244-org-scoped-browser-state branch November 22, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants