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
fix(organizations): read issues without holding two connections, and only real ones
Petr Bauchf249b1f392cc
diff --git a/core/switch_core/db/audit.py b/core/switch_core/db/audit.pyindex ddf7b6785..355860043 100644--- a/core/switch_core/db/audit.py+++ b/core/switch_core/db/audit.py@@ -97,6 +97,18 @@ class OrganizationAuditAction(StrEnum):LINKED_TO_DIRECTORY = "organization.linked_to_directory"+class OrganizationIssueKind(StrEnum):+ """What can need an organization admin's attention+ (`organization_issues.py`). `directory_organization_deleted` is also the+ `details.kind` of the `DIRECTORY_CONFLICT` that reports it. Mirrored by+ hand as `OrganizationIssueKind` in the gateway's `data/api.ts`."""++ NO_ORG_ADMIN = "no_org_admin"+ WORKSPACE_WITHOUT_OWNER = "workspace_without_owner"+ AGENTS_WITHOUT_ACTING_OWNER = "agents_without_acting_owner"+ DIRECTORY_ORGANIZATION_DELETED = "directory_organization_deleted"++class ServerAuditAction(StrEnum):CONNECTOR_APP_SAVED = "connector_app.saved"CONNECTOR_APP_IMPORTED = "connector_app.imported"diff --git a/core/switch_core/gateway/auth.py b/core/switch_core/gateway/auth.pyindex b6d01a0c0..27d8b1703 100644--- a/core/switch_core/gateway/auth.py+++ b/core/switch_core/gateway/auth.py@@ -389,6 +389,19 @@ async def _in_organization(return found+async def tenants_bindable_or_any(+ session_factory: async_sessionmaker[AsyncSession],+ user_id: str,+ *,+ is_operator: bool,+) -> list[str]:+ """`tenants_bindable_by`, or every tenant for the platform operator, who+ may bind any."""+ if is_operator:+ return await all_tenant_ids(session_factory)+ return await tenants_bindable_by(session_factory, user_id)++async def workspaces_in_organization(session_factory: async_sessionmaker[AsyncSession],user_id: str,@@ -511,10 +524,8 @@ async def organization_workspaces_bindable_by(`platform_access` gives them. Each candidate is read on its own shortsession, and only those in the organization are described further."""- candidates = (- await all_tenant_ids(session_factory)- if is_operator- else await tenants_bindable_by(session_factory, user_id)+ candidates = await tenants_bindable_or_any(+ session_factory, user_id, is_operator=is_operator)found: list[TenantMembershipResponse] = []for tenant in await _in_organization(session_factory, candidates, organization_id):diff --git a/core/switch_core/gateway/organizations.py b/core/switch_core/gateway/organizations.pyindex b847b8204..e224aae4d 100644--- a/core/switch_core/gateway/organizations.py+++ b/core/switch_core/gateway/organizations.py@@ -58,6 +58,7 @@ from switch_core.gateway.auth import (get_current_user,organization_workspaces_bindable_by,organizations_bindable_by,+ tenants_bindable_or_any,workspaces_in_organization,workspaces_reached_through_organization,)@@ -100,7 +101,10 @@ from switch_core.organization_access import (workspaces_where_they_own_agents,)from switch_core.organization_directory import DirectoryError, OrganizationDirectory-from switch_core.organization_issues import organization_issues+from switch_core.organization_issues import (+ organization_wide_issues,+ workspace_issues,+)router = APIRouter()@@ -409,20 +413,18 @@ async def list_organization_issues(access = await _require_organization_admin(session, user_store, organization_store, user, operator_restores=True)- organization_id = access.organization_id- workspaces = await organization_workspaces_bindable_by(- session_factory,- user_store,- user.id,- organization_id,- is_operator=access.platform_access,- )- issues = await organization_issues(- session,+ issues, admins = await organization_wide_issues(session, access.organization_id)+ # Let go of the request's connection while each workspace is read on a+ # session of its own.+ await session.commit()+ issues += await workspace_issues(session_factory,user_store,- organization_id=organization_id,- workspaces=[(workspace.id, workspace.name) for workspace in workspaces],+ organization_id=access.organization_id,+ admins=admins,+ candidates=await tenants_bindable_or_any(+ session_factory, user.id, is_operator=access.platform_access+ ),)return [OrganizationIssueDetail(diff --git a/core/switch_core/gateway/schemas.py b/core/switch_core/gateway/schemas.pyindex 04593596c..2fb818d1c 100644--- a/core/switch_core/gateway/schemas.py+++ b/core/switch_core/gateway/schemas.py@@ -20,12 +20,12 @@ from switch_core.bridges.collaboration.models import (ChannelRetirement,RetireOutcome,)+from switch_core.db.audit import OrganizationIssueKindfrom switch_core.db.models import (MAX_BUDGET_AMOUNT,MAX_BUDGET_PERIOD_HOURS,UsageMetric,)-from switch_core.organization_issues import IssueKind# ── Rooms ─────────────────────────────────────────────────────────────────────@@ -1081,7 +1081,7 @@ class OrganizationIssueDetail(BaseModel):(`organization_issues.py`): its kind, the workspace it is in (None forthe organization's own), and the agents it names, if any."""- kind: IssueKind+ kind: OrganizationIssueKindworkspace_id: str | Noneworkspace_name: str | Noneagents: list[str]diff --git a/core/switch_core/organization_issues.py b/core/switch_core/organization_issues.pyindex a5c1b4a9d..6f62418f4 100644--- a/core/switch_core/organization_issues.py+++ b/core/switch_core/organization_issues.py@@ -10,67 +10,52 @@ once someone fixes it rather than once someone dismisses it:operator, who may make someone its admin, can then read this).- `workspace_without_owner`: a workspace with no `owner`.- `agents_without_acting_owner`: agents whose owner is neither a member of- their workspace nor the organization's `org_admin`, so nobody can act for- them as their owner.+ their workspace, nor the organization's `org_admin`, nor the platform+ operator, so nobody can act for them as their owner.- `directory_organization_deleted`: the WorkOS organization this one follows- was deleted after it was linked.+ was deleted."""from __future__ import annotationsfrom dataclasses import dataclass-from typing import Literal-from sqlalchemy import and_, or_, select, true+from sqlalchemy import select, truefrom sqlalchemy.ext.asyncio import AsyncSession, async_sessionmakerfrom switch_core.authz import ORGANIZATION_ADMIN_ROLE-from switch_core.db.audit import OrganizationAuditAction+from switch_core.db.audit import OrganizationAuditAction, OrganizationIssueKindfrom switch_core.db.models import (Agent,Organization,OrganizationAuditEvent,OrganizationMember,+ Tenant,TenantMember,+ User,)from switch_core.db.session_scope import tenant_sessionfrom switch_core.db.stores.user_store import UserStore-IssueKind = Literal[- "no_org_admin",- "workspace_without_owner",- "agents_without_acting_owner",- "directory_organization_deleted",-]-NO_ORG_ADMIN: IssueKind = "no_org_admin"-WORKSPACE_WITHOUT_OWNER: IssueKind = "workspace_without_owner"-AGENTS_WITHOUT_ACTING_OWNER: IssueKind = "agents_without_acting_owner"-DIRECTORY_ORGANIZATION_DELETED: IssueKind = "directory_organization_deleted"-@dataclass(frozen=True)class OrganizationIssue:"""One issue: its kind, the workspace it is in (None for theorganization's own), and the agents it names, if any."""- kind: IssueKind+ kind: OrganizationIssueKindworkspace_id: str | Noneworkspace_name: str | Noneagents: list[str]-async def organization_issues(- session: AsyncSession,- session_factory: async_sessionmaker[AsyncSession],- user_store: UserStore,- *,- organization_id: str,- workspaces: list[tuple[str, str]],-) -> list[OrganizationIssue]:- """The issues of `organization_id` as things stand. `session` is bound- to one of its workspaces, for the organization's own rows; each of- `workspaces`, its workspaces as (id, name), is read on a short session of its own,- after `session` has let go of its connection."""+async def organization_wide_issues(+ session: AsyncSession, organization_id: str+) -> tuple[list[OrganizationIssue], set[str]]:+ """The issues of `organization_id` itself, read on `session`, bound to+ one of its workspaces, and its `org_admin`s, which `workspace_issues`+ needs. The caller commits before reading the workspaces, so it holds no+ connection while they are read."""admins = set(await session.scalars(select(OrganizationMember.user_id).where(@@ -81,50 +66,92 @@ async def organization_issues()issues = []if not admins:- issues.append(OrganizationIssue(NO_ORG_ADMIN, None, None, []))+ issues.append(+ OrganizationIssue(OrganizationIssueKind.NO_ORG_ADMIN, None, None, [])+ )if await _directory_organization_deleted(session, organization_id):- issues.append(OrganizationIssue(DIRECTORY_ORGANIZATION_DELETED, None, None, []))- await session.commit()-- for workspace_id, workspace_name in sorted(workspaces, key=lambda w: w[1]):- async with tenant_session(session_factory, workspace_id) as tenant:- if await user_store.count_owners(tenant) == 0:- issues.append(- OrganizationIssue(- WORKSPACE_WITHOUT_OWNER, workspace_id, workspace_name, []- )- )- stranded = list(- await tenant.scalars(- select(Agent.name)- .where(- Agent.tenant_id == workspace_id,- Agent.owner_id.is_not(None),- Agent.owner_id.not_in(admins) if admins else true(),- ~select(TenantMember.user_id)- .where(- TenantMember.tenant_id == workspace_id,- TenantMember.user_id == Agent.owner_id,- )- .exists(),- )- .order_by(Agent.name)+ issues.append(+ OrganizationIssue(+ OrganizationIssueKind.DIRECTORY_ORGANIZATION_DELETED, None, None, []+ )+ )+ return issues, admins+++async def workspace_issues(+ session_factory: async_sessionmaker[AsyncSession],+ user_store: UserStore,+ *,+ organization_id: str,+ admins: set[str],+ candidates: list[str],+) -> list[OrganizationIssue]:+ """The issues in the workspaces of `organization_id` among `candidates`,+ sorted by workspace name. Each candidate is read on a short session of+ its own, and those of other organizations skipped."""+ found: list[OrganizationIssue] = []+ for tenant_id in candidates:+ async with tenant_session(session_factory, tenant_id) as tenant_db:+ workspace = await tenant_db.get(Tenant, tenant_id)+ if workspace is None or workspace.organization_id != organization_id:+ continue+ without_owner = await user_store.count_owners(tenant_db) == 0+ stranded = await _stranded_agents(tenant_db, tenant_id, admins)+ if without_owner:+ found.append(+ OrganizationIssue(+ OrganizationIssueKind.WORKSPACE_WITHOUT_OWNER,+ tenant_id,+ workspace.name,+ [],))if stranded:- issues.append(+ found.append(OrganizationIssue(- AGENTS_WITHOUT_ACTING_OWNER, workspace_id, workspace_name, stranded+ OrganizationIssueKind.AGENTS_WITHOUT_ACTING_OWNER,+ tenant_id,+ workspace.name,+ stranded,))- return issues+ return sorted(found, key=lambda issue: issue.workspace_name or "")+++async def _stranded_agents(+ session: AsyncSession, tenant_id: str, admins: set[str]+) -> list[str]:+ """The agents of `tenant_id` whose owner is neither its member, nor the+ organization's `org_admin`, nor the platform operator, who may act in any+ workspace without a membership row."""+ return list(+ await session.scalars(+ select(Agent.name)+ .where(+ Agent.tenant_id == tenant_id,+ Agent.owner_id.is_not(None),+ Agent.owner_id.not_in(admins) if admins else true(),+ ~select(TenantMember.user_id)+ .where(+ TenantMember.tenant_id == tenant_id,+ TenantMember.user_id == Agent.owner_id,+ )+ .exists(),+ ~select(User.id)+ .where(User.id == Agent.owner_id, User.role == "admin")+ .exists(),+ )+ .order_by(Agent.name)+ )+ )async def _directory_organization_deleted(session: AsyncSession, organization_id: str) -> bool:- """Whether the organization is linked and the WorkOS organization it- follows was reported deleted after the link was last made."""+ """Whether the WorkOS organization this one follows now was reported+ deleted. A WorkOS organization, once deleted, can't be linked again, so a+ conflict naming the linked id settles it, whenever it was recorded."""linked = await session.scalar(select(Organization.workos_organization_id).where(Organization.id == organization_id@@ -132,25 +159,15 @@ async def _directory_organization_deleted()if linked is None:return False- latest = await session.scalar(- select(OrganizationAuditEvent.action)+ found = await session.scalar(+ select(OrganizationAuditEvent.id).where(OrganizationAuditEvent.organization_id == organization_id,- or_(- OrganizationAuditEvent.action- == OrganizationAuditAction.LINKED_TO_DIRECTORY,- and_(- OrganizationAuditEvent.action- == OrganizationAuditAction.DIRECTORY_CONFLICT,- OrganizationAuditEvent.details["kind"].astext- == DIRECTORY_ORGANIZATION_DELETED,- ),- ),- )- .order_by(- OrganizationAuditEvent.occurred_at.desc(),- OrganizationAuditEvent.id.desc(),+ OrganizationAuditEvent.action == OrganizationAuditAction.DIRECTORY_CONFLICT,+ OrganizationAuditEvent.details["kind"].astext+ == OrganizationIssueKind.DIRECTORY_ORGANIZATION_DELETED,+ OrganizationAuditEvent.details["workos_organization_id"].astext == linked,).limit(1))- return latest == OrganizationAuditAction.DIRECTORY_CONFLICT+ return found is not Nonediff --git a/core/switch_core/workos_mirror.py b/core/switch_core/workos_mirror.pyindex e79921bd6..1db83ddb1 100644--- a/core/switch_core/workos_mirror.py+++ b/core/switch_core/workos_mirror.py@@ -52,6 +52,7 @@ from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmakerfrom switch_core.db.audit import (OrganizationAuditAction,+ OrganizationIssueKind,ServerAuditAction,record_organization_audit_event,record_server_audit_event,@@ -66,7 +67,6 @@ from switch_core.db.models import (from switch_core.db.session_scope import organization_sessionfrom switch_core.db.stores.ownership_lease_store import OwnershipLeaseStorefrom switch_core.db.tenant_lookup import directory_organizations-from switch_core.organization_issues import DIRECTORY_ORGANIZATION_DELETEDfrom switch_core.organization_mirror import MirrorDependencies, apply_from_directoryfrom switch_core.ownership import Fence, OwnedKind, Ownershipfrom switch_core.tenant_context import no_tenant@@ -242,7 +242,9 @@ class WorkOSMirror:if organization_id is None or workos_organization_id is None:returnif kind == "organization.deleted":- await self._organization_deleted(fence, organization_id, data)+ await self._organization_deleted(+ fence, organization_id, workos_organization_id+ )returnsubject = data.get("user_id")if not isinstance(subject, str):@@ -346,7 +348,7 @@ class WorkOSMirror:return completeasync def _organization_deleted(- self, fence: Fence, organization_id: str, data: dict[str, Any]+ self, fence: Fence, organization_id: str, workos_organization_id: str) -> None:"""Deleting a linked organization in WorkOS removes nobody here: thatis too much to take away on one event. It is reported for an operator@@ -354,7 +356,7 @@ class WorkOSMirror:logger.error("WorkOS organization %s, which organization %s follows, was deleted; ""its members are left as they are",- data.get("id"),+ workos_organization_id,organization_id,)await self._ensure_held(fence)@@ -370,7 +372,8 @@ class WorkOSMirror:target_id=organization_id,details={"source": FROM_EVENT,- "kind": DIRECTORY_ORGANIZATION_DELETED,+ "kind": OrganizationIssueKind.DIRECTORY_ORGANIZATION_DELETED,+ "workos_organization_id": workos_organization_id,},)await session.commit()diff --git a/core/tests/switch_core/gateway/test_organization_routes.py b/core/tests/switch_core/gateway/test_organization_routes.pyindex e232fd6e4..b39909d6b 100644--- a/core/tests/switch_core/gateway/test_organization_routes.py+++ b/core/tests/switch_core/gateway/test_organization_routes.py@@ -1101,7 +1101,8 @@ async def _personal_key(async def _agent(session_factory: async_sessionmaker[AsyncSession], tenant_id: str, owner_id: str-) -> None:+) -> str:+ name = f"agent-{uuid.uuid4().hex[:6]}"async with session_factory() as session:client = Client(tenant_id=tenant_id,@@ -1124,7 +1125,7 @@ async def _agent(session.add(Agent(tenant_id=tenant_id,- name=f"agent-{uuid.uuid4().hex[:6]}",+ name=name,description="test agent",agent_type="other",connector_type="claude-code",@@ -1135,6 +1136,7 @@ async def _agent())await session.commit()+ return nameasync def _key_exists(@@ -1359,13 +1361,16 @@ class TestIssues:) -> None:"""Bob left the workspace and the organization; his agent stayed.Ada's own agent, held as the organization's admin with no membership- row, is no issue."""+ row, is no issue, nor is one the platform operator made, who may act+ in any workspace."""ada, bob = _name("ada"), _name("bob")tenant_id = await _workspace(session_factory, {ada: ("owner", "org_admin"), bob: ("member", "member")})- await _agent(session_factory, tenant_id, bob)+ operator_id = await _operator(session_factory)+ bobs_agent = await _agent(session_factory, tenant_id, bob)await _agent(session_factory, tenant_id, ada)+ await _agent(session_factory, tenant_id, operator_id)organization_id = await _organization_of(session_factory, tenant_id)async with tenant_session(session_factory, tenant_id) as session:await session.delete(await session.get(TenantMember, (tenant_id, bob)))@@ -1384,52 +1389,46 @@ class TestIssues:if issue["kind"] == "agents_without_acting_owner"]assert stranded["workspace_id"] == tenant_id- assert len(stranded["agents"]) == 1+ assert stranded["agents"] == [bobs_agent]- async def test_a_deleted_workos_organization_until_it_is_linked_again(+ async def test_a_deleted_workos_organization_until_another_is_linked(self, session_factory: async_sessionmaker[AsyncSession]) -> None:+ """Only a deletion of the WorkOS organization followed now counts,+ whatever order the audit log has it in."""ada = _name("ada")tenant_id = await _workspace(session_factory, {ada: ("owner", "org_admin")})organization_id = await _organization_of(session_factory, tenant_id)+ deleted_id, other_id = _name("org_workos"), _name("org_workos")++ async def follow(workos_organization_id: str) -> None:+ async with session_factory() as session:+ organization = await session.get(Organization, organization_id)+ assert organization is not None+ organization.workos_organization_id = workos_organization_id+ await session.commit()+async with session_factory() as session:- organization = await session.get(Organization, organization_id)- assert organization is not None- organization.workos_organization_id = _name("org_workos")- for action, details in (- (OrganizationAuditAction.LINKED_TO_DIRECTORY, {}),- (- OrganizationAuditAction.DIRECTORY_CONFLICT,- {"kind": "directory_organization_deleted"},- ),- ):+ for reported in (deleted_id, other_id):session.add(OrganizationAuditEvent(organization_id=organization_id,actor_user_id=None,- action=action,+ action=OrganizationAuditAction.DIRECTORY_CONFLICT,target_type="organization",target_id=organization_id,- details=details,+ details={+ "kind": "directory_organization_deleted",+ "workos_organization_id": reported,+ },))- await session.commit()+ await session.commit()- app = _app(session_factory)- async with _client(app, ada, tenant_id) as client:+ async with _client(_app(session_factory), ada, tenant_id) as client:+ await follow(deleted_id)deleted = await client.get("/organizations/current/issues")- async with session_factory() as session:- session.add(- OrganizationAuditEvent(- organization_id=organization_id,- actor_user_id=None,- action=OrganizationAuditAction.LINKED_TO_DIRECTORY,- target_type="organization",- target_id=organization_id,- details={},- )- )- await session.commit()+ await follow(_name("org_workos"))relinked = await client.get("/organizations/current/issues")assert [issue["kind"] for issue in deleted.json()] == [diff --git a/core/tests/switch_core/test_workos_mirror.py b/core/tests/switch_core/test_workos_mirror.pyindex 7a54c1b9e..df2c4160f 100644--- a/core/tests/switch_core/test_workos_mirror.py+++ b/core/tests/switch_core/test_workos_mirror.py@@ -315,7 +315,11 @@ class TestEvents:))assert event.action == OrganizationAuditAction.DIRECTORY_CONFLICT- assert event.details["kind"] == "directory_organization_deleted"+ assert event.details == {+ "source": "directory_event",+ "kind": "directory_organization_deleted",+ "workos_organization_id": workos_id,+ }class TestDailyCheck:diff --git a/gateway/src/data/api.ts b/gateway/src/data/api.tsindex 5ca81736f..a48c9b221 100644--- a/gateway/src/data/api.ts+++ b/gateway/src/data/api.ts@@ -1362,6 +1362,7 @@ export async function removeOrganizationMember();}+// Mirrors `OrganizationIssueKind` in core/switch_core/db/audit.py, by hand.export type OrganizationIssueKind =| "no_org_admin"| "workspace_without_owner"diff --git a/gateway/src/pages/organization/OrganizationMembersSection.tsx b/gateway/src/pages/organization/OrganizationMembersSection.tsxindex ce9d1f1ec..562ca2656 100644--- a/gateway/src/pages/organization/OrganizationMembersSection.tsx+++ b/gateway/src/pages/organization/OrganizationMembersSection.tsx@@ -39,11 +39,14 @@ const ROLE_LABELS: Record<OrganizationRole, string> = {export default function OrganizationMembersSection({selfId,asOperator,+ 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;+ // Called after each change that went through.+ onChanged: () => void;}) {const load = useCallback(() => fetchOrganizationMembers(), []);const { data: members, error, errorStatus, loading, refetch } = useLoad(load);@@ -60,6 +63,7 @@ export default function OrganizationMembersSection({try {const { warning } = await action();setActionWarning(warning);+ onChanged();await refetch();// Your own role decides what this page offers you.if (userId === selfId) await refresh();@@ -69,7 +73,7 @@ export default function OrganizationMembersSection({setBusy(null);}},- [refetch, refresh, selfId],+ [onChanged, refetch, refresh, selfId],);const columns = useMemo<GridColDef<MemberRow>[]>(diff --git a/gateway/src/pages/organization/OrganizationPage.test.tsx b/gateway/src/pages/organization/OrganizationPage.test.tsxindex 154d8606b..a018cde69 100644--- a/gateway/src/pages/organization/OrganizationPage.test.tsx+++ b/gateway/src/pages/organization/OrganizationPage.test.tsx@@ -370,6 +370,31 @@ describe("OrganizationPage", () => {expect(screen.getByText(/reviewer, triage/)).toBeTruthy();});+ 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/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": [],+ "DELETE /organizations/current/members/u2": { warning: null },+ };+ answer(routes);++ render(<OrganizationPage />);+ const remove = await screen.findByRole("button", { name: "Remove [email protected] from the organization" });+ routes["GET /organizations/current/issues"] = [+ { kind: "agents_without_acting_owner", workspace_id: "t1", workspace_name: "Acme", agents: ["triage"] },+ ];+ fireEvent.click(remove);++ expect(await screen.findByText("One thing needs your attention")).toBeTruthy();+ expect(screen.getByText(/triage/)).toBeTruthy();+ });+it("says nothing when nothing needs attention", async () => {signedInAs(session("org_admin", true));answer({diff --git a/gateway/src/pages/organization/OrganizationPage.tsx b/gateway/src/pages/organization/OrganizationPage.tsxindex 2c7745c16..29e0c3f6b 100644--- a/gateway/src/pages/organization/OrganizationPage.tsx+++ b/gateway/src/pages/organization/OrganizationPage.tsx@@ -1,5 +1,5 @@import { Alert, Box, CircularProgress, Stack, Typography } from "@mui/material";-import { useCallback } from "react";+import { useCallback, useState } from "react";import { useAuth } from "../../data/AuthContext";import { fetchCurrentOrganization } from "../../data/api";import { administersOrganization } from "../../data/sessionState";@@ -18,6 +18,10 @@ export default function OrganizationPage() {const { session } = useAuth();const load = useCallback(() => fetchCurrentOrganization(), []);const { data: organization, error } = useLoad(load);+ // A change to the members can make an issue or settle one; the notice is+ // read again, from scratch, after each.+ const [membersChanged, setMembersChanged] = useState(0);+ const onMembersChanged = useCallback(() => setMembersChanged((n) => n + 1), []);const tenant = session?.tenant;if (!session || !tenant) return <CircularProgress />;if (tenant.organization_id === null) {@@ -41,10 +45,14 @@ export default function OrganizationPage() {</Stack>{error && <Alert severity="error">{error}</Alert>}<Stack spacing={4}>- {(isAdmin || session.user.is_operator) && <OrganizationIssuesNotice />}+ {(isAdmin || session.user.is_operator) && <OrganizationIssuesNotice key={membersChanged} />}<WorkspacesSection currentId={tenant.id} canAdd={session.can_add_workspace} />{(isAdmin || session.user.is_operator) && (- <OrganizationMembersSection selfId={session.user.id} asOperator={!isAdmin} />+ <OrganizationMembersSection+ selfId={session.user.id}+ asOperator={!isAdmin}+ onChanged={onMembersChanged}+ />)}{isAdmin && <OrganizationServicesSection />}{isAdmin && <OrganizationConnectorsSection />}