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

ComposerPendingTerminalContexts.tsx

44 lines1.3 KB

1import { cn } from "~/lib/utils";
2import {
3 type TerminalContextDraft,
4 formatTerminalContextLabel,
5 isTerminalContextExpired,
6} from "~/lib/terminalContext";
7import { TerminalContextInlineChip } from "./TerminalContextInlineChip";
8​
9interface ComposerPendingTerminalContextsProps {
10 contexts: ReadonlyArray<TerminalContextDraft>;
11 className?: string;
13​
14interface ComposerPendingTerminalContextChipProps {
15 context: TerminalContextDraft;
17​
18export function ComposerPendingTerminalContextChip({
19 context,
20}: ComposerPendingTerminalContextChipProps) {
21 const label = formatTerminalContextLabel(context);
22 const expired = isTerminalContextExpired(context);
23 const tooltipText = expired
24 ? `Terminal context expired. Remove and re-add ${label} to include it in your message.`
25 : context.text;
26​
27 return <TerminalContextInlineChip label={label} tooltipText={tooltipText} expired={expired} />;
29​
30export function ComposerPendingTerminalContexts(props: ComposerPendingTerminalContextsProps) {
31 const { contexts, className } = props;
32​
33 if (contexts.length === 0) {
34 return null;
35 }
36​
37 return (
38 <div className={cn("flex flex-wrap gap-1.5", className)}>
39 {contexts.map((context) => (
40 <ComposerPendingTerminalContextChip key={context.id} context={context} />
41 ))}
42 </div>
43 );