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

web.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.

web.tsxBlame5108 lines · 3 contributors
fc1817aClaude1/**
2 * Web UI routes — browse repositories, code, commits, diffs.
06d5ffeClaude3 * Now auth-aware with user profiles, repo creation, stars, and syntax highlighting.
fc1817aClaude4 */
5
6import { Hono } from "hono";
79136bbClaude7import { html } from "hono/html";
8e9f1d9Claude8import { eq, and, desc, inArray, sql } from "drizzle-orm";
06d5ffeClaude9import { db } from "../db";
ea52715copilot-swe-agent[bot]10import { config } from "../lib/config";
3951454Claude11import {
12 users,
13 repositories,
14 stars,
15 commitVerifications,
16} from "../db/schema";
fc1817aClaude17import { Layout } from "../views/layout";
cb5a796Claude18import { PendingCommentsBanner as RepoHomePendingBanner } from "../views/pending-comments-banner";
fc1817aClaude19import {
20 RepoHeader,
21 RepoNav,
22 Breadcrumb,
23 FileTable,
06d5ffeClaude24 RepoCard,
25 BranchSwitcher,
26 HighlightedCode,
27 PlainCode,
fc1817aClaude28} from "../views/components";
ea9ed4cClaude29import { DiffView } from "../views/diff-view";
fc1817aClaude30import {
31 getTree,
32 getBlob,
33 listCommits,
34 getCommit,
35 getCommitFullMessage,
36 getDiff,
37 getReadme,
38 getDefaultBranch,
39 listBranches,
398a10cClaude40 listTags,
fc1817aClaude41 repoExists,
06d5ffeClaude42 initBareRepo,
79136bbClaude43 getBlame,
44 getRawBlob,
45 searchCode,
398a10cClaude46 getRepoPath,
fc1817aClaude47} from "../git/repository";
79136bbClaude48import { renderMarkdown, markdownCss } from "../lib/markdown";
06d5ffeClaude49import { highlightCode } from "../lib/highlight";
91a0204Claude50import { computeHealthScore } from "../lib/health-score";
51import type { HealthScore } from "../lib/health-score";
06d5ffeClaude52import { softAuth, requireAuth } from "../middleware/auth";
53import type { AuthEnv } from "../middleware/auth";
8f50ed0Claude54import { trackByName } from "../lib/traffic";
534f04aClaude55import { LandingPage, type LandingLiveFeed } from "../views/landing";
29924bcClaude56import { Landing2030Page } from "../views/landing-2030";
52ad8b1Claude57import { computePublicStats, type PublicStats } from "../lib/public-stats";
534f04aClaude58import {
59 listQueuedAiBuildIssues,
60 listRecentAutoMerges,
61 listRecentAiReviews,
62 countAiReviewsSince,
63 listDemoActivityFeed,
64} from "../lib/demo-activity";
91a0204Claude65import { computeHealthScore, type HealthScore } from "../lib/health-score";
fc1817aClaude66
06d5ffeClaude67const web = new Hono<AuthEnv>();
68
69// Soft auth on all web routes — c.get("user") available but may be null
70web.use("*", softAuth);
fc1817aClaude71
efb11c5Claude72/**
73 * Shared CSS for the polished code-browse surfaces (parallel session 3.E).
74 *
75 * Inlined here rather than in `src/views/layout.tsx` because session 3.E's
76 * scope is route-local and `layout.tsx` is locked. Each polished handler
77 * injects this via a `<style>` tag; the rules are namespaced by surface
78 * prefix (`.new-repo-*`, `.profile-*`, `.tree-*`, `.blob-*`, `.commits-*`,
79 * `.commit-detail-*`, `.blame-*`, `.search-*`) so nothing bleeds into the
80 * `.repo-home-*` styling Agent A already shipped.
81 */
82const codeBrowseCss = `
83 /* ───────── shared primitives ───────── */
84 .cb-hairline::before,
85 .new-repo-hero::before,
86 .profile-hero::before,
87 .commits-hero::before,
88 .commit-detail-card::before,
89 .search-hero::before {
90 content: '';
91 position: absolute;
92 top: 0; left: 0; right: 0;
93 height: 2px;
94 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
95 opacity: 0.7;
96 pointer-events: none;
97 }
98 @keyframes cbHeroOrb {
99 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
100 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
101 }
102 @media (prefers-reduced-motion: reduce) {
103 .new-repo-hero-orb,
104 .profile-hero-orb,
105 .commits-hero-orb { animation: none; }
106 }
107
108 /* ───────── new-repo ───────── */
109 .new-repo-hero {
110 position: relative;
111 margin-bottom: var(--space-5);
112 padding: var(--space-5) var(--space-6);
113 background: var(--bg-elevated);
114 border: 1px solid var(--border);
115 border-radius: 16px;
116 overflow: hidden;
117 }
118 .new-repo-hero-orb-wrap {
119 position: absolute;
120 inset: -25% -10% auto auto;
121 width: 360px;
122 height: 360px;
123 pointer-events: none;
124 z-index: 0;
125 }
126 .new-repo-hero-orb {
127 position: absolute;
128 inset: 0;
129 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.09) 45%, transparent 70%);
130 filter: blur(80px);
131 opacity: 0.7;
132 animation: cbHeroOrb 14s ease-in-out infinite;
133 }
134 .new-repo-hero-inner { position: relative; z-index: 1; }
135 .new-repo-eyebrow {
136 font-size: 12px;
137 font-family: var(--font-mono);
138 color: var(--text-muted);
139 letter-spacing: 0.1em;
140 text-transform: uppercase;
141 margin-bottom: var(--space-2);
142 }
143 .new-repo-eyebrow strong { color: var(--accent); font-weight: 600; }
144 .new-repo-title {
145 font-family: var(--font-display);
146 font-weight: 800;
147 letter-spacing: -0.028em;
148 font-size: clamp(28px, 4vw, 40px);
149 line-height: 1.05;
150 margin: 0 0 var(--space-2);
151 color: var(--text-strong);
152 }
153 .new-repo-sub {
154 font-size: 15px;
155 color: var(--text-muted);
156 margin: 0;
157 line-height: 1.55;
158 max-width: 620px;
159 }
160 .new-repo-form {
161 max-width: 680px;
162 }
163 .new-repo-error {
164 background: rgba(218, 54, 51, 0.12);
165 border: 1px solid rgba(218, 54, 51, 0.35);
166 color: #ffb3b3;
167 padding: 10px 14px;
168 border-radius: 10px;
169 margin-bottom: var(--space-4);
170 font-size: 14px;
171 }
172 .new-repo-form-grid {
173 display: flex;
174 flex-direction: column;
175 gap: var(--space-4);
176 }
177 .new-repo-row { display: flex; flex-direction: column; gap: 6px; }
178 .new-repo-label {
179 font-size: 13px;
180 color: var(--text-strong);
181 font-weight: 600;
182 }
183 .new-repo-label-optional {
184 color: var(--text-muted);
185 font-weight: 400;
186 font-size: 12px;
187 }
188 .new-repo-input {
189 appearance: none;
190 width: 100%;
191 background: var(--bg);
192 border: 1px solid var(--border);
193 color: var(--text-strong);
194 border-radius: 10px;
195 padding: 10px 12px;
196 font-size: 14px;
197 font-family: inherit;
198 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
199 }
200 .new-repo-input:focus {
201 outline: none;
202 border-color: var(--accent);
203 box-shadow: 0 0 0 3px rgba(140,109,255,0.18);
204 }
205 .new-repo-input-disabled {
206 color: var(--text-muted);
207 background: var(--bg-secondary);
208 cursor: not-allowed;
209 }
210 .new-repo-hint {
211 font-size: 12px;
212 color: var(--text-muted);
213 margin: 4px 0 0;
214 }
215 .new-repo-hint code {
216 font-family: var(--font-mono);
217 font-size: 11.5px;
218 background: var(--bg-secondary);
219 border: 1px solid var(--border);
220 border-radius: 5px;
221 padding: 1px 5px;
222 color: var(--text-strong);
223 }
224 .new-repo-visibility {
225 display: grid;
226 grid-template-columns: 1fr 1fr;
227 gap: var(--space-2);
228 }
229 @media (max-width: 600px) {
230 .new-repo-visibility { grid-template-columns: 1fr; }
231 }
232 .new-repo-vis-card {
233 display: flex;
234 gap: 10px;
235 padding: 14px;
236 background: var(--bg);
237 border: 1px solid var(--border);
238 border-radius: 12px;
239 cursor: pointer;
240 transition: border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
241 }
242 .new-repo-vis-card:hover { border-color: var(--border-strong, var(--border)); }
243 .new-repo-vis-card:has(input:checked) {
244 border-color: rgba(140,109,255,0.55);
245 background: rgba(140,109,255,0.06);
246 box-shadow: 0 0 0 1px rgba(140,109,255,0.25);
247 }
248 .new-repo-vis-radio {
249 margin-top: 3px;
250 accent-color: var(--accent);
251 }
252 .new-repo-vis-body { display: flex; flex-direction: column; gap: 4px; }
253 .new-repo-vis-label {
254 font-size: 14px;
255 font-weight: 600;
256 color: var(--text-strong);
257 }
258 .new-repo-vis-desc {
259 font-size: 12.5px;
260 color: var(--text-muted);
261 line-height: 1.45;
262 }
263 .new-repo-callout {
264 margin-top: var(--space-2);
265 padding: var(--space-3) var(--space-4);
266 background: var(--accent-gradient-faint, rgba(140,109,255,0.06));
267 border: 1px solid rgba(140,109,255,0.2);
268 border-radius: 12px;
269 }
270 .new-repo-callout-eyebrow {
271 font-size: 11px;
272 font-family: var(--font-mono);
273 text-transform: uppercase;
274 letter-spacing: 0.12em;
275 color: var(--accent);
276 font-weight: 700;
277 margin-bottom: 4px;
278 }
279 .new-repo-callout-body {
280 font-size: 13px;
281 color: var(--text);
282 line-height: 1.5;
283 margin: 0;
284 }
285 .new-repo-callout-body code {
286 font-family: var(--font-mono);
287 font-size: 12px;
288 color: var(--accent);
289 background: rgba(140,109,255,0.1);
290 border-radius: 4px;
291 padding: 1px 5px;
292 }
398a10cClaude293 .new-repo-templates {
294 display: flex;
295 flex-wrap: wrap;
296 gap: 8px;
297 margin-top: 4px;
298 }
299 .new-repo-template-chip {
300 position: relative;
301 display: inline-flex;
302 align-items: center;
303 gap: 6px;
304 padding: 8px 14px;
305 background: var(--bg);
306 border: 1px solid var(--border);
307 border-radius: 999px;
308 font-size: 13px;
309 color: var(--text);
310 cursor: pointer;
311 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
312 }
313 .new-repo-template-chip input { position: absolute; opacity: 0; pointer-events: none; }
314 .new-repo-template-chip:hover {
315 border-color: var(--border-strong, var(--border));
316 color: var(--text-strong);
317 }
318 .new-repo-template-chip:has(input:checked) {
319 border-color: rgba(140,109,255,0.55);
320 background: rgba(140,109,255,0.10);
321 color: var(--text-strong);
322 box-shadow: 0 0 0 1px rgba(140,109,255,0.25);
323 }
324 .new-repo-template-chip-dot {
325 width: 8px; height: 8px;
326 border-radius: 999px;
327 background: var(--text-faint, var(--text-muted));
328 transition: background 140ms ease, box-shadow 140ms ease;
329 }
330 .new-repo-template-chip:has(input:checked) .new-repo-template-chip-dot {
331 background: linear-gradient(135deg, #8c6dff, #36c5d6);
332 box-shadow: 0 0 8px rgba(140,109,255,0.6);
333 }
efb11c5Claude334 .new-repo-actions {
335 display: flex;
336 gap: var(--space-2);
337 margin-top: var(--space-2);
398a10cClaude338 align-items: center;
339 }
340 .new-repo-submit {
341 min-width: 180px;
342 border: 1px solid rgba(140,109,255,0.45);
343 background: linear-gradient(135deg, #8c6dff 0%, #36c5d6 100%);
344 color: #fff;
345 font-weight: 700;
346 box-shadow: 0 8px 20px -8px rgba(140,109,255,0.55);
347 transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
348 }
349 .new-repo-submit:hover {
350 transform: translateY(-1px);
351 box-shadow: 0 12px 24px -8px rgba(140,109,255,0.7);
352 filter: brightness(1.06);
353 }
354 .new-repo-submit:focus-visible {
355 outline: 3px solid rgba(140,109,255,0.45);
356 outline-offset: 2px;
efb11c5Claude357 }
358
359 /* ───────── profile ───────── */
360 .profile-hero {
361 position: relative;
362 margin-bottom: var(--space-5);
363 padding: var(--space-5) var(--space-6);
364 background: var(--bg-elevated);
365 border: 1px solid var(--border);
366 border-radius: 16px;
367 overflow: hidden;
368 }
369 .profile-hero-orb-wrap {
370 position: absolute;
371 inset: -25% -10% auto auto;
372 width: 360px;
373 height: 360px;
374 pointer-events: none;
375 z-index: 0;
376 }
377 .profile-hero-orb {
378 position: absolute;
379 inset: 0;
380 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.09) 45%, transparent 70%);
381 filter: blur(80px);
382 opacity: 0.7;
383 animation: cbHeroOrb 14s ease-in-out infinite;
384 }
385 .profile-hero-inner {
386 position: relative;
387 z-index: 1;
388 display: flex;
389 align-items: flex-start;
390 gap: var(--space-5);
391 }
392 .profile-hero-avatar {
393 flex: 0 0 auto;
394 width: 88px;
395 height: 88px;
396 border-radius: 50%;
397 background: linear-gradient(135deg, #8c6dff 0%, #36c5d6 100%);
398 color: #fff;
399 display: flex;
400 align-items: center;
401 justify-content: center;
402 font-size: 38px;
403 font-weight: 700;
404 font-family: var(--font-display);
405 box-shadow: 0 8px 24px -8px rgba(140,109,255,0.55);
406 }
407 .profile-hero-text { flex: 1; min-width: 0; }
408 .profile-eyebrow {
409 font-size: 12px;
410 font-family: var(--font-mono);
411 color: var(--text-muted);
412 letter-spacing: 0.1em;
413 text-transform: uppercase;
414 margin-bottom: var(--space-2);
415 }
416 .profile-eyebrow strong { color: var(--accent); font-weight: 600; }
417 .profile-name {
418 font-family: var(--font-display);
419 font-weight: 800;
420 letter-spacing: -0.028em;
421 font-size: clamp(28px, 3.6vw, 36px);
422 line-height: 1.05;
423 margin: 0 0 4px;
424 color: var(--text-strong);
425 }
426 .profile-handle {
427 font-family: var(--font-mono);
428 font-size: 13px;
429 color: var(--text-muted);
430 margin-bottom: var(--space-2);
431 }
432 .profile-bio {
433 font-size: 14.5px;
434 color: var(--text);
435 line-height: 1.55;
436 margin: 0 0 var(--space-3);
437 max-width: 640px;
438 }
439 .profile-meta {
440 display: flex;
441 align-items: center;
442 gap: var(--space-4);
443 flex-wrap: wrap;
444 font-size: 13px;
445 }
446 .profile-meta-link {
447 color: var(--text-muted);
448 transition: color var(--t-fast, 0.15s) ease;
449 }
450 .profile-meta-link:hover { color: var(--accent); text-decoration: none; }
451 .profile-meta-link strong {
452 color: var(--text-strong);
453 font-weight: 600;
454 font-variant-numeric: tabular-nums;
455 }
456 .profile-follow-form { margin: 0; }
457 @media (max-width: 600px) {
458 .profile-hero-inner { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
459 .profile-hero-avatar { width: 64px; height: 64px; font-size: 28px; }
460 }
461 .profile-readme {
462 margin-bottom: var(--space-6);
463 background: var(--bg-elevated);
464 border: 1px solid var(--border);
465 border-radius: 12px;
466 overflow: hidden;
467 }
468 .profile-readme-head {
469 display: flex;
470 align-items: center;
471 gap: 8px;
472 padding: 10px 16px;
473 background: var(--bg-secondary);
474 border-bottom: 1px solid var(--border);
475 font-size: 13px;
476 color: var(--text-muted);
477 }
478 .profile-readme-icon { color: var(--accent); font-size: 14px; }
479 .profile-readme-body { padding: var(--space-5) var(--space-6); }
480 .profile-section-head {
481 display: flex;
482 align-items: baseline;
483 gap: var(--space-2);
484 margin-bottom: var(--space-3);
485 }
486 .profile-section-title {
487 font-family: var(--font-display);
488 font-weight: 700;
489 font-size: 20px;
490 letter-spacing: -0.015em;
491 margin: 0;
492 color: var(--text-strong);
493 }
494 .profile-section-count {
495 font-family: var(--font-mono);
496 font-size: 12px;
497 color: var(--text-muted);
498 background: var(--bg-secondary);
499 border: 1px solid var(--border);
500 border-radius: 999px;
501 padding: 2px 10px;
502 font-variant-numeric: tabular-nums;
503 }
504 .profile-empty {
505 display: flex;
506 align-items: center;
507 justify-content: space-between;
508 gap: var(--space-3);
509 padding: var(--space-4) var(--space-5);
510 background: var(--bg-elevated);
511 border: 1px dashed var(--border);
512 border-radius: 12px;
513 }
514 .profile-empty-text { color: var(--text-muted); font-size: 14px; margin: 0; }
515
516 /* ───────── tree (file browser) ───────── */
517 .tree-header {
518 margin-bottom: var(--space-3);
519 display: flex;
520 flex-direction: column;
521 gap: var(--space-2);
522 }
523 .tree-header-row {
524 display: flex;
525 align-items: center;
526 justify-content: space-between;
527 gap: var(--space-3);
528 flex-wrap: wrap;
529 }
530 .tree-header-stats {
531 display: flex;
532 align-items: center;
533 gap: var(--space-3);
534 font-size: 12px;
535 color: var(--text-muted);
536 }
537 .tree-stat strong {
538 color: var(--text-strong);
539 font-weight: 600;
540 font-variant-numeric: tabular-nums;
541 }
542 .tree-stat-link {
543 color: var(--text-muted);
544 padding: 4px 10px;
545 border-radius: 999px;
546 border: 1px solid var(--border);
547 background: var(--bg-elevated);
548 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease;
549 }
550 .tree-stat-link:hover {
551 color: var(--accent);
552 border-color: rgba(140,109,255,0.45);
553 text-decoration: none;
554 }
555 .tree-breadcrumb-row {
556 font-size: 13px;
557 }
558
559 /* ───────── blob (file viewer) ───────── */
560 .blob-toolbar {
561 margin-bottom: var(--space-3);
562 display: flex;
563 flex-direction: column;
564 gap: var(--space-2);
565 }
566 .blob-breadcrumb { font-size: 13px; }
567 .blob-card {
568 background: var(--bg-elevated);
569 border: 1px solid var(--border);
570 border-radius: 12px;
571 overflow: hidden;
572 }
573 .blob-header-polished {
574 display: flex;
575 align-items: center;
576 justify-content: space-between;
577 gap: var(--space-3);
578 padding: 10px 14px;
579 background: var(--bg-secondary);
580 border-bottom: 1px solid var(--border);
581 }
582 .blob-header-meta {
583 display: flex;
584 align-items: center;
585 gap: var(--space-2);
586 min-width: 0;
587 flex: 1;
588 }
589 .blob-header-icon { font-size: 14px; opacity: 0.85; }
590 .blob-header-name {
591 font-family: var(--font-mono);
592 font-size: 13px;
593 color: var(--text-strong);
594 font-weight: 600;
595 overflow: hidden;
596 text-overflow: ellipsis;
597 white-space: nowrap;
598 }
599 .blob-header-size {
600 font-family: var(--font-mono);
601 font-size: 11.5px;
602 color: var(--text-muted);
603 font-variant-numeric: tabular-nums;
604 border-left: 1px solid var(--border);
605 padding-left: var(--space-2);
606 margin-left: 2px;
607 }
608 .blob-header-actions {
609 display: flex;
610 gap: 6px;
611 flex-shrink: 0;
612 }
613 .blob-pill {
614 display: inline-flex;
615 align-items: center;
616 padding: 4px 12px;
617 font-size: 12px;
618 font-weight: 500;
619 color: var(--text);
620 background: var(--bg-elevated);
621 border: 1px solid var(--border);
622 border-radius: 999px;
623 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
624 }
625 .blob-pill:hover {
626 color: var(--accent);
627 border-color: rgba(140,109,255,0.45);
628 text-decoration: none;
629 background: rgba(140,109,255,0.06);
630 }
631 .blob-pill-accent {
632 color: var(--accent);
633 border-color: rgba(140,109,255,0.35);
634 background: rgba(140,109,255,0.08);
635 }
636 .blob-pill-accent:hover {
637 background: rgba(140,109,255,0.14);
638 }
639 .blob-binary {
640 padding: var(--space-5);
641 color: var(--text-muted);
642 text-align: center;
643 font-size: 13px;
644 background: var(--bg);
645 }
646
647 /* ───────── commits list ───────── */
648 .commits-hero {
649 position: relative;
650 margin-bottom: var(--space-4);
651 padding: var(--space-5) var(--space-6);
652 background: var(--bg-elevated);
653 border: 1px solid var(--border);
654 border-radius: 16px;
655 overflow: hidden;
656 }
657 .commits-hero-orb-wrap {
658 position: absolute;
659 inset: -25% -10% auto auto;
660 width: 320px;
661 height: 320px;
662 pointer-events: none;
663 z-index: 0;
664 }
665 .commits-hero-orb {
666 position: absolute;
667 inset: 0;
668 background: radial-gradient(circle, rgba(140,109,255,0.16), rgba(54,197,214,0.08) 45%, transparent 70%);
669 filter: blur(80px);
670 opacity: 0.7;
671 animation: cbHeroOrb 14s ease-in-out infinite;
672 }
673 .commits-hero-inner { position: relative; z-index: 1; }
674 .commits-eyebrow {
675 font-size: 12px;
676 font-family: var(--font-mono);
677 color: var(--text-muted);
678 letter-spacing: 0.1em;
679 text-transform: uppercase;
680 margin-bottom: var(--space-2);
681 }
682 .commits-eyebrow strong { color: var(--accent); font-weight: 600; }
683 .commits-title {
684 font-family: var(--font-display);
685 font-weight: 800;
686 letter-spacing: -0.025em;
687 font-size: clamp(22px, 3vw, 30px);
688 line-height: 1.15;
689 margin: 0 0 var(--space-2);
690 color: var(--text-strong);
691 }
692 .commits-branch {
693 font-family: var(--font-mono);
694 font-size: 0.7em;
695 color: var(--text);
696 background: var(--bg-secondary);
697 border: 1px solid var(--border);
698 border-radius: 6px;
699 padding: 2px 8px;
700 font-weight: 500;
701 vertical-align: middle;
702 }
703 .commits-sub {
704 font-size: 14px;
705 color: var(--text-muted);
706 margin: 0;
707 line-height: 1.55;
708 max-width: 640px;
709 }
398a10cClaude710 .commits-toolbar {
711 display: flex;
712 justify-content: space-between;
713 align-items: center;
714 flex-wrap: wrap;
715 gap: var(--space-2);
716 margin-bottom: var(--space-3);
717 }
718 .commits-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
719 .commits-toolbar-link {
720 display: inline-flex;
721 align-items: center;
722 gap: 6px;
723 padding: 6px 12px;
724 font-size: 12.5px;
725 font-weight: 500;
726 color: var(--text-muted);
727 background: rgba(255,255,255,0.025);
728 border: 1px solid var(--border);
729 border-radius: 8px;
730 text-decoration: none;
731 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
732 }
733 .commits-toolbar-link:hover {
734 border-color: var(--border-strong);
735 color: var(--text-strong);
736 background: rgba(255,255,255,0.04);
737 text-decoration: none;
738 }
efb11c5Claude739 .commits-list-wrap {
740 background: var(--bg-elevated);
741 border: 1px solid var(--border);
398a10cClaude742 border-radius: 14px;
efb11c5Claude743 overflow: hidden;
398a10cClaude744 position: relative;
745 }
746 .commits-list-wrap::before {
747 content: '';
748 position: absolute;
749 top: 0; left: 0; right: 0;
750 height: 2px;
751 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
752 opacity: 0.55;
753 pointer-events: none;
754 }
755 .commits-day-head {
756 display: flex;
757 align-items: center;
758 gap: 10px;
759 padding: 10px 18px;
760 font-size: 11.5px;
761 font-family: var(--font-mono);
762 text-transform: uppercase;
763 letter-spacing: 0.08em;
764 color: var(--text-muted);
765 background: var(--bg-secondary);
766 border-bottom: 1px solid var(--border);
767 }
768 .commits-day-head:not(:first-child) { border-top: 1px solid var(--border); }
769 .commits-day-head-dot {
770 width: 6px; height: 6px;
771 border-radius: 9999px;
772 background: linear-gradient(135deg, #8c6dff, #36c5d6);
773 }
774 .commits-row {
775 display: flex;
776 align-items: flex-start;
777 gap: 14px;
778 padding: 14px 18px;
779 border-bottom: 1px solid var(--border-subtle);
780 transition: background 120ms ease;
781 }
782 .commits-row:last-child { border-bottom: none; }
783 .commits-row:hover { background: rgba(255,255,255,0.022); }
784 .commits-avatar {
785 width: 34px; height: 34px;
786 border-radius: 9999px;
787 background: linear-gradient(135deg, rgba(140,109,255,0.30), rgba(54,197,214,0.25));
788 color: #fff;
789 display: inline-flex;
790 align-items: center;
791 justify-content: center;
792 font-family: var(--font-display);
793 font-weight: 700;
794 font-size: 13.5px;
795 flex-shrink: 0;
796 box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
797 }
798 .commits-row-body { flex: 1; min-width: 0; }
799 .commits-row-msg {
800 display: flex;
801 align-items: center;
802 gap: 8px;
803 flex-wrap: wrap;
804 }
805 .commits-row-msg a {
806 font-family: var(--font-display);
807 font-weight: 600;
808 font-size: 14px;
809 color: var(--text-strong);
810 text-decoration: none;
811 letter-spacing: -0.005em;
812 }
813 .commits-row-msg a:hover { color: var(--accent); text-decoration: none; }
814 .commits-row-verified {
815 font-size: 9.5px;
816 padding: 1px 7px;
817 border-radius: 9999px;
818 background: rgba(52,211,153,0.16);
819 color: #6ee7b7;
820 box-shadow: inset 0 0 0 1px rgba(52,211,153,0.30);
821 text-transform: uppercase;
822 letter-spacing: 0.06em;
823 font-weight: 700;
824 }
825 .commits-row-meta {
826 margin-top: 4px;
827 display: flex;
828 align-items: center;
829 gap: 8px;
830 flex-wrap: wrap;
831 font-size: 12.5px;
832 color: var(--text-muted);
833 }
834 .commits-row-meta strong { color: var(--text); font-weight: 600; }
835 .commits-row-meta .sep { opacity: 0.4; }
836 .commits-row-time {
837 font-variant-numeric: tabular-nums;
838 }
839 .commits-row-side {
840 display: flex;
841 align-items: center;
842 gap: 8px;
843 flex-shrink: 0;
844 }
845 .commits-row-sha {
846 display: inline-flex;
847 align-items: center;
848 padding: 4px 10px;
849 border-radius: 9999px;
850 font-family: var(--font-mono);
851 font-size: 11.5px;
852 font-weight: 600;
853 color: var(--text-strong);
854 background: rgba(255,255,255,0.04);
855 border: 1px solid var(--border);
856 text-decoration: none;
857 letter-spacing: 0.04em;
858 transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
859 }
860 .commits-row-sha:hover {
861 border-color: rgba(140,109,255,0.55);
862 color: var(--accent);
863 background: rgba(140,109,255,0.08);
864 text-decoration: none;
865 }
866 .commits-row-copy {
867 display: inline-flex;
868 align-items: center;
869 justify-content: center;
870 width: 28px; height: 28px;
871 padding: 0;
872 border-radius: 8px;
873 background: transparent;
874 border: 1px solid var(--border);
875 color: var(--text-muted);
876 cursor: pointer;
877 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
efb11c5Claude878 }
398a10cClaude879 .commits-row-copy:hover {
880 border-color: var(--border-strong);
881 color: var(--text);
882 background: rgba(255,255,255,0.04);
883 }
884 .commits-row-copy.is-copied { color: #6ee7b7; border-color: rgba(52,211,153,0.35); }
efb11c5Claude885 .commits-empty {
398a10cClaude886 position: relative;
887 overflow: hidden;
888 padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 36px);
efb11c5Claude889 text-align: center;
398a10cClaude890 background: var(--bg-elevated);
891 border: 1px dashed var(--border-strong);
892 border-radius: 16px;
893 }
894 .commits-empty-orb {
895 position: absolute;
896 inset: -40% 30% auto 30%;
897 height: 280px;
898 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.10) 45%, transparent 70%);
899 filter: blur(70px);
900 opacity: 0.7;
901 pointer-events: none;
902 z-index: 0;
903 }
904 .commits-empty-inner { position: relative; z-index: 1; }
905 .commits-empty-icon {
906 width: 56px; height: 56px;
907 border-radius: 9999px;
908 background: linear-gradient(135deg, rgba(140,109,255,0.25), rgba(54,197,214,0.20));
909 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.40);
910 display: inline-flex;
911 align-items: center;
912 justify-content: center;
913 color: #c4b5fd;
914 margin: 0 auto 14px;
915 }
916 .commits-empty-title {
917 font-family: var(--font-display);
918 font-size: 18px;
919 font-weight: 700;
920 margin: 0 0 6px;
921 color: var(--text-strong);
922 }
923 .commits-empty-sub {
924 margin: 0 auto 0;
925 font-size: 13.5px;
efb11c5Claude926 color: var(--text-muted);
398a10cClaude927 max-width: 420px;
928 line-height: 1.5;
929 }
930
931 /* ───────── branches list ───────── */
932 .branches-list {
efb11c5Claude933 background: var(--bg-elevated);
398a10cClaude934 border: 1px solid var(--border);
935 border-radius: 14px;
936 overflow: hidden;
937 position: relative;
938 }
939 .branches-list::before {
940 content: '';
941 position: absolute;
942 top: 0; left: 0; right: 0;
943 height: 2px;
944 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
945 opacity: 0.55;
946 pointer-events: none;
947 }
948 .branches-row {
949 display: flex;
950 align-items: center;
951 gap: var(--space-3);
952 padding: 14px 18px;
953 border-bottom: 1px solid var(--border-subtle);
954 transition: background 120ms ease;
955 flex-wrap: wrap;
956 }
957 .branches-row:last-child { border-bottom: none; }
958 .branches-row:hover { background: rgba(255,255,255,0.022); }
959 .branches-row-icon {
960 width: 32px; height: 32px;
961 border-radius: 8px;
962 background: rgba(140,109,255,0.10);
963 color: #c4b5fd;
964 display: inline-flex;
965 align-items: center;
966 justify-content: center;
967 flex-shrink: 0;
968 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.22);
969 }
970 .branches-row-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
971 .branches-row-name {
972 display: inline-flex;
973 align-items: center;
974 gap: 8px;
975 flex-wrap: wrap;
976 }
977 .branches-row-name a {
978 font-family: var(--font-mono);
979 font-size: 13.5px;
980 color: var(--text-strong);
981 font-weight: 600;
982 text-decoration: none;
983 }
984 .branches-row-name a:hover { color: var(--accent); text-decoration: none; }
985 .branches-row-default {
986 font-size: 10px;
987 padding: 2px 8px;
988 border-radius: 9999px;
989 background: rgba(140,109,255,0.14);
990 color: #c4b5fd;
991 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.30);
992 text-transform: uppercase;
993 letter-spacing: 0.08em;
994 font-weight: 700;
995 font-family: var(--font-mono);
996 }
997 .branches-row-meta {
998 display: flex;
999 align-items: center;
1000 gap: 8px;
1001 flex-wrap: wrap;
1002 font-size: 12.5px;
1003 color: var(--text-muted);
1004 font-variant-numeric: tabular-nums;
1005 }
1006 .branches-row-meta .sep { opacity: 0.4; }
1007 .branches-row-meta strong { color: var(--text); font-weight: 600; }
1008 .branches-row-side {
1009 display: flex;
1010 align-items: center;
1011 gap: 10px;
1012 flex-shrink: 0;
1013 flex-wrap: wrap;
1014 }
1015 .branches-row-divergence {
1016 display: inline-flex;
1017 align-items: center;
1018 gap: 8px;
1019 font-family: var(--font-mono);
1020 font-size: 11.5px;
1021 color: var(--text-muted);
1022 padding: 4px 10px;
1023 border-radius: 9999px;
1024 background: rgba(255,255,255,0.035);
1025 border: 1px solid var(--border);
1026 font-variant-numeric: tabular-nums;
1027 }
1028 .branches-row-divergence .ahead { color: #6ee7b7; }
1029 .branches-row-divergence .behind { color: #fca5a5; }
1030 .branches-row-actions {
1031 display: flex;
1032 align-items: center;
1033 gap: 6px;
1034 }
1035 .branches-btn {
1036 display: inline-flex;
1037 align-items: center;
1038 gap: 5px;
1039 padding: 6px 12px;
1040 border-radius: 9999px;
1041 font-size: 12px;
1042 font-weight: 600;
1043 text-decoration: none;
1044 border: 1px solid var(--border);
1045 background: transparent;
1046 color: var(--text-muted);
1047 cursor: pointer;
1048 font: inherit;
1049 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1050 }
1051 .branches-btn:hover {
1052 border-color: var(--border-strong);
1053 color: var(--text);
1054 background: rgba(255,255,255,0.04);
1055 text-decoration: none;
1056 }
1057 .branches-btn-danger {
1058 color: #fca5a5;
1059 border-color: rgba(248,113,113,0.30);
1060 }
1061 .branches-btn-danger:hover {
1062 border-style: dashed;
1063 border-color: rgba(248,113,113,0.65);
1064 background: rgba(248,113,113,0.06);
1065 color: #fecaca;
1066 }
1067
1068 /* ───────── tags list ───────── */
1069 .tags-list {
1070 background: var(--bg-elevated);
1071 border: 1px solid var(--border);
1072 border-radius: 14px;
1073 overflow: hidden;
1074 position: relative;
1075 }
1076 .tags-list::before {
1077 content: '';
1078 position: absolute;
1079 top: 0; left: 0; right: 0;
1080 height: 2px;
1081 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
1082 opacity: 0.55;
1083 pointer-events: none;
1084 }
1085 .tags-row {
1086 display: flex;
1087 align-items: center;
1088 gap: var(--space-3);
1089 padding: 14px 18px;
1090 border-bottom: 1px solid var(--border-subtle);
1091 transition: background 120ms ease;
1092 flex-wrap: wrap;
1093 }
1094 .tags-row:last-child { border-bottom: none; }
1095 .tags-row:hover { background: rgba(255,255,255,0.022); }
1096 .tags-row-icon {
1097 width: 32px; height: 32px;
1098 border-radius: 8px;
1099 background: rgba(54,197,214,0.10);
1100 color: #67e8f9;
1101 display: inline-flex;
1102 align-items: center;
1103 justify-content: center;
1104 flex-shrink: 0;
1105 box-shadow: inset 0 0 0 1px rgba(54,197,214,0.22);
1106 }
1107 .tags-row-main { flex: 1; min-width: 240px; }
1108 .tags-row-name {
1109 display: inline-flex;
1110 align-items: center;
1111 gap: 8px;
1112 flex-wrap: wrap;
1113 }
1114 .tags-row-version {
1115 display: inline-flex;
1116 align-items: center;
1117 padding: 3px 11px;
1118 border-radius: 9999px;
1119 font-family: var(--font-mono);
1120 font-size: 13px;
1121 font-weight: 700;
1122 color: #67e8f9;
1123 background: rgba(54,197,214,0.12);
1124 box-shadow: inset 0 0 0 1px rgba(54,197,214,0.30);
1125 letter-spacing: 0.01em;
1126 }
1127 .tags-row-meta {
1128 margin-top: 4px;
1129 display: flex;
1130 align-items: center;
1131 gap: 8px;
1132 flex-wrap: wrap;
1133 font-size: 12.5px;
1134 color: var(--text-muted);
1135 font-variant-numeric: tabular-nums;
1136 }
1137 .tags-row-meta .sep { opacity: 0.4; }
1138 .tags-row-sha {
1139 font-family: var(--font-mono);
1140 font-size: 11.5px;
1141 color: var(--text-strong);
1142 padding: 2px 8px;
1143 border-radius: 6px;
1144 background: rgba(255,255,255,0.04);
1145 border: 1px solid var(--border);
1146 text-decoration: none;
1147 letter-spacing: 0.04em;
1148 }
1149 .tags-row-sha:hover { border-color: var(--border-strong); color: var(--accent); text-decoration: none; }
1150 .tags-row-side {
1151 display: flex;
1152 align-items: center;
1153 gap: 6px;
1154 flex-shrink: 0;
1155 flex-wrap: wrap;
1156 }
1157 .tags-row-link {
1158 display: inline-flex;
1159 align-items: center;
1160 gap: 5px;
1161 padding: 6px 12px;
1162 border-radius: 9999px;
1163 font-size: 12px;
1164 font-weight: 600;
1165 text-decoration: none;
1166 color: var(--text-muted);
1167 background: rgba(255,255,255,0.025);
1168 border: 1px solid var(--border);
1169 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1170 }
1171 .tags-row-link:hover {
1172 border-color: rgba(140,109,255,0.45);
1173 color: var(--text-strong);
1174 background: rgba(140,109,255,0.06);
1175 text-decoration: none;
efb11c5Claude1176 }
1177
1178 /* ───────── commit detail ───────── */
1179 .commit-detail-card {
1180 position: relative;
1181 margin-bottom: var(--space-5);
1182 padding: var(--space-5) var(--space-5);
1183 background: var(--bg-elevated);
1184 border: 1px solid var(--border);
1185 border-radius: 14px;
1186 overflow: hidden;
1187 }
1188 .commit-detail-eyebrow {
1189 display: flex;
1190 align-items: center;
1191 gap: var(--space-2);
1192 font-size: 12px;
1193 font-family: var(--font-mono);
1194 text-transform: uppercase;
1195 letter-spacing: 0.1em;
1196 color: var(--text-muted);
1197 margin-bottom: var(--space-2);
1198 }
1199 .commit-detail-eyebrow strong { color: var(--accent); font-weight: 600; }
1200 .commit-detail-sha-pill {
1201 font-family: var(--font-mono);
1202 font-size: 11.5px;
1203 color: var(--text-strong);
1204 background: var(--bg-secondary);
1205 border: 1px solid var(--border);
1206 border-radius: 999px;
1207 padding: 2px 10px;
1208 letter-spacing: 0.04em;
1209 }
1210 .commit-detail-verify {
1211 font-size: 10px;
1212 padding: 2px 8px;
1213 border-radius: 999px;
1214 text-transform: uppercase;
1215 letter-spacing: 0.06em;
1216 font-weight: 700;
1217 color: #fff;
1218 }
1219 .commit-detail-verify-ok {
1220 background: linear-gradient(135deg, #2ea043, #34d399);
1221 }
1222 .commit-detail-verify-warn {
1223 background: linear-gradient(135deg, #d29922, #f59e0b);
1224 }
1225 .commit-detail-title {
1226 font-family: var(--font-display);
1227 font-weight: 700;
1228 letter-spacing: -0.018em;
1229 font-size: clamp(20px, 2.5vw, 26px);
1230 line-height: 1.25;
1231 margin: 0 0 var(--space-2);
1232 color: var(--text-strong);
1233 }
1234 .commit-detail-body {
1235 white-space: pre-wrap;
1236 color: var(--text-muted);
1237 font-size: 14px;
1238 line-height: 1.55;
1239 margin: 0 0 var(--space-3);
1240 font-family: var(--font-mono);
1241 background: var(--bg);
1242 border: 1px solid var(--border);
1243 border-radius: 8px;
1244 padding: var(--space-3) var(--space-4);
1245 max-height: 280px;
1246 overflow: auto;
1247 }
1248 .commit-detail-meta {
1249 display: flex;
1250 flex-wrap: wrap;
1251 gap: var(--space-3);
1252 font-size: 13px;
1253 color: var(--text-muted);
1254 margin-bottom: var(--space-3);
1255 }
1256 .commit-detail-author strong { color: var(--text-strong); font-weight: 600; }
1257 .commit-detail-parents { font-size: 13px; color: var(--text-muted); }
1258 .commit-detail-sha-link {
1259 font-family: var(--font-mono);
1260 font-size: 12.5px;
1261 color: var(--accent);
1262 background: rgba(140,109,255,0.08);
1263 border-radius: 6px;
1264 padding: 1px 6px;
1265 margin-left: 2px;
1266 }
1267 .commit-detail-sha-link:hover { background: rgba(140,109,255,0.16); text-decoration: none; }
1268 .commit-detail-stats {
1269 display: flex;
1270 flex-wrap: wrap;
1271 align-items: center;
1272 gap: var(--space-3);
1273 padding-top: var(--space-3);
1274 border-top: 1px solid var(--border);
1275 font-size: 13px;
1276 color: var(--text-muted);
1277 }
1278 .commit-detail-stat {
1279 display: inline-flex;
1280 align-items: center;
1281 gap: 4px;
1282 font-variant-numeric: tabular-nums;
1283 }
1284 .commit-detail-stat strong { color: var(--text-strong); font-weight: 600; }
1285 .commit-detail-stat-add strong { color: #34d399; }
1286 .commit-detail-stat-del strong { color: #f87171; }
1287 .commit-detail-stat-mark {
1288 font-family: var(--font-mono);
1289 font-weight: 700;
1290 font-size: 14px;
1291 }
1292 .commit-detail-stat-add .commit-detail-stat-mark { color: #34d399; }
1293 .commit-detail-stat-del .commit-detail-stat-mark { color: #f87171; }
1294 .commit-detail-sha-full {
1295 margin-left: auto;
1296 font-family: var(--font-mono);
1297 font-size: 11.5px;
1298 color: var(--text-faint);
1299 letter-spacing: 0.02em;
1300 overflow: hidden;
1301 text-overflow: ellipsis;
1302 white-space: nowrap;
1303 max-width: 100%;
1304 }
1305 .commit-detail-checks {
1306 margin-top: var(--space-3);
1307 padding-top: var(--space-3);
1308 border-top: 1px solid var(--border);
1309 }
1310 .commit-detail-checks-head {
1311 display: flex;
1312 align-items: center;
1313 gap: var(--space-2);
1314 font-size: 13px;
1315 color: var(--text-muted);
1316 margin-bottom: 8px;
1317 }
1318 .commit-detail-checks-head strong { color: var(--text-strong); font-weight: 600; }
1319 .commit-detail-check-state-success { color: #34d399; font-weight: 600; }
1320 .commit-detail-check-state-failure { color: #f87171; font-weight: 600; }
1321 .commit-detail-check-state-pending { color: #d29922; font-weight: 600; }
1322 .commit-detail-check-row { display: flex; flex-wrap: wrap; gap: 6px; }
1323 .commit-detail-check {
1324 font-size: 11px;
1325 padding: 2px 8px;
1326 border-radius: 999px;
1327 color: #fff;
1328 font-weight: 500;
1329 }
398a10cClaude1330 .commit-detail-check a { color: inherit; text-decoration: none; }
1331 .commit-detail-check-success { background: #2ea043; }
1332 .commit-detail-check-pending { background: #d29922; }
1333 .commit-detail-check-failure { background: #da3633; }
1334
1335 /* ───────── blame ───────── */
1336 .blame-head { margin-bottom: var(--space-5); }
1337 .blame-eyebrow {
1338 display: inline-flex;
1339 align-items: center;
1340 gap: 8px;
1341 text-transform: uppercase;
1342 font-family: var(--font-mono);
1343 font-size: 11px;
1344 letter-spacing: 0.16em;
1345 color: var(--text-muted);
1346 font-weight: 600;
1347 margin-bottom: 10px;
1348 }
1349 .blame-eyebrow-dot {
1350 width: 8px; height: 8px;
1351 border-radius: 9999px;
1352 background: linear-gradient(135deg, #8c6dff, #36c5d6);
1353 box-shadow: 0 0 0 3px rgba(140,109,255,0.18);
1354 }
1355 .blame-title {
1356 font-family: var(--font-display);
1357 font-size: clamp(22px, 3vw, 30px);
1358 font-weight: 800;
1359 letter-spacing: -0.025em;
1360 line-height: 1.15;
1361 margin: 0 0 6px;
1362 color: var(--text-strong);
1363 }
1364 .blame-title code {
1365 font-family: var(--font-mono);
1366 font-size: 0.78em;
1367 color: var(--text-strong);
1368 font-weight: 700;
1369 }
1370 .blame-sub {
1371 margin: 0;
1372 font-size: 14px;
1373 color: var(--text-muted);
1374 line-height: 1.5;
1375 max-width: 700px;
1376 }
efb11c5Claude1377 .blame-toolbar {
398a10cClaude1378 display: flex;
1379 justify-content: space-between;
1380 align-items: center;
1381 gap: var(--space-3);
efb11c5Claude1382 margin-bottom: var(--space-3);
398a10cClaude1383 flex-wrap: wrap;
efb11c5Claude1384 font-size: 13px;
1385 }
398a10cClaude1386 .blame-toolbar-actions { display: flex; gap: 6px; }
1387 .blame-card {
1388 background: var(--bg-elevated);
1389 border: 1px solid var(--border);
1390 border-radius: 14px;
1391 overflow: hidden;
1392 position: relative;
1393 }
1394 .blame-card::before {
1395 content: '';
1396 position: absolute;
1397 top: 0; left: 0; right: 0;
1398 height: 2px;
1399 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
1400 opacity: 0.55;
1401 pointer-events: none;
1402 }
efb11c5Claude1403 .blame-header {
1404 display: flex;
1405 align-items: center;
1406 justify-content: space-between;
1407 gap: var(--space-3);
1408 padding: 10px 14px;
1409 background: var(--bg-secondary);
1410 border-bottom: 1px solid var(--border);
1411 }
1412 .blame-header-meta {
1413 display: flex;
1414 align-items: center;
1415 gap: var(--space-2);
1416 min-width: 0;
1417 flex-wrap: wrap;
1418 }
1419 .blame-header-icon { color: var(--accent); font-size: 14px; }
1420 .blame-header-name {
1421 font-family: var(--font-mono);
1422 font-size: 13px;
1423 color: var(--text-strong);
1424 font-weight: 600;
1425 }
1426 .blame-header-tag {
1427 font-size: 10.5px;
1428 text-transform: uppercase;
1429 letter-spacing: 0.08em;
1430 font-family: var(--font-mono);
1431 background: rgba(140,109,255,0.12);
1432 color: var(--accent);
1433 border-radius: 999px;
1434 padding: 2px 8px;
1435 font-weight: 600;
1436 }
1437 .blame-header-stats {
1438 font-family: var(--font-mono);
1439 font-size: 11.5px;
1440 color: var(--text-muted);
1441 font-variant-numeric: tabular-nums;
1442 border-left: 1px solid var(--border);
1443 padding-left: var(--space-2);
1444 }
1445 .blame-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
398a10cClaude1446 .blame-table {
1447 width: 100%;
1448 border-collapse: collapse;
1449 font-family: var(--font-mono);
1450 font-size: 12.5px;
1451 line-height: 1.6;
1452 }
1453 .blame-table tr { border-bottom: 1px solid transparent; }
1454 .blame-table tr.blame-row-first { border-top: 1px solid var(--border); }
1455 .blame-table tr:first-child.blame-row-first { border-top: 0; }
1456 .blame-table tr:hover .blame-line-content { background: rgba(255,255,255,0.025); }
1457 .blame-gutter {
1458 width: 220px;
1459 min-width: 220px;
1460 padding: 0 12px;
1461 vertical-align: top;
1462 background: rgba(255,255,255,0.012);
1463 border-right: 1px solid var(--border-subtle);
1464 font-variant-numeric: tabular-nums;
1465 color: var(--text-muted);
1466 font-size: 11px;
1467 white-space: nowrap;
1468 overflow: hidden;
1469 text-overflow: ellipsis;
1470 padding-top: 2px;
1471 padding-bottom: 2px;
1472 }
1473 .blame-gutter-inner {
1474 display: inline-flex;
1475 align-items: center;
1476 gap: 7px;
1477 max-width: 100%;
1478 overflow: hidden;
1479 }
1480 .blame-gutter-sha {
1481 font-family: var(--font-mono);
1482 font-size: 10.5px;
1483 font-weight: 600;
1484 color: #c4b5fd;
1485 background: rgba(140,109,255,0.10);
1486 padding: 1px 7px;
1487 border-radius: 9999px;
1488 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.22);
1489 text-decoration: none;
1490 letter-spacing: 0.04em;
1491 flex-shrink: 0;
1492 transition: background 120ms ease, box-shadow 120ms ease, color 120ms ease;
1493 }
1494 .blame-gutter-sha:hover {
1495 background: rgba(140,109,255,0.22);
1496 color: #ddd6fe;
1497 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.50);
1498 text-decoration: none;
1499 }
1500 .blame-gutter-author {
1501 color: var(--text);
1502 overflow: hidden;
1503 text-overflow: ellipsis;
1504 white-space: nowrap;
1505 font-size: 11px;
1506 font-family: var(--font-sans, inherit);
1507 }
1508 .blame-line-num {
1509 width: 1%;
1510 min-width: 50px;
1511 padding: 0 12px;
1512 text-align: right;
1513 color: var(--text-faint);
1514 user-select: none;
1515 border-right: 1px solid var(--border-subtle);
1516 font-variant-numeric: tabular-nums;
1517 }
1518 .blame-line-content {
1519 padding: 0 14px;
1520 white-space: pre;
1521 color: var(--text);
1522 transition: background 120ms ease;
1523 }
efb11c5Claude1524
1525 /* ───────── search ───────── */
1526 .search-hero {
1527 position: relative;
1528 margin-bottom: var(--space-4);
1529 padding: var(--space-5) var(--space-6);
1530 background: var(--bg-elevated);
1531 border: 1px solid var(--border);
1532 border-radius: 16px;
1533 overflow: hidden;
1534 }
1535 .search-eyebrow {
1536 font-size: 12px;
1537 font-family: var(--font-mono);
1538 color: var(--text-muted);
1539 letter-spacing: 0.1em;
1540 text-transform: uppercase;
1541 margin-bottom: var(--space-2);
1542 }
1543 .search-eyebrow strong { color: var(--accent); font-weight: 600; }
1544 .search-title {
1545 font-family: var(--font-display);
1546 font-weight: 800;
1547 letter-spacing: -0.025em;
1548 font-size: clamp(22px, 3vw, 30px);
1549 line-height: 1.15;
1550 margin: 0 0 var(--space-3);
1551 color: var(--text-strong);
1552 }
1553 .search-form {
1554 display: flex;
1555 gap: var(--space-2);
1556 align-items: stretch;
1557 }
1558 .search-input-wrap {
1559 position: relative;
1560 flex: 1;
1561 display: flex;
1562 align-items: center;
1563 }
1564 .search-input-icon {
1565 position: absolute;
1566 left: 12px;
1567 color: var(--text-muted);
1568 font-size: 15px;
1569 pointer-events: none;
1570 }
1571 .search-input {
1572 appearance: none;
1573 width: 100%;
1574 padding: 10px 12px 10px 34px;
1575 background: var(--bg);
1576 border: 1px solid var(--border);
1577 border-radius: 10px;
1578 color: var(--text-strong);
1579 font-size: 14px;
1580 font-family: inherit;
1581 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
1582 }
1583 .search-input:focus {
1584 outline: none;
1585 border-color: var(--accent);
1586 box-shadow: 0 0 0 3px rgba(140,109,255,0.18);
1587 }
1588 .search-submit { min-width: 96px; }
1589 .search-results-head {
1590 display: flex;
1591 align-items: baseline;
1592 gap: var(--space-2);
1593 margin-bottom: var(--space-3);
1594 font-size: 13px;
1595 color: var(--text-muted);
1596 }
1597 .search-results-count strong {
1598 color: var(--text-strong);
1599 font-weight: 600;
1600 font-variant-numeric: tabular-nums;
1601 }
1602 .search-results-q { color: var(--text-strong); font-weight: 600; }
1603 .search-results-head code {
1604 font-family: var(--font-mono);
1605 font-size: 12px;
1606 background: var(--bg-secondary);
1607 border: 1px solid var(--border);
1608 border-radius: 5px;
1609 padding: 1px 6px;
1610 color: var(--text);
1611 }
1612 .search-empty {
1613 padding: var(--space-5) var(--space-6);
1614 background: var(--bg-elevated);
1615 border: 1px dashed var(--border);
1616 border-radius: 12px;
1617 color: var(--text-muted);
1618 font-size: 14px;
1619 }
1620 .search-empty strong { color: var(--text-strong); }
1621 .search-results {
1622 display: flex;
1623 flex-direction: column;
1624 gap: var(--space-3);
1625 }
1626 .search-file-head {
1627 display: flex;
1628 align-items: center;
1629 justify-content: space-between;
1630 gap: var(--space-2);
1631 }
1632 .search-file-link {
1633 font-family: var(--font-mono);
1634 font-size: 13px;
1635 color: var(--text-strong);
1636 font-weight: 600;
1637 }
1638 .search-file-link:hover { color: var(--accent); text-decoration: none; }
1639 .search-file-count {
1640 font-family: var(--font-mono);
1641 font-size: 11.5px;
1642 color: var(--text-muted);
1643 font-variant-numeric: tabular-nums;
1644 }
1645`;
1646
fc1817aClaude1647// Home page
06d5ffeClaude1648web.get("/", async (c) => {
1649 const user = c.get("user");
1650
1651 if (user) {
0316dbbClaude1652 return c.redirect("/dashboard");
06d5ffeClaude1653 }
1654
8e9f1d9Claude1655 let stats: { publicRepos?: number; users?: number } | undefined;
52ad8b1Claude1656 let publicStats: PublicStats | null = null;
8e9f1d9Claude1657 try {
1658 const [repoRow] = await db
1659 .select({ n: sql<number>`count(*)::int` })
1660 .from(repositories)
1661 .where(eq(repositories.isPrivate, false));
1662 const [userRow] = await db
1663 .select({ n: sql<number>`count(*)::int` })
1664 .from(users);
1665 stats = {
1666 publicRepos: Number(repoRow?.n ?? 0),
1667 users: Number(userRow?.n ?? 0),
1668 };
1669 } catch {
1670 stats = undefined;
1671 }
1672
52ad8b1Claude1673 // Block L4 — public stats counters (5-min in-memory cache; never throws).
1674 try {
1675 publicStats = await computePublicStats();
1676 } catch {
1677 publicStats = null;
1678 }
1679
534f04aClaude1680 // Block M1 — initial SSR snapshot for the live-now demo feed.
1681 // The helpers in lib/demo-activity.ts never throw, but we still wrap
1682 // in try/catch so a freak module-level explosion can't take down /.
1683 let liveFeed: LandingLiveFeed | null = null;
1684 try {
1685 const [queued, merges, reviewList, reviewCount, feed] = await Promise.all([
1686 listQueuedAiBuildIssues(3),
1687 listRecentAutoMerges(3, 24),
1688 listRecentAiReviews(3, 24),
1689 countAiReviewsSince(24),
1690 listDemoActivityFeed(10),
1691 ]);
1692 liveFeed = {
1693 queued: queued.map((i) => ({
1694 repo: i.repo,
1695 number: i.number,
1696 title: i.title,
1697 createdAt: i.createdAt,
1698 })),
1699 merges: merges.map((m) => ({
1700 repo: m.repo,
1701 number: m.number,
1702 title: m.title,
1703 mergedAt: m.mergedAt,
1704 })),
1705 reviews: reviewList.map((r) => ({
1706 repo: r.repo,
1707 prNumber: r.prNumber,
1708 commentSnippet: r.commentSnippet,
1709 createdAt: r.createdAt,
1710 })),
1711 reviewCount,
1712 feed: feed.map((e) => ({
1713 kind: e.kind,
1714 repo: e.repo,
1715 ref: e.ref,
1716 at: e.at,
1717 })),
1718 };
1719 } catch {
1720 liveFeed = null;
1721 }
1722
29924bcClaude1723 // 2030 reboot — the public landing is a self-contained light marketing
1724 // document (its own shell + design system), rendered directly so it never
1725 // inherits the dark app Layout. `publicStats` / `liveFeed` remain computed
1726 // above for the legacy LandingPage and other surfaces; the new page uses the
1727 // headline counters from `stats`.
1728 void publicStats;
1729 void liveFeed;
1730 void LandingPage;
1731 return c.html("<!DOCTYPE html>" + String(<Landing2030Page stats={stats} />));
fc1817aClaude1732});
1733
06d5ffeClaude1734// New repository form
1735web.get("/new", requireAuth, (c) => {
1736 const user = c.get("user")!;
1737 const error = c.req.query("error");
1738
1739 return c.html(
1740 <Layout title="New repository" user={user}>
efb11c5Claude1741 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
1742 <div class="new-repo-hero">
1743 <div class="new-repo-hero-orb-wrap" aria-hidden="true">
1744 <div class="new-repo-hero-orb" />
1745 </div>
1746 <div class="new-repo-hero-inner">
1747 <div class="new-repo-eyebrow">
1748 <strong>Create</strong> · {user.username}
1749 </div>
1750 <h1 class="new-repo-title">
1751 Spin up a <span class="gradient-text">repository</span>.
1752 </h1>
1753 <p class="new-repo-sub">
1754 Push your first commit, and Gluecron wires up gate checks, AI review,
1755 and auto-merge from the moment your branch lands.
1756 </p>
1757 </div>
1758 </div>
06d5ffeClaude1759 <div class="new-repo-form">
efb11c5Claude1760 {error && (
1761 <div class="new-repo-error" role="alert">
1762 {decodeURIComponent(error)}
1763 </div>
1764 )}
1765 <form method="post" action="/new" class="new-repo-form-grid">
1766 <div class="new-repo-row">
1767 <label class="new-repo-label">Owner</label>
1768 <input
1769 type="text"
1770 value={user.username}
1771 disabled
1772 aria-label="Owner"
1773 class="new-repo-input new-repo-input-disabled"
1774 />
06d5ffeClaude1775 </div>
efb11c5Claude1776 <div class="new-repo-row">
1777 <label class="new-repo-label" for="name">
1778 Repository name
1779 </label>
06d5ffeClaude1780 <input
1781 type="text"
1782 id="name"
1783 name="name"
1784 required
1785 pattern="^[a-zA-Z0-9._-]+$"
1786 placeholder="my-project"
1787 autocomplete="off"
efb11c5Claude1788 class="new-repo-input"
06d5ffeClaude1789 />
efb11c5Claude1790 <p class="new-repo-hint">
1791 Lowercase, numbers, dots, dashes, and underscores. The URL will be{" "}
1792 <code>{user.username}/&lt;name&gt;</code>.
1793 </p>
06d5ffeClaude1794 </div>
efb11c5Claude1795 <div class="new-repo-row">
1796 <label class="new-repo-label" for="description">
1797 Description{" "}
1798 <span class="new-repo-label-optional">(optional)</span>
1799 </label>
06d5ffeClaude1800 <input
1801 type="text"
1802 id="description"
1803 name="description"
1804 placeholder="A short description of your repository"
efb11c5Claude1805 class="new-repo-input"
06d5ffeClaude1806 />
1807 </div>
efb11c5Claude1808 <div class="new-repo-row">
1809 <span class="new-repo-label">Visibility</span>
1810 <div class="new-repo-visibility">
1811 <label class="new-repo-vis-card">
1812 <input
1813 type="radio"
1814 name="visibility"
1815 value="public"
1816 checked
1817 class="new-repo-vis-radio"
1818 />
1819 <span class="new-repo-vis-body">
1820 <span class="new-repo-vis-label">Public</span>
1821 <span class="new-repo-vis-desc">
1822 Anyone can see this repository. You choose who can commit.
1823 </span>
1824 </span>
1825 </label>
1826 <label class="new-repo-vis-card">
1827 <input
1828 type="radio"
1829 name="visibility"
1830 value="private"
1831 class="new-repo-vis-radio"
1832 />
1833 <span class="new-repo-vis-body">
1834 <span class="new-repo-vis-label">Private</span>
1835 <span class="new-repo-vis-desc">
1836 Only you (and collaborators you invite) can see this
1837 repository.
1838 </span>
1839 </span>
1840 </label>
1841 </div>
1842 </div>
398a10cClaude1843 <div class="new-repo-row">
1844 <span class="new-repo-label">
1845 Starter content{" "}
1846 <span class="new-repo-label-optional">(cosmetic — your first push wins)</span>
1847 </span>
1848 <div class="new-repo-templates" role="radiogroup" aria-label="Starter content">
1849 <label class="new-repo-template-chip">
1850 <input type="radio" name="starter" value="empty" checked />
1851 <span class="new-repo-template-chip-dot" aria-hidden="true" />
1852 Empty
1853 </label>
1854 <label class="new-repo-template-chip">
1855 <input type="radio" name="starter" value="readme" />
1856 <span class="new-repo-template-chip-dot" aria-hidden="true" />
1857 README
1858 </label>
1859 <label class="new-repo-template-chip">
1860 <input type="radio" name="starter" value="readme-mit" />
1861 <span class="new-repo-template-chip-dot" aria-hidden="true" />
1862 README + MIT
1863 </label>
1864 <label class="new-repo-template-chip">
1865 <input type="radio" name="starter" value="node" />
1866 <span class="new-repo-template-chip-dot" aria-hidden="true" />
1867 Node + .gitignore
1868 </label>
1869 </div>
1870 <p class="new-repo-hint">
1871 Just a UI hint — push your own commits to fill the repo.
1872 </p>
1873 </div>
efb11c5Claude1874 <div class="new-repo-callout">
1875 <div class="new-repo-callout-eyebrow">AI-native by default</div>
1876 <p class="new-repo-callout-body">
1877 Every push is gate-checked and reviewed by Claude automatically.
1878 Label an issue <code>ai-build</code> and Gluecron will open the PR
1879 for you.
1880 </p>
1881 </div>
1882 <div class="new-repo-actions">
398a10cClaude1883 <button type="submit" class="btn new-repo-submit">
efb11c5Claude1884 Create repository
1885 </button>
1886 <a href="/dashboard" class="btn new-repo-cancel">
1887 Cancel
1888 </a>
06d5ffeClaude1889 </div>
1890 </form>
1891 </div>
1892 </Layout>
1893 );
1894});
1895
1896web.post("/new", requireAuth, async (c) => {
1897 const user = c.get("user")!;
1898 const body = await c.req.parseBody();
1899 const name = String(body.name || "").trim();
1900 const description = String(body.description || "").trim();
1901 const isPrivate = body.visibility === "private";
1902
1903 if (!name) {
1904 return c.redirect("/new?error=Repository+name+is+required");
1905 }
1906
c63b860Claude1907 // P4 — plan-quota gate. Fail-open inside the helper so a billing
1908 // outage never blocks repo creation.
1909 const { checkRepoCreateAllowed } = await import("../lib/repo-create-gate");
1910 const gate = await checkRepoCreateAllowed(user.id);
1911 if (!gate.ok) {
1912 return c.redirect(`/new?error=${encodeURIComponent(gate.reason)}`);
1913 }
1914
06d5ffeClaude1915 if (!/^[a-zA-Z0-9._-]+$/.test(name)) {
1916 return c.redirect("/new?error=Invalid+repository+name");
1917 }
1918
1919 if (await repoExists(user.username, name)) {
1920 return c.redirect("/new?error=Repository+already+exists");
1921 }
1922
1923 const diskPath = await initBareRepo(user.username, name);
1924
3ef4c9dClaude1925 const [newRepo] = await db
1926 .insert(repositories)
1927 .values({
1928 name,
1929 ownerId: user.id,
1930 description: description || null,
1931 isPrivate,
1932 diskPath,
1933 })
1934 .returning();
1935
1936 if (newRepo) {
1937 const { bootstrapRepository } = await import("../lib/repo-bootstrap");
1938 await bootstrapRepository({
1939 repositoryId: newRepo.id,
1940 ownerUserId: user.id,
1941 defaultBranch: "main",
1942 });
1943 }
06d5ffeClaude1944
1945 return c.redirect(`/${user.username}/${name}`);
1946});
1947
1948// User profile
fc1817aClaude1949web.get("/:owner", async (c) => {
06d5ffeClaude1950 const { owner: ownerName } = c.req.param();
1951 const user = c.get("user");
1952
1953 // Avoid clashing with fixed routes
1954 if (
1955 ["login", "register", "logout", "new", "settings", "api"].includes(
1956 ownerName
1957 )
1958 ) {
1959 return c.notFound();
1960 }
1961
1962 let ownerUser;
1963 try {
1964 const [found] = await db
1965 .select()
1966 .from(users)
1967 .where(eq(users.username, ownerName))
1968 .limit(1);
1969 ownerUser = found;
1970 } catch {
1971 // DB not available — check if repos exist on disk
1972 ownerUser = null;
1973 }
1974
1975 // Even without DB, show repos if they exist on disk
1976 let repos: any[] = [];
1977 if (ownerUser) {
1978 const allRepos = await db
1979 .select()
1980 .from(repositories)
1981 .where(eq(repositories.ownerId, ownerUser.id))
1982 .orderBy(desc(repositories.updatedAt));
1983
1984 // Show public repos to everyone, private only to owner
1985 repos =
1986 user?.id === ownerUser.id
1987 ? allRepos
1988 : allRepos.filter((r) => !r.isPrivate);
1989 }
1990
7aa8b99Claude1991 // Block J4 — follow counts + viewer's follow state
1992 let followState = {
1993 followers: 0,
1994 following: 0,
1995 viewerFollows: false,
1996 };
1997 if (ownerUser) {
1998 try {
1999 const { followCounts, isFollowing } = await import("../lib/follows");
2000 const counts = await followCounts(ownerUser.id);
2001 followState.followers = counts.followers;
2002 followState.following = counts.following;
2003 if (user && user.id !== ownerUser.id) {
2004 followState.viewerFollows = await isFollowing(user.id, ownerUser.id);
2005 }
2006 } catch {
2007 // DB hiccup — fall back to zeros.
2008 }
2009 }
2010 const canFollow = !!user && !!ownerUser && user.id !== ownerUser.id;
2011
d412586Claude2012 // Block J5 — profile README. Render owner/owner repo's README on the
2013 // profile page (GitHub convention). Tries "<user>/<user>" first, falling
2014 // back to "<user>/.github" for org-style profile repos.
2015 let profileReadmeHtml: string | null = null;
2016 try {
2017 const candidates = [ownerName, ".github"];
2018 for (const rname of candidates) {
2019 if (await repoExists(ownerName, rname)) {
2020 const ref = (await getDefaultBranch(ownerName, rname)) || "main";
2021 const md = await getReadme(ownerName, rname, ref);
2022 if (md) {
2023 profileReadmeHtml = renderMarkdown(md);
2024 break;
2025 }
2026 }
2027 }
2028 } catch {
2029 profileReadmeHtml = null;
2030 }
2031
efb11c5Claude2032 const displayName = ownerUser?.displayName || ownerName;
2033 const memberSince = ownerUser?.createdAt
2034 ? new Date(ownerUser.createdAt as unknown as string | number | Date)
2035 : null;
2036
fc1817aClaude2037 return c.html(
06d5ffeClaude2038 <Layout title={ownerName} user={user}>
efb11c5Claude2039 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
2040 <div class="profile-hero">
2041 <div class="profile-hero-orb-wrap" aria-hidden="true">
2042 <div class="profile-hero-orb" />
06d5ffeClaude2043 </div>
efb11c5Claude2044 <div class="profile-hero-inner">
2045 <div class="profile-hero-avatar" aria-hidden="true">
2046 {displayName[0].toUpperCase()}
2047 </div>
2048 <div class="profile-hero-text">
2049 <div class="profile-eyebrow">
2050 <strong>Developer</strong>
2051 {memberSince && !Number.isNaN(memberSince.getTime()) && (
2052 <>
2053 {" "}· Joined{" "}
2054 {memberSince.toLocaleDateString("en-US", {
2055 month: "short",
2056 year: "numeric",
2057 })}
2058 </>
2059 )}
2060 </div>
2061 <h1 class="profile-name">
2062 <span class="gradient-text">{displayName}</span>
2063 </h1>
2064 <div class="profile-handle">@{ownerName}</div>
2065 {ownerUser?.bio && <p class="profile-bio">{ownerUser.bio}</p>}
2066 <div class="profile-meta">
2067 <a href={`/${ownerName}/followers`} class="profile-meta-link">
2068 <strong>{followState.followers}</strong> follower
2069 {followState.followers === 1 ? "" : "s"}
2070 </a>
2071 <a href={`/${ownerName}/following`} class="profile-meta-link">
2072 <strong>{followState.following}</strong> following
2073 </a>
2074 <a href={`/${ownerName}`} class="profile-meta-link">
2075 <strong>{repos.length}</strong> repo
2076 {repos.length === 1 ? "" : "s"}
2077 </a>
2078 {canFollow && (
2079 <form
2080 method="post"
2081 action={`/${ownerName}/${
2082 followState.viewerFollows ? "unfollow" : "follow"
2083 }`}
2084 class="profile-follow-form"
7aa8b99Claude2085 >
efb11c5Claude2086 <button
2087 type="submit"
2088 class={`btn ${
2089 followState.viewerFollows ? "" : "btn-primary"
2090 } btn-sm`}
2091 >
2092 {followState.viewerFollows ? "Unfollow" : "Follow"}
2093 </button>
2094 </form>
2095 )}
2096 </div>
7aa8b99Claude2097 </div>
06d5ffeClaude2098 </div>
2099 </div>
d412586Claude2100 {profileReadmeHtml && (
efb11c5Claude2101 <div class="profile-readme">
2102 <div class="profile-readme-head">
2103 <span class="profile-readme-icon">{"☰"}</span>
2104 <span>{ownerName}/{ownerName} README.md</span>
2105 </div>
2106 <div
2107 class="markdown-body profile-readme-body"
2108 dangerouslySetInnerHTML={{ __html: profileReadmeHtml }}
2109 />
2110 </div>
d412586Claude2111 )}
efb11c5Claude2112 <div class="profile-section-head">
2113 <h2 class="profile-section-title">Repositories</h2>
2114 <span class="profile-section-count">{repos.length}</span>
2115 </div>
06d5ffeClaude2116 {repos.length === 0 ? (
efb11c5Claude2117 <div class="profile-empty">
2118 <p class="profile-empty-text">
2119 No repositories yet
2120 {user?.id === ownerUser?.id ? "." : ` — ${ownerName} is just getting started.`}
2121 </p>
2122 {user?.id === ownerUser?.id && (
2123 <a href="/new" class="btn btn-primary btn-sm">
2124 + Create your first
2125 </a>
2126 )}
2127 </div>
06d5ffeClaude2128 ) : (
2129 <div class="card-grid">
2130 {repos.map((repo) => (
2131 <RepoCard repo={repo} ownerName={ownerName} />
2132 ))}
2133 </div>
2134 )}
fc1817aClaude2135 </Layout>
2136 );
2137});
2138
06d5ffeClaude2139// Star/unstar a repo
2140web.post("/:owner/:repo/star", requireAuth, async (c) => {
2141 const { owner: ownerName, repo: repoName } = c.req.param();
2142 const user = c.get("user")!;
2143
2144 try {
2145 const [ownerUser] = await db
2146 .select()
2147 .from(users)
2148 .where(eq(users.username, ownerName))
2149 .limit(1);
2150 if (!ownerUser) return c.redirect(`/${ownerName}/${repoName}`);
2151
2152 const [repo] = await db
2153 .select()
2154 .from(repositories)
2155 .where(
2156 and(
2157 eq(repositories.ownerId, ownerUser.id),
2158 eq(repositories.name, repoName)
2159 )
2160 )
2161 .limit(1);
2162 if (!repo) return c.redirect(`/${ownerName}/${repoName}`);
2163
2164 // Toggle star
2165 const [existing] = await db
2166 .select()
2167 .from(stars)
2168 .where(
2169 and(eq(stars.userId, user.id), eq(stars.repositoryId, repo.id))
2170 )
2171 .limit(1);
2172
2173 if (existing) {
2174 await db.delete(stars).where(eq(stars.id, existing.id));
2175 await db
2176 .update(repositories)
2177 .set({ starCount: Math.max(0, repo.starCount - 1) })
2178 .where(eq(repositories.id, repo.id));
2179 } else {
2180 await db.insert(stars).values({
2181 userId: user.id,
2182 repositoryId: repo.id,
2183 });
2184 await db
2185 .update(repositories)
2186 .set({ starCount: repo.starCount + 1 })
2187 .where(eq(repositories.id, repo.id));
2188 }
2189 } catch {
2190 // DB error — ignore
2191 }
2192
2193 return c.redirect(`/${ownerName}/${repoName}`);
2194});
2195
fc1817aClaude2196// Repository overview — file tree at HEAD
2197web.get("/:owner/:repo", async (c) => {
2198 const { owner, repo } = c.req.param();
06d5ffeClaude2199 const user = c.get("user");
fc1817aClaude2200
f1dc7c7Claude2201 // ── Loading skeleton (flag-gated) ──
2202 // Renders an SSR'd shell with file-tree + README placeholders when
2203 // `?skeleton=1` is set. Lets the user see the page structure before
2204 // git ops finish. Behind a flag for now so we never flash before the
2205 // real content lands.
2206 if (c.req.query("skeleton") === "1") {
2207 return c.html(
2208 <Layout title={`${owner}/${repo}`} user={user}>
2209 <style
2210 dangerouslySetInnerHTML={{
2211 __html: `
2212 .repo-skel { background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-elevated) 50%, var(--bg-secondary) 100%); background-size: 200% 100%; animation: repoSkelShimmer 1.4s infinite; border-radius: 6px; display: block; }
2213 @keyframes repoSkelShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
2214 @media (prefers-reduced-motion: reduce) { .repo-skel { animation: none; } }
2215 .repo-skel-hero { height: 132px; border-radius: 16px; margin-bottom: var(--space-4); }
2216 .repo-skel-nav { height: 36px; border-radius: 8px; margin-bottom: var(--space-4); }
2217 .repo-skel-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--space-5); align-items: start; }
2218 @media (max-width: 960px) { .repo-skel-grid { grid-template-columns: minmax(0, 1fr); } }
2219 .repo-skel-branch { height: 32px; width: 200px; border-radius: 8px; margin-bottom: 12px; }
2220 .repo-skel-tree { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-5); }
2221 .repo-skel-tree-row { height: 36px; border-radius: 8px; }
2222 .repo-skel-readme { height: 320px; border-radius: 12px; }
2223 .repo-skel-side { display: flex; flex-direction: column; gap: var(--space-4); }
2224 .repo-skel-side-card { height: 180px; border-radius: 12px; }
2225 `,
2226 }}
2227 />
2228 <div class="repo-skel repo-skel-hero" aria-hidden="true" />
2229 <div class="repo-skel repo-skel-nav" aria-hidden="true" />
2230 <div class="repo-skel-grid" aria-hidden="true">
2231 <div>
2232 <div class="repo-skel repo-skel-branch" />
2233 <div class="repo-skel-tree">
2234 {Array.from({ length: 8 }).map(() => (
2235 <div class="repo-skel repo-skel-tree-row" />
2236 ))}
2237 </div>
2238 <div class="repo-skel repo-skel-readme" />
2239 </div>
2240 <aside class="repo-skel-side">
2241 <div class="repo-skel repo-skel-side-card" />
2242 <div class="repo-skel repo-skel-side-card" />
2243 </aside>
2244 </div>
2245 <span style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0" role="status" aria-live="polite">
2246 Loading {owner}/{repo}…
2247 </span>
2248 </Layout>
2249 );
2250 }
2251
8f50ed0Claude2252 // F1 — fire-and-forget traffic tracking. Never awaits; never throws.
2253 trackByName(owner, repo, "view", {
2254 userId: user?.id || null,
2255 path: `/${owner}/${repo}`,
2256 ip: c.req.header("x-forwarded-for") || c.req.header("x-real-ip") || null,
2257 userAgent: c.req.header("user-agent") || null,
2258 referer: c.req.header("referer") || null,
a28cedeClaude2259 }).catch((err) => {
2260 console.warn(
2261 `[web] view tracking failed for ${owner}/${repo}:`,
2262 err instanceof Error ? err.message : err
2263 );
2264 });
8f50ed0Claude2265
fc1817aClaude2266 if (!(await repoExists(owner, repo))) {
2267 return c.html(
06d5ffeClaude2268 <Layout title="Not Found" user={user}>
fc1817aClaude2269 <div class="empty-state">
2270 <h2>Repository not found</h2>
2271 <p>
2272 {owner}/{repo} does not exist.
2273 </p>
2274 </div>
2275 </Layout>,
2276 404
2277 );
2278 }
2279
05b973eClaude2280 // Parallelize all independent operations
2281 const [defaultBranch, branches] = await Promise.all([
2282 getDefaultBranch(owner, repo).then((b) => b || "main"),
2283 listBranches(owner, repo),
2284 ]);
2285 const [tree, starInfo] = await Promise.all([
2286 getTree(owner, repo, defaultBranch),
2287 // Star info fetched in parallel with tree
2288 (async () => {
2289 try {
2290 const [ownerUser] = await db
2291 .select()
2292 .from(users)
2293 .where(eq(users.username, owner))
2294 .limit(1);
71cd5ecClaude2295 if (!ownerUser)
2296 return {
2297 starCount: 0,
2298 starred: false,
2299 archived: false,
2300 isTemplate: false,
544d842Claude2301 forkCount: 0,
2302 description: null as string | null,
2303 pushedAt: null as Date | null,
2304 createdAt: null as Date | null,
cb5a796Claude2305 repoId: null as string | null,
2306 repoOwnerId: null as string | null,
71cd5ecClaude2307 };
05b973eClaude2308 const [repoRow] = await db
2309 .select()
2310 .from(repositories)
2311 .where(
2312 and(
2313 eq(repositories.ownerId, ownerUser.id),
2314 eq(repositories.name, repo)
2315 )
06d5ffeClaude2316 )
05b973eClaude2317 .limit(1);
71cd5ecClaude2318 if (!repoRow)
2319 return {
2320 starCount: 0,
2321 starred: false,
2322 archived: false,
2323 isTemplate: false,
544d842Claude2324 forkCount: 0,
2325 description: null as string | null,
2326 pushedAt: null as Date | null,
2327 createdAt: null as Date | null,
cb5a796Claude2328 repoId: null as string | null,
2329 repoOwnerId: null as string | null,
71cd5ecClaude2330 };
05b973eClaude2331 let starred = false;
06d5ffeClaude2332 if (user) {
2333 const [star] = await db
2334 .select()
2335 .from(stars)
2336 .where(
2337 and(
2338 eq(stars.userId, user.id),
2339 eq(stars.repositoryId, repoRow.id)
2340 )
2341 )
2342 .limit(1);
2343 starred = !!star;
2344 }
71cd5ecClaude2345 return {
2346 starCount: repoRow.starCount,
2347 starred,
2348 archived: repoRow.isArchived,
2349 isTemplate: repoRow.isTemplate,
544d842Claude2350 forkCount: repoRow.forkCount,
2351 description: repoRow.description as string | null,
2352 pushedAt: (repoRow.pushedAt as Date | null) ?? null,
2353 createdAt: (repoRow.createdAt as Date | null) ?? null,
cb5a796Claude2354 repoId: repoRow.id as string,
2355 repoOwnerId: repoRow.ownerId as string,
71cd5ecClaude2356 };
05b973eClaude2357 } catch {
71cd5ecClaude2358 return {
2359 starCount: 0,
2360 starred: false,
2361 archived: false,
2362 isTemplate: false,
544d842Claude2363 forkCount: 0,
2364 description: null as string | null,
2365 pushedAt: null as Date | null,
2366 createdAt: null as Date | null,
cb5a796Claude2367 repoId: null as string | null,
2368 repoOwnerId: null as string | null,
71cd5ecClaude2369 };
06d5ffeClaude2370 }
05b973eClaude2371 })(),
2372 ]);
544d842Claude2373 const {
2374 starCount,
2375 starred,
2376 archived,
2377 isTemplate,
2378 forkCount,
2379 description,
2380 pushedAt,
2381 createdAt,
cb5a796Claude2382 repoId,
2383 repoOwnerId,
544d842Claude2384 } = starInfo;
2385
91a0204Claude2386 // Health score badge — fire-and-forget, best-effort. If the DB call fails
2387 // or repoId is null (anonymous view of non-DB repo), healthScore stays null
2388 // and the badge simply doesn't render.
2389 let healthScore: HealthScore | null = null;
2390 if (repoId) {
2391 try {
2392 healthScore = await computeHealthScore(repoId);
2393 } catch {
2394 // swallow — badge is optional
2395 }
2396 }
2397
cb5a796Claude2398 // Pending-comments banner data (lazy + best-effort). Only the repo
2399 // owner sees the banner, so non-owner views skip the DB hit entirely.
2400 let repoHomePendingCount = 0;
2401 if (user && repoOwnerId && user.id === repoOwnerId && repoId) {
2402 try {
2403 const { countPendingForRepo } = await import(
2404 "../lib/comment-moderation"
2405 );
2406 repoHomePendingCount = await countPendingForRepo(repoId);
2407 } catch {
2408 /* swallow */
2409 }
2410 }
2411
544d842Claude2412 // Repo-home polish — shared style block (Block 2.A — parallel session 2.A).
2413 // Scoped via .repo-home-* class prefix to prevent bleed into other surfaces.
2414 const repoHomeCss = `
2415 .repo-home-hero {
2416 position: relative;
2417 margin-bottom: var(--space-5);
2418 padding: var(--space-5) var(--space-6);
2419 background: var(--bg-elevated);
2420 border: 1px solid var(--border);
2421 border-radius: 16px;
2422 overflow: hidden;
2423 }
2424 .repo-home-hero::before {
2425 content: '';
2426 position: absolute;
2427 top: 0; left: 0; right: 0;
2428 height: 2px;
2429 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
2430 opacity: 0.7;
2431 pointer-events: none;
2432 }
2433 .repo-home-hero-orb-wrap {
2434 position: absolute;
2435 inset: -25% -10% auto auto;
2436 width: 360px;
2437 height: 360px;
2438 pointer-events: none;
2439 z-index: 0;
2440 }
2441 .repo-home-hero-orb {
2442 position: absolute;
2443 inset: 0;
2444 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.09) 45%, transparent 70%);
2445 filter: blur(80px);
2446 opacity: 0.7;
2447 animation: repoHomeOrb 14s ease-in-out infinite;
2448 }
2449 @keyframes repoHomeOrb {
2450 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
2451 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
2452 }
2453 @media (prefers-reduced-motion: reduce) {
2454 .repo-home-hero-orb { animation: none; }
2455 }
2456 .repo-home-hero-inner {
2457 position: relative;
2458 z-index: 1;
2459 }
2460 .repo-home-hero .repo-header { margin-bottom: var(--space-3); }
2461 .repo-home-eyebrow {
2462 font-size: 12px;
2463 font-family: var(--font-mono);
2464 color: var(--text-muted);
2465 letter-spacing: 0.1em;
2466 text-transform: uppercase;
2467 margin-bottom: var(--space-2);
2468 }
2469 .repo-home-eyebrow strong { color: var(--accent); font-weight: 600; }
2470 .repo-home-description {
2471 font-size: 15px;
2472 line-height: 1.55;
2473 color: var(--text);
2474 margin: 0;
2475 max-width: 720px;
2476 }
2477 .repo-home-description-empty {
2478 font-size: 14px;
2479 color: var(--text-muted);
2480 font-style: italic;
2481 margin: 0;
2482 }
2483 .repo-home-stat-row {
2484 display: flex;
2485 flex-wrap: wrap;
2486 gap: var(--space-4);
2487 margin-top: var(--space-3);
2488 font-size: 13px;
2489 color: var(--text-muted);
2490 }
2491 .repo-home-stat {
2492 display: inline-flex;
2493 align-items: center;
2494 gap: 6px;
2495 }
2496 .repo-home-stat strong {
2497 color: var(--text-strong);
2498 font-weight: 600;
2499 font-variant-numeric: tabular-nums;
2500 }
2501 .repo-home-stat .repo-home-stat-icon {
2502 color: var(--text-faint);
2503 font-size: 14px;
2504 line-height: 1;
2505 }
2506 .repo-home-stat a {
2507 color: var(--text-muted);
2508 transition: color var(--t-fast) var(--ease);
2509 }
2510 .repo-home-stat a:hover { color: var(--accent); text-decoration: none; }
2511
2512 /* Two-column layout: file tree + sidebar */
2513 .repo-home-grid {
2514 display: grid;
2515 grid-template-columns: minmax(0, 1fr) 280px;
2516 gap: var(--space-5);
2517 align-items: start;
2518 }
2519 @media (max-width: 960px) {
2520 .repo-home-grid { grid-template-columns: minmax(0, 1fr); }
2521 }
2522 .repo-home-main { min-width: 0; }
2523
2524 /* Sidebar card */
2525 .repo-home-side {
2526 display: flex;
2527 flex-direction: column;
2528 gap: var(--space-4);
2529 }
2530 .repo-home-side-card {
2531 background: var(--bg-elevated);
2532 border: 1px solid var(--border);
2533 border-radius: 12px;
2534 padding: var(--space-4);
2535 }
2536 .repo-home-side-title {
2537 font-size: 11px;
2538 font-family: var(--font-mono);
2539 letter-spacing: 0.12em;
2540 text-transform: uppercase;
2541 color: var(--text-muted);
2542 margin: 0 0 var(--space-3);
2543 font-weight: 600;
2544 }
2545 .repo-home-side-row {
2546 display: flex;
2547 justify-content: space-between;
2548 align-items: center;
2549 gap: var(--space-2);
2550 font-size: 13px;
2551 padding: 6px 0;
2552 border-top: 1px solid var(--border);
2553 }
2554 .repo-home-side-row:first-of-type { border-top: 0; padding-top: 0; }
2555 .repo-home-side-key {
2556 color: var(--text-muted);
2557 display: inline-flex;
2558 align-items: center;
2559 gap: 6px;
2560 }
2561 .repo-home-side-val {
2562 color: var(--text-strong);
2563 font-weight: 500;
2564 font-variant-numeric: tabular-nums;
2565 max-width: 60%;
2566 text-align: right;
2567 overflow: hidden;
2568 text-overflow: ellipsis;
2569 white-space: nowrap;
2570 }
2571 .repo-home-side-val a { color: var(--text-strong); }
2572 .repo-home-side-val a:hover { color: var(--accent); text-decoration: none; }
2573
2574 /* Clone / Code tabs */
2575 .repo-home-clone {
2576 background: var(--bg-elevated);
2577 border: 1px solid var(--border);
2578 border-radius: 12px;
2579 overflow: hidden;
2580 }
2581 .repo-home-clone-tabs {
2582 display: flex;
2583 gap: 0;
2584 background: var(--bg-secondary);
2585 border-bottom: 1px solid var(--border);
2586 padding: 0 var(--space-2);
2587 }
2588 .repo-home-clone-tab {
2589 appearance: none;
2590 background: transparent;
2591 border: 0;
2592 border-bottom: 2px solid transparent;
2593 padding: 9px 12px;
2594 font-size: 12px;
2595 font-weight: 500;
2596 color: var(--text-muted);
2597 cursor: pointer;
2598 transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
2599 font-family: inherit;
2600 margin-bottom: -1px;
2601 }
2602 .repo-home-clone-tab:hover { color: var(--text-strong); }
2603 .repo-home-clone-tab[aria-selected="true"] {
2604 color: var(--text-strong);
2605 border-bottom-color: var(--accent);
2606 }
2607 .repo-home-clone-body {
2608 padding: var(--space-3);
2609 display: flex;
2610 align-items: center;
2611 gap: var(--space-2);
2612 }
2613 .repo-home-clone-input {
2614 flex: 1;
2615 min-width: 0;
2616 font-family: var(--font-mono);
2617 font-size: 12px;
2618 background: var(--bg);
2619 border: 1px solid var(--border);
2620 border-radius: 8px;
2621 padding: 8px 10px;
2622 color: var(--text-strong);
2623 overflow: hidden;
2624 text-overflow: ellipsis;
2625 white-space: nowrap;
2626 }
2627 .repo-home-clone-copy {
2628 appearance: none;
2629 background: var(--bg-secondary);
2630 border: 1px solid var(--border);
2631 color: var(--text-strong);
2632 border-radius: 8px;
2633 padding: 8px 12px;
2634 font-size: 12px;
2635 font-weight: 600;
2636 cursor: pointer;
2637 transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
2638 font-family: inherit;
2639 }
2640 .repo-home-clone-copy:hover { background: var(--bg-hover); border-color: var(--border-strong, var(--border)); }
2641 .repo-home-clone-pane { display: none; }
2642 .repo-home-clone-pane[data-active="true"] { display: flex; }
2643
2644 /* README card */
2645 .repo-home-readme {
2646 margin-top: var(--space-5);
2647 background: var(--bg-elevated);
2648 border: 1px solid var(--border);
2649 border-radius: 12px;
2650 overflow: hidden;
2651 }
2652 .repo-home-readme-head {
2653 display: flex;
2654 align-items: center;
2655 gap: 8px;
2656 padding: 10px 16px;
2657 background: var(--bg-secondary);
2658 border-bottom: 1px solid var(--border);
2659 font-size: 13px;
2660 color: var(--text-muted);
2661 }
2662 .repo-home-readme-head .repo-home-readme-icon {
2663 color: var(--accent);
2664 font-size: 14px;
2665 }
2666 .repo-home-readme-body {
2667 padding: var(--space-5) var(--space-6);
2668 }
2669
2670 /* Empty-state CTA */
2671 .repo-home-empty {
2672 position: relative;
2673 margin-top: var(--space-4);
2674 background: var(--bg-elevated);
2675 border: 1px solid var(--border);
2676 border-radius: 16px;
2677 padding: var(--space-6);
2678 overflow: hidden;
2679 }
2680 .repo-home-empty::before {
2681 content: '';
2682 position: absolute;
2683 top: 0; left: 0; right: 0;
2684 height: 2px;
2685 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
2686 opacity: 0.7;
2687 pointer-events: none;
2688 }
2689 .repo-home-empty-eyebrow {
2690 font-size: 12px;
2691 font-family: var(--font-mono);
2692 color: var(--accent);
2693 letter-spacing: 0.12em;
2694 text-transform: uppercase;
2695 margin-bottom: var(--space-2);
2696 font-weight: 600;
2697 }
2698 .repo-home-empty-title {
2699 font-family: var(--font-display);
2700 font-weight: 800;
2701 letter-spacing: -0.025em;
2702 font-size: clamp(22px, 3vw, 30px);
2703 line-height: 1.1;
2704 margin: 0 0 var(--space-2);
2705 color: var(--text-strong);
2706 }
2707 .repo-home-empty-sub {
2708 color: var(--text-muted);
2709 font-size: 14px;
2710 line-height: 1.55;
2711 max-width: 640px;
2712 margin: 0 0 var(--space-4);
2713 }
2714 .repo-home-empty-snippet {
2715 background: var(--bg);
2716 border: 1px solid var(--border);
2717 border-radius: 10px;
2718 padding: var(--space-3) var(--space-4);
2719 font-family: var(--font-mono);
2720 font-size: 12.5px;
2721 line-height: 1.7;
2722 color: var(--text-strong);
2723 overflow-x: auto;
2724 white-space: pre;
2725 margin: 0;
2726 }
2727 .repo-home-empty-snippet .repo-home-cmt { color: var(--text-faint); }
2728 .repo-home-empty-snippet .repo-home-cmd { color: var(--accent); }
2729
91a0204Claude2730 /* Health score badge */
2731 .repo-health-badge {
2732 display: inline-flex;
2733 align-items: center;
2734 gap: 5px;
2735 padding: 3px 10px;
2736 border-radius: 999px;
2737 font-size: 11.5px;
2738 font-weight: 700;
2739 font-family: var(--font-mono);
2740 text-decoration: none;
2741 border: 1px solid transparent;
2742 transition: filter 120ms ease, opacity 120ms ease;
2743 vertical-align: middle;
2744 }
2745 .repo-health-badge:hover { filter: brightness(1.15); text-decoration: none; opacity: 0.9; }
2746 .repo-health-badge-elite {
2747 background: rgba(52,211,153,0.15);
2748 color: #6ee7b7;
2749 border-color: rgba(52,211,153,0.30);
2750 }
2751 .repo-health-badge-strong {
2752 background: rgba(96,165,250,0.15);
2753 color: #93c5fd;
2754 border-color: rgba(96,165,250,0.30);
2755 }
2756 .repo-health-badge-improving {
2757 background: rgba(251,191,36,0.15);
2758 color: #fde68a;
2759 border-color: rgba(251,191,36,0.30);
2760 }
2761 .repo-health-badge-needs-attention {
2762 background: rgba(248,113,113,0.15);
2763 color: #fca5a5;
2764 border-color: rgba(248,113,113,0.30);
2765 }
2766
2767 /* Three-option empty-state panel */
2768 .repo-empty-options {
2769 display: grid;
2770 grid-template-columns: repeat(3, 1fr);
2771 gap: var(--space-3);
2772 margin-top: var(--space-5);
2773 }
2774 @media (max-width: 760px) {
2775 .repo-empty-options { grid-template-columns: 1fr; }
2776 }
2777 .repo-empty-option {
2778 position: relative;
2779 background: var(--bg-elevated);
2780 border: 1px solid var(--border);
2781 border-radius: 14px;
2782 padding: var(--space-4) var(--space-4);
2783 display: flex;
2784 flex-direction: column;
2785 gap: var(--space-2);
2786 overflow: hidden;
2787 transition: border-color 140ms ease, background 140ms ease;
2788 }
2789 .repo-empty-option:hover {
2790 border-color: rgba(140,109,255,0.45);
2791 background: rgba(140,109,255,0.04);
2792 }
2793 .repo-empty-option::before {
2794 content: '';
2795 position: absolute;
2796 top: 0; left: 0; right: 0;
2797 height: 2px;
2798 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
2799 opacity: 0.55;
2800 pointer-events: none;
2801 }
2802 .repo-empty-option-label {
2803 font-size: 10px;
2804 font-family: var(--font-mono);
2805 font-weight: 700;
2806 letter-spacing: 0.12em;
2807 text-transform: uppercase;
2808 color: var(--accent);
2809 margin-bottom: 2px;
2810 }
2811 .repo-empty-option-title {
2812 font-family: var(--font-display);
2813 font-weight: 700;
2814 font-size: 16px;
2815 letter-spacing: -0.01em;
2816 color: var(--text-strong);
2817 margin: 0;
2818 }
2819 .repo-empty-option-sub {
2820 font-size: 13px;
2821 color: var(--text-muted);
2822 line-height: 1.5;
2823 margin: 0;
2824 flex: 1;
2825 }
2826 .repo-empty-option-snippet {
2827 background: var(--bg);
2828 border: 1px solid var(--border);
2829 border-radius: 8px;
2830 padding: var(--space-2) var(--space-3);
2831 font-family: var(--font-mono);
2832 font-size: 11.5px;
2833 line-height: 1.75;
2834 color: var(--text-strong);
2835 overflow-x: auto;
2836 white-space: pre;
2837 margin: var(--space-1) 0 0;
2838 }
2839 .repo-empty-option-snippet .reo-cmt { color: var(--text-faint); }
2840 .repo-empty-option-snippet .reo-cmd { color: var(--accent); }
2841 .repo-empty-option-cta {
2842 display: inline-flex;
2843 align-items: center;
2844 gap: 6px;
2845 margin-top: auto;
2846 padding-top: var(--space-2);
2847 font-size: 13px;
2848 font-weight: 600;
2849 color: var(--accent);
2850 text-decoration: none;
2851 transition: color 120ms ease;
2852 }
2853 .repo-empty-option-cta:hover { color: var(--text-strong); text-decoration: none; }
2854
544d842Claude2855 @media (max-width: 720px) {
2856 .repo-home-hero { padding: var(--space-4) var(--space-4); }
2857 .repo-home-clone-body { flex-direction: column; align-items: stretch; }
2858 .repo-home-clone-copy { width: 100%; }
f1dc7c7Claude2859 .repo-home-stat-row { gap: var(--space-2) var(--space-3); font-size: 12.5px; }
2860 .repo-home-side-val { max-width: 55%; }
2861 .repo-home-clone-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
2862 .repo-home-clone-tab { min-height: 44px; padding: 11px 14px; }
2863 .repo-home-side-card { padding: var(--space-3); }
544d842Claude2864 }
2865 `;
2866 const cloneHttpsUrl = `${config.appBaseUrl}/${owner}/${repo}.git`;
60323c5Claude2867 // SSH URL — port-aware:
2868 // Standard port 22 → git@host:owner/repo.git
2869 // Non-standard port → ssh://git@host:PORT/owner/repo.git
544d842Claude2870 let cloneSshUrl = `git@gluecron.com:${owner}/${repo}.git`;
2871 try {
2872 const host = new URL(config.appBaseUrl).hostname;
60323c5Claude2873 const sshHost = (host && host !== "localhost" && host !== "127.0.0.1")
2874 ? host
2875 : "localhost";
2876 const sshPort = config.sshPort;
2877 if (sshPort === 22) {
2878 cloneSshUrl = `git@${sshHost}:${owner}/${repo}.git`;
2879 } else {
2880 cloneSshUrl = `ssh://git@${sshHost}:${sshPort}/${owner}/${repo}.git`;
544d842Claude2881 }
2882 } catch {
2883 // Fall through to default.
2884 }
2885 const cloneCliCmd = `gluecron clone ${owner}/${repo}`;
2886 const formatRelative = (date: Date | null): string => {
2887 if (!date) return "never";
2888 const ms = Date.now() - date.getTime();
2889 const s = Math.max(0, Math.round(ms / 1000));
2890 if (s < 60) return "just now";
2891 const m = Math.round(s / 60);
2892 if (m < 60) return `${m} min ago`;
2893 const h = Math.round(m / 60);
2894 if (h < 24) return `${h}h ago`;
2895 const d = Math.round(h / 24);
2896 if (d < 30) return `${d}d ago`;
2897 const mo = Math.round(d / 30);
2898 if (mo < 12) return `${mo}mo ago`;
2899 const y = Math.round(d / 365);
2900 return `${y}y ago`;
2901 };
06d5ffeClaude2902
fc1817aClaude2903 if (tree.length === 0) {
2904 return c.html(
06d5ffeClaude2905 <Layout title={`${owner}/${repo}`} user={user}>
544d842Claude2906 <style dangerouslySetInnerHTML={{ __html: repoHomeCss }} />
91a0204Claude2907 <style dangerouslySetInnerHTML={{ __html: `
2908 .empty-options-grid {
2909 display: grid;
2910 grid-template-columns: repeat(3, 1fr);
2911 gap: var(--space-4);
2912 margin-top: var(--space-4);
2913 }
2914 @media (max-width: 800px) {
2915 .empty-options-grid { grid-template-columns: 1fr; }
2916 }
2917 .empty-option-card {
2918 position: relative;
2919 background: var(--bg-elevated);
2920 border: 1px solid var(--border);
2921 border-radius: 14px;
2922 padding: var(--space-5);
2923 display: flex;
2924 flex-direction: column;
2925 gap: var(--space-3);
2926 overflow: hidden;
2927 transition: border-color 140ms ease, box-shadow 140ms ease;
2928 }
2929 .empty-option-card:hover {
2930 border-color: rgba(140,109,255,0.45);
2931 box-shadow: 0 8px 24px -8px rgba(140,109,255,0.18);
2932 }
2933 .empty-option-card::before {
2934 content: '';
2935 position: absolute;
2936 top: 0; left: 0; right: 0;
2937 height: 2px;
2938 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
2939 opacity: 0.55;
2940 pointer-events: none;
2941 }
2942 .empty-option-label {
2943 font-size: 10.5px;
2944 font-family: var(--font-mono);
2945 text-transform: uppercase;
2946 letter-spacing: 0.14em;
2947 color: var(--accent);
2948 font-weight: 700;
2949 }
2950 .empty-option-title {
2951 font-family: var(--font-display);
2952 font-weight: 700;
2953 font-size: 17px;
2954 letter-spacing: -0.01em;
2955 color: var(--text-strong);
2956 margin: 0;
2957 line-height: 1.25;
2958 }
2959 .empty-option-body {
2960 font-size: 13px;
2961 color: var(--text-muted);
2962 line-height: 1.55;
2963 margin: 0;
2964 flex: 1;
2965 }
2966 .empty-option-snippet {
2967 background: var(--bg);
2968 border: 1px solid var(--border);
2969 border-radius: 8px;
2970 padding: var(--space-3) var(--space-4);
2971 font-family: var(--font-mono);
2972 font-size: 11.5px;
2973 line-height: 1.75;
2974 color: var(--text-strong);
2975 overflow-x: auto;
2976 white-space: pre;
2977 margin: 0;
2978 }
2979 .empty-option-snippet .ec { color: var(--text-faint); }
2980 .empty-option-snippet .em { color: var(--accent); }
2981 .empty-option-cta {
2982 display: inline-flex;
2983 align-items: center;
2984 gap: 6px;
2985 padding: 8px 16px;
2986 font-size: 13px;
2987 font-weight: 600;
2988 color: var(--text-strong);
2989 background: var(--bg-secondary);
2990 border: 1px solid var(--border);
2991 border-radius: 9999px;
2992 text-decoration: none;
2993 align-self: flex-start;
2994 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
2995 }
2996 .empty-option-cta:hover {
2997 border-color: rgba(140,109,255,0.55);
2998 background: rgba(140,109,255,0.08);
2999 color: var(--accent);
3000 text-decoration: none;
3001 }
3002 .empty-option-cta-accent {
3003 background: linear-gradient(135deg, #8c6dff, #36c5d6);
3004 border-color: transparent;
3005 color: #fff;
3006 }
3007 .empty-option-cta-accent:hover {
3008 background: linear-gradient(135deg, #7c5df0, #28b4c8);
3009 border-color: transparent;
3010 color: #fff;
3011 box-shadow: 0 6px 18px -6px rgba(140,109,255,0.55);
3012 }
3013 ` }} />
544d842Claude3014 <div class="repo-home-hero">
3015 <div class="repo-home-hero-orb-wrap" aria-hidden="true">
3016 <div class="repo-home-hero-orb" />
3017 </div>
3018 <div class="repo-home-hero-inner">
3019 <div class="repo-home-eyebrow">
3020 <strong>Repository</strong> · {owner}
3021 </div>
91a0204Claude3022 <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;">
3023 <RepoHeader
3024 owner={owner}
3025 repo={repo}
3026 starCount={starCount}
3027 starred={starred}
3028 forkCount={forkCount}
3029 currentUser={user?.username}
3030 archived={archived}
3031 isTemplate={isTemplate}
3032 />
3033 {healthScore && (() => {
3034 const gradeLabel: Record<string, string> = {
3035 elite: "Elite", strong: "Strong",
3036 improving: "Improving", "needs-attention": "Needs Attention",
3037 };
3038 return (
3039 <a
3040 href={`/${owner}/${repo}/insights/health`}
3041 class={`repo-health-badge repo-health-badge-${healthScore!.grade}`}
3042 title={`Health score: ${healthScore!.total}/100`}
3043 >
3044 {gradeLabel[healthScore!.grade] ?? healthScore!.grade}
3045 </a>
3046 );
3047 })()}
3048 </div>
544d842Claude3049 {description ? (
3050 <p class="repo-home-description">{description}</p>
3051 ) : (
3052 <p class="repo-home-description-empty">
3053 No description yet — push a README to tell the world what this
3054 ships.
3055 </p>
3056 )}
3057 </div>
3058 </div>
fc1817aClaude3059 <RepoNav owner={owner} repo={repo} active="code" />
91a0204Claude3060 <div style="margin-top:var(--space-4)">
3061 <div style="font-size:12px;font-family:var(--font-mono);color:var(--accent);letter-spacing:0.12em;text-transform:uppercase;font-weight:600;margin-bottom:var(--space-2)">
3062 Getting started
3063 </div>
544d842Claude3064 <h2 class="repo-home-empty-title">
91a0204Claude3065 <span class="gradient-text">{repo}</span> is ready — make your first move.
544d842Claude3066 </h2>
3067 <p class="repo-home-empty-sub">
91a0204Claude3068 Choose how you want to kick things off. Every push wires up gate
3069 checks and AI review automatically.
544d842Claude3070 </p>
91a0204Claude3071 <div class="empty-options-grid">
3072 <div class="empty-option-card">
3073 <div class="empty-option-label">Option A</div>
3074 <h3 class="empty-option-title">Push your first commit</h3>
3075 <p class="empty-option-body">
3076 Wire up an existing project in seconds. Run these commands from
3077 your project directory.
3078 </p>
3079 <pre class="empty-option-snippet"><span class="ec"># from your project directory</span>
3080<span class="em">git remote add</span> origin {cloneHttpsUrl}
3081<span class="em">git branch</span> -M main
3082<span class="em">git push</span> -u origin main</pre>
3083 </div>
3084 <div class="empty-option-card">
3085 <div class="empty-option-label">Option B</div>
3086 <h3 class="empty-option-title">Import from GitHub</h3>
3087 <p class="empty-option-body">
3088 Mirror an existing GitHub repository here in one click. Gluecron
3089 syncs the full history and branches.
3090 </p>
3091 <a href="/import" class="empty-option-cta">
3092 Import repository
3093 </a>
3094 </div>
3095 <div class="empty-option-card">
3096 <div class="empty-option-label">Option C</div>
3097 <h3 class="empty-option-title">Try Spec-to-PR</h3>
3098 <p class="empty-option-body">
3099 Let AI write your first feature. Describe what you want to build
3100 and Gluecron opens a pull request with the code.
3101 </p>
3102 <a href={`/${owner}/${repo}/specs`} class="empty-option-cta empty-option-cta-accent">
3103 Let AI write your first feature
3104 </a>
3105 </div>
3106 </div>
fc1817aClaude3107 </div>
3108 </Layout>
3109 );
3110 }
3111
3112 const readme = await getReadme(owner, repo, defaultBranch);
3113
544d842Claude3114 // Sidebar facts — derived from data we already have.
3115 const fileCount = tree.filter((e: any) => e.type !== "tree").length;
3116 const dirCount = tree.filter((e: any) => e.type === "tree").length;
3117
fc1817aClaude3118 return c.html(
06d5ffeClaude3119 <Layout title={`${owner}/${repo}`} user={user}>
544d842Claude3120 <style dangerouslySetInnerHTML={{ __html: repoHomeCss }} />
3121 <div class="repo-home-hero">
3122 <div class="repo-home-hero-orb-wrap" aria-hidden="true">
3123 <div class="repo-home-hero-orb" />
3124 </div>
3125 <div class="repo-home-hero-inner">
3126 <div class="repo-home-eyebrow">
3127 <strong>Repository</strong> · {owner}
3128 </div>
91a0204Claude3129 <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;">
3130 <RepoHeader
3131 owner={owner}
3132 repo={repo}
3133 starCount={starCount}
3134 starred={starred}
3135 forkCount={forkCount}
3136 currentUser={user?.username}
3137 archived={archived}
3138 isTemplate={isTemplate}
3139 />
3140 {healthScore && (() => {
3141 const gradeLabel: Record<string, string> = {
3142 elite: "Elite", strong: "Strong",
3143 improving: "Improving", "needs-attention": "Needs Attention",
3144 };
3145 return (
3146 <a
3147 href={`/${owner}/${repo}/insights/health`}
3148 class={`repo-health-badge repo-health-badge-${healthScore!.grade}`}
3149 title={`Health score: ${healthScore!.total}/100`}
3150 >
3151 {gradeLabel[healthScore!.grade] ?? healthScore!.grade}
3152 </a>
3153 );
3154 })()}
3155 </div>
544d842Claude3156 {description ? (
3157 <p class="repo-home-description">{description}</p>
3158 ) : (
3159 <p class="repo-home-description-empty">
3160 No description yet.
3161 </p>
3162 )}
3163 <div class="repo-home-stat-row" aria-label="Repository stats">
3164 <span class="repo-home-stat" title="Default branch">
3165 <span class="repo-home-stat-icon">{"⎇"}</span>
3166 <strong>{defaultBranch}</strong>
3167 </span>
3168 <a
3169 href={`/${owner}/${repo}/commits/${defaultBranch}`}
3170 class="repo-home-stat"
3171 title="Browse all branches"
3172 >
3173 <span class="repo-home-stat-icon">{"⊢"}</span>
3174 <strong>{branches.length}</strong>{" "}
3175 branch{branches.length === 1 ? "" : "es"}
3176 </a>
3177 <span class="repo-home-stat" title="Top-level entries">
3178 <span class="repo-home-stat-icon">{"■"}</span>
3179 <strong>{fileCount}</strong> file{fileCount === 1 ? "" : "s"}
3180 {dirCount > 0 && (
3181 <>
3182 {" · "}
3183 <strong>{dirCount}</strong> dir{dirCount === 1 ? "" : "s"}
3184 </>
3185 )}
3186 </span>
3187 {pushedAt && (
3188 <span class="repo-home-stat" title={`Last push: ${pushedAt.toISOString()}`}>
3189 <span class="repo-home-stat-icon">{"↻"}</span>
3190 Updated <strong>{formatRelative(pushedAt)}</strong>
3191 </span>
3192 )}
3193 </div>
3194 </div>
3195 </div>
71cd5ecClaude3196 {isTemplate && user && user.username !== owner && (
3197 <div
3198 class="panel"
dc26881CC LABS App3199 style="margin-bottom:var(--space-4);padding:var(--space-3);display:flex;align-items:center;justify-content:space-between;gap:var(--space-3)"
71cd5ecClaude3200 >
3201 <div style="font-size:13px">
3202 <strong>Template repository.</strong> Create a new repository from
3203 this template's files.
3204 </div>
3205 <form
001af43Claude3206 method="post"
71cd5ecClaude3207 action={`/${owner}/${repo}/use-template`}
dc26881CC LABS App3208 style="display:flex;gap:var(--space-2);align-items:center"
71cd5ecClaude3209 >
3210 <input
3211 type="text"
3212 name="name"
3213 placeholder="new-repo-name"
3214 required
2c3ba6ecopilot-swe-agent[bot]3215 aria-label="New repository name"
71cd5ecClaude3216 style="width:200px"
3217 />
3218 <button type="submit" class="btn btn-primary">
3219 Use this template
3220 </button>
3221 </form>
3222 </div>
3223 )}
fc1817aClaude3224 <RepoNav owner={owner} repo={repo} active="code" />
cb5a796Claude3225 <RepoHomePendingBanner
3226 owner={owner}
3227 repo={repo}
3228 count={repoHomePendingCount}
3229 />
c6018a5Claude3230 {/* ─── Per-repo AI surfaces — RepoNav is locked, so the discovery
3231 row sits just below the nav as a slim CTA strip. Scoped under
3232 `.repo-ai-cta-` so the styles can't bleed onto other pages. ─── */}
3233 <style
3234 dangerouslySetInnerHTML={{
3235 __html: `
3236 .repo-ai-cta-row {
3237 display: flex;
3238 flex-wrap: wrap;
3239 gap: 8px;
3240 margin: 12px 0 18px;
3241 padding: 10px 14px;
3242 background: linear-gradient(135deg, rgba(140,109,255,0.06), rgba(54,197,214,0.04));
3243 border: 1px solid var(--border);
3244 border-radius: 10px;
3245 position: relative;
3246 overflow: hidden;
3247 }
3248 .repo-ai-cta-row::before {
3249 content: '';
3250 position: absolute;
3251 top: 0; left: 0; right: 0;
3252 height: 1px;
3253 background: linear-gradient(90deg, transparent 0%, rgba(140,109,255,0.45) 30%, rgba(54,197,214,0.45) 70%, transparent 100%);
3254 opacity: 0.7;
3255 pointer-events: none;
3256 }
3257 .repo-ai-cta-label {
3258 font-size: 11px;
3259 font-weight: 600;
3260 letter-spacing: 0.06em;
3261 text-transform: uppercase;
3262 color: var(--accent);
3263 align-self: center;
3264 padding-right: 8px;
3265 border-right: 1px solid var(--border);
3266 margin-right: 4px;
3267 }
3268 .repo-ai-cta {
3269 display: inline-flex;
3270 align-items: center;
3271 gap: 6px;
3272 padding: 5px 10px;
3273 font-size: 12.5px;
3274 font-weight: 500;
3275 color: var(--text);
3276 background: var(--bg);
3277 border: 1px solid var(--border);
3278 border-radius: 7px;
3279 text-decoration: none;
3280 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
3281 }
3282 .repo-ai-cta:hover {
3283 border-color: rgba(140,109,255,0.45);
3284 color: var(--text-strong);
3285 background: rgba(140,109,255,0.06);
3286 text-decoration: none;
3287 }
3288 .repo-ai-cta-icon {
3289 opacity: 0.75;
3290 font-size: 12px;
3291 }
3292 @media (max-width: 640px) {
3293 .repo-ai-cta-row { flex-direction: column; align-items: stretch; }
3294 .repo-ai-cta-label { border-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-right: 0; }
3295 }
3296 `,
3297 }}
3298 />
3299 <nav class="repo-ai-cta-row" aria-label="AI surfaces for this repository">
3300 <span class="repo-ai-cta-label">AI surfaces</span>
3301 <a class="repo-ai-cta" href={`/${owner}/${repo}/chat`} title="Rubber-duck chat grounded in this repo">
3302 <span class="repo-ai-cta-icon" aria-hidden="true">{"\u{1F4AC}"}</span>
3303 Chat
3304 </a>
3305 <a class="repo-ai-cta" href={`/${owner}/${repo}/previews`} title="Ephemeral preview URLs per branch">
3306 <span class="repo-ai-cta-icon" aria-hidden="true">{"\u{1F30D}"}</span>
3307 Previews
3308 </a>
3309 <a class="repo-ai-cta" href={`/${owner}/${repo}/migrations/propose`} title="AI proposes the Drizzle migration for a schema change">
3310 <span class="repo-ai-cta-icon" aria-hidden="true">{"⛁"}</span>
3311 Migrations
3312 </a>
3313 <a class="repo-ai-cta" href={`/${owner}/${repo}/semantic-search`} title="Embedding-backed code search">
3314 <span class="repo-ai-cta-icon" aria-hidden="true">{"✨"}</span>
3315 Semantic search
3316 </a>
3317 <a class="repo-ai-cta" href={`/${owner}/${repo}/releases/new`} title="Draft release notes with AI">
3318 <span class="repo-ai-cta-icon" aria-hidden="true">{"\u{1F3F7}"}</span>
3319 AI release notes
3320 </a>
3646bfeClaude3321 <a class="repo-ai-cta" href={`/${owner}/${repo}/dev`} title="Open a hosted VS Code dev environment in the browser">
3322 <span class="repo-ai-cta-icon" aria-hidden="true">{"💻"}</span>
3323 Dev environment
3324 </a>
c6018a5Claude3325 </nav>
544d842Claude3326 <div class="repo-home-grid">
3327 <div class="repo-home-main">
3328 <BranchSwitcher
3329 owner={owner}
3330 repo={repo}
3331 currentRef={defaultBranch}
3332 branches={branches}
3333 pathType="tree"
3334 />
3335 <FileTable
3336 entries={tree}
3337 owner={owner}
3338 repo={repo}
3339 ref={defaultBranch}
3340 path=""
3341 />
3342 {readme && (() => {
3343 const readmeHtml = renderMarkdown(readme);
3344 return (
3345 <div class="repo-home-readme">
3346 <div class="repo-home-readme-head">
3347 <span class="repo-home-readme-icon">{"☰"}</span>
3348 <span>README.md</span>
3349 </div>
3350 <style>{markdownCss}</style>
3351 <div class="markdown-body repo-home-readme-body">
3352 {html([readmeHtml] as unknown as TemplateStringsArray)}
3353 </div>
3354 </div>
3355 );
3356 })()}
3357 </div>
3358 <aside class="repo-home-side" aria-label="Repository details">
3359 <div class="repo-home-clone">
3360 <div class="repo-home-clone-tabs" role="tablist" aria-label="Clone protocol">
3361 <button
3362 type="button"
3363 class="repo-home-clone-tab"
3364 role="tab"
3365 aria-selected="true"
3366 data-pane="https"
3367 data-repo-home-clone-tab
3368 >
3369 HTTPS
3370 </button>
3371 <button
3372 type="button"
3373 class="repo-home-clone-tab"
3374 role="tab"
3375 aria-selected="false"
3376 data-pane="ssh"
3377 data-repo-home-clone-tab
3378 >
3379 SSH
3380 </button>
3381 <button
3382 type="button"
3383 class="repo-home-clone-tab"
3384 role="tab"
3385 aria-selected="false"
3386 data-pane="cli"
3387 data-repo-home-clone-tab
3388 >
3389 CLI
3390 </button>
3391 </div>
3392 <div
3393 class="repo-home-clone-pane"
3394 data-pane="https"
3395 data-active="true"
3396 role="tabpanel"
3397 >
3398 <div class="repo-home-clone-body">
3399 <input
3400 class="repo-home-clone-input"
3401 type="text"
3402 value={cloneHttpsUrl}
3403 readonly
3404 aria-label="HTTPS clone URL"
3405 data-repo-home-clone-input
3406 />
3407 <button
3408 type="button"
3409 class="repo-home-clone-copy"
3410 data-repo-home-copy={cloneHttpsUrl}
3411 >
3412 Copy
3413 </button>
3414 </div>
3415 </div>
3416 <div
3417 class="repo-home-clone-pane"
3418 data-pane="ssh"
3419 data-active="false"
3420 role="tabpanel"
3421 >
3422 <div class="repo-home-clone-body">
3423 <input
3424 class="repo-home-clone-input"
3425 type="text"
3426 value={cloneSshUrl}
3427 readonly
3428 aria-label="SSH clone URL"
3429 data-repo-home-clone-input
3430 />
3431 <button
3432 type="button"
3433 class="repo-home-clone-copy"
3434 data-repo-home-copy={cloneSshUrl}
3435 >
3436 Copy
3437 </button>
3438 </div>
3439 </div>
3440 <div
3441 class="repo-home-clone-pane"
3442 data-pane="cli"
3443 data-active="false"
3444 role="tabpanel"
3445 >
3446 <div class="repo-home-clone-body">
3447 <input
3448 class="repo-home-clone-input"
3449 type="text"
3450 value={cloneCliCmd}
3451 readonly
3452 aria-label="Gluecron CLI clone command"
3453 data-repo-home-clone-input
3454 />
3455 <button
3456 type="button"
3457 class="repo-home-clone-copy"
3458 data-repo-home-copy={cloneCliCmd}
3459 >
3460 Copy
3461 </button>
3462 </div>
79136bbClaude3463 </div>
fc1817aClaude3464 </div>
544d842Claude3465 <div class="repo-home-side-card">
3466 <h3 class="repo-home-side-title">About</h3>
3467 <div class="repo-home-side-row">
3468 <span class="repo-home-side-key">Default branch</span>
3469 <span class="repo-home-side-val">{defaultBranch}</span>
3470 </div>
3471 <div class="repo-home-side-row">
3472 <span class="repo-home-side-key">Branches</span>
3473 <span class="repo-home-side-val">
3474 <a href={`/${owner}/${repo}/commits/${defaultBranch}`}>
3475 {branches.length}
3476 </a>
3477 </span>
3478 </div>
3479 <div class="repo-home-side-row">
3480 <span class="repo-home-side-key">Stars</span>
3481 <span class="repo-home-side-val">{starCount}</span>
3482 </div>
3483 <div class="repo-home-side-row">
3484 <span class="repo-home-side-key">Forks</span>
3485 <span class="repo-home-side-val">{forkCount}</span>
3486 </div>
3487 {pushedAt && (
3488 <div class="repo-home-side-row">
3489 <span class="repo-home-side-key">Last push</span>
3490 <span class="repo-home-side-val">
3491 {formatRelative(pushedAt)}
3492 </span>
3493 </div>
3494 )}
3495 {createdAt && (
3496 <div class="repo-home-side-row">
3497 <span class="repo-home-side-key">Created</span>
3498 <span class="repo-home-side-val">
3499 {formatRelative(createdAt)}
3500 </span>
3501 </div>
3502 )}
3503 {(archived || isTemplate) && (
3504 <div class="repo-home-side-row">
3505 <span class="repo-home-side-key">State</span>
3506 <span class="repo-home-side-val">
3507 {archived ? "Archived" : "Template"}
3508 </span>
3509 </div>
3510 )}
3511 </div>
3512 </aside>
3513 </div>
3514 <script
3515 dangerouslySetInnerHTML={{
3516 __html: `
3517 (function(){
3518 var tabs = document.querySelectorAll('[data-repo-home-clone-tab]');
3519 tabs.forEach(function(tab){
3520 tab.addEventListener('click', function(){
3521 var target = tab.getAttribute('data-pane');
3522 tabs.forEach(function(t){
3523 t.setAttribute('aria-selected', t === tab ? 'true' : 'false');
3524 });
3525 var panes = document.querySelectorAll('.repo-home-clone-pane');
3526 panes.forEach(function(p){
3527 p.setAttribute('data-active', p.getAttribute('data-pane') === target ? 'true' : 'false');
3528 });
3529 });
3530 });
3531 var copyBtns = document.querySelectorAll('[data-repo-home-copy]');
3532 copyBtns.forEach(function(btn){
3533 btn.addEventListener('click', function(){
3534 var text = btn.getAttribute('data-repo-home-copy') || '';
3535 var done = function(){
3536 var prev = btn.textContent;
3537 btn.textContent = 'Copied';
3538 setTimeout(function(){ btn.textContent = prev; }, 1200);
3539 };
3540 if (navigator.clipboard && navigator.clipboard.writeText) {
3541 navigator.clipboard.writeText(text).then(done, done);
3542 } else {
3543 var ta = document.createElement('textarea');
3544 ta.value = text;
3545 document.body.appendChild(ta);
3546 ta.select();
3547 try { document.execCommand('copy'); } catch (e) {}
3548 document.body.removeChild(ta);
3549 done();
3550 }
3551 });
3552 });
3553 })();
3554 `,
3555 }}
3556 />
fc1817aClaude3557 </Layout>
3558 );
3559});
3560
3561// Browse tree at ref/path
3562web.get("/:owner/:repo/tree/:ref{.+$}", async (c) => {
3563 const { owner, repo } = c.req.param();
06d5ffeClaude3564 const user = c.get("user");
fc1817aClaude3565 const refAndPath = c.req.param("ref");
3566
3567 const branches = await listBranches(owner, repo);
3568 let ref = "";
3569 let treePath = "";
3570
3571 for (const branch of branches) {
3572 if (refAndPath === branch || refAndPath.startsWith(branch + "/")) {
3573 ref = branch;
3574 treePath = refAndPath.slice(branch.length + 1);
3575 break;
3576 }
3577 }
3578
3579 if (!ref) {
3580 const slashIdx = refAndPath.indexOf("/");
3581 if (slashIdx === -1) {
3582 ref = refAndPath;
3583 } else {
3584 ref = refAndPath.slice(0, slashIdx);
3585 treePath = refAndPath.slice(slashIdx + 1);
3586 }
3587 }
3588
3589 const tree = await getTree(owner, repo, ref, treePath);
efb11c5Claude3590 const fileCount = tree.filter((e: any) => e.type !== "tree").length;
3591 const dirCount = tree.filter((e: any) => e.type === "tree").length;
fc1817aClaude3592
3593 return c.html(
06d5ffeClaude3594 <Layout title={`${treePath || "/"} — ${owner}/${repo}`} user={user}>
efb11c5Claude3595 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude3596 <RepoHeader owner={owner} repo={repo} />
3597 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude3598 <div class="tree-header">
3599 <div class="tree-header-row">
3600 <BranchSwitcher
3601 owner={owner}
3602 repo={repo}
3603 currentRef={ref}
3604 branches={branches}
3605 pathType="tree"
3606 subPath={treePath}
3607 />
3608 <div class="tree-header-stats">
3609 <span class="tree-stat" title="Entries in this directory">
3610 <strong>{fileCount}</strong> file{fileCount === 1 ? "" : "s"}
3611 {dirCount > 0 && (
3612 <>
3613 {" · "}
3614 <strong>{dirCount}</strong> dir{dirCount === 1 ? "" : "s"}
3615 </>
3616 )}
3617 </span>
3618 <a
3619 href={`/${owner}/${repo}/search`}
3620 class="tree-stat tree-stat-link"
3621 title="Search code in this repository"
3622 >
3623 {"⌕"} Search
3624 </a>
3625 </div>
3626 </div>
3627 <div class="tree-breadcrumb-row">
3628 <Breadcrumb owner={owner} repo={repo} ref={ref} path={treePath} />
3629 </div>
3630 </div>
fc1817aClaude3631 <FileTable
3632 entries={tree}
3633 owner={owner}
3634 repo={repo}
3635 ref={ref}
3636 path={treePath}
3637 />
3638 </Layout>
3639 );
3640});
3641
06d5ffeClaude3642// View file blob with syntax highlighting
fc1817aClaude3643web.get("/:owner/:repo/blob/:ref{.+$}", async (c) => {
3644 const { owner, repo } = c.req.param();
06d5ffeClaude3645 const user = c.get("user");
fc1817aClaude3646 const refAndPath = c.req.param("ref");
3647
3648 const branches = await listBranches(owner, repo);
3649 let ref = "";
3650 let filePath = "";
3651
3652 for (const branch of branches) {
3653 if (refAndPath.startsWith(branch + "/")) {
3654 ref = branch;
3655 filePath = refAndPath.slice(branch.length + 1);
3656 break;
3657 }
3658 }
3659
3660 if (!ref) {
3661 const slashIdx = refAndPath.indexOf("/");
3662 if (slashIdx === -1) return c.text("Not found", 404);
3663 ref = refAndPath.slice(0, slashIdx);
3664 filePath = refAndPath.slice(slashIdx + 1);
3665 }
3666
3667 const blob = await getBlob(owner, repo, ref, filePath);
3668 if (!blob) {
3669 return c.html(
06d5ffeClaude3670 <Layout title="Not Found" user={user}>
fc1817aClaude3671 <div class="empty-state">
3672 <h2>File not found</h2>
3673 </div>
3674 </Layout>,
3675 404
3676 );
3677 }
3678
06d5ffeClaude3679 const fileName = filePath.split("/").pop() || filePath;
efb11c5Claude3680 const lineCount = blob.isBinary
3681 ? 0
3682 : (blob.content.endsWith("\n")
3683 ? blob.content.split("\n").length - 1
3684 : blob.content.split("\n").length);
3685 const formatBytes = (n: number): string => {
3686 if (n < 1024) return `${n} B`;
3687 if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
3688 return `${(n / (1024 * 1024)).toFixed(1)} MB`;
3689 };
fc1817aClaude3690
3691 return c.html(
06d5ffeClaude3692 <Layout title={`${filePath} — ${owner}/${repo}`} user={user}>
efb11c5Claude3693 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude3694 <RepoHeader owner={owner} repo={repo} />
3695 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude3696 <div class="blob-toolbar">
3697 <BranchSwitcher
3698 owner={owner}
3699 repo={repo}
3700 currentRef={ref}
3701 branches={branches}
3702 pathType="blob"
3703 subPath={filePath}
3704 />
3705 <div class="blob-breadcrumb">
3706 <Breadcrumb owner={owner} repo={repo} ref={ref} path={filePath} />
3707 </div>
3708 </div>
3709 <div class="blob-view blob-card">
3710 <div class="blob-header blob-header-polished">
3711 <div class="blob-header-meta">
3712 <span class="blob-header-icon" aria-hidden="true">
3713 {"📄"}
3714 </span>
3715 <span class="blob-header-name">{fileName}</span>
3716 <span class="blob-header-size">
3717 {formatBytes(blob.size)}
3718 {!blob.isBinary && (
3719 <>
3720 {" · "}
3721 {lineCount} line{lineCount === 1 ? "" : "s"}
3722 </>
3723 )}
3724 </span>
3725 </div>
3726 <div class="blob-header-actions">
3727 <a
3728 href={`/${owner}/${repo}/raw/${ref}/${filePath}`}
3729 class="blob-pill"
3730 >
79136bbClaude3731 Raw
3732 </a>
efb11c5Claude3733 <a
3734 href={`/${owner}/${repo}/blame/${ref}/${filePath}`}
3735 class="blob-pill"
3736 >
79136bbClaude3737 Blame
3738 </a>
efb11c5Claude3739 <a
3740 href={`/${owner}/${repo}/timeline/${ref}/${filePath}`}
3741 class="blob-pill"
3742 >
16b325cClaude3743 History
3744 </a>
0074234Claude3745 {user && (
efb11c5Claude3746 <a
3747 href={`/${owner}/${repo}/edit/${ref}/${filePath}`}
3748 class="blob-pill blob-pill-accent"
3749 >
0074234Claude3750 Edit
3751 </a>
3752 )}
efb11c5Claude3753 </div>
fc1817aClaude3754 </div>
3755 {blob.isBinary ? (
efb11c5Claude3756 <div class="blob-binary">
fc1817aClaude3757 Binary file not shown.
3758 </div>
06d5ffeClaude3759 ) : (() => {
3760 const { html: highlighted, language } = highlightCode(
3761 blob.content,
3762 fileName
3763 );
3764 if (language) {
3765 return (
3766 <HighlightedCode
3767 highlightedHtml={highlighted}
efb11c5Claude3768 lineCount={lineCount}
06d5ffeClaude3769 />
3770 );
3771 }
3772 const lines = blob.content.split("\n");
3773 if (lines[lines.length - 1] === "") lines.pop();
3774 return <PlainCode lines={lines} />;
3775 })()}
fc1817aClaude3776 </div>
3777 </Layout>
3778 );
3779});
3780
398a10cClaude3781// ─── Branches list ────────────────────────────────────────────────────────
3782// Lightweight `git for-each-ref` enrichment so each row shows last-commit
3783// author + relative time + ahead/behind vs the default branch. No DB. All
3784// data comes from git plumbing; failures degrade gracefully (counts omitted).
3785web.get("/:owner/:repo/branches", async (c) => {
3786 const { owner, repo } = c.req.param();
3787 const user = c.get("user");
3788
3789 if (!(await repoExists(owner, repo))) return c.notFound();
3790
3791 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
3792 const branches = await listBranches(owner, repo);
3793 const repoDir = getRepoPath(owner, repo);
3794
3795 type BranchRow = {
3796 name: string;
3797 isDefault: boolean;
3798 sha: string;
3799 subject: string;
3800 author: string;
3801 date: string;
3802 ahead: number;
3803 behind: number;
3804 };
3805
3806 const runGit = async (args: string[]): Promise<string> => {
3807 try {
3808 const proc = Bun.spawn(["git", ...args], {
3809 cwd: repoDir,
3810 stdout: "pipe",
3811 stderr: "pipe",
3812 });
3813 const out = await new Response(proc.stdout).text();
3814 await proc.exited;
3815 return out;
3816 } catch {
3817 return "";
3818 }
3819 };
3820
3821 const meta = await runGit([
3822 "for-each-ref",
3823 "--sort=-committerdate",
3824 "--format=%(refname:short)%00%(objectname)%00%(subject)%00%(authorname)%00%(committerdate:iso-strict)",
3825 "refs/heads/",
3826 ]);
3827 const metaByName: Record<
3828 string,
3829 { sha: string; subject: string; author: string; date: string }
3830 > = {};
3831 for (const line of meta.split("\n").filter(Boolean)) {
3832 const [name, sha, subject, author, date] = line.split("\0");
3833 metaByName[name] = { sha, subject, author, date };
3834 }
3835
3836 const branchOrder = [...branches].sort((a, b) => {
3837 if (a === defaultBranch) return -1;
3838 if (b === defaultBranch) return 1;
3839 const aDate = metaByName[a]?.date || "";
3840 const bDate = metaByName[b]?.date || "";
3841 return bDate.localeCompare(aDate);
3842 });
3843
3844 const rows: BranchRow[] = [];
3845 for (const name of branchOrder) {
3846 const m = metaByName[name] || { sha: "", subject: "", author: "", date: "" };
3847 let ahead = 0;
3848 let behind = 0;
3849 if (name !== defaultBranch && metaByName[defaultBranch]) {
3850 const out = await runGit([
3851 "rev-list",
3852 "--left-right",
3853 "--count",
3854 `${defaultBranch}...${name}`,
3855 ]);
3856 const parts = out.trim().split(/\s+/);
3857 if (parts.length === 2) {
3858 behind = parseInt(parts[0], 10) || 0;
3859 ahead = parseInt(parts[1], 10) || 0;
3860 }
3861 }
3862 rows.push({
3863 name,
3864 isDefault: name === defaultBranch,
3865 sha: m.sha,
3866 subject: m.subject,
3867 author: m.author,
3868 date: m.date,
3869 ahead,
3870 behind,
3871 });
3872 }
3873
3874 const relative = (iso: string): string => {
3875 if (!iso) return "—";
3876 const d = new Date(iso);
3877 if (Number.isNaN(d.getTime())) return "—";
3878 const diff = Date.now() - d.getTime();
3879 const m = Math.floor(diff / 60000);
3880 if (m < 1) return "just now";
3881 if (m < 60) return `${m} min ago`;
3882 const h = Math.floor(m / 60);
3883 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
3884 const dd = Math.floor(h / 24);
3885 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
3886 return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
3887 };
3888
3889 const success = c.req.query("success");
3890 const error = c.req.query("error");
3891
3892 return c.html(
3893 <Layout title={`Branches — ${owner}/${repo}`} user={user}>
3894 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
3895 <RepoHeader owner={owner} repo={repo} />
3896 <RepoNav owner={owner} repo={repo} active="code" />
3897 <div
3898 class="branches-wrap"
eed4684Claude3899 style="max-width:1680px;margin:0 auto;padding:var(--space-5) var(--space-4) var(--space-8)"
398a10cClaude3900 >
3901 <header class="branches-head" style="margin-bottom:var(--space-5)">
3902 <div
3903 class="branches-eyebrow"
3904 style="display:inline-flex;align-items:center;gap:8px;text-transform:uppercase;font-family:var(--font-mono);font-size:11px;letter-spacing:0.16em;color:var(--text-muted);font-weight:600;margin-bottom:10px"
3905 >
3906 <span
3907 class="branches-eyebrow-dot"
3908 aria-hidden="true"
3909 style="width:8px;height:8px;border-radius:9999px;background:linear-gradient(135deg,#8c6dff,#36c5d6);box-shadow:0 0 0 3px rgba(140,109,255,0.18)"
3910 />
3911 Repository · Branches
3912 </div>
3913 <h1
3914 class="branches-title"
3915 style="font-family:var(--font-display);font-size:clamp(24px,3.4vw,36px);font-weight:800;letter-spacing:-0.028em;line-height:1.1;margin:0 0 6px;color:var(--text-strong)"
3916 >
3917 <span class="gradient-text">{rows.length}</span>{" "}
3918 branch{rows.length === 1 ? "" : "es"}
3919 </h1>
3920 <p
3921 class="branches-sub"
3922 style="margin:0;font-size:14px;color:var(--text-muted);line-height:1.5;max-width:700px"
3923 >
3924 All work-in-progress lines for{" "}
3925 <code style="font-size:12.5px">{owner}/{repo}</code>. Ahead/behind
3926 counts are relative to{" "}
3927 <code style="font-size:12.5px">{defaultBranch}</code>.
3928 </p>
3929 </header>
3930
3931 {success && (
3932 <div style="margin-bottom:var(--space-4);padding:10px 14px;border-radius:10px;font-size:13.5px;border:1px solid rgba(52,211,153,0.40);background:rgba(52,211,153,0.08);color:#bbf7d0">
3933 {decodeURIComponent(success)}
3934 </div>
3935 )}
3936 {error && (
3937 <div style="margin-bottom:var(--space-4);padding:10px 14px;border-radius:10px;font-size:13.5px;border:1px solid rgba(248,113,113,0.40);background:rgba(248,113,113,0.08);color:#fecaca">
3938 {decodeURIComponent(error)}
3939 </div>
3940 )}
3941
3942 {rows.length === 0 ? (
3943 <div class="commits-empty">
3944 <div class="commits-empty-orb" aria-hidden="true" />
3945 <div class="commits-empty-inner">
3946 <div class="commits-empty-icon" aria-hidden="true">
3947 <svg
3948 width="22"
3949 height="22"
3950 viewBox="0 0 24 24"
3951 fill="none"
3952 stroke="currentColor"
3953 stroke-width="2"
3954 stroke-linecap="round"
3955 stroke-linejoin="round"
3956 >
3957 <line x1="6" y1="3" x2="6" y2="15" />
3958 <circle cx="18" cy="6" r="3" />
3959 <circle cx="6" cy="18" r="3" />
3960 <path d="M18 9a9 9 0 0 1-9 9" />
3961 </svg>
3962 </div>
3963 <h3 class="commits-empty-title">No branches yet</h3>
3964 <p class="commits-empty-sub">
3965 Push your first commit to create the default branch.
3966 </p>
3967 </div>
3968 </div>
3969 ) : (
3970 <div class="branches-list">
3971 {rows.map((r) => (
3972 <div class="branches-row">
3973 <div class="branches-row-icon" aria-hidden="true">
3974 <svg
3975 width="14"
3976 height="14"
3977 viewBox="0 0 24 24"
3978 fill="none"
3979 stroke="currentColor"
3980 stroke-width="2"
3981 stroke-linecap="round"
3982 stroke-linejoin="round"
3983 >
3984 <line x1="6" y1="3" x2="6" y2="15" />
3985 <circle cx="18" cy="6" r="3" />
3986 <circle cx="6" cy="18" r="3" />
3987 <path d="M18 9a9 9 0 0 1-9 9" />
3988 </svg>
3989 </div>
3990 <div class="branches-row-main">
3991 <div class="branches-row-name">
3992 <a href={`/${owner}/${repo}/tree/${r.name}`}>{r.name}</a>
3993 {r.isDefault && (
3994 <span
3995 class="branches-row-default"
3996 title="Default branch"
3997 >
3998 Default
3999 </span>
4000 )}
4001 </div>
4002 <div class="branches-row-meta">
4003 {r.subject ? (
4004 <>
4005 <strong>{r.author || "—"}</strong>
4006 <span class="sep">·</span>
4007 <span
4008 title={r.date ? new Date(r.date).toISOString() : ""}
4009 >
4010 updated {relative(r.date)}
4011 </span>
4012 {r.sha && (
4013 <>
4014 <span class="sep">·</span>
4015 <a
4016 href={`/${owner}/${repo}/commit/${r.sha}`}
4017 style="font-family:var(--font-mono);font-size:11.5px;color:var(--text-muted);text-decoration:none"
4018 >
4019 {r.sha.slice(0, 7)}
4020 </a>
4021 </>
4022 )}
4023 </>
4024 ) : (
4025 <span>No commit metadata</span>
4026 )}
4027 </div>
4028 </div>
4029 <div class="branches-row-side">
4030 {!r.isDefault && (r.ahead > 0 || r.behind > 0) && (
4031 <span
4032 class="branches-row-divergence"
4033 title={`${r.ahead} ahead, ${r.behind} behind ${defaultBranch}`}
4034 >
4035 <span class="ahead">{r.ahead} ahead</span>
4036 <span style="opacity:0.4">|</span>
4037 <span class="behind">{r.behind} behind</span>
4038 </span>
4039 )}
4040 <div class="branches-row-actions">
4041 <a
4042 href={`/${owner}/${repo}/commits/${r.name}`}
4043 class="branches-btn"
4044 title="View commits on this branch"
4045 >
4046 Commits
4047 </a>
4048 {!r.isDefault &&
4049 user &&
4050 user.username === owner && (
4051 <form
4052 method="post"
4053 action={`/${owner}/${repo}/branches/${encodeURIComponent(r.name)}/delete`}
4054 style="margin:0"
4055 onsubmit={`return confirm('Delete branch \\'${r.name}\\'? This cannot be undone.')`}
4056 >
4057 <button
4058 type="submit"
4059 class="branches-btn branches-btn-danger"
4060 >
4061 Delete
4062 </button>
4063 </form>
4064 )}
4065 </div>
4066 </div>
4067 </div>
4068 ))}
4069 </div>
4070 )}
4071 </div>
4072 </Layout>
4073 );
4074});
4075
4076// Delete a branch (owner only). Uses `git branch -D` so we can drop refs
4077// that are not merged into the default branch — matches the explicit
4078// confirmation on the row's delete button.
4079web.post("/:owner/:repo/branches/:name/delete", requireAuth, async (c) => {
4080 const { owner, repo } = c.req.param();
4081 const branchName = decodeURIComponent(c.req.param("name"));
4082 const user = c.get("user")!;
4083
4084 // Owner-only check (mirrors collaborators.tsx pattern).
4085 const [ownerRow] = await db
4086 .select()
4087 .from(users)
4088 .where(eq(users.username, owner))
4089 .limit(1);
4090 if (!ownerRow || ownerRow.id !== user.id) {
4091 return c.redirect(
4092 `/${owner}/${repo}/branches?error=Only+the+owner+can+delete+branches`
4093 );
4094 }
4095
4096 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
4097 if (branchName === defaultBranch) {
4098 return c.redirect(
4099 `/${owner}/${repo}/branches?error=Cannot+delete+the+default+branch`
4100 );
4101 }
4102
4103 const branches = await listBranches(owner, repo);
4104 if (!branches.includes(branchName)) {
4105 return c.redirect(
4106 `/${owner}/${repo}/branches?error=Branch+not+found`
4107 );
4108 }
4109
4110 try {
4111 const repoDir = getRepoPath(owner, repo);
4112 const proc = Bun.spawn(["git", "branch", "-D", branchName], {
4113 cwd: repoDir,
4114 stdout: "pipe",
4115 stderr: "pipe",
4116 });
4117 await proc.exited;
4118 if (proc.exitCode !== 0) {
4119 return c.redirect(
4120 `/${owner}/${repo}/branches?error=Delete+failed`
4121 );
4122 }
4123 } catch {
4124 return c.redirect(`/${owner}/${repo}/branches?error=Delete+failed`);
4125 }
4126
4127 return c.redirect(`/${owner}/${repo}/branches?success=Branch+deleted`);
4128});
4129
4130// ─── Tags list ────────────────────────────────────────────────────────────
4131// Pulls from `listTags` (sorted newest first). For each tag we look up an
4132// associated release row so the "View release" CTA can deep-link directly
4133// without making the user hunt for it.
4134web.get("/:owner/:repo/tags", async (c) => {
4135 const { owner, repo } = c.req.param();
4136 const user = c.get("user");
4137
4138 if (!(await repoExists(owner, repo))) return c.notFound();
4139
4140 const tags = await listTags(owner, repo);
4141
4142 // Map tags -> releases. Best-effort; releases table may not exist in
4143 // every test setup, so any error falls through with an empty set.
4144 const tagsWithReleases = new Set<string>();
4145 try {
4146 const [ownerRow] = await db
4147 .select()
4148 .from(users)
4149 .where(eq(users.username, owner))
4150 .limit(1);
4151 if (ownerRow) {
4152 const [repoRow] = await db
4153 .select()
4154 .from(repositories)
4155 .where(
4156 and(
4157 eq(repositories.ownerId, ownerRow.id),
4158 eq(repositories.name, repo)
4159 )
4160 )
4161 .limit(1);
4162 if (repoRow) {
4163 // Raw SQL so we don't need to import the releases schema here.
4164 const result = await db.execute(
4165 sql`SELECT tag FROM releases WHERE repository_id = ${repoRow.id}`
4166 );
4167 const rows: any[] = (result as any).rows || (result as any) || [];
4168 for (const row of rows) {
4169 const tag = row?.tag;
4170 if (typeof tag === "string") tagsWithReleases.add(tag);
4171 }
4172 }
4173 }
4174 } catch {
4175 // No releases table or DB error — leave set empty.
4176 }
4177
4178 const relative = (iso: string): string => {
4179 if (!iso) return "—";
4180 const d = new Date(iso);
4181 if (Number.isNaN(d.getTime())) return "—";
4182 const diff = Date.now() - d.getTime();
4183 const m = Math.floor(diff / 60000);
4184 if (m < 1) return "just now";
4185 if (m < 60) return `${m} min ago`;
4186 const h = Math.floor(m / 60);
4187 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
4188 const dd = Math.floor(h / 24);
4189 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
4190 return d.toLocaleDateString("en-US", {
4191 month: "short",
4192 day: "numeric",
4193 year: "numeric",
4194 });
4195 };
4196
4197 return c.html(
4198 <Layout title={`Tags — ${owner}/${repo}`} user={user}>
4199 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
4200 <RepoHeader owner={owner} repo={repo} />
4201 <RepoNav owner={owner} repo={repo} active="code" />
4202 <div
4203 class="tags-wrap"
eed4684Claude4204 style="max-width:1680px;margin:0 auto;padding:var(--space-5) var(--space-4) var(--space-8)"
398a10cClaude4205 >
4206 <header class="tags-head" style="margin-bottom:var(--space-5)">
4207 <div
4208 class="tags-eyebrow"
4209 style="display:inline-flex;align-items:center;gap:8px;text-transform:uppercase;font-family:var(--font-mono);font-size:11px;letter-spacing:0.16em;color:var(--text-muted);font-weight:600;margin-bottom:10px"
4210 >
4211 <span
4212 class="tags-eyebrow-dot"
4213 aria-hidden="true"
4214 style="width:8px;height:8px;border-radius:9999px;background:linear-gradient(135deg,#8c6dff,#36c5d6);box-shadow:0 0 0 3px rgba(140,109,255,0.18)"
4215 />
4216 Repository · Tags
4217 </div>
4218 <h1
4219 class="tags-title"
4220 style="font-family:var(--font-display);font-size:clamp(24px,3.4vw,36px);font-weight:800;letter-spacing:-0.028em;line-height:1.1;margin:0 0 6px;color:var(--text-strong)"
4221 >
4222 <span class="gradient-text">{tags.length}</span>{" "}
4223 tag{tags.length === 1 ? "" : "s"}
4224 </h1>
4225 <p
4226 class="tags-sub"
4227 style="margin:0;font-size:14px;color:var(--text-muted);line-height:1.5;max-width:700px"
4228 >
4229 Named points in the history — typically releases, milestones,
4230 or shipped versions. Click a tag to browse the tree at that
4231 revision.
4232 </p>
4233 </header>
4234
4235 {tags.length === 0 ? (
4236 <div class="commits-empty">
4237 <div class="commits-empty-orb" aria-hidden="true" />
4238 <div class="commits-empty-inner">
4239 <div class="commits-empty-icon" aria-hidden="true">
4240 <svg
4241 width="22"
4242 height="22"
4243 viewBox="0 0 24 24"
4244 fill="none"
4245 stroke="currentColor"
4246 stroke-width="2"
4247 stroke-linecap="round"
4248 stroke-linejoin="round"
4249 >
4250 <path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z" />
4251 <line x1="7" y1="7" x2="7.01" y2="7" />
4252 </svg>
4253 </div>
4254 <h3 class="commits-empty-title">No tags yet</h3>
4255 <p class="commits-empty-sub">
4256 Tag a commit to mark a release or milestone. From the CLI:{" "}
4257 <code>git tag v0.1.0 &amp;&amp; git push --tags</code>.
4258 </p>
4259 </div>
4260 </div>
4261 ) : (
4262 <div class="tags-list">
4263 {tags.map((t) => {
4264 const hasRelease = tagsWithReleases.has(t.name);
4265 return (
4266 <div class="tags-row">
4267 <div class="tags-row-icon" aria-hidden="true">
4268 <svg
4269 width="14"
4270 height="14"
4271 viewBox="0 0 24 24"
4272 fill="none"
4273 stroke="currentColor"
4274 stroke-width="2"
4275 stroke-linecap="round"
4276 stroke-linejoin="round"
4277 >
4278 <path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z" />
4279 <line x1="7" y1="7" x2="7.01" y2="7" />
4280 </svg>
4281 </div>
4282 <div class="tags-row-main">
4283 <div class="tags-row-name">
4284 <a
4285 href={`/${owner}/${repo}/tree/${t.name}`}
4286 style="text-decoration:none"
4287 >
4288 <span class="tags-row-version">{t.name}</span>
4289 </a>
4290 </div>
4291 <div class="tags-row-meta">
4292 <span
4293 title={t.date ? new Date(t.date).toISOString() : ""}
4294 >
4295 Tagged {relative(t.date)}
4296 </span>
4297 <span class="sep">·</span>
4298 <a
4299 href={`/${owner}/${repo}/commit/${t.sha}`}
4300 class="tags-row-sha"
4301 title={t.sha}
4302 >
4303 {t.sha.slice(0, 7)}
4304 </a>
4305 </div>
4306 </div>
4307 <div class="tags-row-side">
4308 <a
4309 href={`/${owner}/${repo}/tree/${t.name}`}
4310 class="tags-row-link"
4311 >
4312 Browse files
4313 </a>
4314 {hasRelease && (
4315 <a
4316 href={`/${owner}/${repo}/releases/tag/${t.name}`}
4317 class="tags-row-link"
4318 style="color:#67e8f9;border-color:rgba(54,197,214,0.35);background:rgba(54,197,214,0.06)"
4319 >
4320 View release
4321 </a>
4322 )}
4323 </div>
4324 </div>
4325 );
4326 })}
4327 </div>
4328 )}
4329 </div>
4330 </Layout>
4331 );
4332});
4333
fc1817aClaude4334// Commit log
4335web.get("/:owner/:repo/commits/:ref?", async (c) => {
4336 const { owner, repo } = c.req.param();
06d5ffeClaude4337 const user = c.get("user");
fc1817aClaude4338 const ref =
4339 c.req.param("ref") || (await getDefaultBranch(owner, repo)) || "main";
06d5ffeClaude4340 const branches = await listBranches(owner, repo);
fc1817aClaude4341
4342 const commits = await listCommits(owner, repo, ref, 50);
4343
3951454Claude4344 // Block J3 — batch-fetch cached verification results for the page.
4345 let verifications: Record<string, { verified: boolean; reason: string }> = {};
4346 try {
4347 const [ownerRow] = await db
4348 .select()
4349 .from(users)
4350 .where(eq(users.username, owner))
4351 .limit(1);
4352 if (ownerRow) {
4353 const [repoRow] = await db
4354 .select()
4355 .from(repositories)
4356 .where(
4357 and(
4358 eq(repositories.ownerId, ownerRow.id),
4359 eq(repositories.name, repo)
4360 )
4361 )
4362 .limit(1);
4363 if (repoRow && commits.length > 0) {
4364 const rows = await db
4365 .select()
4366 .from(commitVerifications)
4367 .where(
4368 and(
4369 eq(commitVerifications.repositoryId, repoRow.id),
4370 inArray(
4371 commitVerifications.commitSha,
4372 commits.map((c) => c.sha)
4373 )
4374 )
4375 );
4376 for (const r of rows) {
4377 verifications[r.commitSha] = {
4378 verified: r.verified,
4379 reason: r.reason,
4380 };
4381 }
4382 }
4383 }
4384 } catch {
4385 // DB unavailable — skip the badges gracefully.
4386 }
4387
fc1817aClaude4388 return c.html(
06d5ffeClaude4389 <Layout title={`Commits — ${owner}/${repo}`} user={user}>
efb11c5Claude4390 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude4391 <RepoHeader owner={owner} repo={repo} />
4392 <RepoNav owner={owner} repo={repo} active="commits" />
efb11c5Claude4393 <div class="commits-hero">
4394 <div class="commits-hero-orb-wrap" aria-hidden="true">
4395 <div class="commits-hero-orb" />
fc1817aClaude4396 </div>
efb11c5Claude4397 <div class="commits-hero-inner">
4398 <div class="commits-eyebrow">
4399 <strong>History</strong> · {owner}/{repo}
4400 </div>
4401 <h1 class="commits-title">
4402 <span class="gradient-text">{commits.length}</span> recent commit
4403 {commits.length === 1 ? "" : "s"} on{" "}
4404 <span class="commits-branch">{ref}</span>
4405 </h1>
4406 <p class="commits-sub">
4407 Browse the project's history. Click any commit to see the full
4408 diff, AI review notes, and signature status.
4409 </p>
4410 </div>
4411 </div>
4412 <div class="commits-toolbar">
4413 <BranchSwitcher
3951454Claude4414 owner={owner}
4415 repo={repo}
efb11c5Claude4416 currentRef={ref}
4417 branches={branches}
4418 pathType="commits"
3951454Claude4419 />
398a10cClaude4420 <div class="commits-toolbar-actions">
4421 <a href={`/${owner}/${repo}/branches`} class="commits-toolbar-link">
4422 {"⊢"} Branches
4423 </a>
4424 <a href={`/${owner}/${repo}/tags`} class="commits-toolbar-link">
4425 {"#"} Tags
4426 </a>
4427 </div>
efb11c5Claude4428 </div>
4429 {commits.length === 0 ? (
4430 <div class="commits-empty">
398a10cClaude4431 <div class="commits-empty-orb" aria-hidden="true" />
4432 <div class="commits-empty-inner">
4433 <div class="commits-empty-icon" aria-hidden="true">
4434 <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4435 <circle cx="12" cy="12" r="4" />
4436 <line x1="1.05" y1="12" x2="7" y2="12" />
4437 <line x1="17.01" y1="12" x2="22.96" y2="12" />
4438 </svg>
4439 </div>
4440 <h3 class="commits-empty-title">No commits yet</h3>
4441 <p class="commits-empty-sub">
4442 This branch is empty. Push your first commit, or use the
4443 web editor to create a file.
4444 </p>
4445 </div>
efb11c5Claude4446 </div>
4447 ) : (
4448 <div class="commits-list-wrap">
398a10cClaude4449 {(() => {
4450 // Group commits by day for the section headers.
4451 const dayLabel = (iso: string): string => {
4452 const d = new Date(iso);
4453 if (Number.isNaN(d.getTime())) return "Unknown";
4454 const today = new Date();
4455 const yesterday = new Date(today);
4456 yesterday.setDate(today.getDate() - 1);
4457 const sameDay = (a: Date, b: Date) =>
4458 a.getFullYear() === b.getFullYear() &&
4459 a.getMonth() === b.getMonth() &&
4460 a.getDate() === b.getDate();
4461 if (sameDay(d, today)) return "Today";
4462 if (sameDay(d, yesterday)) return "Yesterday";
4463 return d.toLocaleDateString("en-US", {
4464 month: "long",
4465 day: "numeric",
4466 year: today.getFullYear() === d.getFullYear() ? undefined : "numeric",
4467 });
4468 };
4469 const relative = (iso: string): string => {
4470 const d = new Date(iso);
4471 if (Number.isNaN(d.getTime())) return "";
4472 const diff = Date.now() - d.getTime();
4473 const m = Math.floor(diff / 60000);
4474 if (m < 1) return "just now";
4475 if (m < 60) return `${m} min ago`;
4476 const h = Math.floor(m / 60);
4477 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
4478 const dd = Math.floor(h / 24);
4479 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
4480 return d.toLocaleDateString("en-US", {
4481 month: "short",
4482 day: "numeric",
4483 });
4484 };
4485 const initial = (name: string): string =>
4486 (name || "?").trim().charAt(0).toUpperCase() || "?";
4487 // Build groups preserving order.
4488 const groups: Array<{ label: string; items: typeof commits }> = [];
4489 let lastLabel = "";
4490 for (const cm of commits) {
4491 const label = dayLabel(cm.date);
4492 if (label !== lastLabel) {
4493 groups.push({ label, items: [] });
4494 lastLabel = label;
4495 }
4496 groups[groups.length - 1].items.push(cm);
4497 }
4498 return groups.map((g) => (
4499 <>
4500 <div class="commits-day-head">
4501 <span class="commits-day-head-dot" aria-hidden="true" />
4502 Commits on {g.label}
4503 </div>
4504 {g.items.map((cm) => {
4505 const v = verifications[cm.sha];
4506 return (
4507 <div class="commits-row">
4508 <div class="commits-avatar" aria-hidden="true">
4509 {initial(cm.author)}
4510 </div>
4511 <div class="commits-row-body">
4512 <div class="commits-row-msg">
4513 <a href={`/${owner}/${repo}/commit/${cm.sha}`}>
4514 {cm.message}
4515 </a>
4516 {v?.verified && (
4517 <span
4518 class="commits-row-verified"
4519 title="Signed with a registered key"
4520 >
4521 Verified
4522 </span>
4523 )}
4524 </div>
4525 <div class="commits-row-meta">
4526 <strong>{cm.author}</strong>
4527 <span class="sep">·</span>
4528 <span
4529 class="commits-row-time"
4530 title={new Date(cm.date).toISOString()}
4531 >
4532 committed {relative(cm.date)}
4533 </span>
4534 {cm.parentShas.length > 1 && (
4535 <>
4536 <span class="sep">·</span>
4537 <span>merge of {cm.parentShas.length} parents</span>
4538 </>
4539 )}
4540 </div>
4541 </div>
4542 <div class="commits-row-side">
4543 <a
4544 href={`/${owner}/${repo}/commit/${cm.sha}`}
4545 class="commits-row-sha"
4546 title={cm.sha}
4547 >
4548 {cm.sha.slice(0, 7)}
4549 </a>
4550 <button
4551 type="button"
4552 class="commits-row-copy"
4553 data-copy-sha={cm.sha}
4554 title="Copy full SHA"
4555 aria-label={`Copy SHA ${cm.sha}`}
4556 >
4557 <svg width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true">
4558 <path fill="currentColor" d="M4 1.5h6A1.5 1.5 0 0 1 11.5 3v1h-1V3a.5.5 0 0 0-.5-.5H4a.5.5 0 0 0-.5.5v8a.5.5 0 0 0 .5.5h1v1H4A1.5 1.5 0 0 1 2.5 11V3A1.5 1.5 0 0 1 4 1.5Z" />
4559 <path fill="currentColor" d="M6 5.5h6A1.5 1.5 0 0 1 13.5 7v6A1.5 1.5 0 0 1 12 14.5H6A1.5 1.5 0 0 1 4.5 13V7A1.5 1.5 0 0 1 6 5.5Zm0 1A.5.5 0 0 0 5.5 7v6a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 .5-.5V7a.5.5 0 0 0-.5-.5H6Z" />
4560 </svg>
4561 </button>
4562 </div>
4563 </div>
4564 );
4565 })}
4566 </>
4567 ));
4568 })()}
efb11c5Claude4569 </div>
fc1817aClaude4570 )}
398a10cClaude4571 <script
4572 dangerouslySetInnerHTML={{
4573 __html: `
4574 (function(){
4575 document.addEventListener('click', function(e){
4576 var t = e.target; if (!t) return;
4577 var btn = t.closest && t.closest('[data-copy-sha]');
4578 if (!btn) return;
4579 e.preventDefault();
4580 var sha = btn.getAttribute('data-copy-sha') || '';
4581 if (!navigator.clipboard) return;
4582 navigator.clipboard.writeText(sha).then(function(){
4583 btn.classList.add('is-copied');
4584 setTimeout(function(){ btn.classList.remove('is-copied'); }, 1200);
4585 }).catch(function(){});
4586 });
4587 })();
4588 `,
4589 }}
4590 />
fc1817aClaude4591 </Layout>
4592 );
4593});
4594
4595// Single commit with diff
4596web.get("/:owner/:repo/commit/:sha", async (c) => {
4597 const { owner, repo, sha } = c.req.param();
06d5ffeClaude4598 const user = c.get("user");
fc1817aClaude4599
05b973eClaude4600 // Fetch commit, full message, and diff in parallel
4601 const [commit, fullMessage, diffResult] = await Promise.all([
4602 getCommit(owner, repo, sha),
4603 getCommitFullMessage(owner, repo, sha),
4604 getDiff(owner, repo, sha),
4605 ]);
fc1817aClaude4606 if (!commit) {
4607 return c.html(
06d5ffeClaude4608 <Layout title="Not Found" user={user}>
fc1817aClaude4609 <div class="empty-state">
4610 <h2>Commit not found</h2>
4611 </div>
4612 </Layout>,
4613 404
4614 );
4615 }
4616
3951454Claude4617 // Block J3 — try to verify this commit's signature.
4618 let verification:
4619 | { verified: boolean; reason: string; signatureType: string | null }
4620 | null = null;
0cdfd89Claude4621 // Block J8 — external CI commit statuses rollup.
4622 let statusCombined:
4623 | {
4624 state: "pending" | "success" | "failure";
4625 total: number;
4626 contexts: Array<{
4627 context: string;
4628 state: string;
4629 description: string | null;
4630 targetUrl: string | null;
4631 }>;
4632 }
4633 | null = null;
3951454Claude4634 try {
4635 const [ownerRow] = await db
4636 .select()
4637 .from(users)
4638 .where(eq(users.username, owner))
4639 .limit(1);
4640 if (ownerRow) {
4641 const [repoRow] = await db
4642 .select()
4643 .from(repositories)
4644 .where(
4645 and(
4646 eq(repositories.ownerId, ownerRow.id),
4647 eq(repositories.name, repo)
4648 )
4649 )
4650 .limit(1);
4651 if (repoRow) {
4652 const { verifyCommit } = await import("../lib/signatures");
4653 const v = await verifyCommit(repoRow.id, owner, repo, commit.sha);
4654 verification = {
4655 verified: v.verified,
4656 reason: v.reason,
4657 signatureType: v.signatureType,
4658 };
0cdfd89Claude4659 try {
4660 const { combinedStatus } = await import("../lib/commit-statuses");
4661 const combined = await combinedStatus(repoRow.id, commit.sha);
4662 if (combined.total > 0) {
4663 statusCombined = {
4664 state: combined.state as any,
4665 total: combined.total,
4666 contexts: combined.contexts.map((c) => ({
4667 context: c.context,
4668 state: c.state,
4669 description: c.description,
4670 targetUrl: c.targetUrl,
4671 })),
4672 };
4673 }
4674 } catch {
4675 statusCombined = null;
4676 }
3951454Claude4677 }
4678 }
4679 } catch {
4680 verification = null;
4681 }
4682
05b973eClaude4683 const { files, raw } = diffResult;
fc1817aClaude4684
efb11c5Claude4685 // Diff stats: count additions / deletions across all files for the
4686 // header summary bar. Computed here from the parsed diff so we don't
4687 // touch the DiffView component.
4688 let additions = 0;
4689 let deletions = 0;
4690 for (const f of files) {
4691 const hunks = (f as any).hunks as Array<any> | undefined;
4692 if (Array.isArray(hunks)) {
4693 for (const h of hunks) {
4694 const lines = (h?.lines || []) as Array<any>;
4695 for (const ln of lines) {
4696 const t = ln?.type || ln?.kind;
4697 if (t === "add" || t === "added" || t === "+") additions += 1;
4698 else if (t === "del" || t === "deleted" || t === "delete" || t === "-")
4699 deletions += 1;
4700 }
4701 }
4702 }
4703 }
4704 // Fall back: scan raw if file-level counting yielded zero (it's just a
4705 // header polish — never let a parsing miss break the page).
4706 if (additions === 0 && deletions === 0 && typeof raw === "string") {
4707 for (const line of raw.split("\n")) {
4708 if (line.startsWith("+") && !line.startsWith("+++")) additions += 1;
4709 else if (line.startsWith("-") && !line.startsWith("---")) deletions += 1;
4710 }
4711 }
4712 const fileCount = files.length;
4713
fc1817aClaude4714 return c.html(
06d5ffeClaude4715 <Layout title={`${commit.message} — ${owner}/${repo}`} user={user}>
efb11c5Claude4716 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude4717 <RepoHeader owner={owner} repo={repo} />
efb11c5Claude4718 <div class="commit-detail-card">
4719 <div class="commit-detail-eyebrow">
4720 <strong>Commit</strong>
4721 <span class="commit-detail-sha-pill" title={commit.sha}>
4722 {commit.sha.slice(0, 7)}
4723 </span>
3951454Claude4724 {verification && verification.reason !== "unsigned" && (
4725 <span
efb11c5Claude4726 class={`commit-detail-verify ${
3951454Claude4727 verification.verified
efb11c5Claude4728 ? "commit-detail-verify-ok"
4729 : "commit-detail-verify-warn"
3951454Claude4730 }`}
4731 title={`${verification.signatureType?.toUpperCase() || ""} · ${verification.reason}`}
4732 >
4733 {verification.verified ? "Verified" : verification.reason}
4734 </span>
4735 )}
fc1817aClaude4736 </div>
efb11c5Claude4737 <h1 class="commit-detail-title">{commit.message}</h1>
4738 {fullMessage !== commit.message && (
4739 <pre class="commit-detail-body">{fullMessage}</pre>
4740 )}
4741 <div class="commit-detail-meta">
4742 <span class="commit-detail-author">
4743 <strong>{commit.author}</strong> committed on{" "}
4744 {new Date(commit.date).toLocaleDateString("en-US", {
4745 month: "long",
4746 day: "numeric",
4747 year: "numeric",
4748 })}
4749 </span>
fc1817aClaude4750 {commit.parentShas.length > 0 && (
efb11c5Claude4751 <span class="commit-detail-parents">
4752 {commit.parentShas.length === 1 ? "Parent" : "Parents"}:{" "}
4753 {commit.parentShas.map((p, idx) => (
4754 <>
4755 {idx > 0 && " "}
4756 <a
4757 href={`/${owner}/${repo}/commit/${p}`}
4758 class="commit-detail-sha-link"
4759 >
4760 {p.slice(0, 7)}
4761 </a>
4762 </>
fc1817aClaude4763 ))}
4764 </span>
4765 )}
4766 </div>
efb11c5Claude4767 <div class="commit-detail-stats">
4768 <span class="commit-detail-stat">
4769 <strong>{fileCount}</strong>{" "}
4770 file{fileCount === 1 ? "" : "s"} changed
4771 </span>
4772 <span class="commit-detail-stat commit-detail-stat-add">
4773 <span class="commit-detail-stat-mark">+</span>
4774 <strong>{additions}</strong>
4775 </span>
4776 <span class="commit-detail-stat commit-detail-stat-del">
4777 <span class="commit-detail-stat-mark">−</span>
4778 <strong>{deletions}</strong>
4779 </span>
4780 <span class="commit-detail-sha-full" title="Full SHA">
4781 {commit.sha}
4782 </span>
4783 </div>
0cdfd89Claude4784 {statusCombined && (
efb11c5Claude4785 <div class="commit-detail-checks">
4786 <div class="commit-detail-checks-head">
4787 <strong>Checks</strong>
4788 <span class="commit-detail-checks-summary">
4789 {statusCombined.total} total ·{" "}
4790 <span
4791 class={`commit-detail-check-state commit-detail-check-state-${statusCombined.state}`}
4792 >
4793 {statusCombined.state}
4794 </span>
0cdfd89Claude4795 </span>
efb11c5Claude4796 </div>
4797 <div class="commit-detail-check-row">
0cdfd89Claude4798 {statusCombined.contexts.map((cx) => (
4799 <span
efb11c5Claude4800 class={`commit-detail-check commit-detail-check-${cx.state}`}
0cdfd89Claude4801 title={cx.description || cx.context}
4802 >
4803 {cx.targetUrl ? (
efb11c5Claude4804 <a href={cx.targetUrl} rel="noopener">
0cdfd89Claude4805 {cx.context}: {cx.state}
4806 </a>
4807 ) : (
4808 <>
4809 {cx.context}: {cx.state}
4810 </>
4811 )}
4812 </span>
4813 ))}
4814 </div>
4815 </div>
4816 )}
fc1817aClaude4817 </div>
ea9ed4cClaude4818 <DiffView
4819 raw={raw}
4820 files={files}
4821 viewFileBase={`/${owner}/${repo}/blob/${commit.sha}`}
4822 />
fc1817aClaude4823 </Layout>
4824 );
4825});
4826
79136bbClaude4827// Raw file download
4828web.get("/:owner/:repo/raw/:ref{.+$}", async (c) => {
4829 const { owner, repo } = c.req.param();
4830 const refAndPath = c.req.param("ref");
4831
4832 const branches = await listBranches(owner, repo);
4833 let ref = "";
4834 let filePath = "";
4835
4836 for (const branch of branches) {
4837 if (refAndPath.startsWith(branch + "/")) {
4838 ref = branch;
4839 filePath = refAndPath.slice(branch.length + 1);
4840 break;
4841 }
4842 }
4843
4844 if (!ref) {
4845 const slashIdx = refAndPath.indexOf("/");
4846 if (slashIdx === -1) return c.text("Not found", 404);
4847 ref = refAndPath.slice(0, slashIdx);
4848 filePath = refAndPath.slice(slashIdx + 1);
4849 }
4850
4851 const data = await getRawBlob(owner, repo, ref, filePath);
4852 if (!data) return c.text("Not found", 404);
4853
4854 const fileName = filePath.split("/").pop() || "file";
772a24fClaude4855 return new Response(data as BodyInit, {
79136bbClaude4856 headers: {
4857 "Content-Type": "application/octet-stream",
4858 "Content-Disposition": `attachment; filename="${fileName}"`,
05b973eClaude4859 "Cache-Control": "public, max-age=300, stale-while-revalidate=60",
79136bbClaude4860 },
4861 });
4862});
4863
4864// Blame view
4865web.get("/:owner/:repo/blame/:ref{.+$}", async (c) => {
4866 const { owner, repo } = c.req.param();
4867 const user = c.get("user");
4868 const refAndPath = c.req.param("ref");
4869
4870 const branches = await listBranches(owner, repo);
4871 let ref = "";
4872 let filePath = "";
4873
4874 for (const branch of branches) {
4875 if (refAndPath.startsWith(branch + "/")) {
4876 ref = branch;
4877 filePath = refAndPath.slice(branch.length + 1);
4878 break;
4879 }
4880 }
4881
4882 if (!ref) {
4883 const slashIdx = refAndPath.indexOf("/");
4884 if (slashIdx === -1) return c.text("Not found", 404);
4885 ref = refAndPath.slice(0, slashIdx);
4886 filePath = refAndPath.slice(slashIdx + 1);
4887 }
4888
4889 const blameLines = await getBlame(owner, repo, ref, filePath);
4890 if (blameLines.length === 0) {
4891 return c.html(
4892 <Layout title="Not Found" user={user}>
4893 <div class="empty-state">
4894 <h2>File not found</h2>
4895 </div>
4896 </Layout>,
4897 404
4898 );
4899 }
4900
4901 const fileName = filePath.split("/").pop() || filePath;
efb11c5Claude4902 // Unique contributors (by author) tracked once for the header chip.
4903 const blameAuthors = new Set<string>();
4904 for (const ln of blameLines) blameAuthors.add(ln.author);
79136bbClaude4905
4906 return c.html(
4907 <Layout title={`Blame: ${filePath} — ${owner}/${repo}`} user={user}>
efb11c5Claude4908 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
79136bbClaude4909 <RepoHeader owner={owner} repo={repo} />
4910 <RepoNav owner={owner} repo={repo} active="code" />
398a10cClaude4911 <header class="blame-head">
4912 <div class="blame-eyebrow">
4913 <span class="blame-eyebrow-dot" aria-hidden="true" />
4914 Blame · Line-by-line history
4915 </div>
4916 <h1 class="blame-title">
4917 <code>{fileName}</code>
4918 </h1>
4919 <p class="blame-sub">
4920 Each line is annotated with the commit that last touched it.
4921 Click any SHA to jump to that commit and see the surrounding
4922 change.
4923 </p>
4924 </header>
efb11c5Claude4925 <div class="blame-toolbar">
4926 <Breadcrumb owner={owner} repo={repo} ref={ref} path={filePath} />
4927 </div>
398a10cClaude4928 <div class="blame-card">
4929 <div class="blame-header">
efb11c5Claude4930 <div class="blame-header-meta">
4931 <span class="blame-header-icon" aria-hidden="true">{"⎙"}</span>
4932 <span class="blame-header-name">{fileName}</span>
4933 <span class="blame-header-tag">Blame</span>
4934 <span class="blame-header-stats">
4935 {blameLines.length} line{blameLines.length === 1 ? "" : "s"} ·{" "}
4936 {blameAuthors.size} contributor
4937 {blameAuthors.size === 1 ? "" : "s"}
4938 </span>
4939 </div>
4940 <div class="blame-header-actions">
4941 <a
4942 href={`/${owner}/${repo}/blob/${ref}/${filePath}`}
4943 class="blob-pill"
4944 >
4945 Normal view
4946 </a>
4947 <a
4948 href={`/${owner}/${repo}/raw/${ref}/${filePath}`}
4949 class="blob-pill"
4950 >
4951 Raw
4952 </a>
4953 </div>
79136bbClaude4954 </div>
398a10cClaude4955 <div style="overflow-x:auto">
4956 <table class="blame-table">
79136bbClaude4957 <tbody>
4958 {blameLines.map((line, i) => {
4959 const showInfo =
4960 i === 0 || blameLines[i - 1].sha !== line.sha;
4961 return (
398a10cClaude4962 <tr class={showInfo ? "blame-row-first" : ""}>
4963 <td class="blame-gutter">
79136bbClaude4964 {showInfo && (
398a10cClaude4965 <span class="blame-gutter-inner">
79136bbClaude4966 <a
4967 href={`/${owner}/${repo}/commit/${line.sha}`}
398a10cClaude4968 class="blame-gutter-sha"
4969 title={`Commit ${line.sha}`}
79136bbClaude4970 >
4971 {line.sha.slice(0, 7)}
398a10cClaude4972 </a>
4973 <span class="blame-gutter-author" title={line.author}>
4974 {line.author}
4975 </span>
4976 </span>
79136bbClaude4977 )}
4978 </td>
398a10cClaude4979 <td class="blame-line-num">{line.lineNum}</td>
4980 <td class="blame-line-content">{line.content}</td>
79136bbClaude4981 </tr>
4982 );
4983 })}
4984 </tbody>
4985 </table>
4986 </div>
4987 </div>
4988 </Layout>
4989 );
4990});
4991
4992// Search
4993web.get("/:owner/:repo/search", async (c) => {
4994 const { owner, repo } = c.req.param();
4995 const user = c.get("user");
4996 const q = c.req.query("q") || "";
4997
4998 if (!(await repoExists(owner, repo))) return c.notFound();
4999
5000 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
5001 let results: Array<{ file: string; lineNum: number; line: string }> = [];
5002
5003 if (q.trim()) {
5004 results = await searchCode(owner, repo, defaultBranch, q.trim());
5005 }
5006
5007 return c.html(
5008 <Layout title={`Search — ${owner}/${repo}`} user={user}>
efb11c5Claude5009 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
79136bbClaude5010 <RepoHeader owner={owner} repo={repo} />
5011 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude5012 <div class="search-hero">
5013 <div class="search-eyebrow">
5014 <strong>Search</strong> · {owner}/{repo}
5015 </div>
5016 <h1 class="search-title">
5017 Find any line in <span class="gradient-text">{repo}</span>
5018 </h1>
5019 <form
5020 method="get"
5021 action={`/${owner}/${repo}/search`}
5022 class="search-form"
5023 role="search"
5024 >
5025 <div class="search-input-wrap">
5026 <span class="search-input-icon" aria-hidden="true">{"⌕"}</span>
5027 <input
5028 type="text"
5029 name="q"
5030 value={q}
5031 placeholder="Search code on the default branch…"
5032 aria-label="Search code"
5033 class="search-input"
5034 autocomplete="off"
5035 autofocus
5036 />
5037 </div>
5038 <button type="submit" class="btn btn-primary search-submit">
79136bbClaude5039 Search
5040 </button>
efb11c5Claude5041 </form>
5042 </div>
79136bbClaude5043 {q && (
efb11c5Claude5044 <div class="search-results-head">
5045 <span class="search-results-count">
5046 <strong>{results.length}</strong> result
5047 {results.length !== 1 ? "s" : ""}
5048 </span>
5049 <span class="search-results-query">
5050 for <span class="search-results-q">"{q}"</span> on{" "}
5051 <code>{defaultBranch}</code>
5052 </span>
5053 </div>
79136bbClaude5054 )}
efb11c5Claude5055 {q && results.length === 0 ? (
5056 <div class="search-empty">
5057 <p>
5058 No matches for <strong>"{q}"</strong>. Try a shorter query or check
5059 you're on the right branch.
5060 </p>
5061 </div>
5062 ) : results.length > 0 ? (
79136bbClaude5063 <div class="search-results">
5064 {(() => {
5065 // Group by file
5066 const grouped: Record<
5067 string,
5068 Array<{ lineNum: number; line: string }>
5069 > = {};
5070 for (const r of results) {
5071 if (!grouped[r.file]) grouped[r.file] = [];
5072 grouped[r.file].push({ lineNum: r.lineNum, line: r.line });
5073 }
5074 return Object.entries(grouped).map(([file, matches]) => (
efb11c5Claude5075 <div class="search-file diff-file">
5076 <div class="search-file-head diff-file-header">
79136bbClaude5077 <a
5078 href={`/${owner}/${repo}/blob/${defaultBranch}/${file}`}
efb11c5Claude5079 class="search-file-link"
79136bbClaude5080 >
5081 {file}
5082 </a>
efb11c5Claude5083 <span class="search-file-count">
5084 {matches.length} match{matches.length === 1 ? "" : "es"}
5085 </span>
79136bbClaude5086 </div>
5087 <div class="blob-code">
5088 <table>
5089 <tbody>
5090 {matches.map((m) => (
5091 <tr>
5092 <td class="line-num">{m.lineNum}</td>
5093 <td class="line-content">{m.line}</td>
5094 </tr>
5095 ))}
5096 </tbody>
5097 </table>
5098 </div>
5099 </div>
5100 ));
5101 })()}
5102 </div>
efb11c5Claude5103 ) : null}
79136bbClaude5104 </Layout>
5105 );
5106});
5107
fc1817aClaude5108export default web;