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