Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Let an admin rename another user's agent and edit its options in the Gateway

Abel Dantas20bf50abbeb2
diff --git a/gateway/src/pages/agents/AgentDetailPage.tsx b/gateway/src/pages/agents/AgentDetailPage.tsx
index 4137d77b3..c90928e4d 100644
--- a/gateway/src/pages/agents/AgentDetailPage.tsx
+++ b/gateway/src/pages/agents/AgentDetailPage.tsx
@@ -108,6 +108,10 @@ export default function AgentDetailPage() {
}
const isOwner = !!user && user.id === agent.owner_id;
+ // Renaming and editing options are open to the owner or an admin; agent
+ // management and service access stay with the owner alone, because the
+ // agent then acts on the owner's own machines and credentials.
+ const canManage = isOwner || canAdminTenant;
return (
<Box>
@@ -116,7 +120,7 @@ export default function AgentDetailPage() {
<ArrowBack />
</IconButton>
<Typography variant="h5">{agent.name}</Typography>
- {isOwner && !agent.parent_agent_id && agent.children.length === 0 && (
+ {canManage && !agent.parent_agent_id && agent.children.length === 0 && (
<Tooltip title="Rename agent">
<IconButton
size="small"
@@ -170,7 +174,7 @@ export default function AgentDetailPage() {
<Divider />
<OptionsSection
agent={agent}
- canEdit={isOwner}
+ canEdit={canManage}
onUpdated={refetch}
/>
</>
@@ -178,7 +182,7 @@ export default function AgentDetailPage() {
<Divider />
<AddressingPolicySection
agent={agent}
- canEdit={isOwner || canAdminTenant}
+ canEdit={canManage}
onUpdated={refetch}
/>
<AgentManagementSection
@@ -499,7 +503,7 @@ function OptionsSection({
<>
{!canEdit && (
<Typography variant="body2" color="text.secondary">
- Only the agent's owner can edit these options.
+ Only the agent's owner and admins can edit these options.
</Typography>
)}
<Box sx={{ pointerEvents: canEdit ? "auto" : "none", opacity: canEdit ? 1 : 0.6 }}>
diff --git a/gateway/src/pages/agents/agentManageControls.test.tsx b/gateway/src/pages/agents/agentManageControls.test.tsx
new file mode 100644
index 000000000..d65e04816
--- /dev/null
+++ b/gateway/src/pages/agents/agentManageControls.test.tsx
@@ -0,0 +1,104 @@
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import type { AgentDetail } from "../../data/api";
+import { useAuth } from "../../data/AuthContext";
+import * as hooks from "../../data/hooks";
+import AgentDetailPage from "./AgentDetailPage";
+
+// The server lets an agent's owner or an admin rename it and edit its options,
+// so both see those controls; anyone else sees neither.
+
+vi.mock("react-router", () => ({
+ useNavigate: () => vi.fn(),
+ useParams: () => ({ agentId: "a1" }),
+}));
+
+vi.mock("../../data/AuthContext", () => ({
+ useAuth: vi.fn(),
+}));
+
+vi.mock("../../data/hooks", () => ({
+ useAgent: vi.fn(),
+ useKnownAgentTypes: vi.fn(),
+}));
+
+// The page's other sections fetch on their own; they are not under test here.
+vi.mock("./AddressingPolicySection", () => ({ default: () => null }));
+vi.mock("./AgentManagementSection", () => ({ default: () => null }));
+vi.mock("./ServiceAccessSection", () => ({ default: () => null }));
+
+const agent = {
+ id: "a1",
+ name: "notes-taker",
+ display_name: "Notes Taker",
+ description: "",
+ connector_type: "claude_code",
+ connection_model: "auto_session",
+ owner_id: "u1",
+ owner_name: "ada",
+ parent_agent_id: null,
+ known_agent_type: "notes",
+ known_agent_options: {},
+ integration_profile: {},
+ tools: [],
+ models: [],
+ rooms: [],
+ sessions: [],
+ children: [],
+} as unknown as AgentDetail;
+
+function showPageAs(userId: string, canAdminTenant: boolean) {
+ vi.mocked(useAuth).mockReturnValue({
+ user: { id: userId },
+ canAdminTenant,
+ } as unknown as ReturnType<typeof useAuth>);
+ vi.mocked(hooks.useAgent).mockReturnValue({
+ data: agent,
+ loading: false,
+ error: null,
+ refetch: vi.fn(),
+ });
+ vi.mocked(hooks.useKnownAgentTypes).mockReturnValue({
+ data: [
+ {
+ key: "notes",
+ connector_type: "claude_code",
+ tool_count: 0,
+ options_schema: { type: "object", properties: {} },
+ },
+ ],
+ loading: false,
+ error: null,
+ refetch: vi.fn(),
+ });
+ render(<AgentDetailPage />);
+}
+
+afterEach(cleanup);
+
+describe("agent rename and options", () => {
+ it("are offered to an admin viewing someone else's agent", () => {
+ showPageAs("u2", true);
+
+ expect(screen.getByRole("button", { name: "Rename agent" })).toBeTruthy();
+ expect(screen.getByRole("button", { name: "Save" })).toBeTruthy();
+ expect(screen.queryByText(/can edit these options/)).toBeNull();
+ });
+
+ it("are offered to the owner", () => {
+ showPageAs("u1", false);
+
+ expect(screen.getByRole("button", { name: "Rename agent" })).toBeTruthy();
+ expect(screen.getByRole("button", { name: "Save" })).toBeTruthy();
+ });
+
+ it("are not offered to anyone else", () => {
+ showPageAs("u2", false);
+
+ expect(screen.queryByRole("button", { name: "Rename agent" })).toBeNull();
+ expect(screen.queryByRole("button", { name: "Save" })).toBeNull();
+ expect(
+ screen.getByText("Only the agent's owner and admins can edit these options."),
+ ).toBeTruthy();
+ });
+});