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.tsxBlame563 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"
0316dbbClaude153 | "settings";
fc1817aClaude154}> = ({ owner, repo, active }) => (
155 <div class="repo-nav">
06d5ffeClaude156 <a href={`/${owner}/${repo}`} class={active === "code" ? "active" : ""}>
fc1817aClaude157 Code
158 </a>
79136bbClaude159 <a
160 href={`/${owner}/${repo}/issues`}
161 class={active === "issues" ? "active" : ""}
162 >
163 Issues
164 </a>
c645a86Claude165 <a
166 href={`/${owner}/${repo}/discussions`}
167 class={active === "discussions" ? "active" : ""}
168 >
169 Discussions
170 </a>
1e162a8Claude171 <a
172 href={`/${owner}/${repo}/wiki`}
173 class={active === "wiki" ? "active" : ""}
174 >
175 Wiki
176 </a>
0074234Claude177 <a
178 href={`/${owner}/${repo}/pulls`}
179 class={active === "pulls" ? "active" : ""}
180 >
181 Pull Requests
182 </a>
1e162a8Claude183 <a
184 href={`/${owner}/${repo}/projects`}
185 class={active === "projects" ? "active" : ""}
186 >
187 Projects
188 </a>
fc1817aClaude189 <a
190 href={`/${owner}/${repo}/commits`}
191 class={active === "commits" ? "active" : ""}
192 >
193 Commits
194 </a>
eafe8c6Claude195 <a
196 href={`/${owner}/${repo}/actions`}
197 class={active === "actions" ? "active" : ""}
198 >
199 Actions
200 </a>
3ef4c9dClaude201 <a
202 href={`/${owner}/${repo}/releases`}
203 class={active === "releases" ? "active" : ""}
204 >
205 Releases
206 </a>
207 <a
208 href={`/${owner}/${repo}/gates`}
209 class={active === "gates" ? "active" : ""}
210 >
211 {"\u25CF"} Gates
212 </a>
da3fc18Claude213 <a
214 href={`/${owner}/${repo}/security/vulnerabilities`}
215 class={active === "security" ? "active" : ""}
216 >
217 Security
218 </a>
3ef4c9dClaude219 <a
220 href={`/${owner}/${repo}/insights`}
221 class={active === "insights" ? "active" : ""}
222 >
223 Insights
224 </a>
ef3fd93Claude225 <a
226 href={`/${owner}/${repo}/agents`}
227 class={active === "agents" ? "active" : ""}
228 >
229 Agents
230 </a>
3cbe3d6Claude231 <a
232 href={`/${owner}/${repo}/explain`}
debcf27Claude233 class={`repo-nav-ai${active === "explain" ? " active" : ""}`}
234 style="margin-left: auto"
3cbe3d6Claude235 >
236 {"\u2728"} Explain
237 </a>
debcf27Claude238 <a href={`/${owner}/${repo}/ask`} class="repo-nav-ai">
3ef4c9dClaude239 {"\u2728"} Ask AI
240 </a>
14c3cc8Claude241 <a
242 href={`/${owner}/${repo}/spec`}
debcf27Claude243 class="repo-nav-ai"
14c3cc8Claude244 title="Spec to PR — paste a feature spec, AI opens a draft PR"
245 >
246 {"\u2728"} Spec
247 </a>
d8ef5efClaude248 <a
249 href={`/${owner}/${repo}/ai/tests`}
debcf27Claude250 class="repo-nav-ai"
d8ef5efClaude251 title="AI Tests \u2014 generate failing test stubs from a source file"
252 >
253 {"\u2728"} Tests
254 </a>
fc1817aClaude255 </div>
256);
257
06d5ffeClaude258export const BranchSwitcher: FC<{
259 owner: string;
260 repo: string;
261 currentRef: string;
262 branches: string[];
263 pathType: "tree" | "blob" | "commits";
264 subPath?: string;
265}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
266 if (branches.length <= 1) {
267 return <div class="branch-selector">{currentRef}</div>;
268 }
269
270 return (
271 <div class="branch-dropdown">
272 <button class="branch-selector" type="button">
273 {currentRef} &#9662;
274 </button>
275 <div class="branch-dropdown-content">
276 {branches.map((branch) => {
277 let href: string;
278 if (pathType === "commits") {
279 href = `/${owner}/${repo}/commits/${branch}`;
280 } else if (subPath) {
281 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
282 } else {
283 href = `/${owner}/${repo}/tree/${branch}`;
284 }
285 return (
286 <a
287 href={href}
288 class={branch === currentRef ? "active-branch" : ""}
289 >
290 {branch}
291 </a>
292 );
293 })}
294 </div>
295 </div>
296 );
297};
298
fc1817aClaude299export const Breadcrumb: FC<{
300 owner: string;
301 repo: string;
302 ref: string;
303 path: string;
304}> = ({ owner, repo, ref, path }) => {
305 const parts = path.split("/").filter(Boolean);
306 const crumbs: { name: string; href: string }[] = [
307 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
308 ];
309 let accumulated = "";
310 for (const part of parts) {
311 accumulated += (accumulated ? "/" : "") + part;
312 crumbs.push({
313 name: part,
314 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
315 });
316 }
317 return (
318 <div class="breadcrumb">
319 {crumbs.map((crumb, i) => (
320 <>
321 {i > 0 && <span>/</span>}
322 {i === crumbs.length - 1 ? (
323 <strong>{crumb.name}</strong>
324 ) : (
325 <a href={crumb.href}>{crumb.name}</a>
326 )}
327 </>
328 ))}
329 </div>
330 );
331};
332
333export const FileTable: FC<{
334 entries: GitTreeEntry[];
335 owner: string;
336 repo: string;
337 ref: string;
338 path: string;
339}> = ({ entries, owner, repo, ref, path }) => (
340 <table class="file-table">
341 <tbody>
342 {entries.map((entry) => {
343 const fullPath = path ? `${path}/${entry.name}` : entry.name;
344 const href =
345 entry.type === "tree"
346 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
347 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
348 return (
349 <tr>
350 <td class="file-icon">
351 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
352 </td>
353 <td class="file-name">
354 <a href={href}>{entry.name}</a>
355 </td>
356 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
357 {entry.size !== undefined ? formatSize(entry.size) : ""}
358 </td>
359 </tr>
360 );
361 })}
362 </tbody>
363 </table>
364);
365
06d5ffeClaude366export const HighlightedCode: FC<{
367 highlightedHtml: string;
368 lineCount: number;
369}> = ({ highlightedHtml, lineCount }) => {
370 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
371 return (
372 <div class="blob-code">
373 <table>
374 <tbody>
375 <tr>
376 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
377 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
378 {lineNums.map((n) => (
379 <>
380 <span>{n}</span>
381 {"\n"}
382 </>
383 ))}
384 </pre>
385 </td>
386 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
387 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
388 </td>
389 </tr>
390 </tbody>
391 </table>
392 </div>
393 );
394};
395
396export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
397 <div class="blob-code">
398 <table>
399 <tbody>
400 {lines.map((line, i) => (
401 <tr>
402 <td class="line-num">{i + 1}</td>
403 <td class="line-content">{line}</td>
404 </tr>
405 ))}
406 </tbody>
407 </table>
408 </div>
409);
410
fc1817aClaude411export const CommitList: FC<{
412 commits: GitCommit[];
413 owner: string;
414 repo: string;
3951454Claude415 verifications?: Record<string, { verified: boolean; reason: string }>;
416}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude417 <div class="commit-list">
3951454Claude418 {commits.map((commit) => {
419 const v = verifications?.[commit.sha];
420 return (
421 <div class="commit-item">
422 <div>
423 <div class="commit-message">
424 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
425 {commit.message}
426 </a>
427 {v?.verified && (
428 <span
429 title="Signed with a registered key"
430 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"
431 >
432 Verified
433 </span>
434 )}
435 </div>
436 <div class="commit-meta">
437 {commit.author} committed {formatRelativeDate(commit.date)}
438 </div>
fc1817aClaude439 </div>
3951454Claude440 <a
441 href={`/${owner}/${repo}/commit/${commit.sha}`}
442 class="commit-sha"
443 >
444 {commit.sha.slice(0, 7)}
445 </a>
fc1817aClaude446 </div>
3951454Claude447 );
448 })}
fc1817aClaude449 </div>
450);
451
452export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
453 raw,
454 files,
455}) => {
456 const sections = parseDiff(raw);
457
458 return (
459 <div class="diff-view">
460 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
461 Showing{" "}
462 <strong style="color: var(--text)">{files.length}</strong> changed
463 file{files.length !== 1 ? "s" : ""} with{" "}
464 <span class="stat-add">
465 +{files.reduce((s, f) => s + f.additions, 0)}
466 </span>{" "}
467 and{" "}
468 <span class="stat-del">
469 -{files.reduce((s, f) => s + f.deletions, 0)}
470 </span>
471 </div>
472 {sections.map((section) => (
473 <div class="diff-file">
474 <div class="diff-file-header">{section.path}</div>
475 <div class="diff-content">
476 {section.lines.map((line) => {
477 let cls = "line";
478 if (line.startsWith("+")) cls += " line-add";
479 else if (line.startsWith("-")) cls += " line-del";
480 else if (line.startsWith("@@")) cls += " line-hunk";
481 return <span class={cls}>{line + "\n"}</span>;
482 })}
483 </div>
484 </div>
485 ))}
486 </div>
487 );
488};
489
06d5ffeClaude490export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
491 repo,
492 ownerName,
493}) => (
494 <div class="card">
495 <h3>
496 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
497 </h3>
498 {repo.description && <p>{repo.description}</p>}
499 <div class="card-meta">
500 {repo.isPrivate && <span class="badge">Private</span>}
501 <span>{"\u2606"} {repo.starCount}</span>
502 {repo.pushedAt && (
503 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
504 )}
505 </div>
506 </div>
507);
508
fc1817aClaude509function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
510 const sections: Array<{ path: string; lines: string[] }> = [];
511 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
512 let current: { path: string; lines: string[] } | null = null;
513
514 for (const line of raw.split("\n")) {
515 const match = line.match(diffRegex);
516 if (match) {
517 if (current) sections.push(current);
518 current = { path: match[1], lines: [] };
519 continue;
520 }
521 if (current && !line.startsWith("diff --git")) {
522 if (
523 line.startsWith("index ") ||
524 line.startsWith("--- ") ||
525 line.startsWith("+++ ") ||
526 line.startsWith("new file") ||
527 line.startsWith("deleted file") ||
528 line.startsWith("old mode") ||
529 line.startsWith("new mode")
530 ) {
531 continue;
532 }
533 current.lines.push(line);
534 }
535 }
536 if (current) sections.push(current);
537 return sections;
538}
539
540function formatSize(bytes: number): string {
541 if (bytes < 1024) return `${bytes} B`;
542 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
543 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
544}
545
546function formatRelativeDate(dateStr: string): string {
547 const date = new Date(dateStr);
548 const now = new Date();
549 const diffMs = now.getTime() - date.getTime();
550 const diffMins = Math.floor(diffMs / 60000);
551 if (diffMins < 1) return "just now";
552 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
553 const diffHours = Math.floor(diffMins / 60);
554 if (diffHours < 24)
555 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
556 const diffDays = Math.floor(diffHours / 24);
557 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
558 return date.toLocaleDateString("en-US", {
559 month: "short",
560 day: "numeric",
561 year: "numeric",
562 });
563}