Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ComposerContextPermissions.tsx

41 lines1.5 KB

1import type { RuntimeMode } from "@t3tools/contracts";
2import { useAtomValue } from "@effect/atom-react";
3​
4import { shortcutLabelForCommand } from "../keybindings";
5import { primaryServerKeybindingsAtom } from "../state/server";
6import { ComposerControl } from "./chat/ComposerControl";
7import { runtimeModeConfig } from "./chat/runtimeModeConfig";
8import { ComposerContextLabel } from "./ComposerContextLabel";
9import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
10​
11/** The new-thread strip names the permissions the first send will use; clicking opens them. */
12export function ComposerContextPermissions(props: {
13 runtimeMode: RuntimeMode;
14 onOpen: () => void;
15}) {
16 const shortcutLabel = shortcutLabelForCommand(
17 useAtomValue(primaryServerKeybindingsAtom),
18 "composer.mode",
19 );
20 const { icon: Icon, label } = runtimeModeConfig[props.runtimeMode];
21 return (
22 <Tooltip>
23 <TooltipTrigger
24 render={
25 <ComposerControl
26 size="xs"
27 className="ms-auto min-w-0 shrink-0"
28 aria-label={`Permissions: ${label}`}
29 aria-haspopup="menu"
30 data-composer-context-control
31 onClick={props.onOpen}
32 />
33 }
34 >
35 <Icon aria-hidden="true" className="size-3" />
36 <ComposerContextLabel>{label}</ComposerContextLabel>
37 </TooltipTrigger>
38 <TooltipPopup>Permissions{shortcutLabel ? ` · ${shortcutLabel}` : null}</TooltipPopup>
39 </Tooltip>
40 );