g1t/apps/web/app/routes/repo/code.tsx
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Search across all of g1t, Explore, and a command palette | 1 | import { Search } from "lucide-react"; |
| 2 | import { Form } from "react-router"; | |
| 3 | ||
| Initial g1t: services, event bus, intents and attempts | 4 | import type { Route } from "./+types/code"; |
| 5 | import { TreeView } from "../../components/repo-view"; | |
| Search across all of g1t, Explore, and a command palette | 6 | import { notACredential } from "../../components/ui"; |
| 7 | import { page } from "../../lib/meta"; | |
| Rust repos service with shipping; pull requests kept in the model | 8 | import { repos } from "../../lib/services.server"; |
| Initial g1t: services, event bus, intents and attempts | 9 | import { getViewer, unwrap } from "../../lib/session.server"; |
| 10 | ||
| Search across all of g1t, Explore, and a command palette | 11 | export function meta({ params, ...args }: Route.MetaArgs) { |
| 12 | return page(args, { title: `Code · ${params.owner}/${params.repo} · g1t` }); | |
| 13 | } | |
| 14 | ||
| Initial g1t: services, event bus, intents and attempts | 15 | export async function loader({ params, context }: Route.LoaderArgs) { |
| 16 | const path = { namespace: params.owner, name: params.repo }; | |
| Rust repos service with shipping; pull requests kept in the model | 17 | return unwrap(await repos.tree(path, getViewer(context), null, "")); |
| Initial g1t: services, event bus, intents and attempts | 18 | } |
| 19 | ||
| Search across all of g1t, Explore, and a command palette | 20 | /** |
| 21 | * Searches this repository's code: the search page adds `repo:` for it, so | |
| 22 | * the results can be widened to all of g1t from there. | |
| 23 | */ | |
| 24 | function SearchThisRepository({ repo }: { repo: string }) { | |
| 25 | return ( | |
| 26 | <Form action="/search" role="search" className="relative mb-4 max-w-md"> | |
| 27 | <Search size={14} className="pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-faint" /> | |
| 28 | <input | |
| 29 | name="q" | |
| 30 | {...notACredential()} | |
| 31 | placeholder="Search this repository's code" | |
| 32 | aria-label={`Search ${repo}`} | |
| 33 | className="h-9 w-full rounded-md border border-line bg-surface pr-3 pl-8 text-sm outline-none transition-colors placeholder:text-faint hover:border-line-strong focus:border-accent-dim" | |
| 34 | /> | |
| 35 | <input type="hidden" name="repo" value={repo} /> | |
| 36 | <input type="hidden" name="type" value="code" /> | |
| 37 | </Form> | |
| 38 | ); | |
| 39 | } | |
| 40 | ||
| Initial g1t: services, event bus, intents and attempts | 41 | export default function Code({ loaderData }: Route.ComponentProps) { |
| Search across all of g1t, Explore, and a command palette | 42 | const repo = `${loaderData.repo.namespace}/${loaderData.repo.name}`; |
| 43 | return ( | |
| 44 | <> | |
| 45 | {loaderData.head && <SearchThisRepository repo={repo} />} | |
| 46 | <TreeView tree={loaderData} /> | |
| 47 | </> | |
| 48 | ); | |
| Initial g1t: services, event bus, intents and attempts | 49 | } |