Open History to see the last commit
1import { AuthMcpClientAccess } from "@t3tools/contracts";
2import { useId } from "react";
3
4import { accessConfig } from "../auth/ConnectAgentSurface";
5import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
6
7/** What agents here may do in an environment being linked, with what that does not allow. */
8export function LinkAccessPicker({
9 value,
10 onChange,
11 disabled = false,
12}: {
13 readonly value: AuthMcpClientAccess;
14 readonly onChange: (access: AuthMcpClientAccess) => void;
15 readonly disabled?: boolean;
16}) {
17 const labelId = useId();
18 const selected = accessConfig[value];
19 return (
20 <div className="space-y-1.5">
21 <span id={labelId} className="block text-xs font-medium">
22 What agents here may do there
23 </span>
24 <Select
25 value={value}
26 disabled={disabled}
27 onValueChange={(next) => {
28 if (next !== null) onChange(next as AuthMcpClientAccess);
29 }}
30 >
31 <SelectTrigger aria-labelledby={labelId}>
32 <SelectValue>
33 <span className="flex items-center gap-2">
34 <selected.icon aria-hidden className="size-4" />
35 {selected.label}
36 </span>
37 </SelectValue>
38 </SelectTrigger>
39 <SelectPopup alignItemWithTrigger={false}>
40 {AuthMcpClientAccess.literals.map((option) => {
41 const { label, description, icon: Icon } = accessConfig[option];
42 return (
43 <SelectItem key={option} value={option} hideIndicator>
44 <span className="grid min-w-0 gap-0.5 py-0.5">
45 <span className="inline-flex items-center gap-1.5 font-medium text-foreground">
46 <Icon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
47 {label}
48 </span>
49 <span className="text-xs leading-4 text-muted-foreground">{description}</span>
50 </span>
51 </SelectItem>
52 );
53 })}
54 </SelectPopup>
55 </Select>
56 <p className="text-xs text-muted-foreground">
57 {selected.description} An agent never gets more access there than its own mode here. Below
58 full access, it can change only threads this link started, not that machine's own threads,
59 projects or settings.
60 </p>
61 </div>
62 );
63}