Skip to content

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

70 lines2,798 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.

Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1import { isCodeownersPath } from "@g1t/contracts";
2
Initial g1t: services, event bus, intents and attempts3import type { Route } from "./+types/blob";
Social cards for every page: og.g1t.sh4import { page } from "../../lib/meta";
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar5import { CodeownersFileErrors } from "../../components/codeowners";
Initial g1t: services, event bus, intents and attempts6import { BlobView } from "../../components/repo-view";
Fast pages, required checks on the branch, self-hosted runners, honest incidents7import { highlightLines } from "../../lib/highlight.server";
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar8import { repos, work } from "../../lib/services.server";
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look9import { redirectIfBranchRenamed } from "../../lib/branch-redirect.server";
Initial g1t: services, event bus, intents and attempts10import { getViewer, unwrap } from "../../lib/session.server";
11
Social cards for every page: og.g1t.sh12export function meta({ params, ...args }: Route.MetaArgs) {
13 return page(args, { title: `${params["*"]} · ${params.owner}/${params.repo} · g1t` });
Initial g1t: services, event bus, intents and attempts14}
15
Agents as a team: lifecycle, merge queue, billing and a new shell16export async function loader({ params, context, request }: Route.LoaderArgs) {
17 const viewer = getViewer(context);
Initial g1t: services, event bus, intents and attempts18 const path = { namespace: params.owner, name: params.repo };
Agents as a team: lifecycle, merge queue, billing and a new shell19 const file = params["*"] ?? "";
20 const wantsBlame = new URL(request.url).searchParams.has("blame");
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar21 const [found, blame, list, checked] = await Promise.all([
Agents as a team: lifecycle, merge queue, billing and a new shell22 repos.blob(path, viewer, params.ref, file),
23 wantsBlame ? repos.blame(path, viewer, params.ref, file) : null,
Branches and Tags pages, each file's last commit, and the branch menu on files24 // For the branch menu; the page still shows without it.
25 repos.branches(path, viewer).catch(() => null),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar26 // A CODEOWNERS file is checked as it is shown; the file shows without it.
27 isCodeownersPath(file) ? work.codeownersErrors(path, viewer, params.ref).catch(() => null) : null,
Agents as a team: lifecycle, merge queue, billing and a new shell28 ]);
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar29 const codeowners = checked?.ok ? checked.value : null;
Branches and Tags pages, each file's last commit, and the branch menu on files30 const branches = list?.ok ? list.value : null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look31 // A branch that was renamed: the same file on its new name.
32 if (!found.ok && found.error.code === "not_found") await redirectIfBranchRenamed(request, path, viewer, params.ref);
Agents as a team: lifecycle, merge queue, billing and a new shell33 const blob = unwrap(found);
34 if (blame?.ok && blob.text != null) {
35 return {
36 blob,
37 html: null,
38 blame: { blame: blame.value, lines: await highlightLines(blob.path, blob.text) },
Branches and Tags pages, each file's last commit, and the branch menu on files39 branches,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar40 codeowners,
Agents as a team: lifecycle, merge queue, billing and a new shell41 };
42 }
API and MCP server, Rust identity service, registration, site redesign43 return {
44 blob,
Fast pages, required checks on the branch, self-hosted runners, honest incidents45 html: blob.text == null ? null : await highlightLines(blob.path, blob.text),
Agents as a team: lifecycle, merge queue, billing and a new shell46 blame: null,
Branches and Tags pages, each file's last commit, and the branch menu on files47 branches,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar48 codeowners,
API and MCP server, Rust identity service, registration, site redesign49 };
Initial g1t: services, event bus, intents and attempts50}
51
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar52export default function Blob({ loaderData, params }: Route.ComponentProps) {
53 const { codeowners, blob } = loaderData;
54 // Its errors' lines are marked, when they are this file's.
55 const own = codeowners != null && codeowners.path === blob.path;
56 return (
57 <BlobView
58 blob={blob}
59 html={loaderData.html}
60 blame={loaderData.blame}
61 branches={loaderData.branches}
62 notice={
63 codeowners && (
64 <CodeownersFileErrors report={codeowners} path={blob.path} base={`/${params.owner}/${params.repo}`} />
65 )
66 }
67 marked={own ? codeowners.errors.map((error) => error.line).filter((line) => line > 0) : undefined}
68 />
69 );
Initial g1t: services, event bus, intents and attempts70}