The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
fix(ui): add Cloud invitations to the Members page (#13922)
Devin Foleyc341588bdbb5
diff --git a/doc/SPEC-implementation.md b/doc/SPEC-implementation.mdindex f60ec9ce59..e765e0dd6e 100644--- a/doc/SPEC-implementation.md+++ b/doc/SPEC-implementation.md@@ -1003,6 +1003,13 @@ stack id to the Cloud tenant portfolio endpoint. Client-supplied user ids arenever forwarded. Successful responses are cached briefly per user; self-hostedinstances return `404`.+On Cloud-managed instances, the Members page offers **Invite people** to the+current stack's owner/admin. It opens that stack's Cloud People settings with a+full-page navigation. The destination uses the configured Cloud origin and the+current stack from the authenticated portfolio. The action stays hidden until+that role is known, or when the portfolio request fails. Hiding the tenant-local+Invites tab does not hide this Cloud action.+## 10.2 Goals- `GET /companies/:companyId/goals`diff --git a/ui/src/lib/cloudLinks.test.ts b/ui/src/lib/cloudLinks.test.tsindex 7a6a54e2de..58073c8b36 100644--- a/ui/src/lib/cloudLinks.test.ts+++ b/ui/src/lib/cloudLinks.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import { cloudAppUrl, cloudPortfolioManageUrl, cloudStackCreateUrl, cloudStackEnterUrl } from "./cloudLinks";+import { cloudAppUrl, cloudPortfolioManageUrl, cloudStackCreateUrl, cloudStackEnterUrl, cloudStackInviteUrl } from "./cloudLinks";describe("cloudLinks", () => {it("resolves stack links against the cloud origin", () => {@@ -27,6 +27,15 @@ describe("cloudLinks", () => {);});+ it("opens Cloud People settings on the configured origin with an escaped stack slug", () => {+ expect(cloudStackInviteUrl("https://cloud.example.test/control-plane", "team/with?query")).toBe(+ "https://cloud.example.test/workspaces/team%2Fwith%3Fquery/settings?section=people",+ );+ expect(cloudStackInviteUrl(null, "team")).toBeNull();+ expect(cloudStackInviteUrl("https://cloud.example.test", " ")).toBeNull();+ expect(cloudStackInviteUrl("javascript:alert(1)", "team")).toBeNull();+ });+it("returns null without a usable base or slug", () => {expect(cloudStackEnterUrl(null, "acme")).toBeNull();expect(cloudStackEnterUrl(" ", "acme")).toBeNull();diff --git a/ui/src/lib/cloudLinks.ts b/ui/src/lib/cloudLinks.tsindex 516c61bf7a..79a3f35a3b 100644--- a/ui/src/lib/cloudLinks.ts+++ b/ui/src/lib/cloudLinks.ts@@ -43,6 +43,16 @@ export function cloudStackCreateUrl(cloudBaseUrl: string | null | undefined): streturn cloudAppUrl(cloudBaseUrl, "/stacks/new");}+/** Cloud manages human invitations in the current stack's People settings. */+export function cloudStackInviteUrl(+ cloudBaseUrl: string | null | undefined,+ stackSlug: string | null | undefined,+): string | null {+ const slug = stackSlug?.trim();+ if (!slug) return null;+ return cloudAppUrl(cloudBaseUrl, `/workspaces/${encodeURIComponent(slug)}/settings?section=people`);+}+/*** Cloud's organization portfolio in its explicit manage view. `?manage=1`* matters: the plain launchpad auto-forwards a solo user straight back intodiff --git a/ui/src/pages/CompanyAccess.test.tsx b/ui/src/pages/CompanyAccess.test.tsxindex e1bbf45f0c..3e5b2fe767 100644--- a/ui/src/pages/CompanyAccess.test.tsx+++ b/ui/src/pages/CompanyAccess.test.tsx@@ -15,8 +15,13 @@ const listIssuesMock = vi.hoisted(() => vi.fn());const mockUsePluginSlots = vi.hoisted(() => vi.fn());const mockNavigate = vi.hoisted(() => vi.fn());const listInvitesMock = vi.hoisted(() => vi.fn());+const listCloudStacksMock = vi.hoisted(() => vi.fn());const mockSearchParamsState = vi.hoisted(() => ({ current: new URLSearchParams() }));+vi.mock("@/api/cloud", () => ({+ cloudApi: { listStacks: listCloudStacksMock },+}));+vi.mock("@/api/access", () => ({accessApi: {listMembers: (companyId: string) => listMembersMock(companyId),@@ -503,6 +508,7 @@ describe("CompanyAccess invites tab", () => {document.body.appendChild(container);mockSearchParamsState.current = new URLSearchParams();listInvitesMock.mockResolvedValue({ invites: [], nextOffset: null });+ listCloudStacksMock.mockResolvedValue({ stacks: [] });listMembersMock.mockResolvedValue({members: [],access: { currentUserRole: "owner", canApproveJoinRequests: false },@@ -541,6 +547,8 @@ describe("CompanyAccess invites tab", () => {expect(tabLabels).toEqual(["Members", "Invites"]);expect(container.textContent).toContain("Organization Members");expect(container.textContent).not.toContain("Invite a person");+ expect(container.textContent).not.toContain("Invite people");+ expect(listCloudStacksMock).not.toHaveBeenCalled();await act(async () => {root.unmount();@@ -574,4 +582,73 @@ describe("CompanyAccess invites tab", () => {root.unmount();});});++ function cloudClient(cloudBaseUrl: string | null = "https://cloud.example.test") {+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });+ client.setQueryData(["health"], {+ hiddenSettings: ["company.invites"],+ cloud: { managed: true, managedBy: "paperclip-cloud", cloudBaseUrl, stackSlug: "old-slug" },+ });+ return client;+ }++ function cloudStack(role: string, isCurrent = true) {+ return { stackSlug: isCurrent ? "current-team" : "other-team", role, isCurrent,+ displayName: "Team", primaryHost: null, lifecycleState: "active", sleepState: "awake" };+ }++ it.each(["owner", "admin"])("offers Cloud invitations to the current stack's %s even with local invites hidden", async (role) => {+ listCloudStacksMock.mockResolvedValue({ stacks: [cloudStack("owner", false), cloudStack(role)] });+ const root = await renderPage(cloudClient());++ const invite = [...container.querySelectorAll("a")].find((link) => link.textContent === "Invite people");+ expect(invite?.getAttribute("href")).toBe("https://cloud.example.test/workspaces/current-team/settings?section=people");+ expect(invite?.getAttribute("target")).toBeNull();+ expect(container.querySelectorAll('[role="tab"]')).toHaveLength(0);+ expect(listInvitesMock).not.toHaveBeenCalled();++ await act(async () => root.unmount());+ });++ it.each(["member", "support", "unknown"])("does not expose Cloud invitations to a %s who owns another stack", async (role) => {+ listCloudStacksMock.mockResolvedValue({ stacks: [cloudStack("owner", false), cloudStack(role)] });+ const root = await renderPage(cloudClient());+ expect(container.textContent).not.toContain("Invite people");+ await act(async () => root.unmount());+ });++ it("waits for the Cloud role before showing the invitation action", async () => {+ let resolveStacks!: (value: { stacks: ReturnType<typeof cloudStack>[] }) => void;+ listCloudStacksMock.mockReturnValue(new Promise((resolve) => { resolveStacks = resolve; }));+ const root = await renderPage(cloudClient());+ expect(container.textContent).not.toContain("Invite people");+ await act(async () => resolveStacks({ stacks: [cloudStack("admin")] }));+ await flushReact();+ expect(container.textContent).toContain("Invite people");+ await act(async () => root.unmount());+ });++ it("hides a cached invitation action when the Cloud role refresh fails", async () => {+ const client = cloudClient();+ client.setQueryData(["cloud", "stacks"], { stacks: [cloudStack("owner")] });+ const root = await renderPage(client);+ expect(container.textContent).toContain("Invite people");+ listCloudStacksMock.mockRejectedValue(new Error("Portfolio unavailable"));+ await act(async () => { await client.invalidateQueries({ queryKey: ["cloud", "stacks"] }); });+ await flushReact();+ expect(container.textContent).not.toContain("Invite people");+ await act(async () => root.unmount());+ });++ it("requires an identified current stack and a configured Cloud destination", async () => {+ listCloudStacksMock.mockResolvedValue({ stacks: [cloudStack("owner", false)] });+ const root = await renderPage(cloudClient());+ expect(container.textContent).not.toContain("Invite people");+ await act(async () => root.unmount());++ listCloudStacksMock.mockResolvedValue({ stacks: [cloudStack("owner")] });+ const secondRoot = await renderPage(cloudClient(null));+ expect(container.textContent).not.toContain("Invite people");+ await act(async () => secondRoot.unmount());+ });});diff --git a/ui/src/pages/CompanyAccess.tsx b/ui/src/pages/CompanyAccess.tsxindex 88e262e5a2..1befd061b6 100644--- a/ui/src/pages/CompanyAccess.tsx+++ b/ui/src/pages/CompanyAccess.tsx@@ -5,10 +5,11 @@ import {hidesCompanyPage,type Agent,} from "@paperclipai/shared";-import { Shield, ShieldCheck, Trash2 } from "lucide-react";+import { Shield, ShieldCheck, Trash2, UserPlus } from "lucide-react";import { accessApi, type CompanyMember } from "@/api/access";import { agentsApi } from "@/api/agents";import { ApiError } from "@/api/client";+import { cloudApi } from "@/api/cloud";import { issuesApi } from "@/api/issues";import { Button } from "@/components/ui/button";import {@@ -26,10 +27,12 @@ import { useCompany } from "@/context/CompanyContext";import { useToast } from "@/context/ToastContext";import { Link, Navigate, useSearchParams } from "@/lib/router";import { queryKeys } from "@/lib/queryKeys";+import { cloudStackInviteUrl } from "@/lib/cloudLinks";import { usePluginSlots } from "@/plugins/slots";import { Tabs, TabsContent } from "@/components/ui/tabs";import { PageTabBar } from "@/components/PageTabBar";import { useHiddenSettings } from "@/hooks/useHiddenSettings";+import { useCloudInstance } from "@/hooks/useCloudInstance";import { InvitesSection } from "@/components/access/InvitesSection";const reassignmentIssueStatuses = "backlog,todo,in_progress,in_review,blocked,failed,timed_out";@@ -41,6 +44,21 @@ export function CompanyAccess() {const { pushToast } = useToast();const queryClient = useQueryClient();const [searchParams, setSearchParams] = useSearchParams();+ const cloud = useCloudInstance();+ const cloudStacksQuery = useQuery({+ queryKey: queryKeys.cloud.stacks,+ queryFn: () => cloudApi.listStacks(),+ enabled: Boolean(cloud && selectedCompanyId),+ staleTime: 30_000,+ retry: false,+ });+ const currentStack = cloudStacksQuery.data?.stacks.find((stack) => stack.isCurrent);+ // Company roles can differ from Cloud roles. Only the current stack's+ // owner/admin may invite, even if another portfolio entry grants ownership.+ const cloudInviteUrl = cloud && !cloudStacksQuery.isError &&+ (currentStack?.role === "owner" || currentStack?.role === "admin")+ ? cloudStackInviteUrl(cloud.cloudBaseUrl, currentStack.stackSlug)+ : null;// Invites render as a tab of this page; `company.invites` hides just that// tab while `company.members` (the route gate) hides the whole page.const { hidden: hiddenSettings } = useHiddenSettings();@@ -262,9 +280,16 @@ export function CompanyAccess() {return (<div className="max-w-6xl space-y-8">- <div className="flex items-center gap-2">- <ShieldCheck className="h-5 w-5 text-muted-foreground" />- <h1 className="text-lg font-semibold">Organization Members</h1>+ <div className="flex flex-wrap items-center justify-between gap-3">+ <div className="flex items-center gap-2">+ <ShieldCheck className="h-5 w-5 text-muted-foreground" />+ <h1 className="text-lg font-semibold">Organization Members</h1>+ </div>+ {cloudInviteUrl && (+ <Button asChild>+ <a href={cloudInviteUrl}><UserPlus />Invite people</a>+ </Button>+ )}</div><Tabs value={activeTab} onValueChange={handleTabChange} className="flex flex-col gap-4">