Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
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.tsxBlame571 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"
c645a86Claude151 | "discussions"
da3fc18Claude152 | "security"
bcc4020Claude153 | "settings"
154 | "debt-map";
fc1817aClaude155}> = ({ owner, repo, active }) => (
156 <div class="repo-nav">
06d5ffeClaude157 <a href={`/${owner}/${repo}`} class={active === "code" ? "active" : ""}>
fc1817aClaude158 Code
159 </a>
79136bbClaude160 <a
161 href={`/${owner}/${repo}/issues`}
162 class={active === "issues" ? "active" : ""}
163 >
164 Issues
165 </a>
c645a86Claude166 <a
167 href={`/${owner}/${repo}/discussions`}
168 class={active === "discussions" ? "active" : ""}
169 >
170 Discussions
171 </a>
1e162a8Claude172 <a
173 href={`/${owner}/${repo}/wiki`}
174 class={active === "wiki" ? "active" : ""}
175 >
176 Wiki
177 </a>
0074234Claude178 <a
179 href={`/${owner}/${repo}/pulls`}
180 class={active === "pulls" ? "active" : ""}
181 >
182 Pull Requests
183 </a>
1e162a8Claude184 <a
185 href={`/${owner}/${repo}/projects`}
186 class={active === "projects" ? "active" : ""}
187 >
188 Projects
189 </a>
fc1817aClaude190 <a
191 href={`/${owner}/${repo}/commits`}
192 class={active === "commits" ? "active" : ""}
193 >
194 Commits
195 </a>
eafe8c6Claude196 <a
197 href={`/${owner}/${repo}/actions`}
198 class={active === "actions" ? "active" : ""}
199 >
200 Actions
201 </a>
3ef4c9dClaude202 <a
203 href={`/${owner}/${repo}/releases`}
204 class={active === "releases" ? "active" : ""}
205 >
206 Releases
207 </a>
208 <a
209 href={`/${owner}/${repo}/gates`}
210 class={active === "gates" ? "active" : ""}
211 >
212 {"\u25CF"} Gates
213 </a>
da3fc18Claude214 <a
215 href={`/${owner}/${repo}/security/vulnerabilities`}
216 class={active === "security" ? "active" : ""}
217 >
218 Security
219 </a>
3ef4c9dClaude220 <a
221 href={`/${owner}/${repo}/insights`}
222 class={active === "insights" ? "active" : ""}
223 >
224 Insights
225 </a>
ef3fd93Claude226 <a
227 href={`/${owner}/${repo}/agents`}
228 class={active === "agents" ? "active" : ""}
229 >
230 Agents
231 </a>
3cbe3d6Claude232 <a
233 href={`/${owner}/${repo}/explain`}
debcf27Claude234 class={`repo-nav-ai${active === "explain" ? " active" : ""}`}
235 style="margin-left: auto"
3cbe3d6Claude236 >
237 {"\u2728"} Explain
238 </a>
debcf27Claude239 <a href={`/${owner}/${repo}/ask`} class="repo-nav-ai">
3ef4c9dClaude240 {"\u2728"} Ask AI
241 </a>
14c3cc8Claude242 <a
243 href={`/${owner}/${repo}/spec`}
debcf27Claude244 class="repo-nav-ai"
14c3cc8Claude245 title="Spec to PR — paste a feature spec, AI opens a draft PR"
246 >
247 {"\u2728"} Spec
248 </a>
d8ef5efClaude249 <a
250 href={`/${owner}/${repo}/ai/tests`}
debcf27Claude251 class="repo-nav-ai"
d8ef5efClaude252 title="AI Tests \u2014 generate failing test stubs from a source file"
253 >
254 {"\u2728"} Tests
255 </a>
bcc4020Claude256 <a
257 href={`/${owner}/${repo}/debt-map`}
258 class={`repo-nav-ai${active === "debt-map" ? " active" : ""}`}
259 title="AI Debt Map \u2014 visual technical debt graph with Claude analysis"
260 >
261 {"\u2593"} Debt Map
262 </a>
fc1817aClaude263 </div>
264);
265
06d5ffeClaude266export const BranchSwitcher: FC<{
267 owner: string;
268 repo: string;
269 currentRef: string;
270 branches: string[];
271 pathType: "tree" | "blob" | "commits";
272 subPath?: string;
273}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
274 if (branches.length <= 1) {
275 return <div class="branch-selector">{currentRef}</div>;
276 }
277
278 return (
279 <div class="branch-dropdown">
280 <button class="branch-selector" type="button">
281 {currentRef} &#9662;
282 </button>
283 <div class="branch-dropdown-content">
284 {branches.map((branch) => {
285 let href: string;
286 if (pathType === "commits") {
287 href = `/${owner}/${repo}/commits/${branch}`;
288 } else if (subPath) {
289 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
290 } else {
291 href = `/${owner}/${repo}/tree/${branch}`;
292 }
293 return (
294 <a
295 href={href}
296 class={branch === currentRef ? "active-branch" : ""}
297 >
298 {branch}
299 </a>
300 );
301 })}
302 </div>
303 </div>
304 );
305};
306
fc1817aClaude307export const Breadcrumb: FC<{
308 owner: string;
309 repo: string;
310 ref: string;
311 path: string;
312}> = ({ owner, repo, ref, path }) => {
313 const parts = path.split("/").filter(Boolean);
314 const crumbs: { name: string; href: string }[] = [
315 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
316 ];
317 let accumulated = "";
318 for (const part of parts) {
319 accumulated += (accumulated ? "/" : "") + part;
320 crumbs.push({
321 name: part,
322 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
323 });
324 }
325 return (
326 <div class="breadcrumb">
327 {crumbs.map((crumb, i) => (
328 <>
329 {i > 0 && <span>/</span>}
330 {i === crumbs.length - 1 ? (
331 <strong>{crumb.name}</strong>
332 ) : (
333 <a href={crumb.href}>{crumb.name}</a>
334 )}
335 </>
336 ))}
337 </div>
338 );
339};
340
341export const FileTable: FC<{
342 entries: GitTreeEntry[];
343 owner: string;
344 repo: string;
345 ref: string;
346 path: string;
347}> = ({ entries, owner, repo, ref, path }) => (
348 <table class="file-table">
349 <tbody>
350 {entries.map((entry) => {
351 const fullPath = path ? `${path}/${entry.name}` : entry.name;
352 const href =
353 entry.type === "tree"
354 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
355 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
356 return (
357 <tr>
358 <td class="file-icon">
359 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
360 </td>
361 <td class="file-name">
362 <a href={href}>{entry.name}</a>
363 </td>
364 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
365 {entry.size !== undefined ? formatSize(entry.size) : ""}
366 </td>
367 </tr>
368 );
369 })}
370 </tbody>
371 </table>
372);
373
06d5ffeClaude374export const HighlightedCode: FC<{
375 highlightedHtml: string;
376 lineCount: number;
377}> = ({ highlightedHtml, lineCount }) => {
378 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
379 return (
380 <div class="blob-code">
381 <table>
382 <tbody>
383 <tr>
384 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
385 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
386 {lineNums.map((n) => (
387 <>
388 <span>{n}</span>
389 {"\n"}
390 </>
391 ))}
392 </pre>
393 </td>
394 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
395 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
396 </td>
397 </tr>
398 </tbody>
399 </table>
400 </div>
401 );
402};
403
404export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
405 <div class="blob-code">
406 <table>
407 <tbody>
408 {lines.map((line, i) => (
409 <tr>
410 <td class="line-num">{i + 1}</td>
411 <td class="line-content">{line}</td>
412 </tr>
413 ))}
414 </tbody>
415 </table>
416 </div>
417);
418
fc1817aClaude419export const CommitList: FC<{
420 commits: GitCommit[];
421 owner: string;
422 repo: string;
3951454Claude423 verifications?: Record<string, { verified: boolean; reason: string }>;
424}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude425 <div class="commit-list">
3951454Claude426 {commits.map((commit) => {
427 const v = verifications?.[commit.sha];
428 return (
429 <div class="commit-item">
430 <div>
431 <div class="commit-message">
432 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
433 {commit.message}
434 </a>
435 {v?.verified && (
436 <span
437 title="Signed with a registered key"
438 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"
439 >
440 Verified
441 </span>
442 )}
443 </div>
444 <div class="commit-meta">
445 {commit.author} committed {formatRelativeDate(commit.date)}
446 </div>
fc1817aClaude447 </div>
3951454Claude448 <a
449 href={`/${owner}/${repo}/commit/${commit.sha}`}
450 class="commit-sha"
451 >
452 {commit.sha.slice(0, 7)}
453 </a>
fc1817aClaude454 </div>
3951454Claude455 );
456 })}
fc1817aClaude457 </div>
458);
459
460export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
461 raw,
462 files,
463}) => {
464 const sections = parseDiff(raw);
465
466 return (
467 <div class="diff-view">
468 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
469 Showing{" "}
470 <strong style="color: var(--text)">{files.length}</strong> changed
471 file{files.length !== 1 ? "s" : ""} with{" "}
472 <span class="stat-add">
473 +{files.reduce((s, f) => s + f.additions, 0)}
474 </span>{" "}
475 and{" "}
476 <span class="stat-del">
477 -{files.reduce((s, f) => s + f.deletions, 0)}
478 </span>
479 </div>
480 {sections.map((section) => (
481 <div class="diff-file">
482 <div class="diff-file-header">{section.path}</div>
483 <div class="diff-content">
484 {section.lines.map((line) => {
485 let cls = "line";
486 if (line.startsWith("+")) cls += " line-add";
487 else if (line.startsWith("-")) cls += " line-del";
488 else if (line.startsWith("@@")) cls += " line-hunk";
489 return <span class={cls}>{line + "\n"}</span>;
490 })}
491 </div>
492 </div>
493 ))}
494 </div>
495 );
496};
497
06d5ffeClaude498export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
499 repo,
500 ownerName,
501}) => (
502 <div class="card">
503 <h3>
504 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
505 </h3>
506 {repo.description && <p>{repo.description}</p>}
507 <div class="card-meta">
508 {repo.isPrivate && <span class="badge">Private</span>}
509 <span>{"\u2606"} {repo.starCount}</span>
510 {repo.pushedAt && (
511 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
512 )}
513 </div>
514 </div>
515);
516
fc1817aClaude517function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
518 const sections: Array<{ path: string; lines: string[] }> = [];
519 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
520 let current: { path: string; lines: string[] } | null = null;
521
522 for (const line of raw.split("\n")) {
523 const match = line.match(diffRegex);
524 if (match) {
525 if (current) sections.push(current);
526 current = { path: match[1], lines: [] };
527 continue;
528 }
529 if (current && !line.startsWith("diff --git")) {
530 if (
531 line.startsWith("index ") ||
532 line.startsWith("--- ") ||
533 line.startsWith("+++ ") ||
534 line.startsWith("new file") ||
535 line.startsWith("deleted file") ||
536 line.startsWith("old mode") ||
537 line.startsWith("new mode")
538 ) {
539 continue;
540 }
541 current.lines.push(line);
542 }
543 }
544 if (current) sections.push(current);
545 return sections;
546}
547
548function formatSize(bytes: number): string {
549 if (bytes < 1024) return `${bytes} B`;
550 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
551 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
552}
553
554function formatRelativeDate(dateStr: string): string {
555 const date = new Date(dateStr);
556 const now = new Date();
557 const diffMs = now.getTime() - date.getTime();
558 const diffMins = Math.floor(diffMs / 60000);
559 if (diffMins < 1) return "just now";
560 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
561 const diffHours = Math.floor(diffMins / 60);
562 if (diffHours < 24)
563 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
564 const diffDays = Math.floor(diffHours / 24);
565 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
566 return date.toLocaleDateString("en-US", {
567 month: "short",
568 day: "numeric",
569 year: "numeric",
570 });
571}