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.tsxBlame579 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"
7f992cdClaude154 | "debt-map"
155 | "migrate"
156 | "deployments";
fc1817aClaude157}> = ({ owner, repo, active }) => (
158 <div class="repo-nav">
06d5ffeClaude159 <a href={`/${owner}/${repo}`} class={active === "code" ? "active" : ""}>
fc1817aClaude160 Code
161 </a>
79136bbClaude162 <a
163 href={`/${owner}/${repo}/issues`}
164 class={active === "issues" ? "active" : ""}
165 >
166 Issues
167 </a>
c645a86Claude168 <a
169 href={`/${owner}/${repo}/discussions`}
170 class={active === "discussions" ? "active" : ""}
171 >
172 Discussions
173 </a>
1e162a8Claude174 <a
175 href={`/${owner}/${repo}/wiki`}
176 class={active === "wiki" ? "active" : ""}
177 >
178 Wiki
179 </a>
0074234Claude180 <a
181 href={`/${owner}/${repo}/pulls`}
182 class={active === "pulls" ? "active" : ""}
183 >
184 Pull Requests
185 </a>
1e162a8Claude186 <a
187 href={`/${owner}/${repo}/projects`}
188 class={active === "projects" ? "active" : ""}
189 >
190 Projects
191 </a>
fc1817aClaude192 <a
193 href={`/${owner}/${repo}/commits`}
194 class={active === "commits" ? "active" : ""}
195 >
196 Commits
197 </a>
eafe8c6Claude198 <a
199 href={`/${owner}/${repo}/actions`}
200 class={active === "actions" ? "active" : ""}
201 >
202 Actions
203 </a>
3ef4c9dClaude204 <a
205 href={`/${owner}/${repo}/releases`}
206 class={active === "releases" ? "active" : ""}
207 >
208 Releases
209 </a>
210 <a
211 href={`/${owner}/${repo}/gates`}
212 class={active === "gates" ? "active" : ""}
213 >
214 {"\u25CF"} Gates
215 </a>
da3fc18Claude216 <a
217 href={`/${owner}/${repo}/security/vulnerabilities`}
218 class={active === "security" ? "active" : ""}
219 >
220 Security
221 </a>
c9ed210Claude222 <a
223 href={`/${owner}/${repo}/cloud-deployments`}
224 class={active === "deployments" ? "active" : ""}
225 >
226 Deployments
227 </a>
3ef4c9dClaude228 <a
229 href={`/${owner}/${repo}/insights`}
230 class={active === "insights" ? "active" : ""}
231 >
232 Insights
233 </a>
ef3fd93Claude234 <a
235 href={`/${owner}/${repo}/agents`}
236 class={active === "agents" ? "active" : ""}
237 >
238 Agents
239 </a>
3cbe3d6Claude240 <a
241 href={`/${owner}/${repo}/explain`}
debcf27Claude242 class={`repo-nav-ai${active === "explain" ? " active" : ""}`}
243 style="margin-left: auto"
3cbe3d6Claude244 >
245 {"\u2728"} Explain
246 </a>
debcf27Claude247 <a href={`/${owner}/${repo}/ask`} class="repo-nav-ai">
3ef4c9dClaude248 {"\u2728"} Ask AI
249 </a>
14c3cc8Claude250 <a
251 href={`/${owner}/${repo}/spec`}
debcf27Claude252 class="repo-nav-ai"
14c3cc8Claude253 title="Spec to PR — paste a feature spec, AI opens a draft PR"
254 >
255 {"\u2728"} Spec
256 </a>
d8ef5efClaude257 <a
258 href={`/${owner}/${repo}/ai/tests`}
debcf27Claude259 class="repo-nav-ai"
d8ef5efClaude260 title="AI Tests \u2014 generate failing test stubs from a source file"
261 >
262 {"\u2728"} Tests
263 </a>
bcc4020Claude264 <a
265 href={`/${owner}/${repo}/debt-map`}
266 class={`repo-nav-ai${active === "debt-map" ? " active" : ""}`}
267 title="AI Debt Map \u2014 visual technical debt graph with Claude analysis"
268 >
269 {"\u2593"} Debt Map
270 </a>
fc1817aClaude271 </div>
272);
273
06d5ffeClaude274export const BranchSwitcher: FC<{
275 owner: string;
276 repo: string;
277 currentRef: string;
278 branches: string[];
279 pathType: "tree" | "blob" | "commits";
280 subPath?: string;
281}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
282 if (branches.length <= 1) {
283 return <div class="branch-selector">{currentRef}</div>;
284 }
285
286 return (
287 <div class="branch-dropdown">
288 <button class="branch-selector" type="button">
289 {currentRef} &#9662;
290 </button>
291 <div class="branch-dropdown-content">
292 {branches.map((branch) => {
293 let href: string;
294 if (pathType === "commits") {
295 href = `/${owner}/${repo}/commits/${branch}`;
296 } else if (subPath) {
297 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
298 } else {
299 href = `/${owner}/${repo}/tree/${branch}`;
300 }
301 return (
302 <a
303 href={href}
304 class={branch === currentRef ? "active-branch" : ""}
305 >
306 {branch}
307 </a>
308 );
309 })}
310 </div>
311 </div>
312 );
313};
314
fc1817aClaude315export const Breadcrumb: FC<{
316 owner: string;
317 repo: string;
318 ref: string;
319 path: string;
320}> = ({ owner, repo, ref, path }) => {
321 const parts = path.split("/").filter(Boolean);
322 const crumbs: { name: string; href: string }[] = [
323 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
324 ];
325 let accumulated = "";
326 for (const part of parts) {
327 accumulated += (accumulated ? "/" : "") + part;
328 crumbs.push({
329 name: part,
330 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
331 });
332 }
333 return (
334 <div class="breadcrumb">
335 {crumbs.map((crumb, i) => (
336 <>
337 {i > 0 && <span>/</span>}
338 {i === crumbs.length - 1 ? (
339 <strong>{crumb.name}</strong>
340 ) : (
341 <a href={crumb.href}>{crumb.name}</a>
342 )}
343 </>
344 ))}
345 </div>
346 );
347};
348
349export const FileTable: FC<{
350 entries: GitTreeEntry[];
351 owner: string;
352 repo: string;
353 ref: string;
354 path: string;
355}> = ({ entries, owner, repo, ref, path }) => (
356 <table class="file-table">
357 <tbody>
358 {entries.map((entry) => {
359 const fullPath = path ? `${path}/${entry.name}` : entry.name;
360 const href =
361 entry.type === "tree"
362 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
363 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
364 return (
365 <tr>
366 <td class="file-icon">
367 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
368 </td>
369 <td class="file-name">
370 <a href={href}>{entry.name}</a>
371 </td>
372 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
373 {entry.size !== undefined ? formatSize(entry.size) : ""}
374 </td>
375 </tr>
376 );
377 })}
378 </tbody>
379 </table>
380);
381
06d5ffeClaude382export const HighlightedCode: FC<{
383 highlightedHtml: string;
384 lineCount: number;
385}> = ({ highlightedHtml, lineCount }) => {
386 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
387 return (
388 <div class="blob-code">
389 <table>
390 <tbody>
391 <tr>
392 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
393 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
394 {lineNums.map((n) => (
395 <>
396 <span>{n}</span>
397 {"\n"}
398 </>
399 ))}
400 </pre>
401 </td>
402 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
403 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
404 </td>
405 </tr>
406 </tbody>
407 </table>
408 </div>
409 );
410};
411
412export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
413 <div class="blob-code">
414 <table>
415 <tbody>
416 {lines.map((line, i) => (
417 <tr>
418 <td class="line-num">{i + 1}</td>
419 <td class="line-content">{line}</td>
420 </tr>
421 ))}
422 </tbody>
423 </table>
424 </div>
425);
426
fc1817aClaude427export const CommitList: FC<{
428 commits: GitCommit[];
429 owner: string;
430 repo: string;
3951454Claude431 verifications?: Record<string, { verified: boolean; reason: string }>;
432}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude433 <div class="commit-list">
3951454Claude434 {commits.map((commit) => {
435 const v = verifications?.[commit.sha];
436 return (
437 <div class="commit-item">
438 <div>
439 <div class="commit-message">
440 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
441 {commit.message}
442 </a>
443 {v?.verified && (
444 <span
445 title="Signed with a registered key"
446 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"
447 >
448 Verified
449 </span>
450 )}
451 </div>
452 <div class="commit-meta">
453 {commit.author} committed {formatRelativeDate(commit.date)}
454 </div>
fc1817aClaude455 </div>
3951454Claude456 <a
457 href={`/${owner}/${repo}/commit/${commit.sha}`}
458 class="commit-sha"
459 >
460 {commit.sha.slice(0, 7)}
461 </a>
fc1817aClaude462 </div>
3951454Claude463 );
464 })}
fc1817aClaude465 </div>
466);
467
468export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
469 raw,
470 files,
471}) => {
472 const sections = parseDiff(raw);
473
474 return (
475 <div class="diff-view">
476 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
477 Showing{" "}
478 <strong style="color: var(--text)">{files.length}</strong> changed
479 file{files.length !== 1 ? "s" : ""} with{" "}
480 <span class="stat-add">
481 +{files.reduce((s, f) => s + f.additions, 0)}
482 </span>{" "}
483 and{" "}
484 <span class="stat-del">
485 -{files.reduce((s, f) => s + f.deletions, 0)}
486 </span>
487 </div>
488 {sections.map((section) => (
489 <div class="diff-file">
490 <div class="diff-file-header">{section.path}</div>
491 <div class="diff-content">
492 {section.lines.map((line) => {
493 let cls = "line";
494 if (line.startsWith("+")) cls += " line-add";
495 else if (line.startsWith("-")) cls += " line-del";
496 else if (line.startsWith("@@")) cls += " line-hunk";
497 return <span class={cls}>{line + "\n"}</span>;
498 })}
499 </div>
500 </div>
501 ))}
502 </div>
503 );
504};
505
06d5ffeClaude506export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
507 repo,
508 ownerName,
509}) => (
510 <div class="card">
511 <h3>
512 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
513 </h3>
514 {repo.description && <p>{repo.description}</p>}
515 <div class="card-meta">
516 {repo.isPrivate && <span class="badge">Private</span>}
517 <span>{"\u2606"} {repo.starCount}</span>
518 {repo.pushedAt && (
519 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
520 )}
521 </div>
522 </div>
523);
524
fc1817aClaude525function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
526 const sections: Array<{ path: string; lines: string[] }> = [];
527 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
528 let current: { path: string; lines: string[] } | null = null;
529
530 for (const line of raw.split("\n")) {
531 const match = line.match(diffRegex);
532 if (match) {
533 if (current) sections.push(current);
534 current = { path: match[1], lines: [] };
535 continue;
536 }
537 if (current && !line.startsWith("diff --git")) {
538 if (
539 line.startsWith("index ") ||
540 line.startsWith("--- ") ||
541 line.startsWith("+++ ") ||
542 line.startsWith("new file") ||
543 line.startsWith("deleted file") ||
544 line.startsWith("old mode") ||
545 line.startsWith("new mode")
546 ) {
547 continue;
548 }
549 current.lines.push(line);
550 }
551 }
552 if (current) sections.push(current);
553 return sections;
554}
555
556function formatSize(bytes: number): string {
557 if (bytes < 1024) return `${bytes} B`;
558 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
559 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
560}
561
562function formatRelativeDate(dateStr: string): string {
563 const date = new Date(dateStr);
564 const now = new Date();
565 const diffMs = now.getTime() - date.getTime();
566 const diffMins = Math.floor(diffMs / 60000);
567 if (diffMins < 1) return "just now";
568 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
569 const diffHours = Math.floor(diffMins / 60);
570 if (diffHours < 24)
571 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
572 const diffDays = Math.floor(diffHours / 24);
573 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
574 return date.toLocaleDateString("en-US", {
575 month: "short",
576 day: "numeric",
577 year: "numeric",
578 });
579}