Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

components.tsx

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

components.tsxBlame549 lines · 1 contributor
fc1817aClaude1import type { FC } from "hono/jsx";
06d5ffeClaude2import { html } from "hono/html";
fc1817aClaude3import type { GitCommit, GitTreeEntry, GitDiffFile } from "../git/repository";
06d5ffeClaude4import type { Repository } from "../db/schema";
fc1817aClaude5
8c790e0Claude6/**
7 * Describes the most recent push to a repo, used by RepoHeader to render
8 * the Push Watch discoverability indicator.
9 *
10 * - ageMs < 5 min \u2192 pulsing red "\u25cf Live" badge
11 * - ageMs < 24 hr \u2192 dimmer "\u25cb Watch" link
12 * - otherwise \u2192 nothing shown
13 */
14export interface RecentPush {
15 sha: string;
16 ageMs: number;
17}
18
06d5ffeClaude19export const RepoHeader: FC<{
20 owner: string;
21 repo: string;
22 starCount?: number;
23 starred?: boolean;
c81ab7aClaude24 forkCount?: number;
06d5ffeClaude25 currentUser?: string | null;
c81ab7aClaude26 forkedFrom?: string | null;
71cd5ecClaude27 archived?: boolean;
28 isTemplate?: boolean;
8c790e0Claude29 /** Most recent push info for Push Watch discoverability indicator. */
30 recentPush?: RecentPush | null;
71cd5ecClaude31}> = ({
32 owner,
33 repo,
34 starCount,
35 starred,
36 forkCount,
37 currentUser,
38 forkedFrom,
39 archived,
40 isTemplate,
8c790e0Claude41 recentPush,
42}) => {
43 const FIVE_MIN = 5 * 60 * 1000;
44 const TWENTY_FOUR_HR = 24 * 60 * 60 * 1000;
45 const isLive = recentPush != null && recentPush.ageMs < FIVE_MIN;
46 const isRecent = recentPush != null && recentPush.ageMs < TWENTY_FOUR_HR;
47
48 return (
49 <div class="repo-header">
50 <div>
51 <div class="repo-header-title">
52 <a href={`/${owner}`} class="owner">
53 {owner}
54 </a>
55 <span class="separator">/</span>
56 <a href={`/${owner}/${repo}`} class="name">
57 {repo}
58 </a>
59 {archived && (
60 <span
61 class="repo-header-pill repo-header-pill-archived"
62 title="Read-only: pushes and new issues/PRs disabled"
63 >
64 Archived
65 </span>
66 )}
67 {isTemplate && (
68 <span
69 class="repo-header-pill repo-header-pill-template"
70 title="This repository can be used as a template"
71 >
72 Template
73 </span>
74 )}
75 {isLive && recentPush && (
76 <a
77 href={`/${owner}/${repo}/push/${recentPush.sha}`}
78 class="repo-header-live-badge repo-header-live-badge--live"
79 title="Push in progress \u2014 watch live gate + deploy status"
80 aria-label="Live push \u2014 click to watch status"
81 >
82 <span class="repo-header-live-dot" aria-hidden="true">{"\u25cf"}</span>
83 Live
84 </a>
85 )}
86 {!isLive && isRecent && recentPush && (
87 <a
88 href={`/${owner}/${repo}/push/${recentPush.sha}`}
89 class="repo-header-live-badge repo-header-live-badge--recent"
90 title="Watch the most recent push's gate + deploy results"
91 aria-label="Watch most recent push"
92 >
93 <span aria-hidden="true">{"\u25cb"}</span>
94 Watch
95 </a>
96 )}
97 </div>
98 {forkedFrom && (
99 <div class="repo-header-fork">
100 forked from <a href={`/${forkedFrom}`}>{forkedFrom}</a>
101 </div>
71cd5ecClaude102 )}
c81ab7aClaude103 </div>
8c790e0Claude104 <div class="repo-header-actions">
105 {currentUser && currentUser !== owner && (
106 <form method="post" action={`/${owner}/${repo}/fork`} style="display:inline">
107 <button type="submit" class="star-btn">
108 {"\u2442"} Fork {forkCount !== undefined && forkCount > 0 ? forkCount : ""}
06d5ffeClaude109 </button>
110 </form>
8c790e0Claude111 )}
112 {starCount !== undefined && (
113 currentUser ? (
114 <form method="post" action={`/${owner}/${repo}/star`} style="display:inline">
115 <button
116 type="submit"
117 class={`star-btn${starred ? " starred" : ""}`}
118 >
119 {starred ? "\u2605" : "\u2606"} {starCount}
120 </button>
121 </form>
122 ) : (
123 <span class="star-btn">
124 {"\u2606"} {starCount}
125 </span>
126 )
127 )}
128 </div>
06d5ffeClaude129 </div>
8c790e0Claude130 );
131};
fc1817aClaude132
133export const RepoNav: FC<{
134 owner: string;
135 repo: string;
3ef4c9dClaude136 active:
137 | "code"
138 | "commits"
139 | "issues"
140 | "pulls"
141 | "releases"
eafe8c6Claude142 | "actions"
3ef4c9dClaude143 | "gates"
3cbe3d6Claude144 | "insights"
145 | "explain"
146 | "changelog"
1e162a8Claude147 | "semantic"
148 | "wiki"
0316dbbClaude149 | "projects"
ef3fd93Claude150 | "agents"
0316dbbClaude151 | "settings";
fc1817aClaude152}> = ({ owner, repo, active }) => (
153 <div class="repo-nav">
06d5ffeClaude154 <a href={`/${owner}/${repo}`} class={active === "code" ? "active" : ""}>
fc1817aClaude155 Code
156 </a>
79136bbClaude157 <a
158 href={`/${owner}/${repo}/issues`}
159 class={active === "issues" ? "active" : ""}
160 >
161 Issues
162 </a>
1e162a8Claude163 <a
164 href={`/${owner}/${repo}/wiki`}
165 class={active === "wiki" ? "active" : ""}
166 >
167 Wiki
168 </a>
0074234Claude169 <a
170 href={`/${owner}/${repo}/pulls`}
171 class={active === "pulls" ? "active" : ""}
172 >
173 Pull Requests
174 </a>
1e162a8Claude175 <a
176 href={`/${owner}/${repo}/projects`}
177 class={active === "projects" ? "active" : ""}
178 >
179 Projects
180 </a>
fc1817aClaude181 <a
182 href={`/${owner}/${repo}/commits`}
183 class={active === "commits" ? "active" : ""}
184 >
185 Commits
186 </a>
eafe8c6Claude187 <a
188 href={`/${owner}/${repo}/actions`}
189 class={active === "actions" ? "active" : ""}
190 >
191 Actions
192 </a>
3ef4c9dClaude193 <a
194 href={`/${owner}/${repo}/releases`}
195 class={active === "releases" ? "active" : ""}
196 >
197 Releases
198 </a>
199 <a
200 href={`/${owner}/${repo}/gates`}
201 class={active === "gates" ? "active" : ""}
202 >
203 {"\u25CF"} Gates
204 </a>
205 <a
206 href={`/${owner}/${repo}/insights`}
207 class={active === "insights" ? "active" : ""}
208 >
209 Insights
210 </a>
ef3fd93Claude211 <a
212 href={`/${owner}/${repo}/agents`}
213 class={active === "agents" ? "active" : ""}
214 >
215 Agents
216 </a>
3cbe3d6Claude217 <a
218 href={`/${owner}/${repo}/explain`}
debcf27Claude219 class={`repo-nav-ai${active === "explain" ? " active" : ""}`}
220 style="margin-left: auto"
3cbe3d6Claude221 >
222 {"\u2728"} Explain
223 </a>
debcf27Claude224 <a href={`/${owner}/${repo}/ask`} class="repo-nav-ai">
3ef4c9dClaude225 {"\u2728"} Ask AI
226 </a>
14c3cc8Claude227 <a
228 href={`/${owner}/${repo}/spec`}
debcf27Claude229 class="repo-nav-ai"
14c3cc8Claude230 title="Spec to PR — paste a feature spec, AI opens a draft PR"
231 >
232 {"\u2728"} Spec
233 </a>
d8ef5efClaude234 <a
235 href={`/${owner}/${repo}/ai/tests`}
debcf27Claude236 class="repo-nav-ai"
d8ef5efClaude237 title="AI Tests \u2014 generate failing test stubs from a source file"
238 >
239 {"\u2728"} Tests
240 </a>
fc1817aClaude241 </div>
242);
243
06d5ffeClaude244export const BranchSwitcher: FC<{
245 owner: string;
246 repo: string;
247 currentRef: string;
248 branches: string[];
249 pathType: "tree" | "blob" | "commits";
250 subPath?: string;
251}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
252 if (branches.length <= 1) {
253 return <div class="branch-selector">{currentRef}</div>;
254 }
255
256 return (
257 <div class="branch-dropdown">
258 <button class="branch-selector" type="button">
259 {currentRef} &#9662;
260 </button>
261 <div class="branch-dropdown-content">
262 {branches.map((branch) => {
263 let href: string;
264 if (pathType === "commits") {
265 href = `/${owner}/${repo}/commits/${branch}`;
266 } else if (subPath) {
267 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
268 } else {
269 href = `/${owner}/${repo}/tree/${branch}`;
270 }
271 return (
272 <a
273 href={href}
274 class={branch === currentRef ? "active-branch" : ""}
275 >
276 {branch}
277 </a>
278 );
279 })}
280 </div>
281 </div>
282 );
283};
284
fc1817aClaude285export const Breadcrumb: FC<{
286 owner: string;
287 repo: string;
288 ref: string;
289 path: string;
290}> = ({ owner, repo, ref, path }) => {
291 const parts = path.split("/").filter(Boolean);
292 const crumbs: { name: string; href: string }[] = [
293 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
294 ];
295 let accumulated = "";
296 for (const part of parts) {
297 accumulated += (accumulated ? "/" : "") + part;
298 crumbs.push({
299 name: part,
300 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
301 });
302 }
303 return (
304 <div class="breadcrumb">
305 {crumbs.map((crumb, i) => (
306 <>
307 {i > 0 && <span>/</span>}
308 {i === crumbs.length - 1 ? (
309 <strong>{crumb.name}</strong>
310 ) : (
311 <a href={crumb.href}>{crumb.name}</a>
312 )}
313 </>
314 ))}
315 </div>
316 );
317};
318
319export const FileTable: FC<{
320 entries: GitTreeEntry[];
321 owner: string;
322 repo: string;
323 ref: string;
324 path: string;
325}> = ({ entries, owner, repo, ref, path }) => (
326 <table class="file-table">
327 <tbody>
328 {entries.map((entry) => {
329 const fullPath = path ? `${path}/${entry.name}` : entry.name;
330 const href =
331 entry.type === "tree"
332 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
333 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
334 return (
335 <tr>
336 <td class="file-icon">
337 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
338 </td>
339 <td class="file-name">
340 <a href={href}>{entry.name}</a>
341 </td>
342 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
343 {entry.size !== undefined ? formatSize(entry.size) : ""}
344 </td>
345 </tr>
346 );
347 })}
348 </tbody>
349 </table>
350);
351
06d5ffeClaude352export const HighlightedCode: FC<{
353 highlightedHtml: string;
354 lineCount: number;
355}> = ({ highlightedHtml, lineCount }) => {
356 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
357 return (
358 <div class="blob-code">
359 <table>
360 <tbody>
361 <tr>
362 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
363 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
364 {lineNums.map((n) => (
365 <>
366 <span>{n}</span>
367 {"\n"}
368 </>
369 ))}
370 </pre>
371 </td>
372 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
373 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
374 </td>
375 </tr>
376 </tbody>
377 </table>
378 </div>
379 );
380};
381
382export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
383 <div class="blob-code">
384 <table>
385 <tbody>
386 {lines.map((line, i) => (
387 <tr>
388 <td class="line-num">{i + 1}</td>
389 <td class="line-content">{line}</td>
390 </tr>
391 ))}
392 </tbody>
393 </table>
394 </div>
395);
396
fc1817aClaude397export const CommitList: FC<{
398 commits: GitCommit[];
399 owner: string;
400 repo: string;
3951454Claude401 verifications?: Record<string, { verified: boolean; reason: string }>;
402}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude403 <div class="commit-list">
3951454Claude404 {commits.map((commit) => {
405 const v = verifications?.[commit.sha];
406 return (
407 <div class="commit-item">
408 <div>
409 <div class="commit-message">
410 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
411 {commit.message}
412 </a>
413 {v?.verified && (
414 <span
415 title="Signed with a registered key"
416 style="margin-left:8px;font-size:10px;padding:1px 6px;border-radius:3px;background:var(--green,#2ea043);color:#fff;text-transform:uppercase;letter-spacing:.4px"
417 >
418 Verified
419 </span>
420 )}
421 </div>
422 <div class="commit-meta">
423 {commit.author} committed {formatRelativeDate(commit.date)}
424 </div>
fc1817aClaude425 </div>
3951454Claude426 <a
427 href={`/${owner}/${repo}/commit/${commit.sha}`}
428 class="commit-sha"
429 >
430 {commit.sha.slice(0, 7)}
431 </a>
fc1817aClaude432 </div>
3951454Claude433 );
434 })}
fc1817aClaude435 </div>
436);
437
438export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
439 raw,
440 files,
441}) => {
442 const sections = parseDiff(raw);
443
444 return (
445 <div class="diff-view">
446 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
447 Showing{" "}
448 <strong style="color: var(--text)">{files.length}</strong> changed
449 file{files.length !== 1 ? "s" : ""} with{" "}
450 <span class="stat-add">
451 +{files.reduce((s, f) => s + f.additions, 0)}
452 </span>{" "}
453 and{" "}
454 <span class="stat-del">
455 -{files.reduce((s, f) => s + f.deletions, 0)}
456 </span>
457 </div>
458 {sections.map((section) => (
459 <div class="diff-file">
460 <div class="diff-file-header">{section.path}</div>
461 <div class="diff-content">
462 {section.lines.map((line) => {
463 let cls = "line";
464 if (line.startsWith("+")) cls += " line-add";
465 else if (line.startsWith("-")) cls += " line-del";
466 else if (line.startsWith("@@")) cls += " line-hunk";
467 return <span class={cls}>{line + "\n"}</span>;
468 })}
469 </div>
470 </div>
471 ))}
472 </div>
473 );
474};
475
06d5ffeClaude476export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
477 repo,
478 ownerName,
479}) => (
480 <div class="card">
481 <h3>
482 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
483 </h3>
484 {repo.description && <p>{repo.description}</p>}
485 <div class="card-meta">
486 {repo.isPrivate && <span class="badge">Private</span>}
487 <span>{"\u2606"} {repo.starCount}</span>
488 {repo.pushedAt && (
489 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
490 )}
491 </div>
492 </div>
493);
494
fc1817aClaude495function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
496 const sections: Array<{ path: string; lines: string[] }> = [];
497 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
498 let current: { path: string; lines: string[] } | null = null;
499
500 for (const line of raw.split("\n")) {
501 const match = line.match(diffRegex);
502 if (match) {
503 if (current) sections.push(current);
504 current = { path: match[1], lines: [] };
505 continue;
506 }
507 if (current && !line.startsWith("diff --git")) {
508 if (
509 line.startsWith("index ") ||
510 line.startsWith("--- ") ||
511 line.startsWith("+++ ") ||
512 line.startsWith("new file") ||
513 line.startsWith("deleted file") ||
514 line.startsWith("old mode") ||
515 line.startsWith("new mode")
516 ) {
517 continue;
518 }
519 current.lines.push(line);
520 }
521 }
522 if (current) sections.push(current);
523 return sections;
524}
525
526function formatSize(bytes: number): string {
527 if (bytes < 1024) return `${bytes} B`;
528 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
529 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
530}
531
532function formatRelativeDate(dateStr: string): string {
533 const date = new Date(dateStr);
534 const now = new Date();
535 const diffMs = now.getTime() - date.getTime();
536 const diffMins = Math.floor(diffMs / 60000);
537 if (diffMins < 1) return "just now";
538 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
539 const diffHours = Math.floor(diffMins / 60);
540 if (diffHours < 24)
541 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
542 const diffDays = Math.floor(diffHours / 24);
543 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
544 return date.toLocaleDateString("en-US", {
545 month: "short",
546 day: "numeric",
547 year: "numeric",
548 });
549}