Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
feat(organizations): say in the dashboard where a linked organization's members are changed
Petr Bauchad970189dc01
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 14f1c0cac..bf52d086a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -134,6 +134,17 @@ version of their own to them without also giving them a release of their own.the agent's binding to it. The socket's first frame offers calls(`calls.max_in_flight`, 64); a call over that is answered 429`capacity_exceeded` without running, so the controller sends it over HTTP.+- **Organizations can follow WorkOS (experimental, off by default).** With+ `ORGANIZATION_DIRECTORY=workos`, an organization an operator links to a+ WorkOS organization (`switch-link-workos`) takes its members, and who is+ its Org Admin, from there: at sign-in, from WorkOS's events every 30+ seconds, and in a full check once a day. A change from WorkOS is applied+ even when it breaks a rule Switch keeps (the last Org Admin, agents left+ without an owner who can act for them), and the Organization page tells+ its admins what is left to fix. Adding someone to a linked organization or+ making them Org Admin is done in WorkOS, and the dashboard says so; taking+ either away in Switch ends access at once but lasts only while WorkOS+ agrees. Setup and limits: `docs/old/workos-directory.md`.- **A reconnect storm is paced instead of taking the pool.** When a pod goesaway, every agent and controller it held opens a connection on the podsleft within seconds. On staging (two pods, 1,000 agents, one pod deleted)diff --git a/core/switch_core/gateway/organizations.py b/core/switch_core/gateway/organizations.pyindex e224aae4d..6b6527348 100644--- a/core/switch_core/gateway/organizations.py+++ b/core/switch_core/gateway/organizations.py@@ -236,6 +236,9 @@ async def create_organization(async def current_organization(session: Annotated[AsyncSession, Depends(get_session)],user_store: Annotated[UserStore, Depends(get_user_store)],+ organization_directory: Annotated[+ OrganizationDirectory, Depends(get_organization_directory)+ ],user: Annotated[User, Depends(get_current_user)],) -> CurrentOrganizationResponse:"""The organization the bound workspace belongs to, and the caller's role@@ -250,6 +253,7 @@ async def current_organization(slug=organization.slug,name=organization.name,role=await user_store.organization_role(session, require_tenant_id(), user.id),+ members_from_directory=organization_directory.keeps_members_of(organization),)diff --git a/core/switch_core/gateway/schemas.py b/core/switch_core/gateway/schemas.pyindex 2fb818d1c..cdaa74e38 100644--- a/core/switch_core/gateway/schemas.py+++ b/core/switch_core/gateway/schemas.py@@ -1068,12 +1068,15 @@ class OrganizationSummary(BaseModel):class CurrentOrganizationResponse(BaseModel):"""The bound workspace's organization, and the caller's role in it: None- for the platform operator there on the operator flag alone."""+ for the platform operator there on the operator flag alone.+ `members_from_directory`: its members and `org_admin`s come from a+ directory kept outside Switch (`OrganizationDirectory.keeps_members_of`)."""id: strslug: strname: strrole: str | None+ members_from_directory: boolclass OrganizationIssueDetail(BaseModel):diff --git a/core/switch_core/organization_directory.py b/core/switch_core/organization_directory.pyindex fa1df4f23..b972070b7 100644--- a/core/switch_core/organization_directory.py+++ b/core/switch_core/organization_directory.py@@ -68,6 +68,13 @@ class OrganizationDirectory(Protocol):bound every call: they are handed rows, never a session, and a route mayhold locks while it waits on them."""+ def keeps_members_of(self, organization: Organization) -> bool:+ """Whether the directory, not Switch, is the record of who is in+ `organization` and who is its `org_admin`: then adding someone or+ making them `org_admin` is done there, and what Switch takes away+ lasts only until the directory is read again."""+ ...+async def memberships_at_sign_in(self, subject: str) -> list[DirectoryMembership] | None:@@ -108,6 +115,9 @@ class LocalDirectory:"""Switch's own tables are the record: each change is the route's writeto them, and nothing is asked first."""+ def keeps_members_of(self, organization: Organization) -> bool:+ return False+async def memberships_at_sign_in(self, subject: str) -> list[DirectoryMembership] | None:diff --git a/core/switch_core/workos_directory.py b/core/switch_core/workos_directory.pyindex 944d2202f..52d1fcfda 100644--- a/core/switch_core/workos_directory.py+++ b/core/switch_core/workos_directory.py@@ -251,6 +251,11 @@ class WorkOSDirectory:existing accounts."""return await self._list("/user_management/users", {"email": email})+ def keeps_members_of(self, organization: Organization) -> bool:+ """Only an organization an operator linked follows WorkOS; any other+ is still Switch's own."""+ return organization.workos_organization_id is not None+async def create_organization(self, creator: User, name: str) -> DirectoryOrganization:diff --git a/core/tests/switch_core/gateway/test_organization_directory_routes.py b/core/tests/switch_core/gateway/test_organization_directory_routes.pyindex df91a5064..2d0c86891 100644--- a/core/tests/switch_core/gateway/test_organization_directory_routes.py+++ b/core/tests/switch_core/gateway/test_organization_directory_routes.py@@ -63,6 +63,9 @@ class _Directory:if self.failure is not None:raise self.failure+ def keeps_members_of(self, organization: Organization) -> bool:+ return True+async def create_organization(self, creator: User, name: str) -> DirectoryOrganization:@@ -457,3 +460,18 @@ class TestRemoving:assert response.status_code == 409assert directory.asked == []+++class TestTheCurrentOrganization:+ async def test_says_when_the_directory_keeps_its_members(+ self, session_factory, directory: _Directory+ ) -> None:+ """So the dashboard can say where people are added and made Org Admin."""+ ada = _name("ada")+ tenant_id = await _workspace(session_factory, {ada: ("owner", "org_admin")})++ async with _client(_with(session_factory, directory), ada, tenant_id) as client:+ response = await client.get("/organizations/current")++ assert response.status_code == 200, response.text+ assert response.json()["members_from_directory"] is Truediff --git a/core/tests/switch_core/gateway/test_organization_routes.py b/core/tests/switch_core/gateway/test_organization_routes.pyindex b39909d6b..04c41131c 100644--- a/core/tests/switch_core/gateway/test_organization_routes.py+++ b/core/tests/switch_core/gateway/test_organization_routes.py@@ -946,6 +946,7 @@ class TestTheCurrentOrganization:)assert as_operator.status_code == 200, as_operator.textassert as_operator.json()["role"] is None+ assert as_member.json()["members_from_directory"] is Falseclass TestNamesInTheOrganizationAuditLog:diff --git a/core/tests/switch_core/test_workos_directory.py b/core/tests/switch_core/test_workos_directory.pyindex 8451e67c5..fa377bd6f 100644--- a/core/tests/switch_core/test_workos_directory.py+++ b/core/tests/switch_core/test_workos_directory.py@@ -213,6 +213,16 @@ class TestChangesFromSwitch:await directory.set_role(linked, "u", "member") # type: ignore[arg-type]await directory.remove(linked, "u") # type: ignore[arg-type]+ def test_it_keeps_the_members_of_a_linked_organization_only(self) -> None:+ directory = _directory(lambda request: httpx.Response(500))++ assert directory.keeps_members_of(+ SimpleNamespace(workos_organization_id="org_a") # type: ignore[arg-type]+ )+ assert not directory.keeps_members_of(+ SimpleNamespace(workos_organization_id=None) # type: ignore[arg-type]+ )+async def test_an_organization_switch_keeps_itself_needs_nothing(self) -> None:directory = _directory(lambda request: httpx.Response(500))local = SimpleNamespace(workos_organization_id=None)diff --git a/docs/old/workos-directory.md b/docs/old/workos-directory.mdindex 9ea63cc9a..45160d044 100644--- a/docs/old/workos-directory.md+++ b/docs/old/workos-directory.md@@ -110,6 +110,19 @@ operator, who may then make one), a workspace with no owner, agents whoseowner can no longer act for them, and a linked WorkOS organization that wasdeleted. The audit log keeps the history.+## In the dashboard++On a linked organization's Organization page, the Members section says that+its members and Org Admins come from the organization's account settings+(WorkOS), and does not offer making a member Org Admin. Removing someone or+making an Org Admin a Member is still offered: it ends their access at once,+and the page says it lasts only until WorkOS is read again (their next+sign-in, or the daily check) unless the same change is made there. The+platform operator, on a linked organization with no admin, is told the admin+has to be made in WorkOS. A workspace's Invitations section says that only+people already in the organization can accept, since accepting can't add+anyone new to it.+## Not done yet- **Granting from Switch is refused** for a linked organization: adding adiff --git a/gateway/src/data/api.ts b/gateway/src/data/api.tsindex a48c9b221..748626342 100644--- a/gateway/src/data/api.ts+++ b/gateway/src/data/api.ts@@ -1264,6 +1264,9 @@ export interface CurrentOrganization {name: string;// Null for the platform operator there through operator access alone.role: OrganizationRole | null;+ // Its members, and who is its Org Admin, come from a directory kept outside+ // Switch: people are added and made Org Admin there, not here.+ members_from_directory: boolean;}export interface OperatorWorkspace {diff --git a/gateway/src/pages/organization/OrganizationMembersSection.tsx b/gateway/src/pages/organization/OrganizationMembersSection.tsxindex 562ca2656..22b1b8f8b 100644--- a/gateway/src/pages/organization/OrganizationMembersSection.tsx+++ b/gateway/src/pages/organization/OrganizationMembersSection.tsx@@ -39,12 +39,17 @@ const ROLE_LABELS: Record<OrganizationRole, string> = {export default function OrganizationMembersSection({selfId,asOperator,+ fromDirectory,onChanged,}: {selfId: string;// The platform operator, who is no admin here, may manage the members only// while the organization has no admin left, to make one.asOperator: boolean;+ // The members come from the organization's account settings: nobody can be+ // made Org Admin here, and what is taken away here comes back while those+ // settings still grant it.+ fromDirectory: boolean;// Called after each change that went through.onChanged: () => void;}) {@@ -104,7 +109,11 @@ export default function OrganizationMembersSection({sx={{ fontSize: "0.875rem" }}>{(Object.keys(ROLE_LABELS) as OrganizationRole[]).map((role) => (- <MenuItem key={role} value={role}>+ <MenuItem+ key={role}+ value={role}+ disabled={fromDirectory && role === "org_admin" && row.role !== "org_admin"}+ >{ROLE_LABELS[role]}</MenuItem>))}@@ -139,7 +148,7 @@ export default function OrganizationMembersSection({),},],- [act, busy, selfId],+ [act, busy, fromDirectory, selfId],);// The operator restores an admin and nothing more: removing a member is// refused to them, so there is nothing to offer.@@ -162,8 +171,20 @@ export default function OrganizationMembersSection({)}{asOperator && !error && !loading && (<Alert severity="warning">- This organization has no admin. As platform operator you can make one of its members- an admin; the change is recorded in its audit log, marked as yours.+ {fromDirectory+ ? "This organization has no admin. Its admins come from its account settings, so " ++ "someone has to be made an organization admin there."+ : "This organization has no admin. As platform operator you can make one of its " ++ "members an admin; the change is recorded in its audit log, marked as yours."}+ </Alert>+ )}+ {fromDirectory && !asOperator && (+ <Alert severity="info">+ This organization's members, and who is its admin, come from your organization's+ account settings. Add people and make someone an organization admin there; the change+ shows here shortly. Removing someone here, or making an admin a member, takes effect at+ once but lasts only while the account settings agree: they are read again at the+ person's next sign-in and once a day. Make the same change there to keep it.</Alert>)}{actionError && (diff --git a/gateway/src/pages/organization/OrganizationPage.test.tsx b/gateway/src/pages/organization/OrganizationPage.test.tsxindex a018cde69..0d08591f9 100644--- a/gateway/src/pages/organization/OrganizationPage.test.tsx+++ b/gateway/src/pages/organization/OrganizationPage.test.tsx@@ -89,7 +89,7 @@ describe("OrganizationPage", () => {it("shows an organization admin its members and audit log", async () => {signedInAs(session("org_admin", true));answer({- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": [{ user_id: "u2", name: "Bob", email: "[email protected]", role: "member", created_at: "2026-01-01" },@@ -238,7 +238,7 @@ describe("OrganizationPage", () => {warning: null,};answer({- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": [bob],"GET /organizations/current/audit-events": [],@@ -277,7 +277,7 @@ describe("OrganizationPage", () => {it("adds a workspace, lists it, and refreshes the session", async () => {const refresh = signedInAs(session("org_admin", true));const routes: Record<string, unknown> = {- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": [],"GET /organizations/current/audit-events": [],@@ -305,8 +305,14 @@ describe("OrganizationPage", () => {const members = [{ user_id: "u2", name: "Bob", email: "[email protected]", role: "member", created_at: "2026-01-01" },];- const operatorRoutes = (membersAnswer: unknown) => ({- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: null },+ const operatorRoutes = (membersAnswer: unknown, fromDirectory = false) => ({+ "GET /organizations/current": {+ id: "o1",+ slug: "acme",+ name: "Acme Inc",+ role: null,+ members_from_directory: fromDirectory,+ },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": membersAnswer,"GET /organizations/current/issues": new Refusal(403, "Only an organization admin may do this"),@@ -325,6 +331,18 @@ describe("OrganizationPage", () => {expect(screen.queryByRole("heading", { name: "Audit log" })).toBeNull();});+ it("tells the operator an organization from the account settings gets its admin there", async () => {+ signedInAs(session(null, false, true));+ answer(operatorRoutes(members, true));++ render(<OrganizationPage />);++ expect(await screen.findByText(/someone has to be made an organization admin there/)).toBeTruthy();+ fireEvent.mouseDown(within(await screen.findByTestId("row-u2")).getByRole("combobox"));+ const orgAdmin = await screen.findByRole("option", { name: "Org Admin" });+ expect(orgAdmin.getAttribute("aria-disabled")).toBe("true");+ });+it("tells the operator why where the organization has an admin", async () => {signedInAs(session(null, false, true));answer(operatorRoutes(new Refusal(403, "Only an organization admin may do this")));@@ -345,10 +363,62 @@ describe("OrganizationPage", () => {expect(screen.queryByText(/only while it has no admin/)).toBeNull();});+ it("says where an organization's members come from when it is not here", async () => {+ signedInAs(session("org_admin", true));+ answer({+ "GET /organizations/current": {+ id: "o1",+ slug: "acme",+ name: "Acme Inc",+ role: "org_admin",+ members_from_directory: true,+ },+ "GET /organizations/current/workspaces": [workspace("t1", "Acme")],+ "GET /organizations/current/members": [+ { user_id: "u2", name: "Bob", email: "[email protected]", role: "member", created_at: "2026-01-01" },+ { user_id: "u3", name: "Cy", email: "[email protected]", role: "org_admin", created_at: "2026-01-01" },+ ],+ "GET /organizations/current/audit-events": [],+ "GET /organizations/current/issues": [],+ });++ render(<OrganizationPage />);++ expect(await screen.findByText(/come from your organization's account settings/)).toBeTruthy();+ fireEvent.mouseDown(within(await screen.findByTestId("row-u2")).getByRole("combobox"));+ const promote = await screen.findByRole("option", { name: "Org Admin" });+ expect(promote.getAttribute("aria-disabled")).toBe("true");+ fireEvent.keyDown(promote, { key: "Escape" });+ fireEvent.mouseDown(within(screen.getByTestId("row-u3")).getByRole("combobox"));+ const demote = await screen.findByRole("option", { name: "Member" });+ expect(demote.getAttribute("aria-disabled")).toBeNull();+ expect(screen.getByLabelText("Remove [email protected] from the organization")).toBeTruthy();+ });++ it("says nothing of account settings for an organization kept here", async () => {+ signedInAs(session("org_admin", true));+ answer({+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },+ "GET /organizations/current/workspaces": [workspace("t1", "Acme")],+ "GET /organizations/current/members": [+ { user_id: "u2", name: "Bob", email: "[email protected]", role: "member", created_at: "2026-01-01" },+ ],+ "GET /organizations/current/audit-events": [],+ "GET /organizations/current/issues": [],+ });++ render(<OrganizationPage />);++ fireEvent.mouseDown(within(await screen.findByTestId("row-u2")).getByRole("combobox"));+ const promote = await screen.findByRole("option", { name: "Org Admin" });+ expect(promote.getAttribute("aria-disabled")).toBeNull();+ expect(screen.queryByText(/account settings/)).toBeNull();+ });+it("tells an organization admin what needs their attention", async () => {signedInAs(session("org_admin", true));answer({- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": [],"GET /organizations/current/audit-events": [],@@ -373,7 +443,7 @@ describe("OrganizationPage", () => {it("checks again after a change to the members", async () => {signedInAs(session("org_admin", true));const routes: Record<string, unknown> = {- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": [{ user_id: "u2", name: "Bob", email: "[email protected]", role: "member", created_at: "2026-01-01" },@@ -398,7 +468,7 @@ describe("OrganizationPage", () => {it("says nothing when nothing needs attention", async () => {signedInAs(session("org_admin", true));answer({- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": [],"GET /organizations/current/audit-events": [],@@ -414,7 +484,7 @@ describe("OrganizationPage", () => {it("shows a failure to check as a failure", async () => {signedInAs(session("org_admin", true));answer({- "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin", members_from_directory: false },"GET /organizations/current/workspaces": [workspace("t1", "Acme")],"GET /organizations/current/members": [],"GET /organizations/current/audit-events": [],diff --git a/gateway/src/pages/organization/OrganizationPage.tsx b/gateway/src/pages/organization/OrganizationPage.tsxindex 29e0c3f6b..61736bb67 100644--- a/gateway/src/pages/organization/OrganizationPage.tsx+++ b/gateway/src/pages/organization/OrganizationPage.tsx@@ -51,6 +51,7 @@ export default function OrganizationPage() {<OrganizationMembersSectionselfId={session.user.id}asOperator={!isAdmin}+ fromDirectory={organization?.members_from_directory === true}onChanged={onMembersChanged}/>)}diff --git a/gateway/src/pages/workspace/InvitationsSection.test.tsx b/gateway/src/pages/workspace/InvitationsSection.test.tsxnew file mode 100644index 000000000..40f78b84a--- /dev/null+++ b/gateway/src/pages/workspace/InvitationsSection.test.tsx@@ -0,0 +1,82 @@+import { cleanup, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, it, vi } from "vitest";+import InvitationsSection from "./InvitationsSection";++vi.mock("../../components/DataTable", () => import("../../test/FakeDataTable"));++/** Answers each `GET /path` from `routes`, and counts what was asked. */+function answer(routes: Record<string, unknown>) {+ const asked: string[] = [];+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input: RequestInfo | URL) => {+ const path = String(input).replace(/^\/gateway/, "").split("?")[0];+ asked.push(path);+ if (!(path in routes)) {+ return new Response(JSON.stringify({ detail: `unmocked ${path}` }), { status: 404 });+ }+ const [status, body] = routes[path] as [number, unknown];+ return new Response(JSON.stringify(body), { status });+ }),+ );+ return asked;+}++const organization = (fromDirectory: boolean) => ({+ id: "o1",+ slug: "acme",+ name: "Acme Inc",+ role: "member",+ members_from_directory: fromDirectory,+});++describe("InvitationsSection", () => {+ afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+ });++ it("says only people already in the organization can accept, where it is kept elsewhere", async () => {+ answer({+ "/tenants/t1/invitations": [200, []],+ "/organizations/current": [200, organization(true)],+ });++ render(<InvitationsSection tenantId="t1" inOrganization isOwner emailEnabled={false} />);++ expect(await screen.findByText(/only people already in the organization can accept/)).toBeTruthy();+ });++ it("says nothing of it for an organization kept here", async () => {+ answer({+ "/tenants/t1/invitations": [200, []],+ "/organizations/current": [200, organization(false)],+ });++ render(<InvitationsSection tenantId="t1" inOrganization isOwner emailEnabled={false} />);++ expect(await screen.findByRole("button", { name: "Invite" })).toBeTruthy();+ expect(screen.queryByText(/already in the organization/)).toBeNull();+ });++ it("asks nothing about an organization for a workspace in none", async () => {+ const asked = answer({ "/tenants/t1/invitations": [200, []] });++ render(<InvitationsSection tenantId="t1" inOrganization={false} isOwner emailEnabled={false} />);++ expect(await screen.findByRole("button", { name: "Invite" })).toBeTruthy();+ expect(asked).not.toContain("/organizations/current");+ expect(screen.queryByText(/Could not check/)).toBeNull();+ });++ it("shows a failure to check as a warning", async () => {+ answer({+ "/tenants/t1/invitations": [200, []],+ "/organizations/current": [500, { detail: "The database is unavailable" }],+ });++ render(<InvitationsSection tenantId="t1" inOrganization isOwner emailEnabled={false} />);++ expect(await screen.findByText(/Could not check who can accept an invitation here/)).toBeTruthy();+ });+});diff --git a/gateway/src/pages/workspace/InvitationsSection.tsx b/gateway/src/pages/workspace/InvitationsSection.tsxindex 6fc9e66e4..3e455ab35 100644--- a/gateway/src/pages/workspace/InvitationsSection.tsx+++ b/gateway/src/pages/workspace/InvitationsSection.tsx@@ -10,7 +10,12 @@ import {import type { GridColDef } from "@mui/x-data-grid";import { useCallback, useEffect, useMemo, useState } from "react";import DataTable from "../../components/DataTable";-import { type Invitation, fetchInvitations, revokeInvitation } from "../../data/api";+import {+ type Invitation,+ fetchCurrentOrganization,+ fetchInvitations,+ revokeInvitation,+} from "../../data/api";import { formatDate, titleCase } from "../../theme/hootFormat";import CreateInvitationDialog from "./CreateInvitationDialog";import { useLoad } from "./useLoad";@@ -24,15 +29,24 @@ function invitationStatus(inv: Invitation, now: number): string {export default function InvitationsSection({tenantId,+ inOrganization,isOwner,emailEnabled,}: {tenantId: string;+ inOrganization: boolean;isOwner: boolean;emailEnabled: boolean;}) {const load = useCallback(() => fetchInvitations(tenantId), [tenantId]);const { data: invitations, error, loading, refetch } = useLoad(load);+ // Whether only people already in the organization can accept: where its+ // members come from its account settings, Switch can't add anyone new.+ const loadOrganization = useCallback(+ () => (inOrganization ? fetchCurrentOrganization() : Promise.resolve(null)),+ [inOrganization],+ );+ const { data: organization, error: organizationError } = useLoad(loadOrganization);const [createOpen, setCreateOpen] = useState(false);const [actionError, setActionError] = useState<string | null>(null);// Re-evaluated on a timer so an invitation that expires while the page is@@ -114,6 +128,18 @@ export default function InvitationsSection({Invite</Button></Stack>+ {organization?.members_from_directory && (+ <Alert severity="info">+ This organization's members come from your organization's account settings, so only+ people already in the organization can accept an invitation. Add anyone new there+ first.+ </Alert>+ )}+ {organizationError && (+ <Alert severity="warning">+ Could not check who can accept an invitation here: {organizationError}+ </Alert>+ )}{error && <Alert severity="error">{error}</Alert>}{actionError && (<Alert severity="error" onClose={() => setActionError(null)}>diff --git a/gateway/src/pages/workspace/WorkspacePage.tsx b/gateway/src/pages/workspace/WorkspacePage.tsxindex b7a19ca50..088b423b0 100644--- a/gateway/src/pages/workspace/WorkspacePage.tsx+++ b/gateway/src/pages/workspace/WorkspacePage.tsx@@ -28,6 +28,7 @@ export default function WorkspacePage() {{canAdminTenant ? (<InvitationsSectiontenantId={tenant.id}+ inOrganization={tenant.organization_id !== null}isOwner={isOwner}emailEnabled={session.invite_email_enabled}/>