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