Repository navigation
Commit b04830f
feat(app-shell): avatar menu org entries follow the deployment posture; the org switcher moves into the menu (#34697)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBXim82sEGBUBXqH4hkWyBJX)_
Fixes #34591
repo:objectstack#3 · os-support-ai · session_01WGufzi3ezPzTysQPDEjmVz
Clause-②: no
Metadata-protocol: none
Part of epic #34571. Items 1–3 of the card as ruled; items 4 and 5 are
cut by the ruling (below), so merging this completes the card.
## 维护者速读
-
**改了什么**:头像菜单里的组织菜单项改为按服务端已下发的部署形态显示:单租户不显示任何组织项;多组织显示「我的组织」「创建组织」,加入两个及以上组织才显示「切换组织」;云端托管不显示「创建组织」。顶栏左侧的组织切换器收进头像菜单,左上角只留产品标志与应用切换器。隔离/集团形态下,顶栏的只读「当前组织」名称改为不论加入几个组织都显示(原来只在恰好一个组织时显示)。
- **为什么改**:维护者要求单租户部署不出现组织菜单、左上角留给应用切换;裁决 6937513776
定为只读已下发信号,不加设置项、不加扩展点。
- **风险与回滚**:只改控制台前端(app-shell),无服务端/spec/云端改动;回滚即 revert 本
PR。风险点是多组织用户在隔离/集团形态下顶栏多出一个只读组织名(它替代了原来切换器上显示的名称,不是新控件);单租户顶栏不变。
-
**先看**:`ui/packages/app-shell/src/hooks/useOrgMenuPosture.ts`(`orgMenuEntries`
判定)、`ui/packages/app-shell/src/layout/AppHeader.tsx`(头像菜单组织项那一段)、`ui/packages/app-shell/src/layout/CurrentOrganizationIndicator.tsx`(只读组织名的成员数判定)。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/AppHeader.myOrganizations.test.tsx`,预期
13 个测试全绿,其中 8 个是按部署形态的新矩阵。
- **需要你做的**:无,席位落地。
## Ruling
The `## Ruled` comment on the card (6937513776), binding over the body,
quoted:
> Ruled: A — org menu items follow the served deployment signals
(`features.cloudManaged`, `features.tenancyPosture`, `multiOrgEnabled`
from `GET /auth/config`); **no Setup override key** (item 5 is dropped;
this supersedes the maintainer's earlier 「这些应该在设置中都可以配置」); **no new menu
extension point** (item 4): the cloud layer adds its items through the
existing `manifest.navigationContributions` path
(`setup-nav.contributions.ts`). Single-org member management stays
reachable at Setup → Organization (ruling 6384629949 on #25347). Item 3
(moving `WorkspaceSwitcher` into the avatar menu) is checked against
ADR-0105 before building; a conflict comes back to the maintainer.
The maintainer's answer recorded there, verbatim: 「同意」.
**Cut by the ruling:** item 4 (no new extension point; cloud items come
through the existing `manifest.navigationContributions`, a cloud card)
and item 5 (no Setup key), with their acceptance line 3 (the Setup
"hide" choice).
**Seat ruling (repo:objectstack#3)**, recorded in the claim amendment on
the card (decided under an existing rule, not a maintainer question):
moving the switcher into the avatar menu must not leave a walled-posture
member of two or more organizations without the active organization's
name on screen (objectui#5287: a scoped list says which organization it
is scoped to). So `CurrentOrganizationIndicator` names the active
organization read-only at any membership count on walled postures, where
it renders today (not the top-left app-switcher slot); a read-only name
is not a switcher, so 「左上角应该是切换应用的」 still holds.
**ADR-0105 check (item 3):** its Risks paragraph reads "UI affordances
(org switcher as *write context* + "all my orgs" read views) must land
with Phase 1, not after." It requires the switcher to stay reachable in
group posture and fixes no placement. No ruling text found fixes the
switcher's placement (searched `docs/adr/**`, `ui/docs/adr/**`,
`content/docs/**` outside releases). The switcher stays reachable in
group posture as the avatar menu's submenu, still labelled as the
working organization with its read/write hint; a test pins this.
## What changes
- `hooks/useOrgMenuPosture.ts` (new): `readOrgMenuPosture` reads the
served `features` (`multiOrgEnabled` default-on per the spec,
`cloudManaged` true only when served true, `tenancyPosture` when
recognised); `orgMenuEntries` decides the three entries: single-tenant
none; multi-organization "My Organizations" and "Create organization",
"Switch organization" only at two or more memberships; cloud-managed no
create. `features.cloudManaged` was already typed on `AuthPublicConfig`
on this base, so `ui/packages/auth/src/types.ts` needed no change.
- `layout/AppHeader.tsx`: the avatar menu's organization block uses
`orgMenuEntries`; the header's own `multiOrgEnabled` read is replaced by
the hook. On a walled posture (`group`/`isolated`) the active
organization's name is shown under "My Organizations", since the bar no
longer carries the switcher that showed it.
- `layout/WorkspaceSwitcher.tsx`: split in two. `WorkspaceSwitcherMenu`
is the avatar menu's "Switch organization" submenu (group-posture label
and hint kept, ask-before-leaving kept, full reload to the console root
kept). `WorkspaceSwitcher` keeps only the mobile shell's top-bar button
that opens the native connection switcher; in a plain browser it renders
nothing. The switcher's own "Manage members" and "Create organization"
items are gone: "My Organizations" and the menu's create entry reach the
same pages.
- `layout/CurrentOrganizationIndicator.tsx` (seat ruling above): on a
walled posture it names the server-active organization read-only at one
membership and at two or more alike (before: exactly one, since the
bar's switcher showed the name at two or more). Still nothing on
`single` or an absent/unrecognised posture, nothing with no membership
or no active organization, nothing inside a mobile shell that draws its
own switcher button. Docblock rewritten: it no longer calls
`WorkspaceSwitcher` the header's switcher.
- No cloud control-plane address is added anywhere (the diff's added
lines carry no URL).
## Tests
- `AppHeader.myOrganizations.test.tsx` (the shared AppHeader harness): a
new top-level `describe` with the posture matrix: single-tenant,
multi-org at one and two memberships, cloud-managed, cloud-managed
single-tenant, a server serving no flags, group posture (switcher
reachable as write context), walled posture name. The old case "survives
multi-org self-service being disabled" pinned the behaviour the ruling
reverses and is replaced by the single-tenant case.
- `WorkspaceSwitcher.test.tsx` now covers `WorkspaceSwitcherMenu`: group
label and hint, rows, switching, the active row sending nothing, and its
three null guards (one membership, no active organization, mobile shell)
with a control.
- `CurrentOrganizationIndicator.test.tsx` (its existing harness): the
negative "multiple memberships: that is the switcher's case" pinned the
rule the seat ruling reverses and is replaced by two positives at two
memberships, isolated (names the ACTIVE organization, not the
first-listed other one, and stays control-free) and group (the write
target is named). `AppHeader.singleMembershipOrg`'s composed
multi-membership case now asserts the indicator names the organization
beside the avatar menu's switcher; its unused `waitFor` import (the
`Lint UI` red) is dropped.
- Updated to the new placement: `AppHeader.singleMembershipOrg`,
`AppHeader.unsavedEditsLeave-13231` (the two switcher-only departures
are gone with their items), `AppHeader.organizationNoun-12851`,
`WorkspaceSwitcher.noActiveOrg-12698`,
`WorkspaceSwitcher.organizationNoun-12851`,
`WorkspaceSwitcher.nativeConnectionSwitcher`.
Ablation, one-off (committed head, `scripts/ablation-replace.mjs`, each
mutation proven on disk and restored to the HEAD blob with `git diff
HEAD` empty; the suite imports source, no build in the path):
- `orgMenuEntries` ignoring `multiOrgEnabled`:
`AppHeader.myOrganizations` goes red on exactly "single-tenant: no
organization entry and no top-bar switcher" and "cloud-managed
single-tenant: nothing" (2 failed / 11 passed).
- `createOrganization` ignoring `cloudManaged`: red on exactly
"cloud-managed: no Create organization" (1 failed / 12 passed).
- Fix round, head `808df9a0e`: the indicator's membership guard put back
to `!== 1` (anchor 1 -> 0, blob `3dfcfaac1c8e` -> `06f144b2cbd9`): red
on exactly the three new two-membership pins (two in
`CurrentOrganizationIndicator`, one in `AppHeader.singleMembershipOrg`),
`3 failed | 12 passed (15)`; restored blob == HEAD, `git diff HEAD`
empty.
## Acceptance notes
- **Inherited work.** The first commit on this branch was written by an
earlier run of this claim that a container restart stopped before it
pushed. This run pushed it, reviewed it hunk by hunk, and fixed one
defect in it: the submenu wrapped its content in `DropdownMenuPortal`,
which `@object-ui/components` does not export, so the submenu would have
rendered an undefined element. It now uses the exported submenu
primitives only, like `ViewTabBar`'s submenu. Comments that carried
Chinese labels were rewritten in English (`ui/AGENTS.md` rule -1).
- **Multi-membership on a walled posture keeps an always-visible
organization name in the bar.** The first round left it only under "My
Organizations"; the seat ruling above closed that inside this card
(claim amendment added `CurrentOrganizationIndicator` to the file
surface). The name under "My Organizations" stays, beside the entries
that act on it.
- `OrgBadge.tsx`'s docblock still describes `WorkspaceSwitcher` as the
multi-membership bar surface and the indicator as "exactly one
membership": comment drift only, outside the amended file surface, left
as is.
- `organization.switcher.manageMembers` has no consumer after this
change; it is left in the ten packs (dead keys are not gated;
`check:i18n-dead-keys` is report-only).
- Until `GET /auth/config` resolves, the menu reads the spec's absent
defaults (multi-organization on, not managed), which is the previous
rendering; on a single-tenant deployment the entries drop once the
config arrives. The auth client caches that read.
## Verification
Fix round, read at head `808df9a0e` (first round at `5de170e45`, in its
report on the card).
<details><summary>Targeted tests (10 files)</summary>
`pnpm --dir ui exec vitest run --maxWorkers=2` over
`CurrentOrganizationIndicator`,
`CurrentOrganizationIndicator.noActiveOrg-12698`,
`AppHeader.singleMembershipOrg`, `AppHeader.myOrganizations`,
`AppHeader.organizationNoun-12851`, `AppHeader.unsavedEditsLeave-13231`,
`WorkspaceSwitcher`, `WorkspaceSwitcher.noActiveOrg-12698`,
`WorkspaceSwitcher.organizationNoun-12851`,
`WorkspaceSwitcher.nativeConnectionSwitcher`: `Test Files 10 passed
(10)`, `Tests 63 passed (63)`, lock `VERDICT command-exit 0` (first
round 62: one negative replaced by two positives).
</details>
<details><summary>Lint and type check</summary>
`pnpm --filter @object-ui/app-shell run lint`: `0 errors` (warnings
only, pre-existing). Control: the previous head's
`AppHeader.singleMembershipOrg.test.tsx` fed to the same eslint reports
`'waitFor' is defined but never used ... object-ui/no-unused-imports` as
an error, exit 1. `pnpm --filter @object-ui/app-shell run type-check`
(both programs): lock `VERDICT command-exit 0`, no `error TS`.
</details>
<details><summary>Derived gate families (dispatch-gates)</summary>
`node scripts/pm/dispatch-gates.mjs --commands` at `808df9a0e`: 38
derived, 38 run, every one exit 0 (captured before any pipe); `--ran`
reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN. `pnpm --dir
ui exec vitest run scripts/`: `Test Files 171 passed | 2 skipped`,
`Tests 5077 passed | 2 skipped`. `pnpm check:type-check-debt`:
`--re-measure: OK`. `pnpm --dir ui run check:new-line-citations`: 0 new
citations. overlap-check `--branch=HEAD`: `VERDICT clean exit 0`.
</details>
**Declared narrowing.** The whole `@object-ui/app-shell` suite is not
run locally (first round: started, no verdict after about 50 minutes on
the shared box): NOT MEASURED locally, left to CI's `Test UI`. Repo-wide
scans (`pnpm lint`) are CI's. `origin/main` was not merged in:
overlap-check at `808df9a0e` says it and both PR heads sharing
`AppHeader.tsx` merge cleanly, and main touched no other file of this
diff.
## Live readings round (head `242f43777`)
L1 REWORK 6943845699 M1. Readings in PR comment 6945939831; screenshots,
`readings.txt`, `live-readings.mjs` and `boot.sh` under
`/mnt/project-files/objectstack-seat3/34591-live/` (shared project
folder). `examples/app-showcase` booted under real tenancy configuration
(single, isolated, group), PR-source console driven with
Playwright/Chromium; only cloud-managed is a stand-in (route-intercepted
`GET /auth/config` with `cloudManaged: true`).
- Single-tenant: no organization entry, switcher or indicator (en and
zh-Hans). Multi-organization at one membership: "My Organizations", no
"Switch organization".
- Two memberships under isolated and under group: the switch entry
opens, the unsaved-edit ask fires (Cancel and OK both read), the reload
lands on the root, and the indicator names the new active organization.
- 375 px: the reading **failed** at `808df9a0e` (switch submenu opened
off-screen, box x = -124, width 240). Fixed in this card's surface:
below the phone breakpoint the switch rows render inline in the avatar
menu (`c0c5c134c`); the group hint then widened the phone menu to 442.6
px, bounded with `max-w-60` (`242f43777`). After: menu x = 111, width
256; rows x = 116, width 246, inside 375 px under isolated and group; a
tap switched the active organization under both. Three phone-width pins
added to `WorkspaceSwitcher.test.tsx` (inline at 375 px, hint
width-bounded under group, sub-trigger control at 1024 px).
- At `242f43777`: targeted tests `Test Files 11 passed (11)`, `Tests 74
passed (74)`; app-shell lint and type-check exit 0; `dispatch-gates
--commands` 38 of 38 exit 0; overlap-check clean before both pushes. The
Tests and Verification sections above describe `808df9a0e`.
## Merge-forward (head `cc8c33dbc`)
Merged origin/main 6091b64 (45 first-parent commits) into 242f437
with no text conflicts; the PR's delta is unchanged (14 files,
+778/-407, no locale keys). Main's AppHeader.tsx hunks (phone
back-to-home slot, AssistantTopBarButton, approvals in the inbox panel,
sm-only group dividers) do not touch the avatar-menu org entries or the
header-left org mount. The 26 AppHeader / WorkspaceSwitcher /
CurrentOrganizationIndicator files pass 216/216, app-shell type-check
and lint are green, and dispatch-gates reconciles 38/38.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzi3ezPzTysQPDEjmVz -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4bdbdac commit b04830f
14 files changed
Lines changed: 778 additions & 407 deletions
File tree
- .changeset
- ui/packages/app-shell/src
- hooks
- layout
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
| |||
475 | 477 | | |
476 | 478 | | |
477 | 479 | | |
478 | | - | |
479 | 480 | | |
480 | 481 | | |
481 | 482 | | |
| |||
611 | 612 | | |
612 | 613 | | |
613 | 614 | | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
632 | 626 | | |
633 | 627 | | |
634 | 628 | | |
| |||
954 | 948 | | |
955 | 949 | | |
956 | 950 | | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
963 | 958 | | |
964 | 959 | | |
965 | 960 | | |
| |||
1318 | 1313 | | |
1319 | 1314 | | |
1320 | 1315 | | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
| 1316 | + | |
| 1317 | + | |
1329 | 1318 | | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
1335 | | - | |
1336 | | - | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
1337 | 1335 | | |
1338 | | - | |
| 1336 | + | |
1339 | 1337 | | |
1340 | 1338 | | |
1341 | 1339 | | |
1342 | 1340 | | |
1343 | 1341 | | |
1344 | 1342 | | |
1345 | | - | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
1346 | 1354 | | |
1347 | 1355 | | |
1348 | | - | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1349 | 1360 | | |
1350 | 1361 | | |
1351 | 1362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
12 | 9 | | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | | - | |
| 36 | + | |
| 37 | + | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
69 | 67 | | |
70 | 68 | | |
71 | 69 | | |
| |||
0 commit comments