Open History to see the last commit
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 data-composer-context-control
30 onClick={props.onOpen}
31 />
32 }
33 >
34 <Icon aria-hidden="true" className="size-3" />
35 <ComposerContextLabel>{label}</ComposerContextLabel>
36 </TooltipTrigger>
37 <TooltipPopup>Permissions{shortcutLabel ? ` · ${shortcutLabel}` : null}</TooltipPopup>
38 </Tooltip>
39 );
40}