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