Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
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.tsxBlame605 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;
77cf834Claude31 /** 0-100 health score badge rendered after the repo name. Optional — omit to hide. */
32 healthScore?: number;
71cd5ecClaude33}> = ({
34 owner,
35 repo,
36 starCount,
37 starred,
38 forkCount,
39 currentUser,
40 forkedFrom,
41 archived,
42 isTemplate,
8c790e0Claude43 recentPush,
77cf834Claude44 healthScore,
8c790e0Claude45}) => {
46 const FIVE_MIN = 5 * 60 * 1000;
47 const TWENTY_FOUR_HR = 24 * 60 * 60 * 1000;
48 const isLive = recentPush != null && recentPush.ageMs < FIVE_MIN;
49 const isRecent = recentPush != null && recentPush.ageMs < TWENTY_FOUR_HR;
50
77cf834Claude51 const healthColor =
52 healthScore === undefined ? null :
53 healthScore >= 80 ? "#34d399" :
54 healthScore >= 50 ? "#facc15" :
55 "#f87171";
56
8c790e0Claude57 return (
58 <div class="repo-header">
59 <div>
60 <div class="repo-header-title">
61 <a href={`/${owner}`} class="owner">
62 {owner}
63 </a>
64 <span class="separator">/</span>
65 <a href={`/${owner}/${repo}`} class="name">
66 {repo}
67 </a>
68 {archived && (
69 <span
70 class="repo-header-pill repo-header-pill-archived"
71 title="Read-only: pushes and new issues/PRs disabled"
72 >
73 Archived
74 </span>
75 )}
76 {isTemplate && (
77 <span
78 class="repo-header-pill repo-header-pill-template"
79 title="This repository can be used as a template"
80 >
81 Template
82 </span>
83 )}
77cf834Claude84 {healthScore !== undefined && healthColor && (
85 <a
86 href={`/${owner}/${repo}/health`}
87 title={`Repository health score: ${healthScore}/100 — click for breakdown`}
88 style={`display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:9999px;font-size:11px;font-weight:700;text-decoration:none;color:${healthColor};background:${healthColor}22;border:1px solid ${healthColor}44;`}
89 >
90 &#x2665; Health {healthScore}
91 </a>
92 )}
8c790e0Claude93 {isLive && recentPush && (
94 <a
95 href={`/${owner}/${repo}/push/${recentPush.sha}`}
96 class="repo-header-live-badge repo-header-live-badge--live"
97 title="Push in progress \u2014 watch live gate + deploy status"
98 aria-label="Live push \u2014 click to watch status"
99 >
100 <span class="repo-header-live-dot" aria-hidden="true">{"\u25cf"}</span>
101 Live
102 </a>
103 )}
104 {!isLive && isRecent && recentPush && (
105 <a
106 href={`/${owner}/${repo}/push/${recentPush.sha}`}
107 class="repo-header-live-badge repo-header-live-badge--recent"
108 title="Watch the most recent push's gate + deploy results"
109 aria-label="Watch most recent push"
110 >
111 <span aria-hidden="true">{"\u25cb"}</span>
112 Watch
113 </a>
114 )}
115 </div>
116 {forkedFrom && (
117 <div class="repo-header-fork">
118 forked from <a href={`/${forkedFrom}`}>{forkedFrom}</a>
119 </div>
71cd5ecClaude120 )}
c81ab7aClaude121 </div>
8c790e0Claude122 <div class="repo-header-actions">
123 {currentUser && currentUser !== owner && (
124 <form method="post" action={`/${owner}/${repo}/fork`} style="display:inline">
125 <button type="submit" class="star-btn">
126 {"\u2442"} Fork {forkCount !== undefined && forkCount > 0 ? forkCount : ""}
06d5ffeClaude127 </button>
128 </form>
8c790e0Claude129 )}
130 {starCount !== undefined && (
131 currentUser ? (
132 <form method="post" action={`/${owner}/${repo}/star`} style="display:inline">
133 <button
134 type="submit"
135 class={`star-btn${starred ? " starred" : ""}`}
136 >
137 {starred ? "\u2605" : "\u2606"} {starCount}
138 </button>
139 </form>
140 ) : (
141 <span class="star-btn">
142 {"\u2606"} {starCount}
143 </span>
144 )
145 )}
146 </div>
06d5ffeClaude147 </div>
8c790e0Claude148 );
149};
fc1817aClaude150
151export const RepoNav: FC<{
152 owner: string;
153 repo: string;
3ef4c9dClaude154 active:
155 | "code"
156 | "commits"
157 | "issues"
158 | "pulls"
159 | "releases"
eafe8c6Claude160 | "actions"
3ef4c9dClaude161 | "gates"
3cbe3d6Claude162 | "insights"
163 | "explain"
164 | "changelog"
1e162a8Claude165 | "semantic"
166 | "wiki"
0316dbbClaude167 | "projects"
ef3fd93Claude168 | "agents"
c645a86Claude169 | "discussions"
da3fc18Claude170 | "security"
bcc4020Claude171 | "settings"
7f992cdClaude172 | "debt-map"
173 | "migrate"
77cf834Claude174 | "deployments"
175 | "nl-search";
fc1817aClaude176}> = ({ owner, repo, active }) => (
177 <div class="repo-nav">
06d5ffeClaude178 <a href={`/${owner}/${repo}`} class={active === "code" ? "active" : ""}>
fc1817aClaude179 Code
180 </a>
79136bbClaude181 <a
182 href={`/${owner}/${repo}/issues`}
183 class={active === "issues" ? "active" : ""}
184 >
185 Issues
186 </a>
c645a86Claude187 <a
188 href={`/${owner}/${repo}/discussions`}
189 class={active === "discussions" ? "active" : ""}
190 >
191 Discussions
192 </a>
1e162a8Claude193 <a
194 href={`/${owner}/${repo}/wiki`}
195 class={active === "wiki" ? "active" : ""}
196 >
197 Wiki
198 </a>
0074234Claude199 <a
200 href={`/${owner}/${repo}/pulls`}
201 class={active === "pulls" ? "active" : ""}
202 >
203 Pull Requests
204 </a>
1e162a8Claude205 <a
206 href={`/${owner}/${repo}/projects`}
207 class={active === "projects" ? "active" : ""}
208 >
209 Projects
210 </a>
fc1817aClaude211 <a
212 href={`/${owner}/${repo}/commits`}
213 class={active === "commits" ? "active" : ""}
214 >
215 Commits
216 </a>
eafe8c6Claude217 <a
218 href={`/${owner}/${repo}/actions`}
219 class={active === "actions" ? "active" : ""}
220 >
221 Actions
222 </a>
3ef4c9dClaude223 <a
224 href={`/${owner}/${repo}/releases`}
225 class={active === "releases" ? "active" : ""}
226 >
227 Releases
228 </a>
229 <a
230 href={`/${owner}/${repo}/gates`}
231 class={active === "gates" ? "active" : ""}
232 >
233 {"\u25CF"} Gates
234 </a>
da3fc18Claude235 <a
236 href={`/${owner}/${repo}/security/vulnerabilities`}
237 class={active === "security" ? "active" : ""}
238 >
239 Security
240 </a>
c9ed210Claude241 <a
242 href={`/${owner}/${repo}/cloud-deployments`}
243 class={active === "deployments" ? "active" : ""}
244 >
245 Deployments
246 </a>
3ef4c9dClaude247 <a
248 href={`/${owner}/${repo}/insights`}
249 class={active === "insights" ? "active" : ""}
250 >
251 Insights
252 </a>
ef3fd93Claude253 <a
254 href={`/${owner}/${repo}/agents`}
255 class={active === "agents" ? "active" : ""}
256 >
257 Agents
258 </a>
3cbe3d6Claude259 <a
260 href={`/${owner}/${repo}/explain`}
debcf27Claude261 class={`repo-nav-ai${active === "explain" ? " active" : ""}`}
262 style="margin-left: auto"
3cbe3d6Claude263 >
264 {"\u2728"} Explain
265 </a>
debcf27Claude266 <a href={`/${owner}/${repo}/ask`} class="repo-nav-ai">
3ef4c9dClaude267 {"\u2728"} Ask AI
268 </a>
14c3cc8Claude269 <a
270 href={`/${owner}/${repo}/spec`}
debcf27Claude271 class="repo-nav-ai"
14c3cc8Claude272 title="Spec to PR — paste a feature spec, AI opens a draft PR"
273 >
274 {"\u2728"} Spec
275 </a>
d8ef5efClaude276 <a
277 href={`/${owner}/${repo}/ai/tests`}
debcf27Claude278 class="repo-nav-ai"
d8ef5efClaude279 title="AI Tests \u2014 generate failing test stubs from a source file"
280 >
281 {"\u2728"} Tests
282 </a>
bcc4020Claude283 <a
284 href={`/${owner}/${repo}/debt-map`}
285 class={`repo-nav-ai${active === "debt-map" ? " active" : ""}`}
286 title="AI Debt Map \u2014 visual technical debt graph with Claude analysis"
287 >
288 {"\u2593"} Debt Map
289 </a>
77cf834Claude290 <a
291 href={`/${owner}/${repo}/search/nl`}
292 class={`repo-nav-ai${active === "nl-search" ? " active" : ""}`}
293 title="Natural Language Search \u2014 search by intent, not keywords"
294 >
295 {"\u2728"} NL Search
296 </a>
fc1817aClaude297 </div>
298);
299
06d5ffeClaude300export const BranchSwitcher: FC<{
301 owner: string;
302 repo: string;
303 currentRef: string;
304 branches: string[];
305 pathType: "tree" | "blob" | "commits";
306 subPath?: string;
307}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
308 if (branches.length <= 1) {
309 return <div class="branch-selector">{currentRef}</div>;
310 }
311
312 return (
313 <div class="branch-dropdown">
314 <button class="branch-selector" type="button">
315 {currentRef} &#9662;
316 </button>
317 <div class="branch-dropdown-content">
318 {branches.map((branch) => {
319 let href: string;
320 if (pathType === "commits") {
321 href = `/${owner}/${repo}/commits/${branch}`;
322 } else if (subPath) {
323 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
324 } else {
325 href = `/${owner}/${repo}/tree/${branch}`;
326 }
327 return (
328 <a
329 href={href}
330 class={branch === currentRef ? "active-branch" : ""}
331 >
332 {branch}
333 </a>
334 );
335 })}
336 </div>
337 </div>
338 );
339};
340
fc1817aClaude341export const Breadcrumb: FC<{
342 owner: string;
343 repo: string;
344 ref: string;
345 path: string;
346}> = ({ owner, repo, ref, path }) => {
347 const parts = path.split("/").filter(Boolean);
348 const crumbs: { name: string; href: string }[] = [
349 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
350 ];
351 let accumulated = "";
352 for (const part of parts) {
353 accumulated += (accumulated ? "/" : "") + part;
354 crumbs.push({
355 name: part,
356 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
357 });
358 }
359 return (
360 <div class="breadcrumb">
361 {crumbs.map((crumb, i) => (
362 <>
363 {i > 0 && <span>/</span>}
364 {i === crumbs.length - 1 ? (
365 <strong>{crumb.name}</strong>
366 ) : (
367 <a href={crumb.href}>{crumb.name}</a>
368 )}
369 </>
370 ))}
371 </div>
372 );
373};
374
375export const FileTable: FC<{
376 entries: GitTreeEntry[];
377 owner: string;
378 repo: string;
379 ref: string;
380 path: string;
381}> = ({ entries, owner, repo, ref, path }) => (
382 <table class="file-table">
383 <tbody>
384 {entries.map((entry) => {
385 const fullPath = path ? `${path}/${entry.name}` : entry.name;
386 const href =
387 entry.type === "tree"
388 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
389 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
390 return (
391 <tr>
392 <td class="file-icon">
393 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
394 </td>
395 <td class="file-name">
396 <a href={href}>{entry.name}</a>
397 </td>
398 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
399 {entry.size !== undefined ? formatSize(entry.size) : ""}
400 </td>
401 </tr>
402 );
403 })}
404 </tbody>
405 </table>
406);
407
06d5ffeClaude408export const HighlightedCode: FC<{
409 highlightedHtml: string;
410 lineCount: number;
411}> = ({ highlightedHtml, lineCount }) => {
412 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
413 return (
414 <div class="blob-code">
415 <table>
416 <tbody>
417 <tr>
418 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
419 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
420 {lineNums.map((n) => (
421 <>
422 <span>{n}</span>
423 {"\n"}
424 </>
425 ))}
426 </pre>
427 </td>
428 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
429 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
430 </td>
431 </tr>
432 </tbody>
433 </table>
434 </div>
435 );
436};
437
438export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
439 <div class="blob-code">
440 <table>
441 <tbody>
442 {lines.map((line, i) => (
443 <tr>
444 <td class="line-num">{i + 1}</td>
445 <td class="line-content">{line}</td>
446 </tr>
447 ))}
448 </tbody>
449 </table>
450 </div>
451);
452
fc1817aClaude453export const CommitList: FC<{
454 commits: GitCommit[];
455 owner: string;
456 repo: string;
3951454Claude457 verifications?: Record<string, { verified: boolean; reason: string }>;
458}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude459 <div class="commit-list">
3951454Claude460 {commits.map((commit) => {
461 const v = verifications?.[commit.sha];
462 return (
463 <div class="commit-item">
464 <div>
465 <div class="commit-message">
466 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
467 {commit.message}
468 </a>
469 {v?.verified && (
470 <span
471 title="Signed with a registered key"
472 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"
473 >
474 Verified
475 </span>
476 )}
477 </div>
478 <div class="commit-meta">
479 {commit.author} committed {formatRelativeDate(commit.date)}
480 </div>
fc1817aClaude481 </div>
3951454Claude482 <a
483 href={`/${owner}/${repo}/commit/${commit.sha}`}
484 class="commit-sha"
485 >
486 {commit.sha.slice(0, 7)}
487 </a>
fc1817aClaude488 </div>
3951454Claude489 );
490 })}
fc1817aClaude491 </div>
492);
493
494export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
495 raw,
496 files,
497}) => {
498 const sections = parseDiff(raw);
499
500 return (
501 <div class="diff-view">
502 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
503 Showing{" "}
504 <strong style="color: var(--text)">{files.length}</strong> changed
505 file{files.length !== 1 ? "s" : ""} with{" "}
506 <span class="stat-add">
507 +{files.reduce((s, f) => s + f.additions, 0)}
508 </span>{" "}
509 and{" "}
510 <span class="stat-del">
511 -{files.reduce((s, f) => s + f.deletions, 0)}
512 </span>
513 </div>
514 {sections.map((section) => (
515 <div class="diff-file">
516 <div class="diff-file-header">{section.path}</div>
517 <div class="diff-content">
518 {section.lines.map((line) => {
519 let cls = "line";
520 if (line.startsWith("+")) cls += " line-add";
521 else if (line.startsWith("-")) cls += " line-del";
522 else if (line.startsWith("@@")) cls += " line-hunk";
523 return <span class={cls}>{line + "\n"}</span>;
524 })}
525 </div>
526 </div>
527 ))}
528 </div>
529 );
530};
531
06d5ffeClaude532export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
533 repo,
534 ownerName,
535}) => (
536 <div class="card">
537 <h3>
538 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
539 </h3>
540 {repo.description && <p>{repo.description}</p>}
541 <div class="card-meta">
542 {repo.isPrivate && <span class="badge">Private</span>}
543 <span>{"\u2606"} {repo.starCount}</span>
544 {repo.pushedAt && (
545 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
546 )}
547 </div>
548 </div>
549);
550
fc1817aClaude551function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
552 const sections: Array<{ path: string; lines: string[] }> = [];
553 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
554 let current: { path: string; lines: string[] } | null = null;
555
556 for (const line of raw.split("\n")) {
557 const match = line.match(diffRegex);
558 if (match) {
559 if (current) sections.push(current);
560 current = { path: match[1], lines: [] };
561 continue;
562 }
563 if (current && !line.startsWith("diff --git")) {
564 if (
565 line.startsWith("index ") ||
566 line.startsWith("--- ") ||
567 line.startsWith("+++ ") ||
568 line.startsWith("new file") ||
569 line.startsWith("deleted file") ||
570 line.startsWith("old mode") ||
571 line.startsWith("new mode")
572 ) {
573 continue;
574 }
575 current.lines.push(line);
576 }
577 }
578 if (current) sections.push(current);
579 return sections;
580}
581
582function formatSize(bytes: number): string {
583 if (bytes < 1024) return `${bytes} B`;
584 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
585 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
586}
587
588function formatRelativeDate(dateStr: string): string {
589 const date = new Date(dateStr);
590 const now = new Date();
591 const diffMs = now.getTime() - date.getTime();
592 const diffMins = Math.floor(diffMs / 60000);
593 if (diffMins < 1) return "just now";
594 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
595 const diffHours = Math.floor(diffMins / 60);
596 if (diffHours < 24)
597 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
598 const diffDays = Math.floor(diffHours / 24);
599 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
600 return date.toLocaleDateString("en-US", {
601 month: "short",
602 day: "numeric",
603 year: "numeric",
604 });
605}