g1t/apps/web/app/routes/repo/code.tsx

27 lines1,253 bytesCodeBlame

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.

Initial g1t: services, event bus, intents and attempts1import type { Route } from "./+types/code";
2import { TreeView } from "../../components/repo-view";
Search across all of g1t, Explore, and a command palette3import { page } from "../../lib/meta";
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them4import { lastCommitsFor } from "../../lib/last-commits.server";
Rust repos service with shipping; pull requests kept in the model5import { repos } from "../../lib/services.server";
Initial g1t: services, event bus, intents and attempts6import { getViewer, unwrap } from "../../lib/session.server";
7
Search across all of g1t, Explore, and a command palette8export function meta({ params, ...args }: Route.MetaArgs) {
9 return page(args, { title: `Code · ${params.owner}/${params.repo} · g1t` });
10}
11
Initial g1t: services, event bus, intents and attempts12export async function loader({ params, context }: Route.LoaderArgs) {
13 const path = { namespace: params.owner, name: params.repo };
The code page reads like a forge: a branch menu, search and a Code button above the files14 const viewer = getViewer(context);
15 const [tree, branches] = await Promise.all([
16 repos.tree(path, viewer, null, ""),
17 // For the branch menu; the page still shows without it.
18 repos.branches(path, viewer).catch(() => null),
19 ]);
Branches and Tags pages, each file's last commit, and the branch menu on files20 // Each entry's last commit walks history: streamed in after the list.
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them21 const lastCommits = lastCommitsFor(path, viewer, null, "");
Branches and Tags pages, each file's last commit, and the branch menu on files22 return { tree: unwrap(tree), branches: branches?.ok ? branches.value : null, lastCommits };
Search across all of g1t, Explore, and a command palette23}
24
Initial g1t: services, event bus, intents and attempts25export default function Code({ loaderData }: Route.ComponentProps) {
Branches and Tags pages, each file's last commit, and the branch menu on files26 return <TreeView tree={loaderData.tree} branches={loaderData.branches} lastCommits={loaderData.lastCommits} />;
Initial g1t: services, event bus, intents and attempts27}