Skip to content

Commit 0028cfd

Browse files
committed
fix(web): agent sign-in defaults to Auto access
1 parent 32a0531 commit 0028cfd

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect, it } from "vite-plus/test";
2+
import { RuntimeMode } from "@t3tools/contracts";
3+
4+
import { resolveMcpAccess } from "./ConnectAgentSurface.logic";
5+
6+
it.each(RuntimeMode.literals)("keeps MCP access within the %s policy ceiling", (maxRuntimeMode) => {
7+
const ceiling = { organization: "Example", maxRuntimeMode };
8+
expect(resolveMcpAccess("auto", ceiling)).toBe(
9+
maxRuntimeMode === "full-access" ? "auto" : maxRuntimeMode,
10+
);
11+
expect(resolveMcpAccess("read-only", ceiling)).toBe("read-only");
12+
expect(resolveMcpAccess("approval-required", ceiling)).toBe("approval-required");
13+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
type AuthMcpApprovalDetails,
3+
type AuthMcpClientAccess,
4+
isRuntimeModeAbove,
5+
} from "@t3tools/contracts";
6+
7+
export function resolveMcpAccess(
8+
access: AuthMcpClientAccess,
9+
ceiling: AuthMcpApprovalDetails["runtimeModeCeiling"],
10+
) {
11+
return access !== "read-only" &&
12+
ceiling !== undefined &&
13+
isRuntimeModeAbove(access, ceiling.maxRuntimeMode)
14+
? ceiling.maxRuntimeMode
15+
: access;
16+
}

‎apps/web/src/components/auth/ConnectAgentSurface.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { type ReactNode, useEffect, useState } from "react";
1818
import { PrimaryEnvironmentHttpClient } from "~/environments/primary/httpClient";
1919
import { runPrimaryHttp } from "~/lib/runtime";
2020
import { cn } from "~/lib/utils";
21+
import { resolveMcpAccess } from "./ConnectAgentSurface.logic";
2122
import { runtimeModeConfig } from "../chat/runtimeModeConfig";
2223
import { Alert, AlertDescription } from "../ui/alert";
2324
import { Button } from "../ui/button";
@@ -92,7 +93,11 @@ function oneClickApproves(details: AuthMcpApprovalDetails, access: AuthMcpClient
9293
export function ConnectAgentSurface() {
9394
const [authorization] = useState(readAuthorizationRequest);
9495
const [loaded, setLoaded] = useState<Loaded>({ status: "loading" });
95-
const [access, setAccess] = useState<AuthMcpClientAccess>("read-only");
96+
const [requestedAccess, setAccess] = useState<AuthMcpClientAccess>("auto");
97+
const access = resolveMcpAccess(
98+
requestedAccess,
99+
loaded.status === "ready" ? loaded.details.runtimeModeCeiling : undefined,
100+
);
96101
const [pairingCode, setPairingCode] = useState("");
97102
const [errorMessage, setErrorMessage] = useState("");
98103
const [pending, setPending] = useState<"approve" | "deny" | null>(null);

‎docs/user/outside-agents.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ Only approve a sign-in you just started. To approve, enter a pairing code from
4545
browser already signed in to the environment with permission to manage access
4646
can approve without a code.
4747

48-
Then choose what the agent may do:
48+
Then choose what the agent may do. **Auto** is selected by default, or the
49+
closest lower mode allowed by your organization’s policy:
4950

50-
- **Read only** is the default. The agent can read projects and threads and see
51+
- **Read only** lets the agent read projects and threads and see
5152
the available providers and models. It cannot change anything.
5253
- **Supervised** through **Full access** also let it start, message and stop
5354
threads in every project. A thread it starts or steers cannot run with more

0 commit comments

Comments
 (0)