Skip to content

g1t/apps/web/app/components/ask-composer.tsx

74 lines3,176 bytesCodeBlame
1import { ArrowUp, AtSign, BookMarked, ChevronDown, MessageSquare, Plus, Sparkles } from "lucide-react";
2import type { ReactNode } from "react";
3
4import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
5
6/**
7 * Mission control's place to ask g1t for anything: a question, a plan it
8 * splits into issues for agents, or work started straight away. Shown so
9 * it is clear where this will be, and not usable yet: nothing here sends,
10 * and every control says so. Until then the actions under it do the work.
11 */
12export function AskComposer({ children }: { children?: ReactNode }) {
13 return (
14 <section aria-label="Agent" className="space-y-3">
15 <div aria-disabled="true" className="rounded-xl border border-line bg-surface opacity-80">
16 <p className="flex items-center gap-2 px-4 pt-3 text-sm font-medium text-fg">
17 <Sparkles size={14} className="text-merged" aria-hidden="true" />
18 Agent
19 <span className="rounded-full border border-line px-1.5 text-[0.6875rem] font-normal text-muted">Coming later</span>
20 </p>
21 <label htmlFor="ask-g1t" className="sr-only">
22 Ask the agent (coming later)
23 </label>
24 <textarea
25 id="ask-g1t"
26 disabled
27 rows={2}
28 placeholder="Ask anything, plan something out, or describe work to start. Type @ to add context."
29 className="block w-full cursor-not-allowed resize-none bg-transparent px-4 pt-3.5 pb-2 text-sm text-fg placeholder:text-muted focus:outline-none"
30 />
31 <div className="flex flex-wrap items-center gap-2 px-3 pb-3">
32 <Soon label="Mode">
33 <MessageSquare size={14} /> Ask <ChevronDown size={13} className="text-faint" />
34 </Soon>
35 <Soon label="Scope">
36 <BookMarked size={14} /> All repositories <ChevronDown size={13} className="text-faint" />
37 </Soon>
38 <Soon label="Add context" icon>
39 <Plus size={15} />
40 </Soon>
41 <Soon label="Mention" icon>
42 <AtSign size={14} />
43 </Soon>
44 <span className="ml-auto" />
45 <Soon label="Send" icon>
46 <ArrowUp size={15} />
47 </Soon>
48 </div>
49 </div>
50 {children && <div className="flex flex-wrap items-center gap-2">{children}</div>}
51 </section>
52 );
53}
54
55/** One of the composer's controls: there, disabled, with a tooltip saying why. */
56function Soon({ label, icon, children }: { label: string; icon?: boolean; children: ReactNode }) {
57 return (
58 <Tooltip>
59 <TooltipTrigger asChild>
60 <span tabIndex={0} className="inline-flex rounded-md outline-none focus-visible:ring-2 focus-visible:ring-accent">
61 <button
62 type="button"
63 disabled
64 aria-label={`${label} (coming later)`}
65 className={`pointer-events-none inline-flex h-8 items-center gap-1.5 rounded-md border border-line text-sm text-muted ${icon ? "w-8 justify-center" : "px-2.5"}`}
66 >
67 {children}
68 </button>
69 </span>
70 </TooltipTrigger>
71 <TooltipContent>Agent is coming later</TooltipContent>
72 </Tooltip>
73 );
74}