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.tsxBlame570 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"
c9ed210Claude153 | "deployments"
0316dbbClaude154 | "settings";
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>
c9ed210Claude220 <a
221 href={`/${owner}/${repo}/cloud-deployments`}
222 class={active === "deployments" ? "active" : ""}
223 >
224 Deployments
225 </a>
3ef4c9dClaude226 <a
227 href={`/${owner}/${repo}/insights`}
228 class={active === "insights" ? "active" : ""}
229 >
230 Insights
231 </a>
ef3fd93Claude232 <a
233 href={`/${owner}/${repo}/agents`}
234 class={active === "agents" ? "active" : ""}
235 >
236 Agents
237 </a>
3cbe3d6Claude238 <a
239 href={`/${owner}/${repo}/explain`}
debcf27Claude240 class={`repo-nav-ai${active === "explain" ? " active" : ""}`}
241 style="margin-left: auto"
3cbe3d6Claude242 >
243 {"\u2728"} Explain
244 </a>
debcf27Claude245 <a href={`/${owner}/${repo}/ask`} class="repo-nav-ai">
3ef4c9dClaude246 {"\u2728"} Ask AI
247 </a>
14c3cc8Claude248 <a
249 href={`/${owner}/${repo}/spec`}
debcf27Claude250 class="repo-nav-ai"
14c3cc8Claude251 title="Spec to PR — paste a feature spec, AI opens a draft PR"
252 >
253 {"\u2728"} Spec
254 </a>
d8ef5efClaude255 <a
256 href={`/${owner}/${repo}/ai/tests`}
debcf27Claude257 class="repo-nav-ai"
d8ef5efClaude258 title="AI Tests \u2014 generate failing test stubs from a source file"
259 >
260 {"\u2728"} Tests
261 </a>
fc1817aClaude262 </div>
263);
264
06d5ffeClaude265export const BranchSwitcher: FC<{
266 owner: string;
267 repo: string;
268 currentRef: string;
269 branches: string[];
270 pathType: "tree" | "blob" | "commits";
271 subPath?: string;
272}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
273 if (branches.length <= 1) {
274 return <div class="branch-selector">{currentRef}</div>;
275 }
276
277 return (
278 <div class="branch-dropdown">
279 <button class="branch-selector" type="button">
280 {currentRef} &#9662;
281 </button>
282 <div class="branch-dropdown-content">
283 {branches.map((branch) => {
284 let href: string;
285 if (pathType === "commits") {
286 href = `/${owner}/${repo}/commits/${branch}`;
287 } else if (subPath) {
288 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
289 } else {
290 href = `/${owner}/${repo}/tree/${branch}`;
291 }
292 return (
293 <a
294 href={href}
295 class={branch === currentRef ? "active-branch" : ""}
296 >
297 {branch}
298 </a>
299 );
300 })}
301 </div>
302 </div>
303 );
304};
305
fc1817aClaude306export const Breadcrumb: FC<{
307 owner: string;
308 repo: string;
309 ref: string;
310 path: string;
311}> = ({ owner, repo, ref, path }) => {
312 const parts = path.split("/").filter(Boolean);
313 const crumbs: { name: string; href: string }[] = [
314 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
315 ];
316 let accumulated = "";
317 for (const part of parts) {
318 accumulated += (accumulated ? "/" : "") + part;
319 crumbs.push({
320 name: part,
321 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
322 });
323 }
324 return (
325 <div class="breadcrumb">
326 {crumbs.map((crumb, i) => (
327 <>
328 {i > 0 && <span>/</span>}
329 {i === crumbs.length - 1 ? (
330 <strong>{crumb.name}</strong>
331 ) : (
332 <a href={crumb.href}>{crumb.name}</a>
333 )}
334 </>
335 ))}
336 </div>
337 );
338};
339
340export const FileTable: FC<{
341 entries: GitTreeEntry[];
342 owner: string;
343 repo: string;
344 ref: string;
345 path: string;
346}> = ({ entries, owner, repo, ref, path }) => (
347 <table class="file-table">
348 <tbody>
349 {entries.map((entry) => {
350 const fullPath = path ? `${path}/${entry.name}` : entry.name;
351 const href =
352 entry.type === "tree"
353 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
354 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
355 return (
356 <tr>
357 <td class="file-icon">
358 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
359 </td>
360 <td class="file-name">
361 <a href={href}>{entry.name}</a>
362 </td>
363 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
364 {entry.size !== undefined ? formatSize(entry.size) : ""}
365 </td>
366 </tr>
367 );
368 })}
369 </tbody>
370 </table>
371);
372
06d5ffeClaude373export const HighlightedCode: FC<{
374 highlightedHtml: string;
375 lineCount: number;
376}> = ({ highlightedHtml, lineCount }) => {
377 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
378 return (
379 <div class="blob-code">
380 <table>
381 <tbody>
382 <tr>
383 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
384 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
385 {lineNums.map((n) => (
386 <>
387 <span>{n}</span>
388 {"\n"}
389 </>
390 ))}
391 </pre>
392 </td>
393 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
394 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
395 </td>
396 </tr>
397 </tbody>
398 </table>
399 </div>
400 );
401};
402
403export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
404 <div class="blob-code">
405 <table>
406 <tbody>
407 {lines.map((line, i) => (
408 <tr>
409 <td class="line-num">{i + 1}</td>
410 <td class="line-content">{line}</td>
411 </tr>
412 ))}
413 </tbody>
414 </table>
415 </div>
416);
417
fc1817aClaude418export const CommitList: FC<{
419 commits: GitCommit[];
420 owner: string;
421 repo: string;
3951454Claude422 verifications?: Record<string, { verified: boolean; reason: string }>;
423}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude424 <div class="commit-list">
3951454Claude425 {commits.map((commit) => {
426 const v = verifications?.[commit.sha];
427 return (
428 <div class="commit-item">
429 <div>
430 <div class="commit-message">
431 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
432 {commit.message}
433 </a>
434 {v?.verified && (
435 <span
436 title="Signed with a registered key"
437 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"
438 >
439 Verified
440 </span>
441 )}
442 </div>
443 <div class="commit-meta">
444 {commit.author} committed {formatRelativeDate(commit.date)}
445 </div>
fc1817aClaude446 </div>
3951454Claude447 <a
448 href={`/${owner}/${repo}/commit/${commit.sha}`}
449 class="commit-sha"
450 >
451 {commit.sha.slice(0, 7)}
452 </a>
fc1817aClaude453 </div>
3951454Claude454 );
455 })}
fc1817aClaude456 </div>
457);
458
459export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
460 raw,
461 files,
462}) => {
463 const sections = parseDiff(raw);
464
465 return (
466 <div class="diff-view">
467 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
468 Showing{" "}
469 <strong style="color: var(--text)">{files.length}</strong> changed
470 file{files.length !== 1 ? "s" : ""} with{" "}
471 <span class="stat-add">
472 +{files.reduce((s, f) => s + f.additions, 0)}
473 </span>{" "}
474 and{" "}
475 <span class="stat-del">
476 -{files.reduce((s, f) => s + f.deletions, 0)}
477 </span>
478 </div>
479 {sections.map((section) => (
480 <div class="diff-file">
481 <div class="diff-file-header">{section.path}</div>
482 <div class="diff-content">
483 {section.lines.map((line) => {
484 let cls = "line";
485 if (line.startsWith("+")) cls += " line-add";
486 else if (line.startsWith("-")) cls += " line-del";
487 else if (line.startsWith("@@")) cls += " line-hunk";
488 return <span class={cls}>{line + "\n"}</span>;
489 })}
490 </div>
491 </div>
492 ))}
493 </div>
494 );
495};
496
06d5ffeClaude497export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
498 repo,
499 ownerName,
500}) => (
501 <div class="card">
502 <h3>
503 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
504 </h3>
505 {repo.description && <p>{repo.description}</p>}
506 <div class="card-meta">
507 {repo.isPrivate && <span class="badge">Private</span>}
508 <span>{"\u2606"} {repo.starCount}</span>
509 {repo.pushedAt && (
510 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
511 )}
512 </div>
513 </div>
514);
515
fc1817aClaude516function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
517 const sections: Array<{ path: string; lines: string[] }> = [];
518 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
519 let current: { path: string; lines: string[] } | null = null;
520
521 for (const line of raw.split("\n")) {
522 const match = line.match(diffRegex);
523 if (match) {
524 if (current) sections.push(current);
525 current = { path: match[1], lines: [] };
526 continue;
527 }
528 if (current && !line.startsWith("diff --git")) {
529 if (
530 line.startsWith("index ") ||
531 line.startsWith("--- ") ||
532 line.startsWith("+++ ") ||
533 line.startsWith("new file") ||
534 line.startsWith("deleted file") ||
535 line.startsWith("old mode") ||
536 line.startsWith("new mode")
537 ) {
538 continue;
539 }
540 current.lines.push(line);
541 }
542 }
543 if (current) sections.push(current);
544 return sections;
545}
546
547function formatSize(bytes: number): string {
548 if (bytes < 1024) return `${bytes} B`;
549 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
550 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
551}
552
553function formatRelativeDate(dateStr: string): string {
554 const date = new Date(dateStr);
555 const now = new Date();
556 const diffMs = now.getTime() - date.getTime();
557 const diffMins = Math.floor(diffMs / 60000);
558 if (diffMins < 1) return "just now";
559 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
560 const diffHours = Math.floor(diffMins / 60);
561 if (diffHours < 24)
562 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
563 const diffDays = Math.floor(diffHours / 24);
564 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
565 return date.toLocaleDateString("en-US", {
566 month: "short",
567 day: "numeric",
568 year: "numeric",
569 });
570}