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(dashboard): an organization's Services, on its Organization page
Petr Bauchefcddd2c493f
diff --git a/gateway/src/data/api.ts b/gateway/src/data/api.tsindex 8226c506c..ea31e86d3 100644--- a/gateway/src/data/api.ts+++ b/gateway/src/data/api.ts@@ -1279,6 +1279,52 @@ export async function createOrganizationWorkspace(name: string): Promise<TenantMreturn jsonRequest<TenantMembership>("/organizations/current/workspaces", "POST", { name });}+/** What an organization set for a service across its workspaces: on or off,+ * and whether workspace admins may change it. */+export interface OrganizationServiceSetting {+ enabled: boolean;+ locked: boolean;+}++/** A catalog service as its organization's admins see it. */+export interface OrganizationService {+ slug: string;+ name: string;+ /** Null: the organization has no say, and each workspace decides. */+ setting: OrganizationServiceSetting | null;+ updated_by_name: string | null;+ updated_at: string | null;+ /** In how many of the organization's workspaces it is on now. */+ workspaces_on: number;+ /** People across the organization's workspaces with it connected. */+ connected_members: number;+}++export interface OrganizationServices {+ /** How many workspaces the organization has. */+ workspaces: number;+ services: OrganizationService[];+}++export async function fetchOrganizationServices(): Promise<OrganizationServices> {+ return jsonRequest<OrganizationServices>("/organizations/current/services", "GET");+}++/** Set a service for every workspace; `warning` says what could not be revoked yet. */+export async function setOrganizationService(+ service: string,+ setting: OrganizationServiceSetting,+): Promise<{ warning: string | null }> {+ return jsonRequest(`/organizations/current/services/${service}`, "PUT", setting);+}++/** Give up the organization's say in a service. */+export async function clearOrganizationService(+ service: string,+): Promise<{ warning: string | null }> {+ return jsonRequest(`/organizations/current/services/${service}`, "DELETE");+}+export async function fetchOrganizationMembers(): Promise<OrganizationMember[]> {return jsonRequest<OrganizationMember[]>("/organizations/current/members", "GET");}diff --git a/gateway/src/pages/organization/OrganizationAuditSection.tsx b/gateway/src/pages/organization/OrganizationAuditSection.tsxindex 56deb1ae0..5d1c9e221 100644--- a/gateway/src/pages/organization/OrganizationAuditSection.tsx+++ b/gateway/src/pages/organization/OrganizationAuditSection.tsx@@ -16,6 +16,8 @@ const ACTION_LABELS: Record<string, string> = {"organization.member_removed": "Member removed","organization.connector_app_saved": "Connector app saved","organization.connector_app_removed": "Connector app removed",+ "organization.service_set": "Service switched",+ "organization.service_cleared": "Service left to workspaces",};const COLUMNS: GridColDef<OrganizationAuditEvent>[] = [diff --git a/gateway/src/pages/organization/OrganizationPage.test.tsx b/gateway/src/pages/organization/OrganizationPage.test.tsxindex 5c76aee0e..6f9d8cfb2 100644--- a/gateway/src/pages/organization/OrganizationPage.test.tsx+++ b/gateway/src/pages/organization/OrganizationPage.test.tsx@@ -163,6 +163,44 @@ describe("OrganizationPage", () => {);});+ it("lets an organization admin switch a service off and lock it for every workspace", async () => {+ signedInAs(session("org_admin", true));+ const github = {+ slug: "github",+ name: "GitHub",+ setting: null,+ updated_by_name: null,+ updated_at: null,+ workspaces_on: 2,+ connected_members: 3,+ };+ const fetchMock = answer({+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },+ "GET /organizations/current/workspaces": [workspace("t1", "Acme")],+ "GET /organizations/current/members": [],+ "GET /organizations/current/audit-events": [],+ "GET /organizations/current/services": { workspaces: 3, services: [github] },+ "PUT /organizations/current/services/github": { warning: null },+ });++ render(<OrganizationPage />);++ const card = await screen.findByTestId("organization-service-github");+ expect(within(card).getByText("On in 2 of 3 workspaces · 3 people connected")).toBeTruthy();+ expect((within(card).getByLabelText("Lock GitHub") as HTMLInputElement).disabled).toBe(true);+ fireEvent.mouseDown(within(card).getByRole("combobox"));+ fireEvent.click(await screen.findByRole("option", { name: "Off" }));+ await waitFor(() =>+ expect(fetchMock).toHaveBeenCalledWith(+ "/gateway/organizations/current/services/github",+ expect.objectContaining({+ method: "PUT",+ body: JSON.stringify({ enabled: false, locked: false }),+ }),+ ),+ );+ });+it("shows no connectors where the server keeps them to itself", async () => {signedInAs(session("org_admin", true));const fetchMock = answer({diff --git a/gateway/src/pages/organization/OrganizationPage.tsx b/gateway/src/pages/organization/OrganizationPage.tsxindex a4ae872bb..3f7f4b6d3 100644--- a/gateway/src/pages/organization/OrganizationPage.tsx+++ b/gateway/src/pages/organization/OrganizationPage.tsx@@ -6,6 +6,7 @@ import { administersOrganization } from "../../data/sessionState";import { useLoad } from "../workspace/useLoad";import OrganizationAuditSection from "./OrganizationAuditSection";import OrganizationConnectorsSection from "./OrganizationConnectorsSection";+import OrganizationServicesSection from "./OrganizationServicesSection";import OrganizationMembersSection from "./OrganizationMembersSection";import WorkspacesSection from "./WorkspacesSection";@@ -43,6 +44,7 @@ export default function OrganizationPage() {{(isAdmin || session.user.is_operator) && (<OrganizationMembersSection selfId={session.user.id} asOperator={!isAdmin} />)}+ {isAdmin && <OrganizationServicesSection />}{isAdmin && <OrganizationConnectorsSection />}{isAdmin && <OrganizationAuditSection />}</Stack>diff --git a/gateway/src/pages/organization/OrganizationServicesSection.tsx b/gateway/src/pages/organization/OrganizationServicesSection.tsxnew file mode 100644index 000000000..89ac21794--- /dev/null+++ b/gateway/src/pages/organization/OrganizationServicesSection.tsx@@ -0,0 +1,166 @@+import {+ Alert,+ Checkbox,+ CircularProgress,+ FormControlLabel,+ MenuItem,+ Paper,+ Select,+ Stack,+ Typography,+} from "@mui/material";+import { useCallback, useState } from "react";+import {+ type OrganizationService,+ clearOrganizationService,+ fetchOrganizationServices,+ setOrganizationService,+} from "../../data/api";+import { formatDate } from "../../theme/hootFormat";+import { useLoad } from "../workspace/useLoad";++type Choice = "none" | "on" | "off";++const CHOICE_LABELS: Record<Choice, string> = {+ none: "Each workspace decides",+ on: "On",+ off: "Off",+};++function choiceOf(service: OrganizationService): Choice {+ if (service.setting === null) return "none";+ return service.setting.enabled ? "on" : "off";+}++/** "On in 2 of 3 workspaces · 4 people connected · set by Ada, 1 Oct 2026". */+export function reachText(service: OrganizationService, workspaces: number): string {+ const parts = [`On in ${service.workspaces_on} of ${workspaces} workspace${workspaces === 1 ? "" : "s"}`];+ if (service.connected_members > 0)+ parts.push(+ `${service.connected_members} ${service.connected_members === 1 ? "person" : "people"} connected`,+ );+ if (service.updated_by_name && service.updated_at)+ parts.push(`set by ${service.updated_by_name}, ${formatDate(service.updated_at)}`);+ return parts.join(" · ");+}++/** Each catalog service, on or off for every workspace in the organization,+ * and whether workspace admins may change it. Unlocked, the setting is the+ * default each workspace may override; locked, it is out of their reach.+ * Shown only where the server lets organizations have this say. */+export default function OrganizationServicesSection() {+ const load = useCallback(() => fetchOrganizationServices(), []);+ const { data, error, errorStatus, loading, refetch } = useLoad(load);+ const [busy, setBusy] = useState<string | null>(null);+ const [actionError, setActionError] = useState<string | null>(null);+ const [actionWarning, setActionWarning] = useState<string | null>(null);++ const act = useCallback(+ async (slug: string, action: () => Promise<{ warning: string | null }>) => {+ setBusy(slug);+ setActionError(null);+ setActionWarning(null);+ try {+ const { warning } = await action();+ setActionWarning(warning);+ await refetch();+ } catch (err) {+ setActionError(err instanceof Error ? err.message : "The change failed");+ } finally {+ setBusy(null);+ }+ },+ [refetch],+ );++ // The routes are mounted only where organizations have this say.+ if (errorStatus === 404) return null;++ const choose = (service: OrganizationService, choice: Choice) =>+ act(service.slug, () =>+ choice === "none"+ ? clearOrganizationService(service.slug)+ : setOrganizationService(service.slug, {+ enabled: choice === "on",+ locked: service.setting?.locked ?? false,+ }),+ );++ return (+ <Stack spacing={1.5}>+ <Typography variant="h6">Services</Typography>+ <Typography variant="body2" sx={{ color: "text.secondary" }}>+ Switch a service on or off for every workspace in the organization. Workspace admins can+ change it in their own workspace unless you lock it. Switching a service off keeps+ agents' grants, and gives them back when it is switched on again.+ </Typography>+ {error && <Alert severity="error">{error}</Alert>}+ {actionError && (+ <Alert severity="error" onClose={() => setActionError(null)}>+ {actionError}+ </Alert>+ )}+ {actionWarning && (+ <Alert severity="warning" onClose={() => setActionWarning(null)}>+ {actionWarning}+ </Alert>+ )}+ {loading ? (+ <CircularProgress />+ ) : (+ data?.services.map((service) => {+ const choice = choiceOf(service);+ return (+ <Paper+ key={service.slug}+ variant="outlined"+ sx={{ p: 1.5 }}+ data-testid={`organization-service-${service.slug}`}+ >+ <Stack direction="row" alignItems="center" spacing={1.5}>+ <Typography variant="subtitle2" sx={{ flexGrow: 1 }}>+ {service.name}+ </Typography>+ <Select+ size="small"+ value={choice}+ disabled={busy !== null}+ onChange={(e) => void choose(service, e.target.value as Choice)}+ inputProps={{ "aria-label": `${service.name} for the organization` }}+ sx={{ fontSize: "0.875rem", minWidth: 190 }}+ >+ {(Object.keys(CHOICE_LABELS) as Choice[]).map((value) => (+ <MenuItem key={value} value={value}>+ {CHOICE_LABELS[value]}+ </MenuItem>+ ))}+ </Select>+ <FormControlLabel+ label="Locked"+ control={+ <Checkbox+ size="small"+ checked={service.setting?.locked ?? false}+ disabled={busy !== null || service.setting === null}+ onChange={(_, locked) => {+ const setting = service.setting;+ if (setting === null) return;+ void act(service.slug, () =>+ setOrganizationService(service.slug, { enabled: setting.enabled, locked }),+ );+ }}+ inputProps={{ "aria-label": `Lock ${service.name}` }}+ />+ }+ />+ </Stack>+ <Typography variant="body2" color="text.secondary" sx={{ mt: 0.5 }}>+ {reachText(service, data.workspaces)}+ </Typography>+ </Paper>+ );+ })+ )}+ </Stack>+ );+}