diff --git a/ui/src/pages/Agents.production.tsx b/ui/src/pages/Agents.production.tsx index a5eee50fc8..34512e9dc0 100644 --- a/ui/src/pages/Agents.production.tsx +++ b/ui/src/pages/Agents.production.tsx @@ -14,8 +14,6 @@ import { useSidebar } from "../context/SidebarContext"; import { queryKeys } from "../lib/queryKeys"; import { isPlatformManagedEnvironment } from "../lib/managed-sandbox-environment"; import { AgentStatusBadge, AgentStatusCapsule } from "../components/StatusBadge"; -import { MembershipAction } from "../components/MembershipAction"; -import { StarToggle } from "../components/StarToggle"; import { EntityRow } from "../components/EntityRow"; import { BuiltInLifecycleChip } from "../components/BuiltInAgentBadges"; import { EmptyState } from "../components/EmptyState"; @@ -27,9 +25,7 @@ import { Button } from "@/components/ui/button"; import { AlertTriangle, Bot, Plus, List, GitBranch } from "lucide-react"; import { AGENT_ROLE_LABELS, type Agent, type Environment, type EnvironmentCapabilities } from "@paperclipai/shared"; import { - isStarred, resourceMembershipState, - useResourceMembershipMutation, useResourceMemberships, } from "../hooks/useResourceMemberships"; import { usePublishSharedQueryData, useSharedPollingQuery } from "../hooks/useSharedPolling"; @@ -272,7 +268,6 @@ export function Agents() { }); usePublishSharedQueryData(sharedRuns, runs, runsUpdatedAt); const membershipsQuery = useResourceMemberships(selectedCompanyId); - const membershipMutation = useResourceMembershipMutation(selectedCompanyId); // Map agentId -> first live run + live run count const liveRunByAgent = useMemo(() => { @@ -347,13 +342,6 @@ export function Agents() { const renderAgentRow = (agent: Agent) => { const hasInvalidOrgChain = agent.orgChainHealth?.status === "invalid_org_chain"; - const agentPending = - membershipMutation.isPending && - membershipMutation.variables?.resourceType === "agent" && - membershipMutation.variables.resourceId === agent.id; - const agentStarPending = agentPending && membershipMutation.variables?.starred !== undefined; - const agentJoinLeavePending = agentPending && membershipMutation.variables?.starred === undefined; - const agentStarred = isStarred(membershipsQuery.data, "agent", agent.id); const builtInState = builtInByAgentId.get(agent.id); const showBuiltInLifecycle = builtInState?.status === "needs_setup" || builtInState?.status === "pending_approval"; // Lifecycle chip + inline `Set up`. Rendered inline in @@ -442,37 +430,7 @@ export function Agents() { - membershipMutation.mutate({ - resourceType: "agent", - resourceId: agent.id, - resourceName: agent.name, - starred: next, - })} - /> - membershipMutation.mutate({ - resourceType: "agent", - resourceId: agent.id, - resourceName: agent.name, - state: "joined", - })} - onLeave={() => membershipMutation.mutate({ - resourceType: "agent", - resourceId: agent.id, - resourceName: agent.name, - state: "left", - })} - /> } /> @@ -569,7 +527,6 @@ export function Agents() { showEnvironment={showEnvironmentColumn} tab={tab} memberships={membershipsQuery.data} - membershipMutation={membershipMutation} builtInByAgentId={builtInByAgentId} onConfigureBuiltIn={setConfigureState} /> @@ -614,7 +571,6 @@ function OrgTreeNode({ showEnvironment, tab, memberships, - membershipMutation, builtInByAgentId, onConfigureBuiltIn, }: { @@ -627,7 +583,6 @@ function OrgTreeNode({ showEnvironment: boolean; tab: FilterTab; memberships: ReturnType["data"]; - membershipMutation: ReturnType; builtInByAgentId: Map; onConfigureBuiltIn: (state: BuiltInAgentState) => void; }) { @@ -636,12 +591,6 @@ function OrgTreeNode({ const showBuiltInLifecycle = builtInState?.status === "needs_setup" || builtInState?.status === "pending_approval"; const hasInvalidOrgChain = Boolean(agent && agent.orgChainHealth?.status === "invalid_org_chain"); const membershipState = resourceMembershipState(memberships, "agent", node.id); - const pending = membershipMutation.isPending && - membershipMutation.variables?.resourceType === "agent" && - membershipMutation.variables.resourceId === node.id; - const starPending = pending && membershipMutation.variables?.starred !== undefined; - const joinLeavePending = pending && membershipMutation.variables?.starred === undefined; - const starred = isStarred(memberships, "agent", node.id); return (
@@ -724,38 +673,6 @@ function OrgTreeNode({
- membershipMutation.mutate({ - resourceType: "agent", - resourceId: node.id, - resourceName: node.name, - state: "joined", - })} - onLeave={() => membershipMutation.mutate({ - resourceType: "agent", - resourceId: node.id, - resourceName: node.name, - state: "left", - })} - /> -
- membershipMutation.mutate({ - resourceType: "agent", - resourceId: node.id, - resourceName: node.name, - starred: next, - })} - /> -
{node.reports && node.reports.length > 0 && ( @@ -772,7 +689,6 @@ function OrgTreeNode({ showEnvironment={showEnvironment} tab={tab} memberships={memberships} - membershipMutation={membershipMutation} builtInByAgentId={builtInByAgentId} onConfigureBuiltIn={onConfigureBuiltIn} /> diff --git a/ui/src/pages/Agents.test.tsx b/ui/src/pages/Agents.test.tsx index 332b321ad2..b0586dea5a 100644 --- a/ui/src/pages/Agents.test.tsx +++ b/ui/src/pages/Agents.test.tsx @@ -1005,13 +1005,16 @@ describe("Agents", () => { expect(container.querySelector(".min-w-\\(--sz-7rem\\)")).toBeNull(); }); - it("keeps row membership actions reachable while hiding star actions on mobile", async () => { + it.each([ + ["streamlined", Agents], + ["production", ProductionAgents], + ] as const)("omits star and leave/join actions from %s agent index list and org views", async (_mode, AgentList) => { root = createRoot(container); await act(async () => { root!.render( - + , ); @@ -1019,29 +1022,31 @@ describe("Agents", () => { await flushReact(); await flushReact(); - // List view (default). - const orgAction = container.querySelector('[aria-label="Leave Alpha"]'); - const orgStar = container.querySelector('[aria-label="Star Alpha"]'); - expect(orgAction).not.toBeNull(); - expect(orgStar).not.toBeNull(); - expect(orgAction?.closest(".hidden")).toBeNull(); - expect(orgStar?.closest(".hidden")).not.toBeNull(); - - // List view remains stable after explicitly selecting it. - const listToggle = Array.from(container.querySelectorAll("button")).find( - (btn) => btn.querySelector("svg.lucide-list"), - ); + // Explicitly select the list view and assert the row renders there. + const listToggle = container.querySelector('button[aria-label="List view"]'); + expect(listToggle).not.toBeNull(); await act(async () => { listToggle!.click(); }); await flushReact(); + const listRow = findAgentRow(container, "Alpha"); + expect(listRow).not.toBeNull(); + expect(container.querySelector('[aria-label="Leave Alpha"]')).toBeNull(); + expect(container.querySelector('[aria-label="Join Alpha"]')).toBeNull(); + expect(container.querySelector('[aria-label="Star Alpha"]')).toBeNull(); - const listAction = container.querySelector('[aria-label="Leave Alpha"]'); - const listStar = container.querySelector('[aria-label="Star Alpha"]'); - expect(listAction).not.toBeNull(); - expect(listStar).not.toBeNull(); - expect(listAction?.closest(".hidden")).toBeNull(); - expect(listStar?.closest(".hidden")).not.toBeNull(); + // Explicitly select the org view and assert no membership actions there. + const orgToggle = container.querySelector('button[aria-label="Org chart view"]'); + expect(orgToggle).not.toBeNull(); + await act(async () => { + orgToggle!.click(); + }); + await flushReact(); + await flushReact(); + expect(container.textContent).toContain("Alpha"); + expect(container.querySelector('[aria-label="Leave Alpha"]')).toBeNull(); + expect(container.querySelector('[aria-label="Join Alpha"]')).toBeNull(); + expect(container.querySelector('[aria-label="Star Alpha"]')).toBeNull(); }); it("does not dim left-membership agent names on mobile", async () => { diff --git a/ui/src/pages/Agents.tsx b/ui/src/pages/Agents.tsx index e347a4250b..1ee474816d 100644 --- a/ui/src/pages/Agents.tsx +++ b/ui/src/pages/Agents.tsx @@ -16,8 +16,6 @@ import { useStreamlinedUiEnabled } from "../hooks/useStreamlinedUiEnabled"; import { queryKeys } from "../lib/queryKeys"; import { isPlatformManagedEnvironment } from "../lib/managed-sandbox-environment"; import { AgentStatusBadge, AgentStatusCapsule } from "../components/StatusBadge"; -import { MembershipAction } from "../components/MembershipAction"; -import { StarToggle } from "../components/StarToggle"; import { EntityRow } from "../components/EntityRow"; import { BuiltInLifecycleChip } from "../components/BuiltInAgentBadges"; import { EmptyState } from "../components/EmptyState"; @@ -30,9 +28,7 @@ import { Button } from "@/components/ui/button"; import { AlertTriangle, Bot, Plus, List, Network } from "lucide-react"; import { AGENT_ROLE_LABELS, type Agent, type Environment, type EnvironmentCapabilities } from "@paperclipai/shared"; import { - isStarred, resourceMembershipState, - useResourceMembershipMutation, useResourceMemberships, } from "../hooks/useResourceMemberships"; import { usePublishSharedQueryData, useSharedPollingQuery } from "../hooks/useSharedPolling"; @@ -283,7 +279,6 @@ export function Agents({ initialView = "list" }: { initialView?: AgentsView } = }); usePublishSharedQueryData(sharedRuns, runs, runsUpdatedAt); const membershipsQuery = useResourceMemberships(selectedCompanyId); - const membershipMutation = useResourceMembershipMutation(selectedCompanyId); // Map agentId -> first live run + live run count const liveRunByAgent = useMemo(() => { @@ -352,13 +347,6 @@ export function Agents({ initialView = "list" }: { initialView?: AgentsView } = const renderAgentRow = (agent: Agent) => { const hasInvalidOrgChain = agent.orgChainHealth?.status === "invalid_org_chain"; - const agentPending = - membershipMutation.isPending && - membershipMutation.variables?.resourceType === "agent" && - membershipMutation.variables.resourceId === agent.id; - const agentStarPending = agentPending && membershipMutation.variables?.starred !== undefined; - const agentJoinLeavePending = agentPending && membershipMutation.variables?.starred === undefined; - const agentStarred = isStarred(membershipsQuery.data, "agent", agent.id); const builtInState = builtInByAgentId.get(agent.id); const showBuiltInLifecycle = builtInState?.status === "needs_setup" || builtInState?.status === "pending_approval"; // Keep lifecycle controls with the metadata only when the content area @@ -439,37 +427,7 @@ export function Agents({ initialView = "list" }: { initialView?: AgentsView } = - membershipMutation.mutate({ - resourceType: "agent", - resourceId: agent.id, - resourceName: agent.name, - starred: next, - })} - /> - membershipMutation.mutate({ - resourceType: "agent", - resourceId: agent.id, - resourceName: agent.name, - state: "joined", - })} - onLeave={() => membershipMutation.mutate({ - resourceType: "agent", - resourceId: agent.id, - resourceName: agent.name, - state: "left", - })} - /> } /> @@ -595,7 +553,6 @@ function OrgTreeNode({ showEnvironment, tab, memberships, - membershipMutation, builtInByAgentId, onConfigureBuiltIn, }: { @@ -608,7 +565,6 @@ function OrgTreeNode({ showEnvironment: boolean; tab: FilterTab; memberships: ReturnType["data"]; - membershipMutation: ReturnType; builtInByAgentId: Map; onConfigureBuiltIn: (state: BuiltInAgentState) => void; }) { @@ -617,12 +573,6 @@ function OrgTreeNode({ const showBuiltInLifecycle = builtInState?.status === "needs_setup" || builtInState?.status === "pending_approval"; const hasInvalidOrgChain = Boolean(agent && agent.orgChainHealth?.status === "invalid_org_chain"); const membershipState = resourceMembershipState(memberships, "agent", node.id); - const pending = membershipMutation.isPending && - membershipMutation.variables?.resourceType === "agent" && - membershipMutation.variables.resourceId === node.id; - const starPending = pending && membershipMutation.variables?.starred !== undefined; - const joinLeavePending = pending && membershipMutation.variables?.starred === undefined; - const starred = isStarred(memberships, "agent", node.id); return (
@@ -705,38 +655,6 @@ function OrgTreeNode({
- membershipMutation.mutate({ - resourceType: "agent", - resourceId: node.id, - resourceName: node.name, - state: "joined", - })} - onLeave={() => membershipMutation.mutate({ - resourceType: "agent", - resourceId: node.id, - resourceName: node.name, - state: "left", - })} - /> -
- membershipMutation.mutate({ - resourceType: "agent", - resourceId: node.id, - resourceName: node.name, - starred: next, - })} - /> -
{node.reports && node.reports.length > 0 && ( @@ -753,7 +671,6 @@ function OrgTreeNode({ showEnvironment={showEnvironment} tab={tab} memberships={memberships} - membershipMutation={membershipMutation} builtInByAgentId={builtInByAgentId} onConfigureBuiltIn={onConfigureBuiltIn} />