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

31 lines1,617 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/tree";
Social cards for every page: og.g1t.sh2import { page } from "../../lib/meta";
Initial g1t: services, event bus, intents and attempts3import { TreeView } from "../../components/repo-view";
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look4import { redirectIfBranchRenamed } from "../../lib/branch-redirect.server";
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them5import { lastCommitsFor } from "../../lib/last-commits.server";
Rust repos service with shipping; pull requests kept in the model6import { repos } from "../../lib/services.server";
Initial g1t: services, event bus, intents and attempts7import { getViewer, unwrap } from "../../lib/session.server";
8
Social cards for every page: og.g1t.sh9export function meta({ params, ...args }: Route.MetaArgs) {
Initial g1t: services, event bus, intents and attempts10 const path = params["*"] ? `${params["*"]} · ` : "";
Social cards for every page: og.g1t.sh11 return page(args, { title: `${path}${params.owner}/${params.repo} · g1t` });
Initial g1t: services, event bus, intents and attempts12}
13
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look14export async function loader({ params, context, request }: Route.LoaderArgs) {
Initial g1t: services, event bus, intents and attempts15 const path = { namespace: params.owner, name: params.repo };
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look16 const viewer = getViewer(context);
The code page reads like a forge: a branch menu, search and a Code button above the files17 const [tree, branches] = await Promise.all([
18 repos.tree(path, viewer, params.ref, params["*"] ?? ""),
19 // For the branch menu; the page still shows without it.
20 repos.branches(path, viewer).catch(() => null),
21 ]);
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look22 // A branch that was renamed: the same folder on its new name.
23 if (!tree.ok && tree.error.code === "not_found") await redirectIfBranchRenamed(request, path, viewer, params.ref);
Branches and Tags pages, each file's last commit, and the branch menu on files24 // 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 them25 const lastCommits = lastCommitsFor(path, viewer, params.ref, params["*"] ?? "");
Branches and Tags pages, each file's last commit, and the branch menu on files26 return { tree: unwrap(tree), branches: branches?.ok ? branches.value : null, lastCommits };
Initial g1t: services, event bus, intents and attempts27}
28
29export default function Tree({ loaderData }: Route.ComponentProps) {
Branches and Tags pages, each file's last commit, and the branch menu on files30 return <TreeView tree={loaderData.tree} branches={loaderData.branches} lastCommits={loaderData.lastCommits} />;
Initial g1t: services, event bus, intents and attempts31}