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.tsxBlame4676 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";
18import {
19 RepoHeader,
20 RepoNav,
21 Breadcrumb,
22 FileTable,
06d5ffeClaude23 RepoCard,
24 BranchSwitcher,
25 HighlightedCode,
26 PlainCode,
fc1817aClaude27} from "../views/components";
ea9ed4cClaude28import { DiffView } from "../views/diff-view";
fc1817aClaude29import {
30 getTree,
31 getBlob,
32 listCommits,
33 getCommit,
34 getCommitFullMessage,
35 getDiff,
36 getReadme,
37 getDefaultBranch,
38 listBranches,
398a10cClaude39 listTags,
fc1817aClaude40 repoExists,
06d5ffeClaude41 initBareRepo,
79136bbClaude42 getBlame,
43 getRawBlob,
44 searchCode,
398a10cClaude45 getRepoPath,
fc1817aClaude46} from "../git/repository";
79136bbClaude47import { renderMarkdown, markdownCss } from "../lib/markdown";
06d5ffeClaude48import { highlightCode } from "../lib/highlight";
49import { softAuth, requireAuth } from "../middleware/auth";
50import type { AuthEnv } from "../middleware/auth";
8f50ed0Claude51import { trackByName } from "../lib/traffic";
534f04aClaude52import { LandingPage, type LandingLiveFeed } from "../views/landing";
52ad8b1Claude53import { computePublicStats, type PublicStats } from "../lib/public-stats";
534f04aClaude54import {
55 listQueuedAiBuildIssues,
56 listRecentAutoMerges,
57 listRecentAiReviews,
58 countAiReviewsSince,
59 listDemoActivityFeed,
60} from "../lib/demo-activity";
fc1817aClaude61
06d5ffeClaude62const web = new Hono<AuthEnv>();
63
64// Soft auth on all web routes — c.get("user") available but may be null
65web.use("*", softAuth);
fc1817aClaude66
efb11c5Claude67/**
68 * Shared CSS for the polished code-browse surfaces (parallel session 3.E).
69 *
70 * Inlined here rather than in `src/views/layout.tsx` because session 3.E's
71 * scope is route-local and `layout.tsx` is locked. Each polished handler
72 * injects this via a `<style>` tag; the rules are namespaced by surface
73 * prefix (`.new-repo-*`, `.profile-*`, `.tree-*`, `.blob-*`, `.commits-*`,
74 * `.commit-detail-*`, `.blame-*`, `.search-*`) so nothing bleeds into the
75 * `.repo-home-*` styling Agent A already shipped.
76 */
77const codeBrowseCss = `
78 /* ───────── shared primitives ───────── */
79 .cb-hairline::before,
80 .new-repo-hero::before,
81 .profile-hero::before,
82 .commits-hero::before,
83 .commit-detail-card::before,
84 .search-hero::before {
85 content: '';
86 position: absolute;
87 top: 0; left: 0; right: 0;
88 height: 2px;
89 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
90 opacity: 0.7;
91 pointer-events: none;
92 }
93 @keyframes cbHeroOrb {
94 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
95 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
96 }
97 @media (prefers-reduced-motion: reduce) {
98 .new-repo-hero-orb,
99 .profile-hero-orb,
100 .commits-hero-orb { animation: none; }
101 }
102
103 /* ───────── new-repo ───────── */
104 .new-repo-hero {
105 position: relative;
106 margin-bottom: var(--space-5);
107 padding: var(--space-5) var(--space-6);
108 background: var(--bg-elevated);
109 border: 1px solid var(--border);
110 border-radius: 16px;
111 overflow: hidden;
112 }
113 .new-repo-hero-orb-wrap {
114 position: absolute;
115 inset: -25% -10% auto auto;
116 width: 360px;
117 height: 360px;
118 pointer-events: none;
119 z-index: 0;
120 }
121 .new-repo-hero-orb {
122 position: absolute;
123 inset: 0;
124 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.09) 45%, transparent 70%);
125 filter: blur(80px);
126 opacity: 0.7;
127 animation: cbHeroOrb 14s ease-in-out infinite;
128 }
129 .new-repo-hero-inner { position: relative; z-index: 1; }
130 .new-repo-eyebrow {
131 font-size: 12px;
132 font-family: var(--font-mono);
133 color: var(--text-muted);
134 letter-spacing: 0.1em;
135 text-transform: uppercase;
136 margin-bottom: var(--space-2);
137 }
138 .new-repo-eyebrow strong { color: var(--accent); font-weight: 600; }
139 .new-repo-title {
140 font-family: var(--font-display);
141 font-weight: 800;
142 letter-spacing: -0.028em;
143 font-size: clamp(28px, 4vw, 40px);
144 line-height: 1.05;
145 margin: 0 0 var(--space-2);
146 color: var(--text-strong);
147 }
148 .new-repo-sub {
149 font-size: 15px;
150 color: var(--text-muted);
151 margin: 0;
152 line-height: 1.55;
153 max-width: 620px;
154 }
155 .new-repo-form {
156 max-width: 680px;
157 }
158 .new-repo-error {
159 background: rgba(218, 54, 51, 0.12);
160 border: 1px solid rgba(218, 54, 51, 0.35);
161 color: #ffb3b3;
162 padding: 10px 14px;
163 border-radius: 10px;
164 margin-bottom: var(--space-4);
165 font-size: 14px;
166 }
167 .new-repo-form-grid {
168 display: flex;
169 flex-direction: column;
170 gap: var(--space-4);
171 }
172 .new-repo-row { display: flex; flex-direction: column; gap: 6px; }
173 .new-repo-label {
174 font-size: 13px;
175 color: var(--text-strong);
176 font-weight: 600;
177 }
178 .new-repo-label-optional {
179 color: var(--text-muted);
180 font-weight: 400;
181 font-size: 12px;
182 }
183 .new-repo-input {
184 appearance: none;
185 width: 100%;
186 background: var(--bg);
187 border: 1px solid var(--border);
188 color: var(--text-strong);
189 border-radius: 10px;
190 padding: 10px 12px;
191 font-size: 14px;
192 font-family: inherit;
193 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
194 }
195 .new-repo-input:focus {
196 outline: none;
197 border-color: var(--accent);
198 box-shadow: 0 0 0 3px rgba(140,109,255,0.18);
199 }
200 .new-repo-input-disabled {
201 color: var(--text-muted);
202 background: var(--bg-secondary);
203 cursor: not-allowed;
204 }
205 .new-repo-hint {
206 font-size: 12px;
207 color: var(--text-muted);
208 margin: 4px 0 0;
209 }
210 .new-repo-hint code {
211 font-family: var(--font-mono);
212 font-size: 11.5px;
213 background: var(--bg-secondary);
214 border: 1px solid var(--border);
215 border-radius: 5px;
216 padding: 1px 5px;
217 color: var(--text-strong);
218 }
219 .new-repo-visibility {
220 display: grid;
221 grid-template-columns: 1fr 1fr;
222 gap: var(--space-2);
223 }
224 @media (max-width: 600px) {
225 .new-repo-visibility { grid-template-columns: 1fr; }
226 }
227 .new-repo-vis-card {
228 display: flex;
229 gap: 10px;
230 padding: 14px;
231 background: var(--bg);
232 border: 1px solid var(--border);
233 border-radius: 12px;
234 cursor: pointer;
235 transition: border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
236 }
237 .new-repo-vis-card:hover { border-color: var(--border-strong, var(--border)); }
238 .new-repo-vis-card:has(input:checked) {
239 border-color: rgba(140,109,255,0.55);
240 background: rgba(140,109,255,0.06);
241 box-shadow: 0 0 0 1px rgba(140,109,255,0.25);
242 }
243 .new-repo-vis-radio {
244 margin-top: 3px;
245 accent-color: var(--accent);
246 }
247 .new-repo-vis-body { display: flex; flex-direction: column; gap: 4px; }
248 .new-repo-vis-label {
249 font-size: 14px;
250 font-weight: 600;
251 color: var(--text-strong);
252 }
253 .new-repo-vis-desc {
254 font-size: 12.5px;
255 color: var(--text-muted);
256 line-height: 1.45;
257 }
258 .new-repo-callout {
259 margin-top: var(--space-2);
260 padding: var(--space-3) var(--space-4);
261 background: var(--accent-gradient-faint, rgba(140,109,255,0.06));
262 border: 1px solid rgba(140,109,255,0.2);
263 border-radius: 12px;
264 }
265 .new-repo-callout-eyebrow {
266 font-size: 11px;
267 font-family: var(--font-mono);
268 text-transform: uppercase;
269 letter-spacing: 0.12em;
270 color: var(--accent);
271 font-weight: 700;
272 margin-bottom: 4px;
273 }
274 .new-repo-callout-body {
275 font-size: 13px;
276 color: var(--text);
277 line-height: 1.5;
278 margin: 0;
279 }
280 .new-repo-callout-body code {
281 font-family: var(--font-mono);
282 font-size: 12px;
283 color: var(--accent);
284 background: rgba(140,109,255,0.1);
285 border-radius: 4px;
286 padding: 1px 5px;
287 }
398a10cClaude288 .new-repo-templates {
289 display: flex;
290 flex-wrap: wrap;
291 gap: 8px;
292 margin-top: 4px;
293 }
294 .new-repo-template-chip {
295 position: relative;
296 display: inline-flex;
297 align-items: center;
298 gap: 6px;
299 padding: 8px 14px;
300 background: var(--bg);
301 border: 1px solid var(--border);
302 border-radius: 999px;
303 font-size: 13px;
304 color: var(--text);
305 cursor: pointer;
306 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
307 }
308 .new-repo-template-chip input { position: absolute; opacity: 0; pointer-events: none; }
309 .new-repo-template-chip:hover {
310 border-color: var(--border-strong, var(--border));
311 color: var(--text-strong);
312 }
313 .new-repo-template-chip:has(input:checked) {
314 border-color: rgba(140,109,255,0.55);
315 background: rgba(140,109,255,0.10);
316 color: var(--text-strong);
317 box-shadow: 0 0 0 1px rgba(140,109,255,0.25);
318 }
319 .new-repo-template-chip-dot {
320 width: 8px; height: 8px;
321 border-radius: 999px;
322 background: var(--text-faint, var(--text-muted));
323 transition: background 140ms ease, box-shadow 140ms ease;
324 }
325 .new-repo-template-chip:has(input:checked) .new-repo-template-chip-dot {
326 background: linear-gradient(135deg, #8c6dff, #36c5d6);
327 box-shadow: 0 0 8px rgba(140,109,255,0.6);
328 }
efb11c5Claude329 .new-repo-actions {
330 display: flex;
331 gap: var(--space-2);
332 margin-top: var(--space-2);
398a10cClaude333 align-items: center;
334 }
335 .new-repo-submit {
336 min-width: 180px;
337 border: 1px solid rgba(140,109,255,0.45);
338 background: linear-gradient(135deg, #8c6dff 0%, #36c5d6 100%);
339 color: #fff;
340 font-weight: 700;
341 box-shadow: 0 8px 20px -8px rgba(140,109,255,0.55);
342 transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
343 }
344 .new-repo-submit:hover {
345 transform: translateY(-1px);
346 box-shadow: 0 12px 24px -8px rgba(140,109,255,0.7);
347 filter: brightness(1.06);
348 }
349 .new-repo-submit:focus-visible {
350 outline: 3px solid rgba(140,109,255,0.45);
351 outline-offset: 2px;
efb11c5Claude352 }
353
354 /* ───────── profile ───────── */
355 .profile-hero {
356 position: relative;
357 margin-bottom: var(--space-5);
358 padding: var(--space-5) var(--space-6);
359 background: var(--bg-elevated);
360 border: 1px solid var(--border);
361 border-radius: 16px;
362 overflow: hidden;
363 }
364 .profile-hero-orb-wrap {
365 position: absolute;
366 inset: -25% -10% auto auto;
367 width: 360px;
368 height: 360px;
369 pointer-events: none;
370 z-index: 0;
371 }
372 .profile-hero-orb {
373 position: absolute;
374 inset: 0;
375 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.09) 45%, transparent 70%);
376 filter: blur(80px);
377 opacity: 0.7;
378 animation: cbHeroOrb 14s ease-in-out infinite;
379 }
380 .profile-hero-inner {
381 position: relative;
382 z-index: 1;
383 display: flex;
384 align-items: flex-start;
385 gap: var(--space-5);
386 }
387 .profile-hero-avatar {
388 flex: 0 0 auto;
389 width: 88px;
390 height: 88px;
391 border-radius: 50%;
392 background: linear-gradient(135deg, #8c6dff 0%, #36c5d6 100%);
393 color: #fff;
394 display: flex;
395 align-items: center;
396 justify-content: center;
397 font-size: 38px;
398 font-weight: 700;
399 font-family: var(--font-display);
400 box-shadow: 0 8px 24px -8px rgba(140,109,255,0.55);
401 }
402 .profile-hero-text { flex: 1; min-width: 0; }
403 .profile-eyebrow {
404 font-size: 12px;
405 font-family: var(--font-mono);
406 color: var(--text-muted);
407 letter-spacing: 0.1em;
408 text-transform: uppercase;
409 margin-bottom: var(--space-2);
410 }
411 .profile-eyebrow strong { color: var(--accent); font-weight: 600; }
412 .profile-name {
413 font-family: var(--font-display);
414 font-weight: 800;
415 letter-spacing: -0.028em;
416 font-size: clamp(28px, 3.6vw, 36px);
417 line-height: 1.05;
418 margin: 0 0 4px;
419 color: var(--text-strong);
420 }
421 .profile-handle {
422 font-family: var(--font-mono);
423 font-size: 13px;
424 color: var(--text-muted);
425 margin-bottom: var(--space-2);
426 }
427 .profile-bio {
428 font-size: 14.5px;
429 color: var(--text);
430 line-height: 1.55;
431 margin: 0 0 var(--space-3);
432 max-width: 640px;
433 }
434 .profile-meta {
435 display: flex;
436 align-items: center;
437 gap: var(--space-4);
438 flex-wrap: wrap;
439 font-size: 13px;
440 }
441 .profile-meta-link {
442 color: var(--text-muted);
443 transition: color var(--t-fast, 0.15s) ease;
444 }
445 .profile-meta-link:hover { color: var(--accent); text-decoration: none; }
446 .profile-meta-link strong {
447 color: var(--text-strong);
448 font-weight: 600;
449 font-variant-numeric: tabular-nums;
450 }
451 .profile-follow-form { margin: 0; }
452 @media (max-width: 600px) {
453 .profile-hero-inner { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
454 .profile-hero-avatar { width: 64px; height: 64px; font-size: 28px; }
455 }
456 .profile-readme {
457 margin-bottom: var(--space-6);
458 background: var(--bg-elevated);
459 border: 1px solid var(--border);
460 border-radius: 12px;
461 overflow: hidden;
462 }
463 .profile-readme-head {
464 display: flex;
465 align-items: center;
466 gap: 8px;
467 padding: 10px 16px;
468 background: var(--bg-secondary);
469 border-bottom: 1px solid var(--border);
470 font-size: 13px;
471 color: var(--text-muted);
472 }
473 .profile-readme-icon { color: var(--accent); font-size: 14px; }
474 .profile-readme-body { padding: var(--space-5) var(--space-6); }
475 .profile-section-head {
476 display: flex;
477 align-items: baseline;
478 gap: var(--space-2);
479 margin-bottom: var(--space-3);
480 }
481 .profile-section-title {
482 font-family: var(--font-display);
483 font-weight: 700;
484 font-size: 20px;
485 letter-spacing: -0.015em;
486 margin: 0;
487 color: var(--text-strong);
488 }
489 .profile-section-count {
490 font-family: var(--font-mono);
491 font-size: 12px;
492 color: var(--text-muted);
493 background: var(--bg-secondary);
494 border: 1px solid var(--border);
495 border-radius: 999px;
496 padding: 2px 10px;
497 font-variant-numeric: tabular-nums;
498 }
499 .profile-empty {
500 display: flex;
501 align-items: center;
502 justify-content: space-between;
503 gap: var(--space-3);
504 padding: var(--space-4) var(--space-5);
505 background: var(--bg-elevated);
506 border: 1px dashed var(--border);
507 border-radius: 12px;
508 }
509 .profile-empty-text { color: var(--text-muted); font-size: 14px; margin: 0; }
510
511 /* ───────── tree (file browser) ───────── */
512 .tree-header {
513 margin-bottom: var(--space-3);
514 display: flex;
515 flex-direction: column;
516 gap: var(--space-2);
517 }
518 .tree-header-row {
519 display: flex;
520 align-items: center;
521 justify-content: space-between;
522 gap: var(--space-3);
523 flex-wrap: wrap;
524 }
525 .tree-header-stats {
526 display: flex;
527 align-items: center;
528 gap: var(--space-3);
529 font-size: 12px;
530 color: var(--text-muted);
531 }
532 .tree-stat strong {
533 color: var(--text-strong);
534 font-weight: 600;
535 font-variant-numeric: tabular-nums;
536 }
537 .tree-stat-link {
538 color: var(--text-muted);
539 padding: 4px 10px;
540 border-radius: 999px;
541 border: 1px solid var(--border);
542 background: var(--bg-elevated);
543 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease;
544 }
545 .tree-stat-link:hover {
546 color: var(--accent);
547 border-color: rgba(140,109,255,0.45);
548 text-decoration: none;
549 }
550 .tree-breadcrumb-row {
551 font-size: 13px;
552 }
553
554 /* ───────── blob (file viewer) ───────── */
555 .blob-toolbar {
556 margin-bottom: var(--space-3);
557 display: flex;
558 flex-direction: column;
559 gap: var(--space-2);
560 }
561 .blob-breadcrumb { font-size: 13px; }
562 .blob-card {
563 background: var(--bg-elevated);
564 border: 1px solid var(--border);
565 border-radius: 12px;
566 overflow: hidden;
567 }
568 .blob-header-polished {
569 display: flex;
570 align-items: center;
571 justify-content: space-between;
572 gap: var(--space-3);
573 padding: 10px 14px;
574 background: var(--bg-secondary);
575 border-bottom: 1px solid var(--border);
576 }
577 .blob-header-meta {
578 display: flex;
579 align-items: center;
580 gap: var(--space-2);
581 min-width: 0;
582 flex: 1;
583 }
584 .blob-header-icon { font-size: 14px; opacity: 0.85; }
585 .blob-header-name {
586 font-family: var(--font-mono);
587 font-size: 13px;
588 color: var(--text-strong);
589 font-weight: 600;
590 overflow: hidden;
591 text-overflow: ellipsis;
592 white-space: nowrap;
593 }
594 .blob-header-size {
595 font-family: var(--font-mono);
596 font-size: 11.5px;
597 color: var(--text-muted);
598 font-variant-numeric: tabular-nums;
599 border-left: 1px solid var(--border);
600 padding-left: var(--space-2);
601 margin-left: 2px;
602 }
603 .blob-header-actions {
604 display: flex;
605 gap: 6px;
606 flex-shrink: 0;
607 }
608 .blob-pill {
609 display: inline-flex;
610 align-items: center;
611 padding: 4px 12px;
612 font-size: 12px;
613 font-weight: 500;
614 color: var(--text);
615 background: var(--bg-elevated);
616 border: 1px solid var(--border);
617 border-radius: 999px;
618 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
619 }
620 .blob-pill:hover {
621 color: var(--accent);
622 border-color: rgba(140,109,255,0.45);
623 text-decoration: none;
624 background: rgba(140,109,255,0.06);
625 }
626 .blob-pill-accent {
627 color: var(--accent);
628 border-color: rgba(140,109,255,0.35);
629 background: rgba(140,109,255,0.08);
630 }
631 .blob-pill-accent:hover {
632 background: rgba(140,109,255,0.14);
633 }
634 .blob-binary {
635 padding: var(--space-5);
636 color: var(--text-muted);
637 text-align: center;
638 font-size: 13px;
639 background: var(--bg);
640 }
641
642 /* ───────── commits list ───────── */
643 .commits-hero {
644 position: relative;
645 margin-bottom: var(--space-4);
646 padding: var(--space-5) var(--space-6);
647 background: var(--bg-elevated);
648 border: 1px solid var(--border);
649 border-radius: 16px;
650 overflow: hidden;
651 }
652 .commits-hero-orb-wrap {
653 position: absolute;
654 inset: -25% -10% auto auto;
655 width: 320px;
656 height: 320px;
657 pointer-events: none;
658 z-index: 0;
659 }
660 .commits-hero-orb {
661 position: absolute;
662 inset: 0;
663 background: radial-gradient(circle, rgba(140,109,255,0.16), rgba(54,197,214,0.08) 45%, transparent 70%);
664 filter: blur(80px);
665 opacity: 0.7;
666 animation: cbHeroOrb 14s ease-in-out infinite;
667 }
668 .commits-hero-inner { position: relative; z-index: 1; }
669 .commits-eyebrow {
670 font-size: 12px;
671 font-family: var(--font-mono);
672 color: var(--text-muted);
673 letter-spacing: 0.1em;
674 text-transform: uppercase;
675 margin-bottom: var(--space-2);
676 }
677 .commits-eyebrow strong { color: var(--accent); font-weight: 600; }
678 .commits-title {
679 font-family: var(--font-display);
680 font-weight: 800;
681 letter-spacing: -0.025em;
682 font-size: clamp(22px, 3vw, 30px);
683 line-height: 1.15;
684 margin: 0 0 var(--space-2);
685 color: var(--text-strong);
686 }
687 .commits-branch {
688 font-family: var(--font-mono);
689 font-size: 0.7em;
690 color: var(--text);
691 background: var(--bg-secondary);
692 border: 1px solid var(--border);
693 border-radius: 6px;
694 padding: 2px 8px;
695 font-weight: 500;
696 vertical-align: middle;
697 }
698 .commits-sub {
699 font-size: 14px;
700 color: var(--text-muted);
701 margin: 0;
702 line-height: 1.55;
703 max-width: 640px;
704 }
398a10cClaude705 .commits-toolbar {
706 display: flex;
707 justify-content: space-between;
708 align-items: center;
709 flex-wrap: wrap;
710 gap: var(--space-2);
711 margin-bottom: var(--space-3);
712 }
713 .commits-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
714 .commits-toolbar-link {
715 display: inline-flex;
716 align-items: center;
717 gap: 6px;
718 padding: 6px 12px;
719 font-size: 12.5px;
720 font-weight: 500;
721 color: var(--text-muted);
722 background: rgba(255,255,255,0.025);
723 border: 1px solid var(--border);
724 border-radius: 8px;
725 text-decoration: none;
726 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
727 }
728 .commits-toolbar-link:hover {
729 border-color: var(--border-strong);
730 color: var(--text-strong);
731 background: rgba(255,255,255,0.04);
732 text-decoration: none;
733 }
efb11c5Claude734 .commits-list-wrap {
735 background: var(--bg-elevated);
736 border: 1px solid var(--border);
398a10cClaude737 border-radius: 14px;
efb11c5Claude738 overflow: hidden;
398a10cClaude739 position: relative;
740 }
741 .commits-list-wrap::before {
742 content: '';
743 position: absolute;
744 top: 0; left: 0; right: 0;
745 height: 2px;
746 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
747 opacity: 0.55;
748 pointer-events: none;
749 }
750 .commits-day-head {
751 display: flex;
752 align-items: center;
753 gap: 10px;
754 padding: 10px 18px;
755 font-size: 11.5px;
756 font-family: var(--font-mono);
757 text-transform: uppercase;
758 letter-spacing: 0.08em;
759 color: var(--text-muted);
760 background: var(--bg-secondary);
761 border-bottom: 1px solid var(--border);
762 }
763 .commits-day-head:not(:first-child) { border-top: 1px solid var(--border); }
764 .commits-day-head-dot {
765 width: 6px; height: 6px;
766 border-radius: 9999px;
767 background: linear-gradient(135deg, #8c6dff, #36c5d6);
768 }
769 .commits-row {
770 display: flex;
771 align-items: flex-start;
772 gap: 14px;
773 padding: 14px 18px;
774 border-bottom: 1px solid var(--border-subtle);
775 transition: background 120ms ease;
776 }
777 .commits-row:last-child { border-bottom: none; }
778 .commits-row:hover { background: rgba(255,255,255,0.022); }
779 .commits-avatar {
780 width: 34px; height: 34px;
781 border-radius: 9999px;
782 background: linear-gradient(135deg, rgba(140,109,255,0.30), rgba(54,197,214,0.25));
783 color: #fff;
784 display: inline-flex;
785 align-items: center;
786 justify-content: center;
787 font-family: var(--font-display);
788 font-weight: 700;
789 font-size: 13.5px;
790 flex-shrink: 0;
791 box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
792 }
793 .commits-row-body { flex: 1; min-width: 0; }
794 .commits-row-msg {
795 display: flex;
796 align-items: center;
797 gap: 8px;
798 flex-wrap: wrap;
799 }
800 .commits-row-msg a {
801 font-family: var(--font-display);
802 font-weight: 600;
803 font-size: 14px;
804 color: var(--text-strong);
805 text-decoration: none;
806 letter-spacing: -0.005em;
807 }
808 .commits-row-msg a:hover { color: var(--accent); text-decoration: none; }
809 .commits-row-verified {
810 font-size: 9.5px;
811 padding: 1px 7px;
812 border-radius: 9999px;
813 background: rgba(52,211,153,0.16);
814 color: #6ee7b7;
815 box-shadow: inset 0 0 0 1px rgba(52,211,153,0.30);
816 text-transform: uppercase;
817 letter-spacing: 0.06em;
818 font-weight: 700;
819 }
820 .commits-row-meta {
821 margin-top: 4px;
822 display: flex;
823 align-items: center;
824 gap: 8px;
825 flex-wrap: wrap;
826 font-size: 12.5px;
827 color: var(--text-muted);
828 }
829 .commits-row-meta strong { color: var(--text); font-weight: 600; }
830 .commits-row-meta .sep { opacity: 0.4; }
831 .commits-row-time {
832 font-variant-numeric: tabular-nums;
833 }
834 .commits-row-side {
835 display: flex;
836 align-items: center;
837 gap: 8px;
838 flex-shrink: 0;
839 }
840 .commits-row-sha {
841 display: inline-flex;
842 align-items: center;
843 padding: 4px 10px;
844 border-radius: 9999px;
845 font-family: var(--font-mono);
846 font-size: 11.5px;
847 font-weight: 600;
848 color: var(--text-strong);
849 background: rgba(255,255,255,0.04);
850 border: 1px solid var(--border);
851 text-decoration: none;
852 letter-spacing: 0.04em;
853 transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
854 }
855 .commits-row-sha:hover {
856 border-color: rgba(140,109,255,0.55);
857 color: var(--accent);
858 background: rgba(140,109,255,0.08);
859 text-decoration: none;
860 }
861 .commits-row-copy {
862 display: inline-flex;
863 align-items: center;
864 justify-content: center;
865 width: 28px; height: 28px;
866 padding: 0;
867 border-radius: 8px;
868 background: transparent;
869 border: 1px solid var(--border);
870 color: var(--text-muted);
871 cursor: pointer;
872 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
efb11c5Claude873 }
398a10cClaude874 .commits-row-copy:hover {
875 border-color: var(--border-strong);
876 color: var(--text);
877 background: rgba(255,255,255,0.04);
878 }
879 .commits-row-copy.is-copied { color: #6ee7b7; border-color: rgba(52,211,153,0.35); }
efb11c5Claude880 .commits-empty {
398a10cClaude881 position: relative;
882 overflow: hidden;
883 padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 36px);
efb11c5Claude884 text-align: center;
398a10cClaude885 background: var(--bg-elevated);
886 border: 1px dashed var(--border-strong);
887 border-radius: 16px;
888 }
889 .commits-empty-orb {
890 position: absolute;
891 inset: -40% 30% auto 30%;
892 height: 280px;
893 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.10) 45%, transparent 70%);
894 filter: blur(70px);
895 opacity: 0.7;
896 pointer-events: none;
897 z-index: 0;
898 }
899 .commits-empty-inner { position: relative; z-index: 1; }
900 .commits-empty-icon {
901 width: 56px; height: 56px;
902 border-radius: 9999px;
903 background: linear-gradient(135deg, rgba(140,109,255,0.25), rgba(54,197,214,0.20));
904 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.40);
905 display: inline-flex;
906 align-items: center;
907 justify-content: center;
908 color: #c4b5fd;
909 margin: 0 auto 14px;
910 }
911 .commits-empty-title {
912 font-family: var(--font-display);
913 font-size: 18px;
914 font-weight: 700;
915 margin: 0 0 6px;
916 color: var(--text-strong);
917 }
918 .commits-empty-sub {
919 margin: 0 auto 0;
920 font-size: 13.5px;
efb11c5Claude921 color: var(--text-muted);
398a10cClaude922 max-width: 420px;
923 line-height: 1.5;
924 }
925
926 /* ───────── branches list ───────── */
927 .branches-list {
efb11c5Claude928 background: var(--bg-elevated);
398a10cClaude929 border: 1px solid var(--border);
930 border-radius: 14px;
931 overflow: hidden;
932 position: relative;
933 }
934 .branches-list::before {
935 content: '';
936 position: absolute;
937 top: 0; left: 0; right: 0;
938 height: 2px;
939 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
940 opacity: 0.55;
941 pointer-events: none;
942 }
943 .branches-row {
944 display: flex;
945 align-items: center;
946 gap: var(--space-3);
947 padding: 14px 18px;
948 border-bottom: 1px solid var(--border-subtle);
949 transition: background 120ms ease;
950 flex-wrap: wrap;
951 }
952 .branches-row:last-child { border-bottom: none; }
953 .branches-row:hover { background: rgba(255,255,255,0.022); }
954 .branches-row-icon {
955 width: 32px; height: 32px;
956 border-radius: 8px;
957 background: rgba(140,109,255,0.10);
958 color: #c4b5fd;
959 display: inline-flex;
960 align-items: center;
961 justify-content: center;
962 flex-shrink: 0;
963 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.22);
964 }
965 .branches-row-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
966 .branches-row-name {
967 display: inline-flex;
968 align-items: center;
969 gap: 8px;
970 flex-wrap: wrap;
971 }
972 .branches-row-name a {
973 font-family: var(--font-mono);
974 font-size: 13.5px;
975 color: var(--text-strong);
976 font-weight: 600;
977 text-decoration: none;
978 }
979 .branches-row-name a:hover { color: var(--accent); text-decoration: none; }
980 .branches-row-default {
981 font-size: 10px;
982 padding: 2px 8px;
983 border-radius: 9999px;
984 background: rgba(140,109,255,0.14);
985 color: #c4b5fd;
986 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.30);
987 text-transform: uppercase;
988 letter-spacing: 0.08em;
989 font-weight: 700;
990 font-family: var(--font-mono);
991 }
992 .branches-row-meta {
993 display: flex;
994 align-items: center;
995 gap: 8px;
996 flex-wrap: wrap;
997 font-size: 12.5px;
998 color: var(--text-muted);
999 font-variant-numeric: tabular-nums;
1000 }
1001 .branches-row-meta .sep { opacity: 0.4; }
1002 .branches-row-meta strong { color: var(--text); font-weight: 600; }
1003 .branches-row-side {
1004 display: flex;
1005 align-items: center;
1006 gap: 10px;
1007 flex-shrink: 0;
1008 flex-wrap: wrap;
1009 }
1010 .branches-row-divergence {
1011 display: inline-flex;
1012 align-items: center;
1013 gap: 8px;
1014 font-family: var(--font-mono);
1015 font-size: 11.5px;
1016 color: var(--text-muted);
1017 padding: 4px 10px;
1018 border-radius: 9999px;
1019 background: rgba(255,255,255,0.035);
1020 border: 1px solid var(--border);
1021 font-variant-numeric: tabular-nums;
1022 }
1023 .branches-row-divergence .ahead { color: #6ee7b7; }
1024 .branches-row-divergence .behind { color: #fca5a5; }
1025 .branches-row-actions {
1026 display: flex;
1027 align-items: center;
1028 gap: 6px;
1029 }
1030 .branches-btn {
1031 display: inline-flex;
1032 align-items: center;
1033 gap: 5px;
1034 padding: 6px 12px;
1035 border-radius: 9999px;
1036 font-size: 12px;
1037 font-weight: 600;
1038 text-decoration: none;
1039 border: 1px solid var(--border);
1040 background: transparent;
1041 color: var(--text-muted);
1042 cursor: pointer;
1043 font: inherit;
1044 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1045 }
1046 .branches-btn:hover {
1047 border-color: var(--border-strong);
1048 color: var(--text);
1049 background: rgba(255,255,255,0.04);
1050 text-decoration: none;
1051 }
1052 .branches-btn-danger {
1053 color: #fca5a5;
1054 border-color: rgba(248,113,113,0.30);
1055 }
1056 .branches-btn-danger:hover {
1057 border-style: dashed;
1058 border-color: rgba(248,113,113,0.65);
1059 background: rgba(248,113,113,0.06);
1060 color: #fecaca;
1061 }
1062
1063 /* ───────── tags list ───────── */
1064 .tags-list {
1065 background: var(--bg-elevated);
1066 border: 1px solid var(--border);
1067 border-radius: 14px;
1068 overflow: hidden;
1069 position: relative;
1070 }
1071 .tags-list::before {
1072 content: '';
1073 position: absolute;
1074 top: 0; left: 0; right: 0;
1075 height: 2px;
1076 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
1077 opacity: 0.55;
1078 pointer-events: none;
1079 }
1080 .tags-row {
1081 display: flex;
1082 align-items: center;
1083 gap: var(--space-3);
1084 padding: 14px 18px;
1085 border-bottom: 1px solid var(--border-subtle);
1086 transition: background 120ms ease;
1087 flex-wrap: wrap;
1088 }
1089 .tags-row:last-child { border-bottom: none; }
1090 .tags-row:hover { background: rgba(255,255,255,0.022); }
1091 .tags-row-icon {
1092 width: 32px; height: 32px;
1093 border-radius: 8px;
1094 background: rgba(54,197,214,0.10);
1095 color: #67e8f9;
1096 display: inline-flex;
1097 align-items: center;
1098 justify-content: center;
1099 flex-shrink: 0;
1100 box-shadow: inset 0 0 0 1px rgba(54,197,214,0.22);
1101 }
1102 .tags-row-main { flex: 1; min-width: 240px; }
1103 .tags-row-name {
1104 display: inline-flex;
1105 align-items: center;
1106 gap: 8px;
1107 flex-wrap: wrap;
1108 }
1109 .tags-row-version {
1110 display: inline-flex;
1111 align-items: center;
1112 padding: 3px 11px;
1113 border-radius: 9999px;
1114 font-family: var(--font-mono);
1115 font-size: 13px;
1116 font-weight: 700;
1117 color: #67e8f9;
1118 background: rgba(54,197,214,0.12);
1119 box-shadow: inset 0 0 0 1px rgba(54,197,214,0.30);
1120 letter-spacing: 0.01em;
1121 }
1122 .tags-row-meta {
1123 margin-top: 4px;
1124 display: flex;
1125 align-items: center;
1126 gap: 8px;
1127 flex-wrap: wrap;
1128 font-size: 12.5px;
1129 color: var(--text-muted);
1130 font-variant-numeric: tabular-nums;
1131 }
1132 .tags-row-meta .sep { opacity: 0.4; }
1133 .tags-row-sha {
1134 font-family: var(--font-mono);
1135 font-size: 11.5px;
1136 color: var(--text-strong);
1137 padding: 2px 8px;
1138 border-radius: 6px;
1139 background: rgba(255,255,255,0.04);
1140 border: 1px solid var(--border);
1141 text-decoration: none;
1142 letter-spacing: 0.04em;
1143 }
1144 .tags-row-sha:hover { border-color: var(--border-strong); color: var(--accent); text-decoration: none; }
1145 .tags-row-side {
1146 display: flex;
1147 align-items: center;
1148 gap: 6px;
1149 flex-shrink: 0;
1150 flex-wrap: wrap;
1151 }
1152 .tags-row-link {
1153 display: inline-flex;
1154 align-items: center;
1155 gap: 5px;
1156 padding: 6px 12px;
1157 border-radius: 9999px;
1158 font-size: 12px;
1159 font-weight: 600;
1160 text-decoration: none;
1161 color: var(--text-muted);
1162 background: rgba(255,255,255,0.025);
1163 border: 1px solid var(--border);
1164 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1165 }
1166 .tags-row-link:hover {
1167 border-color: rgba(140,109,255,0.45);
1168 color: var(--text-strong);
1169 background: rgba(140,109,255,0.06);
1170 text-decoration: none;
efb11c5Claude1171 }
1172
1173 /* ───────── commit detail ───────── */
1174 .commit-detail-card {
1175 position: relative;
1176 margin-bottom: var(--space-5);
1177 padding: var(--space-5) var(--space-5);
1178 background: var(--bg-elevated);
1179 border: 1px solid var(--border);
1180 border-radius: 14px;
1181 overflow: hidden;
1182 }
1183 .commit-detail-eyebrow {
1184 display: flex;
1185 align-items: center;
1186 gap: var(--space-2);
1187 font-size: 12px;
1188 font-family: var(--font-mono);
1189 text-transform: uppercase;
1190 letter-spacing: 0.1em;
1191 color: var(--text-muted);
1192 margin-bottom: var(--space-2);
1193 }
1194 .commit-detail-eyebrow strong { color: var(--accent); font-weight: 600; }
1195 .commit-detail-sha-pill {
1196 font-family: var(--font-mono);
1197 font-size: 11.5px;
1198 color: var(--text-strong);
1199 background: var(--bg-secondary);
1200 border: 1px solid var(--border);
1201 border-radius: 999px;
1202 padding: 2px 10px;
1203 letter-spacing: 0.04em;
1204 }
1205 .commit-detail-verify {
1206 font-size: 10px;
1207 padding: 2px 8px;
1208 border-radius: 999px;
1209 text-transform: uppercase;
1210 letter-spacing: 0.06em;
1211 font-weight: 700;
1212 color: #fff;
1213 }
1214 .commit-detail-verify-ok {
1215 background: linear-gradient(135deg, #2ea043, #34d399);
1216 }
1217 .commit-detail-verify-warn {
1218 background: linear-gradient(135deg, #d29922, #f59e0b);
1219 }
1220 .commit-detail-title {
1221 font-family: var(--font-display);
1222 font-weight: 700;
1223 letter-spacing: -0.018em;
1224 font-size: clamp(20px, 2.5vw, 26px);
1225 line-height: 1.25;
1226 margin: 0 0 var(--space-2);
1227 color: var(--text-strong);
1228 }
1229 .commit-detail-body {
1230 white-space: pre-wrap;
1231 color: var(--text-muted);
1232 font-size: 14px;
1233 line-height: 1.55;
1234 margin: 0 0 var(--space-3);
1235 font-family: var(--font-mono);
1236 background: var(--bg);
1237 border: 1px solid var(--border);
1238 border-radius: 8px;
1239 padding: var(--space-3) var(--space-4);
1240 max-height: 280px;
1241 overflow: auto;
1242 }
1243 .commit-detail-meta {
1244 display: flex;
1245 flex-wrap: wrap;
1246 gap: var(--space-3);
1247 font-size: 13px;
1248 color: var(--text-muted);
1249 margin-bottom: var(--space-3);
1250 }
1251 .commit-detail-author strong { color: var(--text-strong); font-weight: 600; }
1252 .commit-detail-parents { font-size: 13px; color: var(--text-muted); }
1253 .commit-detail-sha-link {
1254 font-family: var(--font-mono);
1255 font-size: 12.5px;
1256 color: var(--accent);
1257 background: rgba(140,109,255,0.08);
1258 border-radius: 6px;
1259 padding: 1px 6px;
1260 margin-left: 2px;
1261 }
1262 .commit-detail-sha-link:hover { background: rgba(140,109,255,0.16); text-decoration: none; }
1263 .commit-detail-stats {
1264 display: flex;
1265 flex-wrap: wrap;
1266 align-items: center;
1267 gap: var(--space-3);
1268 padding-top: var(--space-3);
1269 border-top: 1px solid var(--border);
1270 font-size: 13px;
1271 color: var(--text-muted);
1272 }
1273 .commit-detail-stat {
1274 display: inline-flex;
1275 align-items: center;
1276 gap: 4px;
1277 font-variant-numeric: tabular-nums;
1278 }
1279 .commit-detail-stat strong { color: var(--text-strong); font-weight: 600; }
1280 .commit-detail-stat-add strong { color: #34d399; }
1281 .commit-detail-stat-del strong { color: #f87171; }
1282 .commit-detail-stat-mark {
1283 font-family: var(--font-mono);
1284 font-weight: 700;
1285 font-size: 14px;
1286 }
1287 .commit-detail-stat-add .commit-detail-stat-mark { color: #34d399; }
1288 .commit-detail-stat-del .commit-detail-stat-mark { color: #f87171; }
1289 .commit-detail-sha-full {
1290 margin-left: auto;
1291 font-family: var(--font-mono);
1292 font-size: 11.5px;
1293 color: var(--text-faint);
1294 letter-spacing: 0.02em;
1295 overflow: hidden;
1296 text-overflow: ellipsis;
1297 white-space: nowrap;
1298 max-width: 100%;
1299 }
1300 .commit-detail-checks {
1301 margin-top: var(--space-3);
1302 padding-top: var(--space-3);
1303 border-top: 1px solid var(--border);
1304 }
1305 .commit-detail-checks-head {
1306 display: flex;
1307 align-items: center;
1308 gap: var(--space-2);
1309 font-size: 13px;
1310 color: var(--text-muted);
1311 margin-bottom: 8px;
1312 }
1313 .commit-detail-checks-head strong { color: var(--text-strong); font-weight: 600; }
1314 .commit-detail-check-state-success { color: #34d399; font-weight: 600; }
1315 .commit-detail-check-state-failure { color: #f87171; font-weight: 600; }
1316 .commit-detail-check-state-pending { color: #d29922; font-weight: 600; }
1317 .commit-detail-check-row { display: flex; flex-wrap: wrap; gap: 6px; }
1318 .commit-detail-check {
1319 font-size: 11px;
1320 padding: 2px 8px;
1321 border-radius: 999px;
1322 color: #fff;
1323 font-weight: 500;
1324 }
398a10cClaude1325 .commit-detail-check a { color: inherit; text-decoration: none; }
1326 .commit-detail-check-success { background: #2ea043; }
1327 .commit-detail-check-pending { background: #d29922; }
1328 .commit-detail-check-failure { background: #da3633; }
1329
1330 /* ───────── blame ───────── */
1331 .blame-head { margin-bottom: var(--space-5); }
1332 .blame-eyebrow {
1333 display: inline-flex;
1334 align-items: center;
1335 gap: 8px;
1336 text-transform: uppercase;
1337 font-family: var(--font-mono);
1338 font-size: 11px;
1339 letter-spacing: 0.16em;
1340 color: var(--text-muted);
1341 font-weight: 600;
1342 margin-bottom: 10px;
1343 }
1344 .blame-eyebrow-dot {
1345 width: 8px; height: 8px;
1346 border-radius: 9999px;
1347 background: linear-gradient(135deg, #8c6dff, #36c5d6);
1348 box-shadow: 0 0 0 3px rgba(140,109,255,0.18);
1349 }
1350 .blame-title {
1351 font-family: var(--font-display);
1352 font-size: clamp(22px, 3vw, 30px);
1353 font-weight: 800;
1354 letter-spacing: -0.025em;
1355 line-height: 1.15;
1356 margin: 0 0 6px;
1357 color: var(--text-strong);
1358 }
1359 .blame-title code {
1360 font-family: var(--font-mono);
1361 font-size: 0.78em;
1362 color: var(--text-strong);
1363 font-weight: 700;
1364 }
1365 .blame-sub {
1366 margin: 0;
1367 font-size: 14px;
1368 color: var(--text-muted);
1369 line-height: 1.5;
1370 max-width: 700px;
1371 }
efb11c5Claude1372 .blame-toolbar {
398a10cClaude1373 display: flex;
1374 justify-content: space-between;
1375 align-items: center;
1376 gap: var(--space-3);
efb11c5Claude1377 margin-bottom: var(--space-3);
398a10cClaude1378 flex-wrap: wrap;
efb11c5Claude1379 font-size: 13px;
1380 }
398a10cClaude1381 .blame-toolbar-actions { display: flex; gap: 6px; }
1382 .blame-card {
1383 background: var(--bg-elevated);
1384 border: 1px solid var(--border);
1385 border-radius: 14px;
1386 overflow: hidden;
1387 position: relative;
1388 }
1389 .blame-card::before {
1390 content: '';
1391 position: absolute;
1392 top: 0; left: 0; right: 0;
1393 height: 2px;
1394 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
1395 opacity: 0.55;
1396 pointer-events: none;
1397 }
efb11c5Claude1398 .blame-header {
1399 display: flex;
1400 align-items: center;
1401 justify-content: space-between;
1402 gap: var(--space-3);
1403 padding: 10px 14px;
1404 background: var(--bg-secondary);
1405 border-bottom: 1px solid var(--border);
1406 }
1407 .blame-header-meta {
1408 display: flex;
1409 align-items: center;
1410 gap: var(--space-2);
1411 min-width: 0;
1412 flex-wrap: wrap;
1413 }
1414 .blame-header-icon { color: var(--accent); font-size: 14px; }
1415 .blame-header-name {
1416 font-family: var(--font-mono);
1417 font-size: 13px;
1418 color: var(--text-strong);
1419 font-weight: 600;
1420 }
1421 .blame-header-tag {
1422 font-size: 10.5px;
1423 text-transform: uppercase;
1424 letter-spacing: 0.08em;
1425 font-family: var(--font-mono);
1426 background: rgba(140,109,255,0.12);
1427 color: var(--accent);
1428 border-radius: 999px;
1429 padding: 2px 8px;
1430 font-weight: 600;
1431 }
1432 .blame-header-stats {
1433 font-family: var(--font-mono);
1434 font-size: 11.5px;
1435 color: var(--text-muted);
1436 font-variant-numeric: tabular-nums;
1437 border-left: 1px solid var(--border);
1438 padding-left: var(--space-2);
1439 }
1440 .blame-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
398a10cClaude1441 .blame-table {
1442 width: 100%;
1443 border-collapse: collapse;
1444 font-family: var(--font-mono);
1445 font-size: 12.5px;
1446 line-height: 1.6;
1447 }
1448 .blame-table tr { border-bottom: 1px solid transparent; }
1449 .blame-table tr.blame-row-first { border-top: 1px solid var(--border); }
1450 .blame-table tr:first-child.blame-row-first { border-top: 0; }
1451 .blame-table tr:hover .blame-line-content { background: rgba(255,255,255,0.025); }
1452 .blame-gutter {
1453 width: 220px;
1454 min-width: 220px;
1455 padding: 0 12px;
1456 vertical-align: top;
1457 background: rgba(255,255,255,0.012);
1458 border-right: 1px solid var(--border-subtle);
1459 font-variant-numeric: tabular-nums;
1460 color: var(--text-muted);
1461 font-size: 11px;
1462 white-space: nowrap;
1463 overflow: hidden;
1464 text-overflow: ellipsis;
1465 padding-top: 2px;
1466 padding-bottom: 2px;
1467 }
1468 .blame-gutter-inner {
1469 display: inline-flex;
1470 align-items: center;
1471 gap: 7px;
1472 max-width: 100%;
1473 overflow: hidden;
1474 }
1475 .blame-gutter-sha {
1476 font-family: var(--font-mono);
1477 font-size: 10.5px;
1478 font-weight: 600;
1479 color: #c4b5fd;
1480 background: rgba(140,109,255,0.10);
1481 padding: 1px 7px;
1482 border-radius: 9999px;
1483 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.22);
1484 text-decoration: none;
1485 letter-spacing: 0.04em;
1486 flex-shrink: 0;
1487 transition: background 120ms ease, box-shadow 120ms ease, color 120ms ease;
1488 }
1489 .blame-gutter-sha:hover {
1490 background: rgba(140,109,255,0.22);
1491 color: #ddd6fe;
1492 box-shadow: inset 0 0 0 1px rgba(140,109,255,0.50);
1493 text-decoration: none;
1494 }
1495 .blame-gutter-author {
1496 color: var(--text);
1497 overflow: hidden;
1498 text-overflow: ellipsis;
1499 white-space: nowrap;
1500 font-size: 11px;
1501 font-family: var(--font-sans, inherit);
1502 }
1503 .blame-line-num {
1504 width: 1%;
1505 min-width: 50px;
1506 padding: 0 12px;
1507 text-align: right;
1508 color: var(--text-faint);
1509 user-select: none;
1510 border-right: 1px solid var(--border-subtle);
1511 font-variant-numeric: tabular-nums;
1512 }
1513 .blame-line-content {
1514 padding: 0 14px;
1515 white-space: pre;
1516 color: var(--text);
1517 transition: background 120ms ease;
1518 }
efb11c5Claude1519
1520 /* ───────── search ───────── */
1521 .search-hero {
1522 position: relative;
1523 margin-bottom: var(--space-4);
1524 padding: var(--space-5) var(--space-6);
1525 background: var(--bg-elevated);
1526 border: 1px solid var(--border);
1527 border-radius: 16px;
1528 overflow: hidden;
1529 }
1530 .search-eyebrow {
1531 font-size: 12px;
1532 font-family: var(--font-mono);
1533 color: var(--text-muted);
1534 letter-spacing: 0.1em;
1535 text-transform: uppercase;
1536 margin-bottom: var(--space-2);
1537 }
1538 .search-eyebrow strong { color: var(--accent); font-weight: 600; }
1539 .search-title {
1540 font-family: var(--font-display);
1541 font-weight: 800;
1542 letter-spacing: -0.025em;
1543 font-size: clamp(22px, 3vw, 30px);
1544 line-height: 1.15;
1545 margin: 0 0 var(--space-3);
1546 color: var(--text-strong);
1547 }
1548 .search-form {
1549 display: flex;
1550 gap: var(--space-2);
1551 align-items: stretch;
1552 }
1553 .search-input-wrap {
1554 position: relative;
1555 flex: 1;
1556 display: flex;
1557 align-items: center;
1558 }
1559 .search-input-icon {
1560 position: absolute;
1561 left: 12px;
1562 color: var(--text-muted);
1563 font-size: 15px;
1564 pointer-events: none;
1565 }
1566 .search-input {
1567 appearance: none;
1568 width: 100%;
1569 padding: 10px 12px 10px 34px;
1570 background: var(--bg);
1571 border: 1px solid var(--border);
1572 border-radius: 10px;
1573 color: var(--text-strong);
1574 font-size: 14px;
1575 font-family: inherit;
1576 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
1577 }
1578 .search-input:focus {
1579 outline: none;
1580 border-color: var(--accent);
1581 box-shadow: 0 0 0 3px rgba(140,109,255,0.18);
1582 }
1583 .search-submit { min-width: 96px; }
1584 .search-results-head {
1585 display: flex;
1586 align-items: baseline;
1587 gap: var(--space-2);
1588 margin-bottom: var(--space-3);
1589 font-size: 13px;
1590 color: var(--text-muted);
1591 }
1592 .search-results-count strong {
1593 color: var(--text-strong);
1594 font-weight: 600;
1595 font-variant-numeric: tabular-nums;
1596 }
1597 .search-results-q { color: var(--text-strong); font-weight: 600; }
1598 .search-results-head code {
1599 font-family: var(--font-mono);
1600 font-size: 12px;
1601 background: var(--bg-secondary);
1602 border: 1px solid var(--border);
1603 border-radius: 5px;
1604 padding: 1px 6px;
1605 color: var(--text);
1606 }
1607 .search-empty {
1608 padding: var(--space-5) var(--space-6);
1609 background: var(--bg-elevated);
1610 border: 1px dashed var(--border);
1611 border-radius: 12px;
1612 color: var(--text-muted);
1613 font-size: 14px;
1614 }
1615 .search-empty strong { color: var(--text-strong); }
1616 .search-results {
1617 display: flex;
1618 flex-direction: column;
1619 gap: var(--space-3);
1620 }
1621 .search-file-head {
1622 display: flex;
1623 align-items: center;
1624 justify-content: space-between;
1625 gap: var(--space-2);
1626 }
1627 .search-file-link {
1628 font-family: var(--font-mono);
1629 font-size: 13px;
1630 color: var(--text-strong);
1631 font-weight: 600;
1632 }
1633 .search-file-link:hover { color: var(--accent); text-decoration: none; }
1634 .search-file-count {
1635 font-family: var(--font-mono);
1636 font-size: 11.5px;
1637 color: var(--text-muted);
1638 font-variant-numeric: tabular-nums;
1639 }
1640`;
1641
fc1817aClaude1642// Home page
06d5ffeClaude1643web.get("/", async (c) => {
1644 const user = c.get("user");
1645
1646 if (user) {
0316dbbClaude1647 return c.redirect("/dashboard");
06d5ffeClaude1648 }
1649
8e9f1d9Claude1650 let stats: { publicRepos?: number; users?: number } | undefined;
52ad8b1Claude1651 let publicStats: PublicStats | null = null;
8e9f1d9Claude1652 try {
1653 const [repoRow] = await db
1654 .select({ n: sql<number>`count(*)::int` })
1655 .from(repositories)
1656 .where(eq(repositories.isPrivate, false));
1657 const [userRow] = await db
1658 .select({ n: sql<number>`count(*)::int` })
1659 .from(users);
1660 stats = {
1661 publicRepos: Number(repoRow?.n ?? 0),
1662 users: Number(userRow?.n ?? 0),
1663 };
1664 } catch {
1665 stats = undefined;
1666 }
1667
52ad8b1Claude1668 // Block L4 — public stats counters (5-min in-memory cache; never throws).
1669 try {
1670 publicStats = await computePublicStats();
1671 } catch {
1672 publicStats = null;
1673 }
1674
534f04aClaude1675 // Block M1 — initial SSR snapshot for the live-now demo feed.
1676 // The helpers in lib/demo-activity.ts never throw, but we still wrap
1677 // in try/catch so a freak module-level explosion can't take down /.
1678 let liveFeed: LandingLiveFeed | null = null;
1679 try {
1680 const [queued, merges, reviewList, reviewCount, feed] = await Promise.all([
1681 listQueuedAiBuildIssues(3),
1682 listRecentAutoMerges(3, 24),
1683 listRecentAiReviews(3, 24),
1684 countAiReviewsSince(24),
1685 listDemoActivityFeed(10),
1686 ]);
1687 liveFeed = {
1688 queued: queued.map((i) => ({
1689 repo: i.repo,
1690 number: i.number,
1691 title: i.title,
1692 createdAt: i.createdAt,
1693 })),
1694 merges: merges.map((m) => ({
1695 repo: m.repo,
1696 number: m.number,
1697 title: m.title,
1698 mergedAt: m.mergedAt,
1699 })),
1700 reviews: reviewList.map((r) => ({
1701 repo: r.repo,
1702 prNumber: r.prNumber,
1703 commentSnippet: r.commentSnippet,
1704 createdAt: r.createdAt,
1705 })),
1706 reviewCount,
1707 feed: feed.map((e) => ({
1708 kind: e.kind,
1709 repo: e.repo,
1710 ref: e.ref,
1711 at: e.at,
1712 })),
1713 };
1714 } catch {
1715 liveFeed = null;
1716 }
1717
fc1817aClaude1718 return c.html(
5f2e749Claude1719 <Layout
1720 user={null}
1721 // Block L10 — SEO + Open Graph for the public landing.
1722 fullTitle="Gluecron — The git host built around Claude"
1723 description="Label an issue. Walk away. Wake up to a merged PR. Gluecron is the AI-native git host with built-in code review, auto-merge, and a Claude-first toolchain."
1724 ogTitle="Gluecron — The git host built around Claude"
1725 ogDescription="Label an issue. Walk away. Wake up to a merged PR. Gluecron is the AI-native git host with built-in code review, auto-merge, and a Claude-first toolchain."
1726 ogType="website"
1727 twitterCard="summary_large_image"
1728 >
534f04aClaude1729 <LandingPage stats={stats} publicStats={publicStats} liveFeed={liveFeed} />
fc1817aClaude1730 </Layout>
1731 );
1732});
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,
71cd5ecClaude2305 };
05b973eClaude2306 const [repoRow] = await db
2307 .select()
2308 .from(repositories)
2309 .where(
2310 and(
2311 eq(repositories.ownerId, ownerUser.id),
2312 eq(repositories.name, repo)
2313 )
06d5ffeClaude2314 )
05b973eClaude2315 .limit(1);
71cd5ecClaude2316 if (!repoRow)
2317 return {
2318 starCount: 0,
2319 starred: false,
2320 archived: false,
2321 isTemplate: false,
544d842Claude2322 forkCount: 0,
2323 description: null as string | null,
2324 pushedAt: null as Date | null,
2325 createdAt: null as Date | null,
71cd5ecClaude2326 };
05b973eClaude2327 let starred = false;
06d5ffeClaude2328 if (user) {
2329 const [star] = await db
2330 .select()
2331 .from(stars)
2332 .where(
2333 and(
2334 eq(stars.userId, user.id),
2335 eq(stars.repositoryId, repoRow.id)
2336 )
2337 )
2338 .limit(1);
2339 starred = !!star;
2340 }
71cd5ecClaude2341 return {
2342 starCount: repoRow.starCount,
2343 starred,
2344 archived: repoRow.isArchived,
2345 isTemplate: repoRow.isTemplate,
544d842Claude2346 forkCount: repoRow.forkCount,
2347 description: repoRow.description as string | null,
2348 pushedAt: (repoRow.pushedAt as Date | null) ?? null,
2349 createdAt: (repoRow.createdAt as Date | null) ?? null,
71cd5ecClaude2350 };
05b973eClaude2351 } catch {
71cd5ecClaude2352 return {
2353 starCount: 0,
2354 starred: false,
2355 archived: false,
2356 isTemplate: false,
544d842Claude2357 forkCount: 0,
2358 description: null as string | null,
2359 pushedAt: null as Date | null,
2360 createdAt: null as Date | null,
71cd5ecClaude2361 };
06d5ffeClaude2362 }
05b973eClaude2363 })(),
2364 ]);
544d842Claude2365 const {
2366 starCount,
2367 starred,
2368 archived,
2369 isTemplate,
2370 forkCount,
2371 description,
2372 pushedAt,
2373 createdAt,
2374 } = starInfo;
2375
2376 // Repo-home polish — shared style block (Block 2.A — parallel session 2.A).
2377 // Scoped via .repo-home-* class prefix to prevent bleed into other surfaces.
2378 const repoHomeCss = `
2379 .repo-home-hero {
2380 position: relative;
2381 margin-bottom: var(--space-5);
2382 padding: var(--space-5) var(--space-6);
2383 background: var(--bg-elevated);
2384 border: 1px solid var(--border);
2385 border-radius: 16px;
2386 overflow: hidden;
2387 }
2388 .repo-home-hero::before {
2389 content: '';
2390 position: absolute;
2391 top: 0; left: 0; right: 0;
2392 height: 2px;
2393 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
2394 opacity: 0.7;
2395 pointer-events: none;
2396 }
2397 .repo-home-hero-orb-wrap {
2398 position: absolute;
2399 inset: -25% -10% auto auto;
2400 width: 360px;
2401 height: 360px;
2402 pointer-events: none;
2403 z-index: 0;
2404 }
2405 .repo-home-hero-orb {
2406 position: absolute;
2407 inset: 0;
2408 background: radial-gradient(circle, rgba(140,109,255,0.18), rgba(54,197,214,0.09) 45%, transparent 70%);
2409 filter: blur(80px);
2410 opacity: 0.7;
2411 animation: repoHomeOrb 14s ease-in-out infinite;
2412 }
2413 @keyframes repoHomeOrb {
2414 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
2415 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
2416 }
2417 @media (prefers-reduced-motion: reduce) {
2418 .repo-home-hero-orb { animation: none; }
2419 }
2420 .repo-home-hero-inner {
2421 position: relative;
2422 z-index: 1;
2423 }
2424 .repo-home-hero .repo-header { margin-bottom: var(--space-3); }
2425 .repo-home-eyebrow {
2426 font-size: 12px;
2427 font-family: var(--font-mono);
2428 color: var(--text-muted);
2429 letter-spacing: 0.1em;
2430 text-transform: uppercase;
2431 margin-bottom: var(--space-2);
2432 }
2433 .repo-home-eyebrow strong { color: var(--accent); font-weight: 600; }
2434 .repo-home-description {
2435 font-size: 15px;
2436 line-height: 1.55;
2437 color: var(--text);
2438 margin: 0;
2439 max-width: 720px;
2440 }
2441 .repo-home-description-empty {
2442 font-size: 14px;
2443 color: var(--text-muted);
2444 font-style: italic;
2445 margin: 0;
2446 }
2447 .repo-home-stat-row {
2448 display: flex;
2449 flex-wrap: wrap;
2450 gap: var(--space-4);
2451 margin-top: var(--space-3);
2452 font-size: 13px;
2453 color: var(--text-muted);
2454 }
2455 .repo-home-stat {
2456 display: inline-flex;
2457 align-items: center;
2458 gap: 6px;
2459 }
2460 .repo-home-stat strong {
2461 color: var(--text-strong);
2462 font-weight: 600;
2463 font-variant-numeric: tabular-nums;
2464 }
2465 .repo-home-stat .repo-home-stat-icon {
2466 color: var(--text-faint);
2467 font-size: 14px;
2468 line-height: 1;
2469 }
2470 .repo-home-stat a {
2471 color: var(--text-muted);
2472 transition: color var(--t-fast) var(--ease);
2473 }
2474 .repo-home-stat a:hover { color: var(--accent); text-decoration: none; }
2475
2476 /* Two-column layout: file tree + sidebar */
2477 .repo-home-grid {
2478 display: grid;
2479 grid-template-columns: minmax(0, 1fr) 280px;
2480 gap: var(--space-5);
2481 align-items: start;
2482 }
2483 @media (max-width: 960px) {
2484 .repo-home-grid { grid-template-columns: minmax(0, 1fr); }
2485 }
2486 .repo-home-main { min-width: 0; }
2487
2488 /* Sidebar card */
2489 .repo-home-side {
2490 display: flex;
2491 flex-direction: column;
2492 gap: var(--space-4);
2493 }
2494 .repo-home-side-card {
2495 background: var(--bg-elevated);
2496 border: 1px solid var(--border);
2497 border-radius: 12px;
2498 padding: var(--space-4);
2499 }
2500 .repo-home-side-title {
2501 font-size: 11px;
2502 font-family: var(--font-mono);
2503 letter-spacing: 0.12em;
2504 text-transform: uppercase;
2505 color: var(--text-muted);
2506 margin: 0 0 var(--space-3);
2507 font-weight: 600;
2508 }
2509 .repo-home-side-row {
2510 display: flex;
2511 justify-content: space-between;
2512 align-items: center;
2513 gap: var(--space-2);
2514 font-size: 13px;
2515 padding: 6px 0;
2516 border-top: 1px solid var(--border);
2517 }
2518 .repo-home-side-row:first-of-type { border-top: 0; padding-top: 0; }
2519 .repo-home-side-key {
2520 color: var(--text-muted);
2521 display: inline-flex;
2522 align-items: center;
2523 gap: 6px;
2524 }
2525 .repo-home-side-val {
2526 color: var(--text-strong);
2527 font-weight: 500;
2528 font-variant-numeric: tabular-nums;
2529 max-width: 60%;
2530 text-align: right;
2531 overflow: hidden;
2532 text-overflow: ellipsis;
2533 white-space: nowrap;
2534 }
2535 .repo-home-side-val a { color: var(--text-strong); }
2536 .repo-home-side-val a:hover { color: var(--accent); text-decoration: none; }
2537
2538 /* Clone / Code tabs */
2539 .repo-home-clone {
2540 background: var(--bg-elevated);
2541 border: 1px solid var(--border);
2542 border-radius: 12px;
2543 overflow: hidden;
2544 }
2545 .repo-home-clone-tabs {
2546 display: flex;
2547 gap: 0;
2548 background: var(--bg-secondary);
2549 border-bottom: 1px solid var(--border);
2550 padding: 0 var(--space-2);
2551 }
2552 .repo-home-clone-tab {
2553 appearance: none;
2554 background: transparent;
2555 border: 0;
2556 border-bottom: 2px solid transparent;
2557 padding: 9px 12px;
2558 font-size: 12px;
2559 font-weight: 500;
2560 color: var(--text-muted);
2561 cursor: pointer;
2562 transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
2563 font-family: inherit;
2564 margin-bottom: -1px;
2565 }
2566 .repo-home-clone-tab:hover { color: var(--text-strong); }
2567 .repo-home-clone-tab[aria-selected="true"] {
2568 color: var(--text-strong);
2569 border-bottom-color: var(--accent);
2570 }
2571 .repo-home-clone-body {
2572 padding: var(--space-3);
2573 display: flex;
2574 align-items: center;
2575 gap: var(--space-2);
2576 }
2577 .repo-home-clone-input {
2578 flex: 1;
2579 min-width: 0;
2580 font-family: var(--font-mono);
2581 font-size: 12px;
2582 background: var(--bg);
2583 border: 1px solid var(--border);
2584 border-radius: 8px;
2585 padding: 8px 10px;
2586 color: var(--text-strong);
2587 overflow: hidden;
2588 text-overflow: ellipsis;
2589 white-space: nowrap;
2590 }
2591 .repo-home-clone-copy {
2592 appearance: none;
2593 background: var(--bg-secondary);
2594 border: 1px solid var(--border);
2595 color: var(--text-strong);
2596 border-radius: 8px;
2597 padding: 8px 12px;
2598 font-size: 12px;
2599 font-weight: 600;
2600 cursor: pointer;
2601 transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
2602 font-family: inherit;
2603 }
2604 .repo-home-clone-copy:hover { background: var(--bg-hover); border-color: var(--border-strong, var(--border)); }
2605 .repo-home-clone-pane { display: none; }
2606 .repo-home-clone-pane[data-active="true"] { display: flex; }
2607
2608 /* README card */
2609 .repo-home-readme {
2610 margin-top: var(--space-5);
2611 background: var(--bg-elevated);
2612 border: 1px solid var(--border);
2613 border-radius: 12px;
2614 overflow: hidden;
2615 }
2616 .repo-home-readme-head {
2617 display: flex;
2618 align-items: center;
2619 gap: 8px;
2620 padding: 10px 16px;
2621 background: var(--bg-secondary);
2622 border-bottom: 1px solid var(--border);
2623 font-size: 13px;
2624 color: var(--text-muted);
2625 }
2626 .repo-home-readme-head .repo-home-readme-icon {
2627 color: var(--accent);
2628 font-size: 14px;
2629 }
2630 .repo-home-readme-body {
2631 padding: var(--space-5) var(--space-6);
2632 }
2633
2634 /* Empty-state CTA */
2635 .repo-home-empty {
2636 position: relative;
2637 margin-top: var(--space-4);
2638 background: var(--bg-elevated);
2639 border: 1px solid var(--border);
2640 border-radius: 16px;
2641 padding: var(--space-6);
2642 overflow: hidden;
2643 }
2644 .repo-home-empty::before {
2645 content: '';
2646 position: absolute;
2647 top: 0; left: 0; right: 0;
2648 height: 2px;
2649 background: linear-gradient(90deg, transparent 0%, #8c6dff 30%, #36c5d6 70%, transparent 100%);
2650 opacity: 0.7;
2651 pointer-events: none;
2652 }
2653 .repo-home-empty-eyebrow {
2654 font-size: 12px;
2655 font-family: var(--font-mono);
2656 color: var(--accent);
2657 letter-spacing: 0.12em;
2658 text-transform: uppercase;
2659 margin-bottom: var(--space-2);
2660 font-weight: 600;
2661 }
2662 .repo-home-empty-title {
2663 font-family: var(--font-display);
2664 font-weight: 800;
2665 letter-spacing: -0.025em;
2666 font-size: clamp(22px, 3vw, 30px);
2667 line-height: 1.1;
2668 margin: 0 0 var(--space-2);
2669 color: var(--text-strong);
2670 }
2671 .repo-home-empty-sub {
2672 color: var(--text-muted);
2673 font-size: 14px;
2674 line-height: 1.55;
2675 max-width: 640px;
2676 margin: 0 0 var(--space-4);
2677 }
2678 .repo-home-empty-snippet {
2679 background: var(--bg);
2680 border: 1px solid var(--border);
2681 border-radius: 10px;
2682 padding: var(--space-3) var(--space-4);
2683 font-family: var(--font-mono);
2684 font-size: 12.5px;
2685 line-height: 1.7;
2686 color: var(--text-strong);
2687 overflow-x: auto;
2688 white-space: pre;
2689 margin: 0;
2690 }
2691 .repo-home-empty-snippet .repo-home-cmt { color: var(--text-faint); }
2692 .repo-home-empty-snippet .repo-home-cmd { color: var(--accent); }
2693
2694 @media (max-width: 720px) {
2695 .repo-home-hero { padding: var(--space-4) var(--space-4); }
2696 .repo-home-clone-body { flex-direction: column; align-items: stretch; }
2697 .repo-home-clone-copy { width: 100%; }
f1dc7c7Claude2698 .repo-home-stat-row { gap: var(--space-2) var(--space-3); font-size: 12.5px; }
2699 .repo-home-side-val { max-width: 55%; }
2700 .repo-home-clone-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
2701 .repo-home-clone-tab { min-height: 44px; padding: 11px 14px; }
2702 .repo-home-side-card { padding: var(--space-3); }
544d842Claude2703 }
2704 `;
2705 const cloneHttpsUrl = `${config.appBaseUrl}/${owner}/${repo}.git`;
2706 // Best-effort SSH URL. If APP_BASE_URL is a hostname, this looks right; for
2707 // localhost it'll still render and just be slightly silly (which is fine for dev).
2708 let cloneSshUrl = `git@gluecron.com:${owner}/${repo}.git`;
2709 try {
2710 const host = new URL(config.appBaseUrl).hostname;
2711 if (host && host !== "localhost" && host !== "127.0.0.1") {
2712 cloneSshUrl = `git@${host}:${owner}/${repo}.git`;
2713 }
2714 } catch {
2715 // Fall through to default.
2716 }
2717 const cloneCliCmd = `gluecron clone ${owner}/${repo}`;
2718 const formatRelative = (date: Date | null): string => {
2719 if (!date) return "never";
2720 const ms = Date.now() - date.getTime();
2721 const s = Math.max(0, Math.round(ms / 1000));
2722 if (s < 60) return "just now";
2723 const m = Math.round(s / 60);
2724 if (m < 60) return `${m} min ago`;
2725 const h = Math.round(m / 60);
2726 if (h < 24) return `${h}h ago`;
2727 const d = Math.round(h / 24);
2728 if (d < 30) return `${d}d ago`;
2729 const mo = Math.round(d / 30);
2730 if (mo < 12) return `${mo}mo ago`;
2731 const y = Math.round(d / 365);
2732 return `${y}y ago`;
2733 };
06d5ffeClaude2734
fc1817aClaude2735 if (tree.length === 0) {
2736 return c.html(
06d5ffeClaude2737 <Layout title={`${owner}/${repo}`} user={user}>
544d842Claude2738 <style dangerouslySetInnerHTML={{ __html: repoHomeCss }} />
2739 <div class="repo-home-hero">
2740 <div class="repo-home-hero-orb-wrap" aria-hidden="true">
2741 <div class="repo-home-hero-orb" />
2742 </div>
2743 <div class="repo-home-hero-inner">
2744 <div class="repo-home-eyebrow">
2745 <strong>Repository</strong> · {owner}
2746 </div>
2747 <RepoHeader
2748 owner={owner}
2749 repo={repo}
2750 starCount={starCount}
2751 starred={starred}
2752 forkCount={forkCount}
2753 currentUser={user?.username}
2754 archived={archived}
2755 isTemplate={isTemplate}
2756 />
2757 {description ? (
2758 <p class="repo-home-description">{description}</p>
2759 ) : (
2760 <p class="repo-home-description-empty">
2761 No description yet — push a README to tell the world what this
2762 ships.
2763 </p>
2764 )}
2765 </div>
2766 </div>
fc1817aClaude2767 <RepoNav owner={owner} repo={repo} active="code" />
544d842Claude2768 <div class="repo-home-empty">
2769 <div class="repo-home-empty-eyebrow">Getting started</div>
2770 <h2 class="repo-home-empty-title">
2771 Push your first commit to{" "}
2772 <span class="gradient-text">{repo}</span>.
2773 </h2>
2774 <p class="repo-home-empty-sub">
2775 This repository is empty. Paste the snippet below in an existing
2776 project directory to wire it up to Gluecron — your push triggers
2777 gate checks and AI review automatically.
2778 </p>
2779 <pre class="repo-home-empty-snippet">
2780 <span class="repo-home-cmt">
2781 # from an existing project directory
2782 </span>
2783 {"\n"}
2784 <span class="repo-home-cmd">git remote add</span>
2785 {` origin ${cloneHttpsUrl}`}
2786 {"\n"}
2787 <span class="repo-home-cmd">git branch</span>
2788 {` -M main`}
2789 {"\n"}
2790 <span class="repo-home-cmd">git push</span>
2791 {` -u origin main`}
2792 </pre>
fc1817aClaude2793 </div>
2794 </Layout>
2795 );
2796 }
2797
2798 const readme = await getReadme(owner, repo, defaultBranch);
2799
544d842Claude2800 // Sidebar facts — derived from data we already have.
2801 const fileCount = tree.filter((e: any) => e.type !== "tree").length;
2802 const dirCount = tree.filter((e: any) => e.type === "tree").length;
2803
fc1817aClaude2804 return c.html(
06d5ffeClaude2805 <Layout title={`${owner}/${repo}`} user={user}>
544d842Claude2806 <style dangerouslySetInnerHTML={{ __html: repoHomeCss }} />
2807 <div class="repo-home-hero">
2808 <div class="repo-home-hero-orb-wrap" aria-hidden="true">
2809 <div class="repo-home-hero-orb" />
2810 </div>
2811 <div class="repo-home-hero-inner">
2812 <div class="repo-home-eyebrow">
2813 <strong>Repository</strong> · {owner}
2814 </div>
2815 <RepoHeader
2816 owner={owner}
2817 repo={repo}
2818 starCount={starCount}
2819 starred={starred}
2820 forkCount={forkCount}
2821 currentUser={user?.username}
2822 archived={archived}
2823 isTemplate={isTemplate}
2824 />
2825 {description ? (
2826 <p class="repo-home-description">{description}</p>
2827 ) : (
2828 <p class="repo-home-description-empty">
2829 No description yet.
2830 </p>
2831 )}
2832 <div class="repo-home-stat-row" aria-label="Repository stats">
2833 <span class="repo-home-stat" title="Default branch">
2834 <span class="repo-home-stat-icon">{"⎇"}</span>
2835 <strong>{defaultBranch}</strong>
2836 </span>
2837 <a
2838 href={`/${owner}/${repo}/commits/${defaultBranch}`}
2839 class="repo-home-stat"
2840 title="Browse all branches"
2841 >
2842 <span class="repo-home-stat-icon">{"⊢"}</span>
2843 <strong>{branches.length}</strong>{" "}
2844 branch{branches.length === 1 ? "" : "es"}
2845 </a>
2846 <span class="repo-home-stat" title="Top-level entries">
2847 <span class="repo-home-stat-icon">{"■"}</span>
2848 <strong>{fileCount}</strong> file{fileCount === 1 ? "" : "s"}
2849 {dirCount > 0 && (
2850 <>
2851 {" · "}
2852 <strong>{dirCount}</strong> dir{dirCount === 1 ? "" : "s"}
2853 </>
2854 )}
2855 </span>
2856 {pushedAt && (
2857 <span class="repo-home-stat" title={`Last push: ${pushedAt.toISOString()}`}>
2858 <span class="repo-home-stat-icon">{"↻"}</span>
2859 Updated <strong>{formatRelative(pushedAt)}</strong>
2860 </span>
2861 )}
2862 </div>
2863 </div>
2864 </div>
71cd5ecClaude2865 {isTemplate && user && user.username !== owner && (
2866 <div
2867 class="panel"
dc26881CC LABS App2868 style="margin-bottom:var(--space-4);padding:var(--space-3);display:flex;align-items:center;justify-content:space-between;gap:var(--space-3)"
71cd5ecClaude2869 >
2870 <div style="font-size:13px">
2871 <strong>Template repository.</strong> Create a new repository from
2872 this template's files.
2873 </div>
2874 <form
001af43Claude2875 method="post"
71cd5ecClaude2876 action={`/${owner}/${repo}/use-template`}
dc26881CC LABS App2877 style="display:flex;gap:var(--space-2);align-items:center"
71cd5ecClaude2878 >
2879 <input
2880 type="text"
2881 name="name"
2882 placeholder="new-repo-name"
2883 required
2c3ba6ecopilot-swe-agent[bot]2884 aria-label="New repository name"
71cd5ecClaude2885 style="width:200px"
2886 />
2887 <button type="submit" class="btn btn-primary">
2888 Use this template
2889 </button>
2890 </form>
2891 </div>
2892 )}
fc1817aClaude2893 <RepoNav owner={owner} repo={repo} active="code" />
544d842Claude2894 <div class="repo-home-grid">
2895 <div class="repo-home-main">
2896 <BranchSwitcher
2897 owner={owner}
2898 repo={repo}
2899 currentRef={defaultBranch}
2900 branches={branches}
2901 pathType="tree"
2902 />
2903 <FileTable
2904 entries={tree}
2905 owner={owner}
2906 repo={repo}
2907 ref={defaultBranch}
2908 path=""
2909 />
2910 {readme && (() => {
2911 const readmeHtml = renderMarkdown(readme);
2912 return (
2913 <div class="repo-home-readme">
2914 <div class="repo-home-readme-head">
2915 <span class="repo-home-readme-icon">{"☰"}</span>
2916 <span>README.md</span>
2917 </div>
2918 <style>{markdownCss}</style>
2919 <div class="markdown-body repo-home-readme-body">
2920 {html([readmeHtml] as unknown as TemplateStringsArray)}
2921 </div>
2922 </div>
2923 );
2924 })()}
2925 </div>
2926 <aside class="repo-home-side" aria-label="Repository details">
2927 <div class="repo-home-clone">
2928 <div class="repo-home-clone-tabs" role="tablist" aria-label="Clone protocol">
2929 <button
2930 type="button"
2931 class="repo-home-clone-tab"
2932 role="tab"
2933 aria-selected="true"
2934 data-pane="https"
2935 data-repo-home-clone-tab
2936 >
2937 HTTPS
2938 </button>
2939 <button
2940 type="button"
2941 class="repo-home-clone-tab"
2942 role="tab"
2943 aria-selected="false"
2944 data-pane="ssh"
2945 data-repo-home-clone-tab
2946 >
2947 SSH
2948 </button>
2949 <button
2950 type="button"
2951 class="repo-home-clone-tab"
2952 role="tab"
2953 aria-selected="false"
2954 data-pane="cli"
2955 data-repo-home-clone-tab
2956 >
2957 CLI
2958 </button>
2959 </div>
2960 <div
2961 class="repo-home-clone-pane"
2962 data-pane="https"
2963 data-active="true"
2964 role="tabpanel"
2965 >
2966 <div class="repo-home-clone-body">
2967 <input
2968 class="repo-home-clone-input"
2969 type="text"
2970 value={cloneHttpsUrl}
2971 readonly
2972 aria-label="HTTPS clone URL"
2973 data-repo-home-clone-input
2974 />
2975 <button
2976 type="button"
2977 class="repo-home-clone-copy"
2978 data-repo-home-copy={cloneHttpsUrl}
2979 >
2980 Copy
2981 </button>
2982 </div>
2983 </div>
2984 <div
2985 class="repo-home-clone-pane"
2986 data-pane="ssh"
2987 data-active="false"
2988 role="tabpanel"
2989 >
2990 <div class="repo-home-clone-body">
2991 <input
2992 class="repo-home-clone-input"
2993 type="text"
2994 value={cloneSshUrl}
2995 readonly
2996 aria-label="SSH clone URL"
2997 data-repo-home-clone-input
2998 />
2999 <button
3000 type="button"
3001 class="repo-home-clone-copy"
3002 data-repo-home-copy={cloneSshUrl}
3003 >
3004 Copy
3005 </button>
3006 </div>
3007 </div>
3008 <div
3009 class="repo-home-clone-pane"
3010 data-pane="cli"
3011 data-active="false"
3012 role="tabpanel"
3013 >
3014 <div class="repo-home-clone-body">
3015 <input
3016 class="repo-home-clone-input"
3017 type="text"
3018 value={cloneCliCmd}
3019 readonly
3020 aria-label="Gluecron CLI clone command"
3021 data-repo-home-clone-input
3022 />
3023 <button
3024 type="button"
3025 class="repo-home-clone-copy"
3026 data-repo-home-copy={cloneCliCmd}
3027 >
3028 Copy
3029 </button>
3030 </div>
79136bbClaude3031 </div>
fc1817aClaude3032 </div>
544d842Claude3033 <div class="repo-home-side-card">
3034 <h3 class="repo-home-side-title">About</h3>
3035 <div class="repo-home-side-row">
3036 <span class="repo-home-side-key">Default branch</span>
3037 <span class="repo-home-side-val">{defaultBranch}</span>
3038 </div>
3039 <div class="repo-home-side-row">
3040 <span class="repo-home-side-key">Branches</span>
3041 <span class="repo-home-side-val">
3042 <a href={`/${owner}/${repo}/commits/${defaultBranch}`}>
3043 {branches.length}
3044 </a>
3045 </span>
3046 </div>
3047 <div class="repo-home-side-row">
3048 <span class="repo-home-side-key">Stars</span>
3049 <span class="repo-home-side-val">{starCount}</span>
3050 </div>
3051 <div class="repo-home-side-row">
3052 <span class="repo-home-side-key">Forks</span>
3053 <span class="repo-home-side-val">{forkCount}</span>
3054 </div>
3055 {pushedAt && (
3056 <div class="repo-home-side-row">
3057 <span class="repo-home-side-key">Last push</span>
3058 <span class="repo-home-side-val">
3059 {formatRelative(pushedAt)}
3060 </span>
3061 </div>
3062 )}
3063 {createdAt && (
3064 <div class="repo-home-side-row">
3065 <span class="repo-home-side-key">Created</span>
3066 <span class="repo-home-side-val">
3067 {formatRelative(createdAt)}
3068 </span>
3069 </div>
3070 )}
3071 {(archived || isTemplate) && (
3072 <div class="repo-home-side-row">
3073 <span class="repo-home-side-key">State</span>
3074 <span class="repo-home-side-val">
3075 {archived ? "Archived" : "Template"}
3076 </span>
3077 </div>
3078 )}
3079 </div>
3080 </aside>
3081 </div>
3082 <script
3083 dangerouslySetInnerHTML={{
3084 __html: `
3085 (function(){
3086 var tabs = document.querySelectorAll('[data-repo-home-clone-tab]');
3087 tabs.forEach(function(tab){
3088 tab.addEventListener('click', function(){
3089 var target = tab.getAttribute('data-pane');
3090 tabs.forEach(function(t){
3091 t.setAttribute('aria-selected', t === tab ? 'true' : 'false');
3092 });
3093 var panes = document.querySelectorAll('.repo-home-clone-pane');
3094 panes.forEach(function(p){
3095 p.setAttribute('data-active', p.getAttribute('data-pane') === target ? 'true' : 'false');
3096 });
3097 });
3098 });
3099 var copyBtns = document.querySelectorAll('[data-repo-home-copy]');
3100 copyBtns.forEach(function(btn){
3101 btn.addEventListener('click', function(){
3102 var text = btn.getAttribute('data-repo-home-copy') || '';
3103 var done = function(){
3104 var prev = btn.textContent;
3105 btn.textContent = 'Copied';
3106 setTimeout(function(){ btn.textContent = prev; }, 1200);
3107 };
3108 if (navigator.clipboard && navigator.clipboard.writeText) {
3109 navigator.clipboard.writeText(text).then(done, done);
3110 } else {
3111 var ta = document.createElement('textarea');
3112 ta.value = text;
3113 document.body.appendChild(ta);
3114 ta.select();
3115 try { document.execCommand('copy'); } catch (e) {}
3116 document.body.removeChild(ta);
3117 done();
3118 }
3119 });
3120 });
3121 })();
3122 `,
3123 }}
3124 />
fc1817aClaude3125 </Layout>
3126 );
3127});
3128
3129// Browse tree at ref/path
3130web.get("/:owner/:repo/tree/:ref{.+$}", async (c) => {
3131 const { owner, repo } = c.req.param();
06d5ffeClaude3132 const user = c.get("user");
fc1817aClaude3133 const refAndPath = c.req.param("ref");
3134
3135 const branches = await listBranches(owner, repo);
3136 let ref = "";
3137 let treePath = "";
3138
3139 for (const branch of branches) {
3140 if (refAndPath === branch || refAndPath.startsWith(branch + "/")) {
3141 ref = branch;
3142 treePath = refAndPath.slice(branch.length + 1);
3143 break;
3144 }
3145 }
3146
3147 if (!ref) {
3148 const slashIdx = refAndPath.indexOf("/");
3149 if (slashIdx === -1) {
3150 ref = refAndPath;
3151 } else {
3152 ref = refAndPath.slice(0, slashIdx);
3153 treePath = refAndPath.slice(slashIdx + 1);
3154 }
3155 }
3156
3157 const tree = await getTree(owner, repo, ref, treePath);
efb11c5Claude3158 const fileCount = tree.filter((e: any) => e.type !== "tree").length;
3159 const dirCount = tree.filter((e: any) => e.type === "tree").length;
fc1817aClaude3160
3161 return c.html(
06d5ffeClaude3162 <Layout title={`${treePath || "/"} — ${owner}/${repo}`} user={user}>
efb11c5Claude3163 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude3164 <RepoHeader owner={owner} repo={repo} />
3165 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude3166 <div class="tree-header">
3167 <div class="tree-header-row">
3168 <BranchSwitcher
3169 owner={owner}
3170 repo={repo}
3171 currentRef={ref}
3172 branches={branches}
3173 pathType="tree"
3174 subPath={treePath}
3175 />
3176 <div class="tree-header-stats">
3177 <span class="tree-stat" title="Entries in this directory">
3178 <strong>{fileCount}</strong> file{fileCount === 1 ? "" : "s"}
3179 {dirCount > 0 && (
3180 <>
3181 {" · "}
3182 <strong>{dirCount}</strong> dir{dirCount === 1 ? "" : "s"}
3183 </>
3184 )}
3185 </span>
3186 <a
3187 href={`/${owner}/${repo}/search`}
3188 class="tree-stat tree-stat-link"
3189 title="Search code in this repository"
3190 >
3191 {"⌕"} Search
3192 </a>
3193 </div>
3194 </div>
3195 <div class="tree-breadcrumb-row">
3196 <Breadcrumb owner={owner} repo={repo} ref={ref} path={treePath} />
3197 </div>
3198 </div>
fc1817aClaude3199 <FileTable
3200 entries={tree}
3201 owner={owner}
3202 repo={repo}
3203 ref={ref}
3204 path={treePath}
3205 />
3206 </Layout>
3207 );
3208});
3209
06d5ffeClaude3210// View file blob with syntax highlighting
fc1817aClaude3211web.get("/:owner/:repo/blob/:ref{.+$}", async (c) => {
3212 const { owner, repo } = c.req.param();
06d5ffeClaude3213 const user = c.get("user");
fc1817aClaude3214 const refAndPath = c.req.param("ref");
3215
3216 const branches = await listBranches(owner, repo);
3217 let ref = "";
3218 let filePath = "";
3219
3220 for (const branch of branches) {
3221 if (refAndPath.startsWith(branch + "/")) {
3222 ref = branch;
3223 filePath = refAndPath.slice(branch.length + 1);
3224 break;
3225 }
3226 }
3227
3228 if (!ref) {
3229 const slashIdx = refAndPath.indexOf("/");
3230 if (slashIdx === -1) return c.text("Not found", 404);
3231 ref = refAndPath.slice(0, slashIdx);
3232 filePath = refAndPath.slice(slashIdx + 1);
3233 }
3234
3235 const blob = await getBlob(owner, repo, ref, filePath);
3236 if (!blob) {
3237 return c.html(
06d5ffeClaude3238 <Layout title="Not Found" user={user}>
fc1817aClaude3239 <div class="empty-state">
3240 <h2>File not found</h2>
3241 </div>
3242 </Layout>,
3243 404
3244 );
3245 }
3246
06d5ffeClaude3247 const fileName = filePath.split("/").pop() || filePath;
efb11c5Claude3248 const lineCount = blob.isBinary
3249 ? 0
3250 : (blob.content.endsWith("\n")
3251 ? blob.content.split("\n").length - 1
3252 : blob.content.split("\n").length);
3253 const formatBytes = (n: number): string => {
3254 if (n < 1024) return `${n} B`;
3255 if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
3256 return `${(n / (1024 * 1024)).toFixed(1)} MB`;
3257 };
fc1817aClaude3258
3259 return c.html(
06d5ffeClaude3260 <Layout title={`${filePath} — ${owner}/${repo}`} user={user}>
efb11c5Claude3261 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude3262 <RepoHeader owner={owner} repo={repo} />
3263 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude3264 <div class="blob-toolbar">
3265 <BranchSwitcher
3266 owner={owner}
3267 repo={repo}
3268 currentRef={ref}
3269 branches={branches}
3270 pathType="blob"
3271 subPath={filePath}
3272 />
3273 <div class="blob-breadcrumb">
3274 <Breadcrumb owner={owner} repo={repo} ref={ref} path={filePath} />
3275 </div>
3276 </div>
3277 <div class="blob-view blob-card">
3278 <div class="blob-header blob-header-polished">
3279 <div class="blob-header-meta">
3280 <span class="blob-header-icon" aria-hidden="true">
3281 {"📄"}
3282 </span>
3283 <span class="blob-header-name">{fileName}</span>
3284 <span class="blob-header-size">
3285 {formatBytes(blob.size)}
3286 {!blob.isBinary && (
3287 <>
3288 {" · "}
3289 {lineCount} line{lineCount === 1 ? "" : "s"}
3290 </>
3291 )}
3292 </span>
3293 </div>
3294 <div class="blob-header-actions">
3295 <a
3296 href={`/${owner}/${repo}/raw/${ref}/${filePath}`}
3297 class="blob-pill"
3298 >
79136bbClaude3299 Raw
3300 </a>
efb11c5Claude3301 <a
3302 href={`/${owner}/${repo}/blame/${ref}/${filePath}`}
3303 class="blob-pill"
3304 >
79136bbClaude3305 Blame
3306 </a>
efb11c5Claude3307 <a
3308 href={`/${owner}/${repo}/timeline/${ref}/${filePath}`}
3309 class="blob-pill"
3310 >
16b325cClaude3311 History
3312 </a>
0074234Claude3313 {user && (
efb11c5Claude3314 <a
3315 href={`/${owner}/${repo}/edit/${ref}/${filePath}`}
3316 class="blob-pill blob-pill-accent"
3317 >
0074234Claude3318 Edit
3319 </a>
3320 )}
efb11c5Claude3321 </div>
fc1817aClaude3322 </div>
3323 {blob.isBinary ? (
efb11c5Claude3324 <div class="blob-binary">
fc1817aClaude3325 Binary file not shown.
3326 </div>
06d5ffeClaude3327 ) : (() => {
3328 const { html: highlighted, language } = highlightCode(
3329 blob.content,
3330 fileName
3331 );
3332 if (language) {
3333 return (
3334 <HighlightedCode
3335 highlightedHtml={highlighted}
efb11c5Claude3336 lineCount={lineCount}
06d5ffeClaude3337 />
3338 );
3339 }
3340 const lines = blob.content.split("\n");
3341 if (lines[lines.length - 1] === "") lines.pop();
3342 return <PlainCode lines={lines} />;
3343 })()}
fc1817aClaude3344 </div>
3345 </Layout>
3346 );
3347});
3348
398a10cClaude3349// ─── Branches list ────────────────────────────────────────────────────────
3350// Lightweight `git for-each-ref` enrichment so each row shows last-commit
3351// author + relative time + ahead/behind vs the default branch. No DB. All
3352// data comes from git plumbing; failures degrade gracefully (counts omitted).
3353web.get("/:owner/:repo/branches", async (c) => {
3354 const { owner, repo } = c.req.param();
3355 const user = c.get("user");
3356
3357 if (!(await repoExists(owner, repo))) return c.notFound();
3358
3359 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
3360 const branches = await listBranches(owner, repo);
3361 const repoDir = getRepoPath(owner, repo);
3362
3363 type BranchRow = {
3364 name: string;
3365 isDefault: boolean;
3366 sha: string;
3367 subject: string;
3368 author: string;
3369 date: string;
3370 ahead: number;
3371 behind: number;
3372 };
3373
3374 const runGit = async (args: string[]): Promise<string> => {
3375 try {
3376 const proc = Bun.spawn(["git", ...args], {
3377 cwd: repoDir,
3378 stdout: "pipe",
3379 stderr: "pipe",
3380 });
3381 const out = await new Response(proc.stdout).text();
3382 await proc.exited;
3383 return out;
3384 } catch {
3385 return "";
3386 }
3387 };
3388
3389 const meta = await runGit([
3390 "for-each-ref",
3391 "--sort=-committerdate",
3392 "--format=%(refname:short)%00%(objectname)%00%(subject)%00%(authorname)%00%(committerdate:iso-strict)",
3393 "refs/heads/",
3394 ]);
3395 const metaByName: Record<
3396 string,
3397 { sha: string; subject: string; author: string; date: string }
3398 > = {};
3399 for (const line of meta.split("\n").filter(Boolean)) {
3400 const [name, sha, subject, author, date] = line.split("\0");
3401 metaByName[name] = { sha, subject, author, date };
3402 }
3403
3404 const branchOrder = [...branches].sort((a, b) => {
3405 if (a === defaultBranch) return -1;
3406 if (b === defaultBranch) return 1;
3407 const aDate = metaByName[a]?.date || "";
3408 const bDate = metaByName[b]?.date || "";
3409 return bDate.localeCompare(aDate);
3410 });
3411
3412 const rows: BranchRow[] = [];
3413 for (const name of branchOrder) {
3414 const m = metaByName[name] || { sha: "", subject: "", author: "", date: "" };
3415 let ahead = 0;
3416 let behind = 0;
3417 if (name !== defaultBranch && metaByName[defaultBranch]) {
3418 const out = await runGit([
3419 "rev-list",
3420 "--left-right",
3421 "--count",
3422 `${defaultBranch}...${name}`,
3423 ]);
3424 const parts = out.trim().split(/\s+/);
3425 if (parts.length === 2) {
3426 behind = parseInt(parts[0], 10) || 0;
3427 ahead = parseInt(parts[1], 10) || 0;
3428 }
3429 }
3430 rows.push({
3431 name,
3432 isDefault: name === defaultBranch,
3433 sha: m.sha,
3434 subject: m.subject,
3435 author: m.author,
3436 date: m.date,
3437 ahead,
3438 behind,
3439 });
3440 }
3441
3442 const relative = (iso: string): string => {
3443 if (!iso) return "—";
3444 const d = new Date(iso);
3445 if (Number.isNaN(d.getTime())) return "—";
3446 const diff = Date.now() - d.getTime();
3447 const m = Math.floor(diff / 60000);
3448 if (m < 1) return "just now";
3449 if (m < 60) return `${m} min ago`;
3450 const h = Math.floor(m / 60);
3451 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
3452 const dd = Math.floor(h / 24);
3453 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
3454 return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
3455 };
3456
3457 const success = c.req.query("success");
3458 const error = c.req.query("error");
3459
3460 return c.html(
3461 <Layout title={`Branches — ${owner}/${repo}`} user={user}>
3462 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
3463 <RepoHeader owner={owner} repo={repo} />
3464 <RepoNav owner={owner} repo={repo} active="code" />
3465 <div
3466 class="branches-wrap"
3467 style="max-width:1100px;margin:0 auto;padding:var(--space-5) var(--space-4) var(--space-8)"
3468 >
3469 <header class="branches-head" style="margin-bottom:var(--space-5)">
3470 <div
3471 class="branches-eyebrow"
3472 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"
3473 >
3474 <span
3475 class="branches-eyebrow-dot"
3476 aria-hidden="true"
3477 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)"
3478 />
3479 Repository · Branches
3480 </div>
3481 <h1
3482 class="branches-title"
3483 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)"
3484 >
3485 <span class="gradient-text">{rows.length}</span>{" "}
3486 branch{rows.length === 1 ? "" : "es"}
3487 </h1>
3488 <p
3489 class="branches-sub"
3490 style="margin:0;font-size:14px;color:var(--text-muted);line-height:1.5;max-width:700px"
3491 >
3492 All work-in-progress lines for{" "}
3493 <code style="font-size:12.5px">{owner}/{repo}</code>. Ahead/behind
3494 counts are relative to{" "}
3495 <code style="font-size:12.5px">{defaultBranch}</code>.
3496 </p>
3497 </header>
3498
3499 {success && (
3500 <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">
3501 {decodeURIComponent(success)}
3502 </div>
3503 )}
3504 {error && (
3505 <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">
3506 {decodeURIComponent(error)}
3507 </div>
3508 )}
3509
3510 {rows.length === 0 ? (
3511 <div class="commits-empty">
3512 <div class="commits-empty-orb" aria-hidden="true" />
3513 <div class="commits-empty-inner">
3514 <div class="commits-empty-icon" aria-hidden="true">
3515 <svg
3516 width="22"
3517 height="22"
3518 viewBox="0 0 24 24"
3519 fill="none"
3520 stroke="currentColor"
3521 stroke-width="2"
3522 stroke-linecap="round"
3523 stroke-linejoin="round"
3524 >
3525 <line x1="6" y1="3" x2="6" y2="15" />
3526 <circle cx="18" cy="6" r="3" />
3527 <circle cx="6" cy="18" r="3" />
3528 <path d="M18 9a9 9 0 0 1-9 9" />
3529 </svg>
3530 </div>
3531 <h3 class="commits-empty-title">No branches yet</h3>
3532 <p class="commits-empty-sub">
3533 Push your first commit to create the default branch.
3534 </p>
3535 </div>
3536 </div>
3537 ) : (
3538 <div class="branches-list">
3539 {rows.map((r) => (
3540 <div class="branches-row">
3541 <div class="branches-row-icon" aria-hidden="true">
3542 <svg
3543 width="14"
3544 height="14"
3545 viewBox="0 0 24 24"
3546 fill="none"
3547 stroke="currentColor"
3548 stroke-width="2"
3549 stroke-linecap="round"
3550 stroke-linejoin="round"
3551 >
3552 <line x1="6" y1="3" x2="6" y2="15" />
3553 <circle cx="18" cy="6" r="3" />
3554 <circle cx="6" cy="18" r="3" />
3555 <path d="M18 9a9 9 0 0 1-9 9" />
3556 </svg>
3557 </div>
3558 <div class="branches-row-main">
3559 <div class="branches-row-name">
3560 <a href={`/${owner}/${repo}/tree/${r.name}`}>{r.name}</a>
3561 {r.isDefault && (
3562 <span
3563 class="branches-row-default"
3564 title="Default branch"
3565 >
3566 Default
3567 </span>
3568 )}
3569 </div>
3570 <div class="branches-row-meta">
3571 {r.subject ? (
3572 <>
3573 <strong>{r.author || "—"}</strong>
3574 <span class="sep">·</span>
3575 <span
3576 title={r.date ? new Date(r.date).toISOString() : ""}
3577 >
3578 updated {relative(r.date)}
3579 </span>
3580 {r.sha && (
3581 <>
3582 <span class="sep">·</span>
3583 <a
3584 href={`/${owner}/${repo}/commit/${r.sha}`}
3585 style="font-family:var(--font-mono);font-size:11.5px;color:var(--text-muted);text-decoration:none"
3586 >
3587 {r.sha.slice(0, 7)}
3588 </a>
3589 </>
3590 )}
3591 </>
3592 ) : (
3593 <span>No commit metadata</span>
3594 )}
3595 </div>
3596 </div>
3597 <div class="branches-row-side">
3598 {!r.isDefault && (r.ahead > 0 || r.behind > 0) && (
3599 <span
3600 class="branches-row-divergence"
3601 title={`${r.ahead} ahead, ${r.behind} behind ${defaultBranch}`}
3602 >
3603 <span class="ahead">{r.ahead} ahead</span>
3604 <span style="opacity:0.4">|</span>
3605 <span class="behind">{r.behind} behind</span>
3606 </span>
3607 )}
3608 <div class="branches-row-actions">
3609 <a
3610 href={`/${owner}/${repo}/commits/${r.name}`}
3611 class="branches-btn"
3612 title="View commits on this branch"
3613 >
3614 Commits
3615 </a>
3616 {!r.isDefault &&
3617 user &&
3618 user.username === owner && (
3619 <form
3620 method="post"
3621 action={`/${owner}/${repo}/branches/${encodeURIComponent(r.name)}/delete`}
3622 style="margin:0"
3623 onsubmit={`return confirm('Delete branch \\'${r.name}\\'? This cannot be undone.')`}
3624 >
3625 <button
3626 type="submit"
3627 class="branches-btn branches-btn-danger"
3628 >
3629 Delete
3630 </button>
3631 </form>
3632 )}
3633 </div>
3634 </div>
3635 </div>
3636 ))}
3637 </div>
3638 )}
3639 </div>
3640 </Layout>
3641 );
3642});
3643
3644// Delete a branch (owner only). Uses `git branch -D` so we can drop refs
3645// that are not merged into the default branch — matches the explicit
3646// confirmation on the row's delete button.
3647web.post("/:owner/:repo/branches/:name/delete", requireAuth, async (c) => {
3648 const { owner, repo } = c.req.param();
3649 const branchName = decodeURIComponent(c.req.param("name"));
3650 const user = c.get("user")!;
3651
3652 // Owner-only check (mirrors collaborators.tsx pattern).
3653 const [ownerRow] = await db
3654 .select()
3655 .from(users)
3656 .where(eq(users.username, owner))
3657 .limit(1);
3658 if (!ownerRow || ownerRow.id !== user.id) {
3659 return c.redirect(
3660 `/${owner}/${repo}/branches?error=Only+the+owner+can+delete+branches`
3661 );
3662 }
3663
3664 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
3665 if (branchName === defaultBranch) {
3666 return c.redirect(
3667 `/${owner}/${repo}/branches?error=Cannot+delete+the+default+branch`
3668 );
3669 }
3670
3671 const branches = await listBranches(owner, repo);
3672 if (!branches.includes(branchName)) {
3673 return c.redirect(
3674 `/${owner}/${repo}/branches?error=Branch+not+found`
3675 );
3676 }
3677
3678 try {
3679 const repoDir = getRepoPath(owner, repo);
3680 const proc = Bun.spawn(["git", "branch", "-D", branchName], {
3681 cwd: repoDir,
3682 stdout: "pipe",
3683 stderr: "pipe",
3684 });
3685 await proc.exited;
3686 if (proc.exitCode !== 0) {
3687 return c.redirect(
3688 `/${owner}/${repo}/branches?error=Delete+failed`
3689 );
3690 }
3691 } catch {
3692 return c.redirect(`/${owner}/${repo}/branches?error=Delete+failed`);
3693 }
3694
3695 return c.redirect(`/${owner}/${repo}/branches?success=Branch+deleted`);
3696});
3697
3698// ─── Tags list ────────────────────────────────────────────────────────────
3699// Pulls from `listTags` (sorted newest first). For each tag we look up an
3700// associated release row so the "View release" CTA can deep-link directly
3701// without making the user hunt for it.
3702web.get("/:owner/:repo/tags", async (c) => {
3703 const { owner, repo } = c.req.param();
3704 const user = c.get("user");
3705
3706 if (!(await repoExists(owner, repo))) return c.notFound();
3707
3708 const tags = await listTags(owner, repo);
3709
3710 // Map tags -> releases. Best-effort; releases table may not exist in
3711 // every test setup, so any error falls through with an empty set.
3712 const tagsWithReleases = new Set<string>();
3713 try {
3714 const [ownerRow] = await db
3715 .select()
3716 .from(users)
3717 .where(eq(users.username, owner))
3718 .limit(1);
3719 if (ownerRow) {
3720 const [repoRow] = await db
3721 .select()
3722 .from(repositories)
3723 .where(
3724 and(
3725 eq(repositories.ownerId, ownerRow.id),
3726 eq(repositories.name, repo)
3727 )
3728 )
3729 .limit(1);
3730 if (repoRow) {
3731 // Raw SQL so we don't need to import the releases schema here.
3732 const result = await db.execute(
3733 sql`SELECT tag FROM releases WHERE repository_id = ${repoRow.id}`
3734 );
3735 const rows: any[] = (result as any).rows || (result as any) || [];
3736 for (const row of rows) {
3737 const tag = row?.tag;
3738 if (typeof tag === "string") tagsWithReleases.add(tag);
3739 }
3740 }
3741 }
3742 } catch {
3743 // No releases table or DB error — leave set empty.
3744 }
3745
3746 const relative = (iso: string): string => {
3747 if (!iso) return "—";
3748 const d = new Date(iso);
3749 if (Number.isNaN(d.getTime())) return "—";
3750 const diff = Date.now() - d.getTime();
3751 const m = Math.floor(diff / 60000);
3752 if (m < 1) return "just now";
3753 if (m < 60) return `${m} min ago`;
3754 const h = Math.floor(m / 60);
3755 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
3756 const dd = Math.floor(h / 24);
3757 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
3758 return d.toLocaleDateString("en-US", {
3759 month: "short",
3760 day: "numeric",
3761 year: "numeric",
3762 });
3763 };
3764
3765 return c.html(
3766 <Layout title={`Tags — ${owner}/${repo}`} user={user}>
3767 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
3768 <RepoHeader owner={owner} repo={repo} />
3769 <RepoNav owner={owner} repo={repo} active="code" />
3770 <div
3771 class="tags-wrap"
3772 style="max-width:1100px;margin:0 auto;padding:var(--space-5) var(--space-4) var(--space-8)"
3773 >
3774 <header class="tags-head" style="margin-bottom:var(--space-5)">
3775 <div
3776 class="tags-eyebrow"
3777 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"
3778 >
3779 <span
3780 class="tags-eyebrow-dot"
3781 aria-hidden="true"
3782 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)"
3783 />
3784 Repository · Tags
3785 </div>
3786 <h1
3787 class="tags-title"
3788 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)"
3789 >
3790 <span class="gradient-text">{tags.length}</span>{" "}
3791 tag{tags.length === 1 ? "" : "s"}
3792 </h1>
3793 <p
3794 class="tags-sub"
3795 style="margin:0;font-size:14px;color:var(--text-muted);line-height:1.5;max-width:700px"
3796 >
3797 Named points in the history — typically releases, milestones,
3798 or shipped versions. Click a tag to browse the tree at that
3799 revision.
3800 </p>
3801 </header>
3802
3803 {tags.length === 0 ? (
3804 <div class="commits-empty">
3805 <div class="commits-empty-orb" aria-hidden="true" />
3806 <div class="commits-empty-inner">
3807 <div class="commits-empty-icon" aria-hidden="true">
3808 <svg
3809 width="22"
3810 height="22"
3811 viewBox="0 0 24 24"
3812 fill="none"
3813 stroke="currentColor"
3814 stroke-width="2"
3815 stroke-linecap="round"
3816 stroke-linejoin="round"
3817 >
3818 <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" />
3819 <line x1="7" y1="7" x2="7.01" y2="7" />
3820 </svg>
3821 </div>
3822 <h3 class="commits-empty-title">No tags yet</h3>
3823 <p class="commits-empty-sub">
3824 Tag a commit to mark a release or milestone. From the CLI:{" "}
3825 <code>git tag v0.1.0 &amp;&amp; git push --tags</code>.
3826 </p>
3827 </div>
3828 </div>
3829 ) : (
3830 <div class="tags-list">
3831 {tags.map((t) => {
3832 const hasRelease = tagsWithReleases.has(t.name);
3833 return (
3834 <div class="tags-row">
3835 <div class="tags-row-icon" aria-hidden="true">
3836 <svg
3837 width="14"
3838 height="14"
3839 viewBox="0 0 24 24"
3840 fill="none"
3841 stroke="currentColor"
3842 stroke-width="2"
3843 stroke-linecap="round"
3844 stroke-linejoin="round"
3845 >
3846 <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" />
3847 <line x1="7" y1="7" x2="7.01" y2="7" />
3848 </svg>
3849 </div>
3850 <div class="tags-row-main">
3851 <div class="tags-row-name">
3852 <a
3853 href={`/${owner}/${repo}/tree/${t.name}`}
3854 style="text-decoration:none"
3855 >
3856 <span class="tags-row-version">{t.name}</span>
3857 </a>
3858 </div>
3859 <div class="tags-row-meta">
3860 <span
3861 title={t.date ? new Date(t.date).toISOString() : ""}
3862 >
3863 Tagged {relative(t.date)}
3864 </span>
3865 <span class="sep">·</span>
3866 <a
3867 href={`/${owner}/${repo}/commit/${t.sha}`}
3868 class="tags-row-sha"
3869 title={t.sha}
3870 >
3871 {t.sha.slice(0, 7)}
3872 </a>
3873 </div>
3874 </div>
3875 <div class="tags-row-side">
3876 <a
3877 href={`/${owner}/${repo}/tree/${t.name}`}
3878 class="tags-row-link"
3879 >
3880 Browse files
3881 </a>
3882 {hasRelease && (
3883 <a
3884 href={`/${owner}/${repo}/releases/tag/${t.name}`}
3885 class="tags-row-link"
3886 style="color:#67e8f9;border-color:rgba(54,197,214,0.35);background:rgba(54,197,214,0.06)"
3887 >
3888 View release
3889 </a>
3890 )}
3891 </div>
3892 </div>
3893 );
3894 })}
3895 </div>
3896 )}
3897 </div>
3898 </Layout>
3899 );
3900});
3901
fc1817aClaude3902// Commit log
3903web.get("/:owner/:repo/commits/:ref?", async (c) => {
3904 const { owner, repo } = c.req.param();
06d5ffeClaude3905 const user = c.get("user");
fc1817aClaude3906 const ref =
3907 c.req.param("ref") || (await getDefaultBranch(owner, repo)) || "main";
06d5ffeClaude3908 const branches = await listBranches(owner, repo);
fc1817aClaude3909
3910 const commits = await listCommits(owner, repo, ref, 50);
3911
3951454Claude3912 // Block J3 — batch-fetch cached verification results for the page.
3913 let verifications: Record<string, { verified: boolean; reason: string }> = {};
3914 try {
3915 const [ownerRow] = await db
3916 .select()
3917 .from(users)
3918 .where(eq(users.username, owner))
3919 .limit(1);
3920 if (ownerRow) {
3921 const [repoRow] = await db
3922 .select()
3923 .from(repositories)
3924 .where(
3925 and(
3926 eq(repositories.ownerId, ownerRow.id),
3927 eq(repositories.name, repo)
3928 )
3929 )
3930 .limit(1);
3931 if (repoRow && commits.length > 0) {
3932 const rows = await db
3933 .select()
3934 .from(commitVerifications)
3935 .where(
3936 and(
3937 eq(commitVerifications.repositoryId, repoRow.id),
3938 inArray(
3939 commitVerifications.commitSha,
3940 commits.map((c) => c.sha)
3941 )
3942 )
3943 );
3944 for (const r of rows) {
3945 verifications[r.commitSha] = {
3946 verified: r.verified,
3947 reason: r.reason,
3948 };
3949 }
3950 }
3951 }
3952 } catch {
3953 // DB unavailable — skip the badges gracefully.
3954 }
3955
fc1817aClaude3956 return c.html(
06d5ffeClaude3957 <Layout title={`Commits — ${owner}/${repo}`} user={user}>
efb11c5Claude3958 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude3959 <RepoHeader owner={owner} repo={repo} />
3960 <RepoNav owner={owner} repo={repo} active="commits" />
efb11c5Claude3961 <div class="commits-hero">
3962 <div class="commits-hero-orb-wrap" aria-hidden="true">
3963 <div class="commits-hero-orb" />
fc1817aClaude3964 </div>
efb11c5Claude3965 <div class="commits-hero-inner">
3966 <div class="commits-eyebrow">
3967 <strong>History</strong> · {owner}/{repo}
3968 </div>
3969 <h1 class="commits-title">
3970 <span class="gradient-text">{commits.length}</span> recent commit
3971 {commits.length === 1 ? "" : "s"} on{" "}
3972 <span class="commits-branch">{ref}</span>
3973 </h1>
3974 <p class="commits-sub">
3975 Browse the project's history. Click any commit to see the full
3976 diff, AI review notes, and signature status.
3977 </p>
3978 </div>
3979 </div>
3980 <div class="commits-toolbar">
3981 <BranchSwitcher
3951454Claude3982 owner={owner}
3983 repo={repo}
efb11c5Claude3984 currentRef={ref}
3985 branches={branches}
3986 pathType="commits"
3951454Claude3987 />
398a10cClaude3988 <div class="commits-toolbar-actions">
3989 <a href={`/${owner}/${repo}/branches`} class="commits-toolbar-link">
3990 {"⊢"} Branches
3991 </a>
3992 <a href={`/${owner}/${repo}/tags`} class="commits-toolbar-link">
3993 {"#"} Tags
3994 </a>
3995 </div>
efb11c5Claude3996 </div>
3997 {commits.length === 0 ? (
3998 <div class="commits-empty">
398a10cClaude3999 <div class="commits-empty-orb" aria-hidden="true" />
4000 <div class="commits-empty-inner">
4001 <div class="commits-empty-icon" aria-hidden="true">
4002 <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4003 <circle cx="12" cy="12" r="4" />
4004 <line x1="1.05" y1="12" x2="7" y2="12" />
4005 <line x1="17.01" y1="12" x2="22.96" y2="12" />
4006 </svg>
4007 </div>
4008 <h3 class="commits-empty-title">No commits yet</h3>
4009 <p class="commits-empty-sub">
4010 This branch is empty. Push your first commit, or use the
4011 web editor to create a file.
4012 </p>
4013 </div>
efb11c5Claude4014 </div>
4015 ) : (
4016 <div class="commits-list-wrap">
398a10cClaude4017 {(() => {
4018 // Group commits by day for the section headers.
4019 const dayLabel = (iso: string): string => {
4020 const d = new Date(iso);
4021 if (Number.isNaN(d.getTime())) return "Unknown";
4022 const today = new Date();
4023 const yesterday = new Date(today);
4024 yesterday.setDate(today.getDate() - 1);
4025 const sameDay = (a: Date, b: Date) =>
4026 a.getFullYear() === b.getFullYear() &&
4027 a.getMonth() === b.getMonth() &&
4028 a.getDate() === b.getDate();
4029 if (sameDay(d, today)) return "Today";
4030 if (sameDay(d, yesterday)) return "Yesterday";
4031 return d.toLocaleDateString("en-US", {
4032 month: "long",
4033 day: "numeric",
4034 year: today.getFullYear() === d.getFullYear() ? undefined : "numeric",
4035 });
4036 };
4037 const relative = (iso: string): string => {
4038 const d = new Date(iso);
4039 if (Number.isNaN(d.getTime())) return "";
4040 const diff = Date.now() - d.getTime();
4041 const m = Math.floor(diff / 60000);
4042 if (m < 1) return "just now";
4043 if (m < 60) return `${m} min ago`;
4044 const h = Math.floor(m / 60);
4045 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
4046 const dd = Math.floor(h / 24);
4047 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
4048 return d.toLocaleDateString("en-US", {
4049 month: "short",
4050 day: "numeric",
4051 });
4052 };
4053 const initial = (name: string): string =>
4054 (name || "?").trim().charAt(0).toUpperCase() || "?";
4055 // Build groups preserving order.
4056 const groups: Array<{ label: string; items: typeof commits }> = [];
4057 let lastLabel = "";
4058 for (const cm of commits) {
4059 const label = dayLabel(cm.date);
4060 if (label !== lastLabel) {
4061 groups.push({ label, items: [] });
4062 lastLabel = label;
4063 }
4064 groups[groups.length - 1].items.push(cm);
4065 }
4066 return groups.map((g) => (
4067 <>
4068 <div class="commits-day-head">
4069 <span class="commits-day-head-dot" aria-hidden="true" />
4070 Commits on {g.label}
4071 </div>
4072 {g.items.map((cm) => {
4073 const v = verifications[cm.sha];
4074 return (
4075 <div class="commits-row">
4076 <div class="commits-avatar" aria-hidden="true">
4077 {initial(cm.author)}
4078 </div>
4079 <div class="commits-row-body">
4080 <div class="commits-row-msg">
4081 <a href={`/${owner}/${repo}/commit/${cm.sha}`}>
4082 {cm.message}
4083 </a>
4084 {v?.verified && (
4085 <span
4086 class="commits-row-verified"
4087 title="Signed with a registered key"
4088 >
4089 Verified
4090 </span>
4091 )}
4092 </div>
4093 <div class="commits-row-meta">
4094 <strong>{cm.author}</strong>
4095 <span class="sep">·</span>
4096 <span
4097 class="commits-row-time"
4098 title={new Date(cm.date).toISOString()}
4099 >
4100 committed {relative(cm.date)}
4101 </span>
4102 {cm.parentShas.length > 1 && (
4103 <>
4104 <span class="sep">·</span>
4105 <span>merge of {cm.parentShas.length} parents</span>
4106 </>
4107 )}
4108 </div>
4109 </div>
4110 <div class="commits-row-side">
4111 <a
4112 href={`/${owner}/${repo}/commit/${cm.sha}`}
4113 class="commits-row-sha"
4114 title={cm.sha}
4115 >
4116 {cm.sha.slice(0, 7)}
4117 </a>
4118 <button
4119 type="button"
4120 class="commits-row-copy"
4121 data-copy-sha={cm.sha}
4122 title="Copy full SHA"
4123 aria-label={`Copy SHA ${cm.sha}`}
4124 >
4125 <svg width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true">
4126 <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" />
4127 <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" />
4128 </svg>
4129 </button>
4130 </div>
4131 </div>
4132 );
4133 })}
4134 </>
4135 ));
4136 })()}
efb11c5Claude4137 </div>
fc1817aClaude4138 )}
398a10cClaude4139 <script
4140 dangerouslySetInnerHTML={{
4141 __html: `
4142 (function(){
4143 document.addEventListener('click', function(e){
4144 var t = e.target; if (!t) return;
4145 var btn = t.closest && t.closest('[data-copy-sha]');
4146 if (!btn) return;
4147 e.preventDefault();
4148 var sha = btn.getAttribute('data-copy-sha') || '';
4149 if (!navigator.clipboard) return;
4150 navigator.clipboard.writeText(sha).then(function(){
4151 btn.classList.add('is-copied');
4152 setTimeout(function(){ btn.classList.remove('is-copied'); }, 1200);
4153 }).catch(function(){});
4154 });
4155 })();
4156 `,
4157 }}
4158 />
fc1817aClaude4159 </Layout>
4160 );
4161});
4162
4163// Single commit with diff
4164web.get("/:owner/:repo/commit/:sha", async (c) => {
4165 const { owner, repo, sha } = c.req.param();
06d5ffeClaude4166 const user = c.get("user");
fc1817aClaude4167
05b973eClaude4168 // Fetch commit, full message, and diff in parallel
4169 const [commit, fullMessage, diffResult] = await Promise.all([
4170 getCommit(owner, repo, sha),
4171 getCommitFullMessage(owner, repo, sha),
4172 getDiff(owner, repo, sha),
4173 ]);
fc1817aClaude4174 if (!commit) {
4175 return c.html(
06d5ffeClaude4176 <Layout title="Not Found" user={user}>
fc1817aClaude4177 <div class="empty-state">
4178 <h2>Commit not found</h2>
4179 </div>
4180 </Layout>,
4181 404
4182 );
4183 }
4184
3951454Claude4185 // Block J3 — try to verify this commit's signature.
4186 let verification:
4187 | { verified: boolean; reason: string; signatureType: string | null }
4188 | null = null;
0cdfd89Claude4189 // Block J8 — external CI commit statuses rollup.
4190 let statusCombined:
4191 | {
4192 state: "pending" | "success" | "failure";
4193 total: number;
4194 contexts: Array<{
4195 context: string;
4196 state: string;
4197 description: string | null;
4198 targetUrl: string | null;
4199 }>;
4200 }
4201 | null = null;
3951454Claude4202 try {
4203 const [ownerRow] = await db
4204 .select()
4205 .from(users)
4206 .where(eq(users.username, owner))
4207 .limit(1);
4208 if (ownerRow) {
4209 const [repoRow] = await db
4210 .select()
4211 .from(repositories)
4212 .where(
4213 and(
4214 eq(repositories.ownerId, ownerRow.id),
4215 eq(repositories.name, repo)
4216 )
4217 )
4218 .limit(1);
4219 if (repoRow) {
4220 const { verifyCommit } = await import("../lib/signatures");
4221 const v = await verifyCommit(repoRow.id, owner, repo, commit.sha);
4222 verification = {
4223 verified: v.verified,
4224 reason: v.reason,
4225 signatureType: v.signatureType,
4226 };
0cdfd89Claude4227 try {
4228 const { combinedStatus } = await import("../lib/commit-statuses");
4229 const combined = await combinedStatus(repoRow.id, commit.sha);
4230 if (combined.total > 0) {
4231 statusCombined = {
4232 state: combined.state as any,
4233 total: combined.total,
4234 contexts: combined.contexts.map((c) => ({
4235 context: c.context,
4236 state: c.state,
4237 description: c.description,
4238 targetUrl: c.targetUrl,
4239 })),
4240 };
4241 }
4242 } catch {
4243 statusCombined = null;
4244 }
3951454Claude4245 }
4246 }
4247 } catch {
4248 verification = null;
4249 }
4250
05b973eClaude4251 const { files, raw } = diffResult;
fc1817aClaude4252
efb11c5Claude4253 // Diff stats: count additions / deletions across all files for the
4254 // header summary bar. Computed here from the parsed diff so we don't
4255 // touch the DiffView component.
4256 let additions = 0;
4257 let deletions = 0;
4258 for (const f of files) {
4259 const hunks = (f as any).hunks as Array<any> | undefined;
4260 if (Array.isArray(hunks)) {
4261 for (const h of hunks) {
4262 const lines = (h?.lines || []) as Array<any>;
4263 for (const ln of lines) {
4264 const t = ln?.type || ln?.kind;
4265 if (t === "add" || t === "added" || t === "+") additions += 1;
4266 else if (t === "del" || t === "deleted" || t === "delete" || t === "-")
4267 deletions += 1;
4268 }
4269 }
4270 }
4271 }
4272 // Fall back: scan raw if file-level counting yielded zero (it's just a
4273 // header polish — never let a parsing miss break the page).
4274 if (additions === 0 && deletions === 0 && typeof raw === "string") {
4275 for (const line of raw.split("\n")) {
4276 if (line.startsWith("+") && !line.startsWith("+++")) additions += 1;
4277 else if (line.startsWith("-") && !line.startsWith("---")) deletions += 1;
4278 }
4279 }
4280 const fileCount = files.length;
4281
fc1817aClaude4282 return c.html(
06d5ffeClaude4283 <Layout title={`${commit.message} — ${owner}/${repo}`} user={user}>
efb11c5Claude4284 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude4285 <RepoHeader owner={owner} repo={repo} />
efb11c5Claude4286 <div class="commit-detail-card">
4287 <div class="commit-detail-eyebrow">
4288 <strong>Commit</strong>
4289 <span class="commit-detail-sha-pill" title={commit.sha}>
4290 {commit.sha.slice(0, 7)}
4291 </span>
3951454Claude4292 {verification && verification.reason !== "unsigned" && (
4293 <span
efb11c5Claude4294 class={`commit-detail-verify ${
3951454Claude4295 verification.verified
efb11c5Claude4296 ? "commit-detail-verify-ok"
4297 : "commit-detail-verify-warn"
3951454Claude4298 }`}
4299 title={`${verification.signatureType?.toUpperCase() || ""} · ${verification.reason}`}
4300 >
4301 {verification.verified ? "Verified" : verification.reason}
4302 </span>
4303 )}
fc1817aClaude4304 </div>
efb11c5Claude4305 <h1 class="commit-detail-title">{commit.message}</h1>
4306 {fullMessage !== commit.message && (
4307 <pre class="commit-detail-body">{fullMessage}</pre>
4308 )}
4309 <div class="commit-detail-meta">
4310 <span class="commit-detail-author">
4311 <strong>{commit.author}</strong> committed on{" "}
4312 {new Date(commit.date).toLocaleDateString("en-US", {
4313 month: "long",
4314 day: "numeric",
4315 year: "numeric",
4316 })}
4317 </span>
fc1817aClaude4318 {commit.parentShas.length > 0 && (
efb11c5Claude4319 <span class="commit-detail-parents">
4320 {commit.parentShas.length === 1 ? "Parent" : "Parents"}:{" "}
4321 {commit.parentShas.map((p, idx) => (
4322 <>
4323 {idx > 0 && " "}
4324 <a
4325 href={`/${owner}/${repo}/commit/${p}`}
4326 class="commit-detail-sha-link"
4327 >
4328 {p.slice(0, 7)}
4329 </a>
4330 </>
fc1817aClaude4331 ))}
4332 </span>
4333 )}
4334 </div>
efb11c5Claude4335 <div class="commit-detail-stats">
4336 <span class="commit-detail-stat">
4337 <strong>{fileCount}</strong>{" "}
4338 file{fileCount === 1 ? "" : "s"} changed
4339 </span>
4340 <span class="commit-detail-stat commit-detail-stat-add">
4341 <span class="commit-detail-stat-mark">+</span>
4342 <strong>{additions}</strong>
4343 </span>
4344 <span class="commit-detail-stat commit-detail-stat-del">
4345 <span class="commit-detail-stat-mark">−</span>
4346 <strong>{deletions}</strong>
4347 </span>
4348 <span class="commit-detail-sha-full" title="Full SHA">
4349 {commit.sha}
4350 </span>
4351 </div>
0cdfd89Claude4352 {statusCombined && (
efb11c5Claude4353 <div class="commit-detail-checks">
4354 <div class="commit-detail-checks-head">
4355 <strong>Checks</strong>
4356 <span class="commit-detail-checks-summary">
4357 {statusCombined.total} total ·{" "}
4358 <span
4359 class={`commit-detail-check-state commit-detail-check-state-${statusCombined.state}`}
4360 >
4361 {statusCombined.state}
4362 </span>
0cdfd89Claude4363 </span>
efb11c5Claude4364 </div>
4365 <div class="commit-detail-check-row">
0cdfd89Claude4366 {statusCombined.contexts.map((cx) => (
4367 <span
efb11c5Claude4368 class={`commit-detail-check commit-detail-check-${cx.state}`}
0cdfd89Claude4369 title={cx.description || cx.context}
4370 >
4371 {cx.targetUrl ? (
efb11c5Claude4372 <a href={cx.targetUrl} rel="noopener">
0cdfd89Claude4373 {cx.context}: {cx.state}
4374 </a>
4375 ) : (
4376 <>
4377 {cx.context}: {cx.state}
4378 </>
4379 )}
4380 </span>
4381 ))}
4382 </div>
4383 </div>
4384 )}
fc1817aClaude4385 </div>
ea9ed4cClaude4386 <DiffView
4387 raw={raw}
4388 files={files}
4389 viewFileBase={`/${owner}/${repo}/blob/${commit.sha}`}
4390 />
fc1817aClaude4391 </Layout>
4392 );
4393});
4394
79136bbClaude4395// Raw file download
4396web.get("/:owner/:repo/raw/:ref{.+$}", async (c) => {
4397 const { owner, repo } = c.req.param();
4398 const refAndPath = c.req.param("ref");
4399
4400 const branches = await listBranches(owner, repo);
4401 let ref = "";
4402 let filePath = "";
4403
4404 for (const branch of branches) {
4405 if (refAndPath.startsWith(branch + "/")) {
4406 ref = branch;
4407 filePath = refAndPath.slice(branch.length + 1);
4408 break;
4409 }
4410 }
4411
4412 if (!ref) {
4413 const slashIdx = refAndPath.indexOf("/");
4414 if (slashIdx === -1) return c.text("Not found", 404);
4415 ref = refAndPath.slice(0, slashIdx);
4416 filePath = refAndPath.slice(slashIdx + 1);
4417 }
4418
4419 const data = await getRawBlob(owner, repo, ref, filePath);
4420 if (!data) return c.text("Not found", 404);
4421
4422 const fileName = filePath.split("/").pop() || "file";
772a24fClaude4423 return new Response(data as BodyInit, {
79136bbClaude4424 headers: {
4425 "Content-Type": "application/octet-stream",
4426 "Content-Disposition": `attachment; filename="${fileName}"`,
05b973eClaude4427 "Cache-Control": "public, max-age=300, stale-while-revalidate=60",
79136bbClaude4428 },
4429 });
4430});
4431
4432// Blame view
4433web.get("/:owner/:repo/blame/:ref{.+$}", async (c) => {
4434 const { owner, repo } = c.req.param();
4435 const user = c.get("user");
4436 const refAndPath = c.req.param("ref");
4437
4438 const branches = await listBranches(owner, repo);
4439 let ref = "";
4440 let filePath = "";
4441
4442 for (const branch of branches) {
4443 if (refAndPath.startsWith(branch + "/")) {
4444 ref = branch;
4445 filePath = refAndPath.slice(branch.length + 1);
4446 break;
4447 }
4448 }
4449
4450 if (!ref) {
4451 const slashIdx = refAndPath.indexOf("/");
4452 if (slashIdx === -1) return c.text("Not found", 404);
4453 ref = refAndPath.slice(0, slashIdx);
4454 filePath = refAndPath.slice(slashIdx + 1);
4455 }
4456
4457 const blameLines = await getBlame(owner, repo, ref, filePath);
4458 if (blameLines.length === 0) {
4459 return c.html(
4460 <Layout title="Not Found" user={user}>
4461 <div class="empty-state">
4462 <h2>File not found</h2>
4463 </div>
4464 </Layout>,
4465 404
4466 );
4467 }
4468
4469 const fileName = filePath.split("/").pop() || filePath;
efb11c5Claude4470 // Unique contributors (by author) tracked once for the header chip.
4471 const blameAuthors = new Set<string>();
4472 for (const ln of blameLines) blameAuthors.add(ln.author);
79136bbClaude4473
4474 return c.html(
4475 <Layout title={`Blame: ${filePath} — ${owner}/${repo}`} user={user}>
efb11c5Claude4476 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
79136bbClaude4477 <RepoHeader owner={owner} repo={repo} />
4478 <RepoNav owner={owner} repo={repo} active="code" />
398a10cClaude4479 <header class="blame-head">
4480 <div class="blame-eyebrow">
4481 <span class="blame-eyebrow-dot" aria-hidden="true" />
4482 Blame · Line-by-line history
4483 </div>
4484 <h1 class="blame-title">
4485 <code>{fileName}</code>
4486 </h1>
4487 <p class="blame-sub">
4488 Each line is annotated with the commit that last touched it.
4489 Click any SHA to jump to that commit and see the surrounding
4490 change.
4491 </p>
4492 </header>
efb11c5Claude4493 <div class="blame-toolbar">
4494 <Breadcrumb owner={owner} repo={repo} ref={ref} path={filePath} />
4495 </div>
398a10cClaude4496 <div class="blame-card">
4497 <div class="blame-header">
efb11c5Claude4498 <div class="blame-header-meta">
4499 <span class="blame-header-icon" aria-hidden="true">{"⎙"}</span>
4500 <span class="blame-header-name">{fileName}</span>
4501 <span class="blame-header-tag">Blame</span>
4502 <span class="blame-header-stats">
4503 {blameLines.length} line{blameLines.length === 1 ? "" : "s"} ·{" "}
4504 {blameAuthors.size} contributor
4505 {blameAuthors.size === 1 ? "" : "s"}
4506 </span>
4507 </div>
4508 <div class="blame-header-actions">
4509 <a
4510 href={`/${owner}/${repo}/blob/${ref}/${filePath}`}
4511 class="blob-pill"
4512 >
4513 Normal view
4514 </a>
4515 <a
4516 href={`/${owner}/${repo}/raw/${ref}/${filePath}`}
4517 class="blob-pill"
4518 >
4519 Raw
4520 </a>
4521 </div>
79136bbClaude4522 </div>
398a10cClaude4523 <div style="overflow-x:auto">
4524 <table class="blame-table">
79136bbClaude4525 <tbody>
4526 {blameLines.map((line, i) => {
4527 const showInfo =
4528 i === 0 || blameLines[i - 1].sha !== line.sha;
4529 return (
398a10cClaude4530 <tr class={showInfo ? "blame-row-first" : ""}>
4531 <td class="blame-gutter">
79136bbClaude4532 {showInfo && (
398a10cClaude4533 <span class="blame-gutter-inner">
79136bbClaude4534 <a
4535 href={`/${owner}/${repo}/commit/${line.sha}`}
398a10cClaude4536 class="blame-gutter-sha"
4537 title={`Commit ${line.sha}`}
79136bbClaude4538 >
4539 {line.sha.slice(0, 7)}
398a10cClaude4540 </a>
4541 <span class="blame-gutter-author" title={line.author}>
4542 {line.author}
4543 </span>
4544 </span>
79136bbClaude4545 )}
4546 </td>
398a10cClaude4547 <td class="blame-line-num">{line.lineNum}</td>
4548 <td class="blame-line-content">{line.content}</td>
79136bbClaude4549 </tr>
4550 );
4551 })}
4552 </tbody>
4553 </table>
4554 </div>
4555 </div>
4556 </Layout>
4557 );
4558});
4559
4560// Search
4561web.get("/:owner/:repo/search", async (c) => {
4562 const { owner, repo } = c.req.param();
4563 const user = c.get("user");
4564 const q = c.req.query("q") || "";
4565
4566 if (!(await repoExists(owner, repo))) return c.notFound();
4567
4568 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
4569 let results: Array<{ file: string; lineNum: number; line: string }> = [];
4570
4571 if (q.trim()) {
4572 results = await searchCode(owner, repo, defaultBranch, q.trim());
4573 }
4574
4575 return c.html(
4576 <Layout title={`Search — ${owner}/${repo}`} user={user}>
efb11c5Claude4577 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
79136bbClaude4578 <RepoHeader owner={owner} repo={repo} />
4579 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude4580 <div class="search-hero">
4581 <div class="search-eyebrow">
4582 <strong>Search</strong> · {owner}/{repo}
4583 </div>
4584 <h1 class="search-title">
4585 Find any line in <span class="gradient-text">{repo}</span>
4586 </h1>
4587 <form
4588 method="get"
4589 action={`/${owner}/${repo}/search`}
4590 class="search-form"
4591 role="search"
4592 >
4593 <div class="search-input-wrap">
4594 <span class="search-input-icon" aria-hidden="true">{"⌕"}</span>
4595 <input
4596 type="text"
4597 name="q"
4598 value={q}
4599 placeholder="Search code on the default branch…"
4600 aria-label="Search code"
4601 class="search-input"
4602 autocomplete="off"
4603 autofocus
4604 />
4605 </div>
4606 <button type="submit" class="btn btn-primary search-submit">
79136bbClaude4607 Search
4608 </button>
efb11c5Claude4609 </form>
4610 </div>
79136bbClaude4611 {q && (
efb11c5Claude4612 <div class="search-results-head">
4613 <span class="search-results-count">
4614 <strong>{results.length}</strong> result
4615 {results.length !== 1 ? "s" : ""}
4616 </span>
4617 <span class="search-results-query">
4618 for <span class="search-results-q">"{q}"</span> on{" "}
4619 <code>{defaultBranch}</code>
4620 </span>
4621 </div>
79136bbClaude4622 )}
efb11c5Claude4623 {q && results.length === 0 ? (
4624 <div class="search-empty">
4625 <p>
4626 No matches for <strong>"{q}"</strong>. Try a shorter query or check
4627 you're on the right branch.
4628 </p>
4629 </div>
4630 ) : results.length > 0 ? (
79136bbClaude4631 <div class="search-results">
4632 {(() => {
4633 // Group by file
4634 const grouped: Record<
4635 string,
4636 Array<{ lineNum: number; line: string }>
4637 > = {};
4638 for (const r of results) {
4639 if (!grouped[r.file]) grouped[r.file] = [];
4640 grouped[r.file].push({ lineNum: r.lineNum, line: r.line });
4641 }
4642 return Object.entries(grouped).map(([file, matches]) => (
efb11c5Claude4643 <div class="search-file diff-file">
4644 <div class="search-file-head diff-file-header">
79136bbClaude4645 <a
4646 href={`/${owner}/${repo}/blob/${defaultBranch}/${file}`}
efb11c5Claude4647 class="search-file-link"
79136bbClaude4648 >
4649 {file}
4650 </a>
efb11c5Claude4651 <span class="search-file-count">
4652 {matches.length} match{matches.length === 1 ? "" : "es"}
4653 </span>
79136bbClaude4654 </div>
4655 <div class="blob-code">
4656 <table>
4657 <tbody>
4658 {matches.map((m) => (
4659 <tr>
4660 <td class="line-num">{m.lineNum}</td>
4661 <td class="line-content">{m.line}</td>
4662 </tr>
4663 ))}
4664 </tbody>
4665 </table>
4666 </div>
4667 </div>
4668 ));
4669 })()}
4670 </div>
efb11c5Claude4671 ) : null}
79136bbClaude4672 </Layout>
4673 );
4674});
4675
fc1817aClaude4676export default web;