Repository navigation
Commit a57efde
fix(console): keep the browser copies of favorites, recents, last app and the pinned list view per organization (#36341)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbUq2j5tRRVo3TVY3wcS1Fdg)_
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`.
<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
#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`.
</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>1 parent 4e55e4e commit a57efde
15 files changed
Lines changed: 613 additions & 71 deletions
File tree
- .changeset
- ui/packages/app-shell/src
- context
- __tests__
- utils
- views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| 35 | + | |
33 | 36 | | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
240 | 244 | | |
241 | 245 | | |
242 | 246 | | |
243 | | - | |
| 247 | + | |
244 | 248 | | |
245 | | - | |
| 249 | + | |
246 | 250 | | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
252 | | - | |
| 256 | + | |
253 | 257 | | |
254 | | - | |
| 258 | + | |
255 | 259 | | |
256 | 260 | | |
257 | 261 | | |
| |||
340 | 344 | | |
341 | 345 | | |
342 | 346 | | |
| 347 | + | |
343 | 348 | | |
344 | 349 | | |
345 | | - | |
| 350 | + | |
346 | 351 | | |
347 | | - | |
348 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
349 | 355 | | |
350 | | - | |
351 | | - | |
| 356 | + | |
| 357 | + | |
352 | 358 | | |
353 | 359 | | |
354 | 360 | | |
355 | 361 | | |
356 | | - | |
| 362 | + | |
357 | 363 | | |
358 | 364 | | |
359 | 365 | | |
| |||
383 | 389 | | |
384 | 390 | | |
385 | 391 | | |
386 | | - | |
387 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
388 | 396 | | |
389 | 397 | | |
390 | 398 | | |
| |||
406 | 414 | | |
407 | 415 | | |
408 | 416 | | |
409 | | - | |
| 417 | + | |
410 | 418 | | |
411 | 419 | | |
412 | 420 | | |
| |||
415 | 423 | | |
416 | 424 | | |
417 | 425 | | |
418 | | - | |
| 426 | + | |
419 | 427 | | |
420 | 428 | | |
421 | 429 | | |
| |||
427 | 435 | | |
428 | 436 | | |
429 | 437 | | |
430 | | - | |
| 438 | + | |
431 | 439 | | |
432 | 440 | | |
433 | | - | |
| 441 | + | |
434 | 442 | | |
435 | 443 | | |
436 | 444 | | |
| |||
444 | 452 | | |
445 | 453 | | |
446 | 454 | | |
447 | | - | |
| 455 | + | |
448 | 456 | | |
449 | 457 | | |
450 | | - | |
| 458 | + | |
451 | 459 | | |
452 | 460 | | |
453 | 461 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
| 74 | + | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | | - | |
| 83 | + | |
82 | 84 | | |
83 | | - | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| |||
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
134 | 139 | | |
135 | 140 | | |
136 | | - | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | | - | |
| 144 | + | |
140 | 145 | | |
141 | 146 | | |
142 | 147 | | |
| |||
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
154 | | - | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | | - | |
| 162 | + | |
158 | 163 | | |
159 | 164 | | |
160 | 165 | | |
| |||
166 | 171 | | |
167 | 172 | | |
168 | 173 | | |
169 | | - | |
| 174 | + | |
170 | 175 | | |
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
175 | | - | |
| 180 | + | |
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
181 | | - | |
| 186 | + | |
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
61 | 63 | | |
62 | | - | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | | - | |
| 71 | + | |
70 | 72 | | |
71 | | - | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
85 | | - | |
| 90 | + | |
86 | 91 | | |
87 | | - | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
99 | | - | |
100 | | - | |
| 105 | + | |
| 106 | + | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
| |||
119 | 125 | | |
120 | 126 | | |
121 | 127 | | |
122 | | - | |
| 128 | + | |
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
127 | | - | |
| 133 | + | |
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
132 | 138 | | |
133 | | - | |
134 | | - | |
135 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
136 | 144 | | |
137 | 145 | | |
138 | | - | |
| 146 | + | |
139 | 147 | | |
140 | 148 | | |
141 | 149 | | |
| |||
0 commit comments