Skip to content

Commit b04830f

Browse files
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
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
feat(app-shell): the avatar menu's organization entries follow the deployment posture, and the organization switcher moves into the avatar menu
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The avatar menu reads the deployment signals the server already serves on `GET /api/v1/auth/config` (`features.multiOrgEnabled`, `features.cloudManaged`, `features.tenancyPosture`) and offers organization entries by them:
11+
12+
- **Single-tenant** (`multiOrgEnabled` false, the `single` posture): no organization entry at all, and no organization switcher. Member management for the one organization stays at Setup → Organization.
13+
- **Multi-organization**: "My Organizations" and "Create organization"; "Switch organization" joins them only when the member belongs to two or more organizations.
14+
- **Cloud-managed** (`cloudManaged` true): no "Create organization"; organizations are created on the cloud there.
15+
16+
A server that serves none of these flags reads the spec's defaults (multi-organization on, not managed), which is the menu as it was.
17+
18+
The organization switcher no longer sits at the left of the top bar, which now holds only the product mark and the app switcher. It is the avatar menu's "Switch organization" submenu. Under the `group` posture it still names the working organization (the write target) and says that views show data from every organization the member belongs to (ADR-0105). On a walled posture (`group` or `isolated`) the top bar still names the active organization, read-only, now at any membership count (before, only at exactly one), so a member of two or more organizations still sees which organization lists are scoped to; the name is also shown under "My Organizations". The switcher's own "Manage members" and "Create organization" items are gone: "My Organizations" and the menu's own create entry lead to the same pages. Inside the ObjectStack mobile shell, the top-bar button that opens the shell's native connection switcher is unchanged.
19+
20+
There is no Setup setting for this menu.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* useOrgMenuPosture — which organization entries the avatar menu offers, read
3+
* from the deployment signals the server already serves on `GET /auth/config`
4+
* (objectstack-ai/objectstack#34591, ruling 6937513776):
5+
*
6+
* - `features.multiOrgEnabled` — the multi-organization capability flag. The
7+
* server derives it from the effective tenancy posture (`false` on `single`,
8+
* and on a degraded deployment that asked for isolation but has none), and
9+
* the spec says the console offers creating, switching and leaving
10+
* organizations only when it is on. It is default-on: absent reads as on.
11+
* - `features.cloudManaged` — the cloud's control plane runs this environment.
12+
* Organizations are created on the cloud there, so the console offers no
13+
* create entry; the cloud adds its own entries through the existing
14+
* `manifest.navigationContributions` path, never through this menu. Absent
15+
* reads as not managed.
16+
* - `features.tenancyPosture` — how to render organization context (ADR-0105
17+
* D1): under `group` the switcher picks the WRITE target, so it says so.
18+
*
19+
* There is no Setup override: the menu follows the served signals alone (the
20+
* ruling drops the card's settings key). Single-organization member
21+
* management stays reachable at Setup → Organization (ruling 6384629949), so a
22+
* single-tenant menu without organization entries closes no door.
23+
*
24+
* Until the config resolves the defaults are the spec's absent readings
25+
* (multi-organization on, not managed), which is today's rendering.
26+
*/
27+
28+
import { useEffect, useState } from 'react';
29+
import { useAuth } from '@object-ui/auth';
30+
import type { AuthPublicConfig, TenancyPosture } from '@object-ui/auth';
31+
32+
const POSTURES: readonly TenancyPosture[] = ['single', 'group', 'isolated'];
33+
34+
export interface OrgMenuPosture {
35+
/** `features.multiOrgEnabled !== false` — the spec's default-on reading. */
36+
multiOrgEnabled: boolean;
37+
/** `features.cloudManaged === true`. */
38+
cloudManaged: boolean;
39+
/** `features.tenancyPosture` when it is a recognised posture, else `undefined`. */
40+
tenancyPosture: TenancyPosture | undefined;
41+
}
42+
43+
const UNRESOLVED: OrgMenuPosture = {
44+
multiOrgEnabled: true,
45+
cloudManaged: false,
46+
tenancyPosture: undefined,
47+
};
48+
49+
/** The served `features` object, read into the three answers above. */
50+
export function readOrgMenuPosture(features: AuthPublicConfig['features'] | null | undefined): OrgMenuPosture {
51+
const posture: unknown = features?.tenancyPosture;
52+
return {
53+
multiOrgEnabled: features?.multiOrgEnabled !== false,
54+
cloudManaged: features?.cloudManaged === true,
55+
tenancyPosture:
56+
typeof posture === 'string' && (POSTURES as readonly string[]).includes(posture)
57+
? (posture as TenancyPosture)
58+
: undefined,
59+
};
60+
}
61+
62+
export interface OrgMenuEntries {
63+
/** "My Organizations" → `/organizations?manage=1`. */
64+
myOrganizations: boolean;
65+
/** "Switch organization" — the organization switcher, inside the avatar menu. */
66+
switchOrganization: boolean;
67+
/** "Create organization" → `/organizations?create=1`. */
68+
createOrganization: boolean;
69+
}
70+
71+
/**
72+
* The avatar menu's organization entries for one deployment and one member.
73+
*
74+
* - single-tenant (`multiOrgEnabled` off) ⇒ none;
75+
* - multi-organization ⇒ My Organizations and Create organization, plus Switch
76+
* organization only at two or more memberships (one has nothing to switch to);
77+
* - cloud-managed ⇒ no Create organization.
78+
*
79+
* `hasOrgSection` is the member's own organization context (memberships still
80+
* loading, any membership, or an active organization): with none there is
81+
* nothing to manage or switch, as before.
82+
*/
83+
export function orgMenuEntries(input: {
84+
posture: Pick<OrgMenuPosture, 'multiOrgEnabled' | 'cloudManaged'>;
85+
hasOrgSection: boolean;
86+
membershipCount: number;
87+
}): OrgMenuEntries {
88+
const offered = input.posture.multiOrgEnabled && input.hasOrgSection;
89+
return {
90+
myOrganizations: offered,
91+
switchOrganization: offered && input.membershipCount > 1,
92+
createOrganization: offered && !input.posture.cloudManaged,
93+
};
94+
}
95+
96+
export function useOrgMenuPosture(): OrgMenuPosture {
97+
const { getAuthConfig } = useAuth();
98+
const [posture, setPosture] = useState<OrgMenuPosture>(UNRESOLVED);
99+
100+
useEffect(() => {
101+
let cancelled = false;
102+
getAuthConfig?.()
103+
.then((cfg) => {
104+
if (!cancelled) setPosture(readOrgMenuPosture(cfg?.features));
105+
})
106+
.catch(() => {
107+
/* config unavailable — keep the absent readings; the server still enforces */
108+
});
109+
return () => {
110+
cancelled = true;
111+
};
112+
}, [getAuthConfig]);
113+
114+
return posture;
115+
}

‎ui/packages/app-shell/src/layout/AppHeader.tsx‎

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import { useState, useEffect, useLayoutEffect, useCallback, useRef, type RefObje
7676
import { useOffline } from '@object-ui/react';
7777
import { PresenceAvatars, useTenantPresence, type PresenceUser } from '@object-ui/collaboration';
7878
import { ModeToggle } from './ModeToggle.js';
79-
import { WorkspaceSwitcher } from './WorkspaceSwitcher.js';
79+
import { WorkspaceSwitcher, WorkspaceSwitcherMenu } from './WorkspaceSwitcher.js';
8080
import { CurrentOrganizationIndicator } from './CurrentOrganizationIndicator.js';
8181
import { LocaleSwitcher } from './LocaleSwitcher.js';
8282
import { NotificationPreferencesMenu } from './NotificationPreferencesMenu.js';
@@ -107,6 +107,8 @@ import { useStudioEntryGate } from '../hooks/useStudioDesignGate.js';
107107
import { useSharedActivityFeed, type ActivityFeedReading } from '../hooks/sharedUserFeeds.js';
108108
import { useInboxBell } from '../hooks/useInboxBell.js';
109109
import { useHomePath } from '../hooks/useHomePath.js';
110+
import { orgMenuEntries, useOrgMenuPosture } from '../hooks/useOrgMenuPosture.js';
111+
import { postureHasOrgWall } from '../hooks/useTenancyPosture.js';
110112
import { useServedViewItems } from '../hooks/useServedViewItems.js';
111113
import { viewTabLabel } from '../views/viewTabLabel.js';
112114
import { resolveViewId } from '../utils/resolveViewId.js';
@@ -475,7 +477,6 @@ export function AppHeader({
475477
organizations,
476478
activeOrganization,
477479
isOrganizationsLoading,
478-
getAuthConfig,
479480
} = useAuth();
480481
const dataSource = useAdapter();
481482
// Runtime AI gating: hide the top-bar AI entry point when the server serves
@@ -611,24 +612,17 @@ export function AppHeader({
611612
: apiActivity;
612613
const orgList = organizations ?? [];
613614
const hasOrgSection = isOrganizationsLoading || orgList.length > 0 || !!activeOrganization;
614-
// Mirror the server's `beforeCreateOrganization` gate so the "Create
615-
// workspace" entry only shows where multi-org self-service is enabled.
616-
// Default to allowed until the config resolves (avoids hiding it on slow
617-
// networks); the server still enforces.
618-
const [multiOrgDisabled, setMultiOrgDisabled] = useState(false);
619-
useEffect(() => {
620-
let cancelled = false;
621-
getAuthConfig?.()
622-
.then((cfg) => {
623-
if (!cancelled) setMultiOrgDisabled(cfg?.features?.multiOrgEnabled === false);
624-
})
625-
.catch(() => {
626-
/* leave default — server still enforces */
627-
});
628-
return () => {
629-
cancelled = true;
630-
};
631-
}, [getAuthConfig]);
615+
// The avatar menu's organization entries follow the served deployment
616+
// signals (objectstack-ai/objectstack#34591): none on a single-tenant
617+
// deployment, no create entry on a cloud-managed one, and the switcher only
618+
// at two or more memberships. Until the config resolves, the spec's absent
619+
// readings keep today's rendering; the server still enforces.
620+
const orgMenuPosture = useOrgMenuPosture();
621+
const orgMenu = orgMenuEntries({
622+
posture: orgMenuPosture,
623+
hasOrgSection,
624+
membershipCount: orgList.length,
625+
});
632626

633627
// Build path segments (only used in `app` variant)
634628
const pathParts = location.pathname.split('/').filter(Boolean);
@@ -954,12 +948,13 @@ export function AppHeader({
954948
reports GA. */}
955949
{!isApp && <PreviewBadge className="ml-2 hidden sm:inline-flex" />}
956950

957-
{/* Organization context — "which org am I in", right after the brand and
958-
before the app/section breadcrumb. Two mutually exclusive renderers:
959-
the switcher for multi-membership users (name + switch dropdown),
960-
and the read-only indicator for the single-membership case the
961-
switcher declines to render, on walled deployments only
962-
(objectui#5287 — the switcher's own visibility rule is unchanged). */}
951+
{/* Organization context, right after the brand. The web organization
952+
switcher lives in the avatar menu (objectstack-ai/objectstack#34591):
953+
the left of the bar is the product mark and the app switcher. What
954+
stays here: the mobile shell's own connection-switcher button
955+
(renders only inside a shell that announces it), and the read-only
956+
organization name on a walled deployment, at any membership count
957+
(objectui#5287). */}
963958
<WorkspaceSwitcher />
964959
<CurrentOrganizationIndicator />
965960

@@ -1318,34 +1313,50 @@ export function AppHeader({
13181313
</DropdownMenuItem>
13191314
)}
13201315
{/*
1321-
* Workspace entries. The header-left WorkspaceSwitcher carries
1322-
* the same destinations, but it renders NOTHING below two orgs
1323-
* (`orgList.length <= 1` → null) — so for the single-org majority
1324-
* the avatar menu is the ONLY door to workspace management.
1325-
* Leaving just the create shortcut here is what shut every path
1326-
* to Members / Invitations / Organization settings for them
1327-
* (objectstack#8096): the picker at `/organizations` auto-skips
1328-
* with one org, and the switcher never appears.
1316+
* Organization entries, by deployment posture (`orgMenuEntries`,
1317+
* objectstack-ai/objectstack#34591, ruling 6937513776).
13291318
*
1330-
* "My Organizations" → `?manage=1`, which OrganizationsPage reads as
1331-
* "the user came here to MANAGE": multi-org users get the picker,
1332-
* a single-org user is deep-linked straight to that org's members
1333-
* page (there is no choice worth showing them). Deliberately NOT
1334-
* gated on `multiOrgDisabled` — that flag governs CREATING orgs;
1335-
* where self-service creation is off this entry is the only way
1336-
* in, so gating it there would re-close the door.
1319+
* Single-tenant (`multiOrgEnabled` off): none. Member management
1320+
* for the one organization is Setup → Organization (ruling
1321+
* 6384629949), so dropping these closes no door.
1322+
*
1323+
* Multi-organization: "My Organizations" → `?manage=1`, which
1324+
* OrganizationsPage reads as "came here to MANAGE" — a member of
1325+
* one organization is deep-linked to its members page, since the
1326+
* picker auto-skips at one organization (objectstack#8096: this
1327+
* entry is that member's door, as the switcher is not offered at
1328+
* one membership). Then the switcher, at two or more memberships,
1329+
* and "Create organization" unless the cloud manages this
1330+
* environment (organizations are created on the cloud there).
1331+
*
1332+
* On a walled posture the active organization's name also rides
1333+
* under "My Organizations", beside the entries that act on it; the
1334+
* bar names it read-only (`CurrentOrganizationIndicator`).
13371335
*/}
1338-
{hasOrgSection && (
1336+
{orgMenu.myOrganizations && (
13391337
<DropdownMenuItem
13401338
onClick={() => leaveTo('/organizations?manage=1')}
13411339
className="cursor-pointer"
13421340
data-testid="header-my-organizations"
13431341
>
13441342
<Building2 className="mr-2 h-4 w-4" />
1345-
{t('organizations.mine', { defaultValue: 'My Organizations' })}
1343+
<span className="grid min-w-0 flex-1 leading-tight">
1344+
<span>{t('organizations.mine', { defaultValue: 'My Organizations' })}</span>
1345+
{activeOrganization && postureHasOrgWall(orgMenuPosture.tenancyPosture) && (
1346+
<span
1347+
className="truncate text-xs text-muted-foreground"
1348+
data-testid="header-my-organizations-current"
1349+
>
1350+
{activeOrganization.name}
1351+
</span>
1352+
)}
1353+
</span>
13461354
</DropdownMenuItem>
13471355
)}
1348-
{hasOrgSection && !multiOrgDisabled && (
1356+
{orgMenu.switchOrganization && (
1357+
<WorkspaceSwitcherMenu isGroupPosture={orgMenuPosture.tenancyPosture === 'group'} />
1358+
)}
1359+
{orgMenu.createOrganization && (
13491360
<DropdownMenuItem
13501361
onClick={() => leaveTo('/organizations?create=1')}
13511362
className="cursor-pointer"

‎ui/packages/app-shell/src/layout/CurrentOrganizationIndicator.tsx‎

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
/**
2-
* CurrentOrganizationIndicator — read-only "which organization am I in" for
3-
* users who have exactly ONE membership (objectui#5287).
2+
* CurrentOrganizationIndicator — read-only "which organization am I in" on a
3+
* walled deployment, at any membership count (objectui#5287).
44
*
5-
* `WorkspaceSwitcher` is a multi-membership affordance: with one organization
6-
* there is nothing to switch to, so it renders nothing — and it is also the
7-
* only place the console ever showed the organization name. On a walled
8-
* deployment that left a single-membership business user with no indication
9-
* anywhere of which organization they were looking at, while every list on the
10-
* page was silently scoped to it. Found in a downstream multi-tenant
11-
* acceptance run (case S20-001).
5+
* On a walled posture every list on the page is silently scoped to the active
6+
* organization, so the top bar must say which one without the user opening
7+
* anything. Found in a downstream multi-tenant acceptance run (case S20-001)
8+
* for a single-membership user, who had no organization name anywhere.
129
*
13-
* This is the other half of that surface, deliberately a SEPARATE component:
10+
* The organization switcher is not in the top bar: the left of the bar is the
11+
* product mark and the app switcher, and switching lives in the avatar menu
12+
* (`WorkspaceSwitcherMenu`, objectstack-ai/objectstack#34591). So this
13+
* indicator is the bar's only organization name, at one membership and at two
14+
* or more alike (seat ruling repo:objectstack#3 on that card).
1415
*
15-
* - the switcher's visibility rule is unchanged (`orgList.length <= 1` still
16-
* renders nothing — a one-entry dropdown was the rejected option);
17-
* - this renders in exactly the case the switcher declines, and renders no
18-
* control at all: no trigger, no menu, no click target. The name is
19-
* context, not navigation. Members / workspace management stay reachable
20-
* from the avatar menu's "My Workspaces" entry (objectstack#8096), which
21-
* is what covers this configuration.
16+
* It renders no control at all: no trigger, no menu, no click target. The name
17+
* is context, not navigation; a read-only name is not a switcher. Switching and
18+
* members / workspace management stay in the avatar menu ("Switch
19+
* organization", "My Organizations").
2220
*
2321
* ## Why it is gated on the tenancy posture, not on "an org exists"
2422
*
@@ -35,7 +33,8 @@
3533
*
3634
* Inside the mobile shell, when it announces `showConnectionSwitcher`, this
3735
* renders nothing: `WorkspaceSwitcher` then draws the same badge and name, at
38-
* the same widths, as the button that opens the shell's native switcher.
36+
* the same widths, as the top-bar button that opens the shell's native
37+
* switcher.
3938
*
4039
* An absent or unrecognized posture (older server, config fetch still in
4140
* flight or failed) renders nothing, matching how every other posture-keyed
@@ -61,11 +60,10 @@ export function CurrentOrganizationIndicator() {
6160
// exactly as it is today. Also covers the not-yet-resolved config.
6261
if (!postureHasOrgWall(posture)) return null;
6362

64-
const orgList = organizations ?? [];
65-
66-
// Exactly one membership. Two or more is the switcher's case and it must
67-
// stay the only affordance there; zero means no organization context at all.
68-
if (orgList.length !== 1) return null;
63+
// Any membership count names the organization: the switcher is in the
64+
// avatar menu, so this is the bar's only organization name. Zero memberships
65+
// means no organization context at all.
66+
if ((organizations ?? []).length === 0) return null;
6967

7068
// The organization the SERVER reports as active, never a guess from the
7169
// membership list (objectui#12698): a session with no active organization —

0 commit comments

Comments
 (0)