Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Simplify files panel header (#4828)
Julius Marminge08e4932f0465
diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsxindex 83524009c..fe652b6fd 100644--- a/apps/web/src/components/RightPanelTabs.tsx+++ b/apps/web/src/components/RightPanelTabs.tsx@@ -358,6 +358,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {<divclassName={cn("workspace-topbar gap-1 pl-2",+ !ownsDesktopTitleBar && "[--workspace-topbar-height:--spacing(11)]",props.mode === "inline" ? "pr-28" : "pr-3",ownsDesktopTitleBar && "wco:pr-[calc(var(--workspace-native-controls-inset)+6rem)]",props.mode === "inline" && props.maximized && COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,diff --git a/apps/web/src/components/files/FileBrowserPanel.tsx b/apps/web/src/components/files/FileBrowserPanel.tsxindex 3f53d6553..307d44137 100644--- a/apps/web/src/components/files/FileBrowserPanel.tsx+++ b/apps/web/src/components/files/FileBrowserPanel.tsx@@ -3,12 +3,15 @@ import type {ContextMenuOpenContext as TreeContextMenuOpenContext,} from "@pierre/trees";import type { EnvironmentId, ProjectEntry } from "@t3tools/contracts";-import { FileTree, useFileTree } from "@pierre/trees/react";+import { FileTree, useFileTree, useFileTreeSearch } from "@pierre/trees/react";import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";-import { RefreshCw, Search } from "lucide-react";+import { RotateCw } from "lucide-react";import { useEffect, useMemo, useRef } from "react";+import { Button } from "~/components/ui/button";+import { InputGroup, InputGroupInput } from "~/components/ui/input-group";import { toastManager } from "~/components/ui/toast";+import { Tooltip, TooltipPopup, TooltipTrigger } from "~/components/ui/tooltip";import { useComposerHandleContext } from "~/composerHandleContext";import { writeTextToClipboard } from "~/hooks/useCopyToClipboard";import { useTheme } from "~/hooks/useTheme";@@ -42,6 +45,55 @@ function treePath(entry: ProjectEntry): string {return entry.kind === "directory" ? `${entry.path}/` : entry.path;}+function RefreshFilesButton(props: { isPending: boolean; onRefresh: () => void }) {+ return (+ <Tooltip>+ <TooltipTrigger+ render={+ <Button+ type="button"+ variant="ghost"+ size="icon-xs"+ aria-label="Refresh workspace files"+ onClick={props.onRefresh}+ />+ }+ >+ <RotateCw className={cn(props.isPending && "animate-spin")} />+ </TooltipTrigger>+ <TooltipPopup>{props.isPending ? "Refreshing…" : "Refresh files"}</TooltipPopup>+ </Tooltip>+ );+}++function FileSearchField(props: {+ ariaLabel: string;+ name: string;+ onClose: () => void;+ onValueChange: (value: string) => void;+ value: string;+}) {+ return (+ <InputGroup variant="ghost" className="h-7 min-w-0 flex-1 rounded-md">+ <InputGroupInput+ type="search"+ name={props.name}+ size="sm"+ value={props.value}+ aria-label={props.ariaLabel}+ placeholder="Search files"+ spellCheck={false}+ onChange={(event) => props.onValueChange(event.target.value)}+ onKeyDown={(event) => {+ if (event.key !== "Escape") return;+ props.onClose();+ event.currentTarget.blur();+ }}+ />+ </InputGroup>+ );+}+export default function FileBrowserPanel({environmentId,cwd,@@ -176,9 +228,17 @@ export default function FileBrowserPanel({}},paths: [],- search: true,+ search: false,unsafeCSS: TREE_UNSAFE_CSS,});+ const search = useFileTreeSearch(model);+ const handleSearchValueChange = (value: string) => {+ if (value.trim().length === 0) {+ search.close();+ return;+ }+ search.setValue(value);+ };useEffect(() => {if (previousTreePathsRef.current === treePaths) return;@@ -187,11 +247,6 @@ export default function FileBrowserPanel({model.resetPaths(treePaths);}, [entryKinds, model, treePaths]);- const fileCount = useMemo(- () => entries.reduce((count, entry) => count + (entry.kind === "file" ? 1 : 0), 0),- [entries],- );-// Tag tree drags with the composer mention payload. The row is read from// the composed event path (the tree's shadow root is open), so this does// not depend on running after the tree's own dragstart handler; the drag@@ -223,32 +278,15 @@ export default function FileBrowserPanel({className="flex min-h-0 flex-1 flex-col bg-background"data-file-browser-panel={`${environmentId}:${cwd}`}>- <div className="flex h-9 shrink-0 items-center gap-2 border-b border-border/60 px-3">- <div className="min-w-0 flex-1">- <div className="truncate text-xs font-medium text-foreground">{projectName}</div>- <div className="truncate text-[10px] leading-none text-muted-foreground">- {entriesQuery.isPending && entriesQuery.data === null- ? "Indexing…"- : `${fileCount.toLocaleString()} files`}- {entriesQuery.data?.truncated ? " · partial" : ""}- </div>- </div>- <button- type="button"- className="rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground"- aria-label="Search workspace files"- onClick={() => model.openSearch()}- >- <Search className="size-3.5" />- </button>- <button- type="button"- className="rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground"- aria-label="Refresh workspace files"- onClick={entriesQuery.refresh}- >- <RefreshCw className={cn("size-3.5", entriesQuery.isPending && "animate-spin")} />- </button>+ <div className="surface-subheader gap-1 px-2" data-surface-subheader>+ <RefreshFilesButton isPending={entriesQuery.isPending} onRefresh={entriesQuery.refresh} />+ <FileSearchField+ name="project-files-search"+ ariaLabel={`Search ${projectName} files`}+ value={search.value}+ onValueChange={handleSearchValueChange}+ onClose={search.close}+ /></div>{entriesQuery.error && entriesQuery.data === null ? (<div className="p-4 text-xs leading-relaxed text-destructive">{entriesQuery.error}</div>diff --git a/apps/web/src/components/preview/PreviewChromeRow.tsx b/apps/web/src/components/preview/PreviewChromeRow.tsxindex 8044b4722..1f4eb95d6 100644--- a/apps/web/src/components/preview/PreviewChromeRow.tsx+++ b/apps/web/src/components/preview/PreviewChromeRow.tsx@@ -166,7 +166,7 @@ export function PreviewChromeRow({</Tooltip></div>- <InputGroup className="group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background">+ <InputGroup variant="ghost" className="group/address h-7 flex-1 rounded-md"><Tooltip><TooltipTriggerrender={diff --git a/apps/web/src/components/ui/input-group.tsx b/apps/web/src/components/ui/input-group.tsxindex 2d6316273..2ac9ee1ed 100644--- a/apps/web/src/components/ui/input-group.tsx+++ b/apps/web/src/components/ui/input-group.tsx@@ -7,13 +7,31 @@ import { cn } from "~/lib/utils";import { Input, type InputProps } from "~/components/ui/input";import { Textarea, type TextareaProps } from "~/components/ui/textarea";-function InputGroup({ className, ...props }: React.ComponentProps<"div">) {+const inputGroupVariants = cva(+ "relative inline-flex w-full min-w-0 items-center rounded-lg border text-base text-foreground ring-ring/24 transition-shadow has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]",+ {+ defaultVariants: {+ variant: "default",+ },+ variants: {+ variant: {+ default:+ "border-input bg-background not-dark:bg-clip-padding shadow-xs/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)]",+ ghost:+ "border-transparent bg-transparent shadow-none hover:bg-muted/40 has-[input:focus-visible,textarea:focus-visible]:bg-background",+ },+ },+ },+);++function InputGroup({+ className,+ variant,+ ...props+}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupVariants>) {return (<div- className={cn(- "relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]",- className,- )}+ className={cn(inputGroupVariants({ variant }), className)}data-slot="input-group"role="group"{...props}