Skip to content

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

55 lines2,648 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";
Merge checks: statuses and check runs on every commit5import { commitChecksFor } from "../../lib/commit-checks.server";
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb976import { aboutFor } from "../../lib/about.server";
7import { environmentsFor } from "../../lib/deployments.server";
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them8import { lastCommitsFor } from "../../lib/last-commits.server";
Rust repos service with shipping; pull requests kept in the model9import { repos } from "../../lib/services.server";
Initial g1t: services, event bus, intents and attempts10import { getViewer, unwrap } from "../../lib/session.server";
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9711import { projectHomepage } from "../../lib/about";
12import { useProject } from "./layout";
Initial g1t: services, event bus, intents and attempts13
Social cards for every page: og.g1t.sh14export function meta({ params, ...args }: Route.MetaArgs) {
Initial g1t: services, event bus, intents and attempts15 const path = params["*"] ? `${params["*"]} · ` : "";
Social cards for every page: og.g1t.sh16 return page(args, { title: `${path}${params.owner}/${params.repo} · g1t` });
Initial g1t: services, event bus, intents and attempts17}
18
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look19export async function loader({ params, context, request }: Route.LoaderArgs) {
Initial g1t: services, event bus, intents and attempts20 const path = { namespace: params.owner, name: params.repo };
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look21 const viewer = getViewer(context);
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9722 const [tree, branches, environments] = await Promise.all([
The code page reads like a forge: a branch menu, search and a Code button above the files23 repos.tree(path, viewer, params.ref, params["*"] ?? ""),
24 // For the branch menu; the page still shows without it.
25 repos.branches(path, viewer).catch(() => null),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9726 // For the About sidebar's Deployments panel, shown at the root only.
27 params["*"] ? null : environmentsFor(path, viewer),
The code page reads like a forge: a branch menu, search and a Code button above the files28 ]);
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look29 // A branch that was renamed: the same folder on its new name.
30 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 files31 // 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 them32 const lastCommits = lastCommitsFor(path, viewer, params.ref, params["*"] ?? "");
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9733 const value = unwrap(tree);
34 // The About beside the files, streamed in after them.
35 const about = value.head && !value.path ? aboutFor(path, viewer, value.repo.id) : null;
Merge checks: statuses and check runs on every commit36 // The latest commit's checks: streamed in beside it.
37 const checks = commitChecksFor(path, viewer, [value.head?.hash]);
38 return { tree: value, branches: branches?.ok ? branches.value : null, lastCommits, about, deployments: environments, checks };
Initial g1t: services, event bus, intents and attempts39}
40
41export default function Tree({ loaderData }: Route.ComponentProps) {
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9742 const project = useProject();
43 return (
44 <TreeView
45 tree={loaderData.tree}
46 branches={loaderData.branches}
47 lastCommits={loaderData.lastCommits}
Merge checks: statuses and check runs on every commit48 checks={loaderData.checks}
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9749 about={loaderData.about}
50 canPush={Boolean(project?.access.can.push)}
51 homepage={projectHomepage(project?.project ?? null)}
52 deployments={loaderData.deployments}
53 />
54 );
Initial g1t: services, event bus, intents and attempts55}

This file's history is long; its oldest lines are credited to the oldest commit read.