@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

next
tsx 49 lines 1.67 KB
Raw
1 'use client';
2
3 import { FileTree, useFileTree, useFileTreeSelection } from '@pierre/trees/react';
4 import { File } from '@pierre/diffs/react';
5 import { CopyButton } from './copy-button';
6
7 export interface RepoFile {
8 path: string;
9 contents: string;
10 composio: boolean;
11 prerenderedHTML: string;
12 }
13
14 /**
15 * RepoBrowserClient — the IDE-style split: file tree on the left (@pierre/trees),
16 * the selected file's code on the right (@pierre/diffs). Code is prerendered on
17 * the server so the first paint is correct; selection swaps which file shows.
18 */
19 export function RepoBrowserClient({
20 files,
21 heightClass = 'max-h-[640px]',
22 }: {
23 files: RepoFile[];
24 heightClass?: string;
25 }) {
26 const paths = files.map((f) => f.path);
27 const { model } = useFileTree({ paths, initialSelectedPaths: [paths[0]], initialExpansion: 'open' });
28 const selected = useFileTreeSelection(model);
29
30 const path = selected.find((p) => files.some((f) => f.path === p)) ?? paths[0];
31 const file = files.find((f) => f.path === path) ?? files[0];
32
33 return (
34 <div className="grid grid-cols-1 overflow-hidden rounded-sm border border-fd-border bg-fd-card md:grid-cols-[minmax(0,260px)_minmax(0,1fr)]">
35 <div className={`${heightClass} overflow-auto border-b border-fd-border p-2 md:border-b-0 md:border-r`}>
36 <FileTree model={model} />
37 </div>
38 <div className={`relative ${heightClass} overflow-auto`}>
39 <CopyButton text={file.contents} className="absolute right-2 top-2 z-10" />
40 <File
41 key={file.path}
42 file={{ name: file.path, contents: file.contents }}
43 prerenderedHTML={file.prerenderedHTML}
44 disableWorkerPool
45 />
46 </div>
47 </div>
48 );
49 }