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.tsxBlame499 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
06d5ffeClaude6export const RepoHeader: FC<{
7 owner: string;
8 repo: string;
9 starCount?: number;
10 starred?: boolean;
c81ab7aClaude11 forkCount?: number;
06d5ffeClaude12 currentUser?: string | null;
c81ab7aClaude13 forkedFrom?: string | null;
71cd5ecClaude14 archived?: boolean;
15 isTemplate?: boolean;
16}> = ({
17 owner,
18 repo,
19 starCount,
20 starred,
21 forkCount,
22 currentUser,
23 forkedFrom,
24 archived,
25 isTemplate,
26}) => (
fc1817aClaude27 <div class="repo-header">
c81ab7aClaude28 <div>
29 <div style="display: flex; align-items: center; gap: 8px; font-size: 20px">
30 <a href={`/${owner}`} class="owner">
31 {owner}
32 </a>
33 <span class="separator">/</span>
34 <a href={`/${owner}/${repo}`} class="name">
35 {repo}
36 </a>
71cd5ecClaude37 {archived && (
38 <span
39 class="badge"
40 style="background:var(--bg-secondary);color:var(--text-muted);font-size:11px;padding:2px 8px;border-radius:10px;text-transform:uppercase;letter-spacing:0.5px"
41 title="Read-only: pushes and new issues/PRs disabled"
42 >
43 Archived
44 </span>
45 )}
46 {isTemplate && (
47 <span
48 class="badge"
49 style="background:var(--bg-secondary);color:var(--accent);font-size:11px;padding:2px 8px;border-radius:10px;text-transform:uppercase;letter-spacing:0.5px"
50 title="This repository can be used as a template"
51 >
52 Template
53 </span>
54 )}
c81ab7aClaude55 </div>
56 {forkedFrom && (
57 <div style="font-size: 12px; color: var(--text-muted); margin-top: 2px">
58 forked from <a href={`/${forkedFrom}`}>{forkedFrom}</a>
59 </div>
60 )}
61 </div>
06d5ffeClaude62 <div class="repo-header-actions">
c81ab7aClaude63 {currentUser && currentUser !== owner && (
45e31d0Claude64 <form method="post" action={`/${owner}/${repo}/fork`} style="display:inline">
c81ab7aClaude65 <button type="submit" class="star-btn">
66 {"\u2442"} Fork {forkCount !== undefined && forkCount > 0 ? forkCount : ""}
67 </button>
68 </form>
69 )}
06d5ffeClaude70 {starCount !== undefined && (
71 currentUser ? (
45e31d0Claude72 <form method="post" action={`/${owner}/${repo}/star`} style="display:inline">
06d5ffeClaude73 <button
74 type="submit"
75 class={`star-btn${starred ? " starred" : ""}`}
76 >
77 {starred ? "\u2605" : "\u2606"} {starCount}
78 </button>
79 </form>
80 ) : (
81 <span class="star-btn">
82 {"\u2606"} {starCount}
83 </span>
84 )
85 )}
86 </div>
fc1817aClaude87 </div>
88);
89
90export const RepoNav: FC<{
91 owner: string;
92 repo: string;
3ef4c9dClaude93 active:
94 | "code"
95 | "commits"
96 | "issues"
97 | "pulls"
98 | "releases"
eafe8c6Claude99 | "actions"
3ef4c9dClaude100 | "gates"
3cbe3d6Claude101 | "insights"
102 | "explain"
103 | "changelog"
1e162a8Claude104 | "semantic"
105 | "wiki"
0316dbbClaude106 | "projects"
107 | "settings";
fc1817aClaude108}> = ({ owner, repo, active }) => (
109 <div class="repo-nav">
06d5ffeClaude110 <a href={`/${owner}/${repo}`} class={active === "code" ? "active" : ""}>
fc1817aClaude111 Code
112 </a>
79136bbClaude113 <a
114 href={`/${owner}/${repo}/issues`}
115 class={active === "issues" ? "active" : ""}
116 >
117 Issues
118 </a>
1e162a8Claude119 <a
120 href={`/${owner}/${repo}/wiki`}
121 class={active === "wiki" ? "active" : ""}
122 >
123 Wiki
124 </a>
0074234Claude125 <a
126 href={`/${owner}/${repo}/pulls`}
127 class={active === "pulls" ? "active" : ""}
128 >
129 Pull Requests
130 </a>
1e162a8Claude131 <a
132 href={`/${owner}/${repo}/projects`}
133 class={active === "projects" ? "active" : ""}
134 >
135 Projects
136 </a>
fc1817aClaude137 <a
138 href={`/${owner}/${repo}/commits`}
139 class={active === "commits" ? "active" : ""}
140 >
141 Commits
142 </a>
eafe8c6Claude143 <a
144 href={`/${owner}/${repo}/actions`}
145 class={active === "actions" ? "active" : ""}
146 >
147 Actions
148 </a>
3ef4c9dClaude149 <a
150 href={`/${owner}/${repo}/releases`}
151 class={active === "releases" ? "active" : ""}
152 >
153 Releases
154 </a>
155 <a
156 href={`/${owner}/${repo}/gates`}
157 class={active === "gates" ? "active" : ""}
158 >
159 {"\u25CF"} Gates
160 </a>
161 <a
162 href={`/${owner}/${repo}/insights`}
163 class={active === "insights" ? "active" : ""}
164 >
165 Insights
166 </a>
3cbe3d6Claude167 <a
168 href={`/${owner}/${repo}/explain`}
169 class={active === "explain" ? "active" : ""}
170 style="margin-left: auto; color: #bc8cff"
171 >
172 {"\u2728"} Explain
173 </a>
174 <a href={`/${owner}/${repo}/ask`} style="color: #bc8cff">
3ef4c9dClaude175 {"\u2728"} Ask AI
176 </a>
14c3cc8Claude177 <a
178 href={`/${owner}/${repo}/spec`}
179 style="color: #bc8cff"
180 title="Spec to PR — paste a feature spec, AI opens a draft PR"
181 >
182 {"\u2728"} Spec
183 </a>
d8ef5efClaude184 <a
185 href={`/${owner}/${repo}/ai/tests`}
186 style="color: #bc8cff"
187 title="AI Tests \u2014 generate failing test stubs from a source file"
188 >
189 {"\u2728"} Tests
190 </a>
fc1817aClaude191 </div>
192);
193
06d5ffeClaude194export const BranchSwitcher: FC<{
195 owner: string;
196 repo: string;
197 currentRef: string;
198 branches: string[];
199 pathType: "tree" | "blob" | "commits";
200 subPath?: string;
201}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
202 if (branches.length <= 1) {
203 return <div class="branch-selector">{currentRef}</div>;
204 }
205
206 return (
207 <div class="branch-dropdown">
208 <button class="branch-selector" type="button">
209 {currentRef} &#9662;
210 </button>
211 <div class="branch-dropdown-content">
212 {branches.map((branch) => {
213 let href: string;
214 if (pathType === "commits") {
215 href = `/${owner}/${repo}/commits/${branch}`;
216 } else if (subPath) {
217 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
218 } else {
219 href = `/${owner}/${repo}/tree/${branch}`;
220 }
221 return (
222 <a
223 href={href}
224 class={branch === currentRef ? "active-branch" : ""}
225 >
226 {branch}
227 </a>
228 );
229 })}
230 </div>
231 </div>
232 );
233};
234
fc1817aClaude235export const Breadcrumb: FC<{
236 owner: string;
237 repo: string;
238 ref: string;
239 path: string;
240}> = ({ owner, repo, ref, path }) => {
241 const parts = path.split("/").filter(Boolean);
242 const crumbs: { name: string; href: string }[] = [
243 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
244 ];
245 let accumulated = "";
246 for (const part of parts) {
247 accumulated += (accumulated ? "/" : "") + part;
248 crumbs.push({
249 name: part,
250 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
251 });
252 }
253 return (
254 <div class="breadcrumb">
255 {crumbs.map((crumb, i) => (
256 <>
257 {i > 0 && <span>/</span>}
258 {i === crumbs.length - 1 ? (
259 <strong>{crumb.name}</strong>
260 ) : (
261 <a href={crumb.href}>{crumb.name}</a>
262 )}
263 </>
264 ))}
265 </div>
266 );
267};
268
269export const FileTable: FC<{
270 entries: GitTreeEntry[];
271 owner: string;
272 repo: string;
273 ref: string;
274 path: string;
275}> = ({ entries, owner, repo, ref, path }) => (
276 <table class="file-table">
277 <tbody>
278 {entries.map((entry) => {
279 const fullPath = path ? `${path}/${entry.name}` : entry.name;
280 const href =
281 entry.type === "tree"
282 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
283 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
284 return (
285 <tr>
286 <td class="file-icon">
287 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
288 </td>
289 <td class="file-name">
290 <a href={href}>{entry.name}</a>
291 </td>
292 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
293 {entry.size !== undefined ? formatSize(entry.size) : ""}
294 </td>
295 </tr>
296 );
297 })}
298 </tbody>
299 </table>
300);
301
06d5ffeClaude302export const HighlightedCode: FC<{
303 highlightedHtml: string;
304 lineCount: number;
305}> = ({ highlightedHtml, lineCount }) => {
306 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
307 return (
308 <div class="blob-code">
309 <table>
310 <tbody>
311 <tr>
312 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
313 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
314 {lineNums.map((n) => (
315 <>
316 <span>{n}</span>
317 {"\n"}
318 </>
319 ))}
320 </pre>
321 </td>
322 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
323 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
324 </td>
325 </tr>
326 </tbody>
327 </table>
328 </div>
329 );
330};
331
332export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
333 <div class="blob-code">
334 <table>
335 <tbody>
336 {lines.map((line, i) => (
337 <tr>
338 <td class="line-num">{i + 1}</td>
339 <td class="line-content">{line}</td>
340 </tr>
341 ))}
342 </tbody>
343 </table>
344 </div>
345);
346
fc1817aClaude347export const CommitList: FC<{
348 commits: GitCommit[];
349 owner: string;
350 repo: string;
3951454Claude351 verifications?: Record<string, { verified: boolean; reason: string }>;
352}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude353 <div class="commit-list">
3951454Claude354 {commits.map((commit) => {
355 const v = verifications?.[commit.sha];
356 return (
357 <div class="commit-item">
358 <div>
359 <div class="commit-message">
360 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
361 {commit.message}
362 </a>
363 {v?.verified && (
364 <span
365 title="Signed with a registered key"
366 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"
367 >
368 Verified
369 </span>
370 )}
371 </div>
372 <div class="commit-meta">
373 {commit.author} committed {formatRelativeDate(commit.date)}
374 </div>
fc1817aClaude375 </div>
3951454Claude376 <a
377 href={`/${owner}/${repo}/commit/${commit.sha}`}
378 class="commit-sha"
379 >
380 {commit.sha.slice(0, 7)}
381 </a>
fc1817aClaude382 </div>
3951454Claude383 );
384 })}
fc1817aClaude385 </div>
386);
387
388export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
389 raw,
390 files,
391}) => {
392 const sections = parseDiff(raw);
393
394 return (
395 <div class="diff-view">
396 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
397 Showing{" "}
398 <strong style="color: var(--text)">{files.length}</strong> changed
399 file{files.length !== 1 ? "s" : ""} with{" "}
400 <span class="stat-add">
401 +{files.reduce((s, f) => s + f.additions, 0)}
402 </span>{" "}
403 and{" "}
404 <span class="stat-del">
405 -{files.reduce((s, f) => s + f.deletions, 0)}
406 </span>
407 </div>
408 {sections.map((section) => (
409 <div class="diff-file">
410 <div class="diff-file-header">{section.path}</div>
411 <div class="diff-content">
412 {section.lines.map((line) => {
413 let cls = "line";
414 if (line.startsWith("+")) cls += " line-add";
415 else if (line.startsWith("-")) cls += " line-del";
416 else if (line.startsWith("@@")) cls += " line-hunk";
417 return <span class={cls}>{line + "\n"}</span>;
418 })}
419 </div>
420 </div>
421 ))}
422 </div>
423 );
424};
425
06d5ffeClaude426export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
427 repo,
428 ownerName,
429}) => (
430 <div class="card">
431 <h3>
432 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
433 </h3>
434 {repo.description && <p>{repo.description}</p>}
435 <div class="card-meta">
436 {repo.isPrivate && <span class="badge">Private</span>}
437 <span>{"\u2606"} {repo.starCount}</span>
438 {repo.pushedAt && (
439 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
440 )}
441 </div>
442 </div>
443);
444
fc1817aClaude445function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
446 const sections: Array<{ path: string; lines: string[] }> = [];
447 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
448 let current: { path: string; lines: string[] } | null = null;
449
450 for (const line of raw.split("\n")) {
451 const match = line.match(diffRegex);
452 if (match) {
453 if (current) sections.push(current);
454 current = { path: match[1], lines: [] };
455 continue;
456 }
457 if (current && !line.startsWith("diff --git")) {
458 if (
459 line.startsWith("index ") ||
460 line.startsWith("--- ") ||
461 line.startsWith("+++ ") ||
462 line.startsWith("new file") ||
463 line.startsWith("deleted file") ||
464 line.startsWith("old mode") ||
465 line.startsWith("new mode")
466 ) {
467 continue;
468 }
469 current.lines.push(line);
470 }
471 }
472 if (current) sections.push(current);
473 return sections;
474}
475
476function formatSize(bytes: number): string {
477 if (bytes < 1024) return `${bytes} B`;
478 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
479 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
480}
481
482function formatRelativeDate(dateStr: string): string {
483 const date = new Date(dateStr);
484 const now = new Date();
485 const diffMs = now.getTime() - date.getTime();
486 const diffMins = Math.floor(diffMs / 60000);
487 if (diffMins < 1) return "just now";
488 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
489 const diffHours = Math.floor(diffMins / 60);
490 if (diffHours < 24)
491 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
492 const diffDays = Math.floor(diffHours / 24);
493 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
494 return date.toLocaleDateString("en-US", {
495 month: "short",
496 day: "numeric",
497 year: "numeric",
498 });
499}