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.tsxBlame6309 lines · 5 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";
ebaae0fClaude8import { eq, and, desc, inArray, sql, gte, count } from "drizzle-orm";
06d5ffeClaude9import { db } from "../db";
a74f4edccanty labs10import { fireWebhooks } from "./webhooks";
ea52715copilot-swe-agent[bot]11import { config } from "../lib/config";
3951454Claude12import {
13 users,
14 repositories,
15 stars,
16 commitVerifications,
8c790e0Claude17 activityFeed,
ebaae0fClaude18 pullRequests,
19 prComments,
20 issues,
21 labels,
22 issueLabels,
641aa42Claude23 repoOnboardingData,
3951454Claude24} from "../db/schema";
fc1817aClaude25import { Layout } from "../views/layout";
cb5a796Claude26import { PendingCommentsBanner as RepoHomePendingBanner } from "../views/pending-comments-banner";
fc1817aClaude27import {
28 RepoHeader,
29 RepoNav,
30 Breadcrumb,
31 FileTable,
06d5ffeClaude32 RepoCard,
33 BranchSwitcher,
34 HighlightedCode,
35 PlainCode,
f6730d0ccantynz-alt36 Button,
37 sharedComponentStyles,
8c790e0Claude38 type RecentPush,
fc1817aClaude39} from "../views/components";
ea9ed4cClaude40import { DiffView } from "../views/diff-view";
fc1817aClaude41import {
42 getTree,
43 getBlob,
44 listCommits,
45 getCommit,
46 getCommitFullMessage,
47 getDiff,
48 getReadme,
49 getDefaultBranch,
50 listBranches,
398a10cClaude51 listTags,
fc1817aClaude52 repoExists,
06d5ffeClaude53 initBareRepo,
79136bbClaude54 getBlame,
55 getRawBlob,
56 searchCode,
398a10cClaude57 getRepoPath,
fc1817aClaude58} from "../git/repository";
79136bbClaude59import { renderMarkdown, markdownCss } from "../lib/markdown";
06d5ffeClaude60import { highlightCode } from "../lib/highlight";
91a0204Claude61import { computeHealthScore } from "../lib/health-score";
62import type { HealthScore } from "../lib/health-score";
06d5ffeClaude63import { softAuth, requireAuth } from "../middleware/auth";
64import type { AuthEnv } from "../middleware/auth";
5bb52faccanty labs65import { resolveRepoAccess, satisfiesAccess } from "../middleware/repo-access";
53c9249Claude66import { claudeSemanticSearch } from "../lib/claude-semantic-search";
67import { isAiAvailable } from "../lib/ai-client";
8f50ed0Claude68import { trackByName } from "../lib/traffic";
8ed88f2ccantynz-alt69import { LandingPage } from "../views/landing";
29924bcClaude70import { Landing2030Page } from "../views/landing-2030";
8ed88f2ccantynz-alt71import { LandingProPage, type LandingProLiveFeed } from "../views/landing-pro";
52ad8b1Claude72import { computePublicStats, type PublicStats } from "../lib/public-stats";
534f04aClaude73import {
74 listQueuedAiBuildIssues,
75 listRecentAutoMerges,
76 listRecentAiReviews,
77 countAiReviewsSince,
78 listDemoActivityFeed,
79} from "../lib/demo-activity";
11c3ab6ccanty labs80import { AgentWorkspace } from "../views/agent-workspace";
81import { DailyBrief } from "../views/daily-brief";
82import { TrustReport } from "../views/trust-report";
83import { ProductionLayers } from "../views/production-layers";
84import { DistributionView } from "../views/distribution";
85import { OrgMemory } from "../views/org-memory";
fc1817aClaude86
06d5ffeClaude87const web = new Hono<AuthEnv>();
88
89// Soft auth on all web routes — c.get("user") available but may be null
90web.use("*", softAuth);
fc1817aClaude91
5bb52faccanty labs92// ---------------------------------------------------------------------------
93// SECURITY: repo-content access gate.
94//
95// Every route that serves repository CONTENT (file tree, blobs, raw files,
96// blame, commits, diffs, branches, tags, code search, repo overview) MUST call
97// this before touching git-on-disk. Public repos resolve to "read" for
98// anonymous viewers (so public browsing stays fully anonymous); private repos
99// require a logged-in viewer with at least read access.
100//
101// Returns a 404 Response when the repo is missing OR the viewer lacks read
102// access — deliberately 404 (not 403) so we never leak the existence of a
103// private repo. Returns `null` when access is granted; callers proceed as
104// normal. The owner-username → user → repositories lookup mirrors the pattern
105// used by `requireRepoAccess` in ../middleware/repo-access.
106// ---------------------------------------------------------------------------
107async function assertRepoReadable(
108 c: any,
109 owner: string,
110 repo: string
111): Promise<Response | null> {
112 const user = c.get("user") ?? null;
113
114 const notFound = () =>
115 c.html(
116 <Layout title="Not Found" user={user}>
117 <div class="empty-state">
118 <h2>Repository not found</h2>
119 <p>
120 {owner}/{repo} does not exist.
121 </p>
122 </div>
123 </Layout>,
124 404
125 );
126
6b75ac1ccanty labs127 // Explicit dev/test bypass: when no database is configured at all there are
128 // no persisted repositories to protect (private repos only exist as DB rows),
129 // and the browse routes render purely from git-on-disk. This is a positively
130 // established condition (DATABASE_URL unset), NOT an error inference — so the
131 // access gate below can safely fail CLOSED on any runtime error. In
132 // production DATABASE_URL is always set, so this branch never runs there.
133 if (!config.databaseUrl) return null;
134
5bb52faccanty labs135 try {
527e1e3ccantynz-alt136 // Case-insensitive slug match; carry back the CANONICAL owner/repo so we
137 // can (a) never feed the caller's raw casing to the git layer and (b)
138 // redirect to the canonical URL below.
5bb52faccanty labs139 const [ownerRow] = await db
527e1e3ccantynz-alt140 .select({ id: users.id, username: users.username })
5bb52faccanty labs141 .from(users)
527e1e3ccantynz-alt142 .where(sql`lower(${users.username}) = lower(${owner})`)
5bb52faccanty labs143 .limit(1);
144 if (!ownerRow) return notFound();
145
146 const [repoRow] = await db
527e1e3ccantynz-alt147 .select({
148 id: repositories.id,
149 name: repositories.name,
150 isPrivate: repositories.isPrivate,
151 })
5bb52faccanty labs152 .from(repositories)
153 .where(
527e1e3ccantynz-alt154 and(
155 eq(repositories.ownerId, ownerRow.id),
156 sql`lower(${repositories.name}) = lower(${repo})`
157 )
5bb52faccanty labs158 )
159 .limit(1);
160 if (!repoRow) return notFound();
161
162 const access = await resolveRepoAccess({
163 repoId: repoRow.id,
164 userId: user?.id ?? null,
165 isPublic: !repoRow.isPrivate,
166 });
167 // Positive denial: the repo exists and the viewer lacks read access.
168 // Return 404 (not 403) so we never confirm a private repo's existence.
169 if (!satisfiesAccess(access, "read")) return notFound();
170
527e1e3ccantynz-alt171 // Canonical-casing redirect. If the URL used a different casing than the
172 // stored slug (e.g. /ccantynz/gluecron.com for Gluecron.com), 302 to the
173 // canonical path so every downstream git-on-disk op receives the real
174 // casing and never 404s on the case-sensitive filesystem (the "R3" trap).
175 // Done AFTER the access check so a private repo's exact casing is never
176 // revealed to a caller who can't read it.
177 if (ownerRow.username !== owner || repoRow.name !== repo) {
178 const segs = c.req.path.split("/");
179 // segs = ["", "<owner>", "<repo>", ...rest]
180 segs[1] = encodeURIComponent(ownerRow.username);
181 segs[2] = encodeURIComponent(repoRow.name);
182 const search = new URL(c.req.url).search;
183 return c.redirect(segs.join("/") + search, 302);
184 }
185
5bb52faccanty labs186 return null;
187 } catch (err) {
6b75ac1ccanty labs188 // Fail CLOSED. A DB is configured (checked above) but the privacy-flag
189 // lookup errored, so we cannot positively establish that this repo is
190 // public. Denying is the only safe choice for an access-control gate —
191 // failing open here would re-expose private repos during a DB hiccup,
192 // which is the exact vulnerability this function exists to close.
5bb52faccanty labs193 console.warn(
6b75ac1ccanty labs194 `[web] assertRepoReadable: access check failed for ${owner}/${repo} — denying:`,
5bb52faccanty labs195 err instanceof Error ? err.message : err
196 );
6b75ac1ccanty labs197 return notFound();
5bb52faccanty labs198 }
199}
200
ebaae0fClaude201// ---------------------------------------------------------------------------
202// Repo AI stats — computed once per repo home page load, best-effort.
203// Fast because every WHERE clause is bounded to a 7-day window.
204// ---------------------------------------------------------------------------
205interface RepoAiStats {
206 mergedCount: number;
207 reviewCount: number;
208 securityAlertCount: number;
209 hoursSaved: string;
210}
211
212async function getRepoAiStats(repoId: string): Promise<RepoAiStats> {
213 const since = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
214
215 // 1. AI-merged PRs this week: activity_feed entries with action =
216 // 'auto_merge.merged' in the last 7 days for this repo.
217 // This is cheaper than a JOIN on pull_requests and covers both the
218 // `mergedBy = botUser` pattern and the autopilot auto-merge path.
219 const [mergedRow] = await db
220 .select({ n: count() })
221 .from(activityFeed)
222 .where(
223 and(
224 eq(activityFeed.repositoryId, repoId),
225 eq(activityFeed.action, "auto_merge.merged"),
226 gte(activityFeed.createdAt, since)
227 )
228 );
229 const mergedCount = Number(mergedRow?.n ?? 0);
230
231 // 2. AI reviews this week: pr_comments where is_ai_review = true in
232 // the last 7 days, joined through pull_requests to scope to this repo.
233 const [reviewRow] = await db
234 .select({ n: count() })
235 .from(prComments)
236 .innerJoin(pullRequests, eq(prComments.pullRequestId, pullRequests.id))
237 .where(
238 and(
239 eq(pullRequests.repositoryId, repoId),
240 eq(prComments.isAiReview, true),
241 gte(prComments.createdAt, since)
242 )
243 );
244 const reviewCount = Number(reviewRow?.n ?? 0);
245
246 // 3. Open security alerts: open issues that carry a label whose name
247 // contains 'security' (case-insensitive) for this repo.
248 const [secRow] = await db
249 .select({ n: count() })
250 .from(issues)
251 .innerJoin(issueLabels, eq(issueLabels.issueId, issues.id))
252 .innerJoin(labels, eq(issueLabels.labelId, labels.id))
253 .where(
254 and(
255 eq(issues.repositoryId, repoId),
256 eq(issues.state, "open"),
257 sql`lower(${labels.name}) like '%security%'`
258 )
259 );
260 const securityAlertCount = Number(secRow?.n ?? 0);
261
262 // Hours saved: each AI-merged PR ~ 1.5 h, each AI review ~ 0.5 h.
263 const hours = mergedCount * 1.5 + reviewCount * 0.5;
264 const hoursSaved = hours.toFixed(1);
265
266 return { mergedCount, reviewCount, securityAlertCount, hoursSaved };
267}
268
8c790e0Claude269/**
270 * Query the most recent push to a repo from the activity_feed table.
271 * Returns a RecentPush if there's been a push in the last 24 hours,
272 * or null otherwise. Used by the RepoHeader live/watch indicator.
273 *
274 * Queries activity_feed where action='push' and targetId holds the commit SHA.
275 */
276async function getRecentPush(repoId: string): Promise<RecentPush | null> {
277 try {
278 const cutoff = new Date(Date.now() - 24 * 60 * 60 * 1000);
279 const [row] = await db
280 .select({
281 targetId: activityFeed.targetId,
282 createdAt: activityFeed.createdAt,
283 })
284 .from(activityFeed)
285 .where(
286 and(
287 eq(activityFeed.repositoryId, repoId),
288 eq(activityFeed.action, "push"),
289 sql`${activityFeed.createdAt} >= ${cutoff.toISOString()}`
290 )
291 )
292 .orderBy(desc(activityFeed.createdAt))
293 .limit(1);
294 if (!row || !row.targetId) return null;
295 return {
296 sha: row.targetId,
297 ageMs: Date.now() - new Date(row.createdAt).getTime(),
298 };
299 } catch {
300 // DB unavailable or schema mismatch — degrade gracefully.
301 return null;
302 }
303}
304
efb11c5Claude305/**
306 * Shared CSS for the polished code-browse surfaces (parallel session 3.E).
307 *
308 * Inlined here rather than in `src/views/layout.tsx` because session 3.E's
309 * scope is route-local and `layout.tsx` is locked. Each polished handler
310 * injects this via a `<style>` tag; the rules are namespaced by surface
311 * prefix (`.new-repo-*`, `.profile-*`, `.tree-*`, `.blob-*`, `.commits-*`,
312 * `.commit-detail-*`, `.blame-*`, `.search-*`) so nothing bleeds into the
313 * `.repo-home-*` styling Agent A already shipped.
314 */
315const codeBrowseCss = `
316 /* ───────── shared primitives ───────── */
317 .cb-hairline::before,
318 .new-repo-hero::before,
319 .profile-hero::before,
320 .commits-hero::before,
321 .commit-detail-card::before,
322 .search-hero::before {
323 content: '';
324 position: absolute;
325 top: 0; left: 0; right: 0;
326 height: 2px;
6fd5915Claude327 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
efb11c5Claude328 opacity: 0.7;
329 pointer-events: none;
330 }
331 @keyframes cbHeroOrb {
332 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
333 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
334 }
335 @media (prefers-reduced-motion: reduce) {
336 .new-repo-hero-orb,
337 .profile-hero-orb,
338 .commits-hero-orb { animation: none; }
339 }
340
341 /* ───────── new-repo ───────── */
342 .new-repo-hero {
343 position: relative;
344 margin-bottom: var(--space-5);
345 padding: var(--space-5) var(--space-6);
346 background: var(--bg-elevated);
347 border: 1px solid var(--border);
348 border-radius: 16px;
349 overflow: hidden;
350 }
351 .new-repo-hero-orb-wrap {
352 position: absolute;
353 inset: -25% -10% auto auto;
354 width: 360px;
355 height: 360px;
356 pointer-events: none;
357 z-index: 0;
358 }
359 .new-repo-hero-orb {
360 position: absolute;
361 inset: 0;
6fd5915Claude362 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.09) 45%, transparent 70%);
efb11c5Claude363 filter: blur(80px);
364 opacity: 0.7;
365 animation: cbHeroOrb 14s ease-in-out infinite;
366 }
367 .new-repo-hero-inner { position: relative; z-index: 1; }
368 .new-repo-eyebrow {
369 font-size: 12px;
370 font-family: var(--font-mono);
371 color: var(--text-muted);
372 letter-spacing: 0.1em;
373 text-transform: uppercase;
374 margin-bottom: var(--space-2);
375 }
376 .new-repo-eyebrow strong { color: var(--accent); font-weight: 600; }
377 .new-repo-title {
378 font-family: var(--font-display);
379 font-weight: 800;
380 letter-spacing: -0.028em;
381 font-size: clamp(28px, 4vw, 40px);
382 line-height: 1.05;
383 margin: 0 0 var(--space-2);
384 color: var(--text-strong);
385 }
386 .new-repo-sub {
387 font-size: 15px;
388 color: var(--text-muted);
389 margin: 0;
390 line-height: 1.55;
391 max-width: 620px;
392 }
393 .new-repo-form {
394 max-width: 680px;
395 }
396 .new-repo-error {
397 background: rgba(218, 54, 51, 0.12);
398 border: 1px solid rgba(218, 54, 51, 0.35);
399 color: #ffb3b3;
400 padding: 10px 14px;
401 border-radius: 10px;
402 margin-bottom: var(--space-4);
403 font-size: 14px;
404 }
405 .new-repo-form-grid {
406 display: flex;
407 flex-direction: column;
408 gap: var(--space-4);
409 }
410 .new-repo-row { display: flex; flex-direction: column; gap: 6px; }
411 .new-repo-label {
412 font-size: 13px;
413 color: var(--text-strong);
414 font-weight: 600;
415 }
416 .new-repo-label-optional {
417 color: var(--text-muted);
418 font-weight: 400;
419 font-size: 12px;
420 }
421 .new-repo-input {
422 appearance: none;
423 width: 100%;
424 background: var(--bg);
425 border: 1px solid var(--border);
426 color: var(--text-strong);
427 border-radius: 10px;
428 padding: 10px 12px;
429 font-size: 14px;
430 font-family: inherit;
431 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
432 }
433 .new-repo-input:focus {
434 outline: none;
435 border-color: var(--accent);
6fd5915Claude436 box-shadow: 0 0 0 3px rgba(91,110,232,0.18);
efb11c5Claude437 }
438 .new-repo-input-disabled {
439 color: var(--text-muted);
440 background: var(--bg-secondary);
441 cursor: not-allowed;
442 }
443 .new-repo-hint {
444 font-size: 12px;
445 color: var(--text-muted);
446 margin: 4px 0 0;
447 }
448 .new-repo-hint code {
449 font-family: var(--font-mono);
450 font-size: 11.5px;
451 background: var(--bg-secondary);
452 border: 1px solid var(--border);
453 border-radius: 5px;
454 padding: 1px 5px;
455 color: var(--text-strong);
456 }
457 .new-repo-visibility {
458 display: grid;
459 grid-template-columns: 1fr 1fr;
460 gap: var(--space-2);
461 }
462 @media (max-width: 600px) {
463 .new-repo-visibility { grid-template-columns: 1fr; }
464 }
465 .new-repo-vis-card {
466 display: flex;
467 gap: 10px;
468 padding: 14px;
469 background: var(--bg);
470 border: 1px solid var(--border);
471 border-radius: 12px;
472 cursor: pointer;
473 transition: border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
474 }
475 .new-repo-vis-card:hover { border-color: var(--border-strong, var(--border)); }
476 .new-repo-vis-card:has(input:checked) {
6fd5915Claude477 border-color: rgba(91,110,232,0.55);
478 background: rgba(91,110,232,0.06);
479 box-shadow: 0 0 0 1px rgba(91,110,232,0.25);
efb11c5Claude480 }
481 .new-repo-vis-radio {
482 margin-top: 3px;
483 accent-color: var(--accent);
484 }
485 .new-repo-vis-body { display: flex; flex-direction: column; gap: 4px; }
486 .new-repo-vis-label {
487 font-size: 14px;
488 font-weight: 600;
489 color: var(--text-strong);
490 }
491 .new-repo-vis-desc {
492 font-size: 12.5px;
493 color: var(--text-muted);
494 line-height: 1.45;
495 }
496 .new-repo-callout {
497 margin-top: var(--space-2);
498 padding: var(--space-3) var(--space-4);
6fd5915Claude499 background: var(--accent-gradient-faint, rgba(91,110,232,0.06));
500 border: 1px solid rgba(91,110,232,0.2);
efb11c5Claude501 border-radius: 12px;
502 }
503 .new-repo-callout-eyebrow {
504 font-size: 11px;
505 font-family: var(--font-mono);
506 text-transform: uppercase;
507 letter-spacing: 0.12em;
508 color: var(--accent);
509 font-weight: 700;
510 margin-bottom: 4px;
511 }
512 .new-repo-callout-body {
513 font-size: 13px;
514 color: var(--text);
515 line-height: 1.5;
516 margin: 0;
517 }
518 .new-repo-callout-body code {
519 font-family: var(--font-mono);
520 font-size: 12px;
521 color: var(--accent);
6fd5915Claude522 background: rgba(91,110,232,0.1);
efb11c5Claude523 border-radius: 4px;
524 padding: 1px 5px;
525 }
398a10cClaude526 .new-repo-templates {
527 display: flex;
528 flex-wrap: wrap;
529 gap: 8px;
530 margin-top: 4px;
531 }
532 .new-repo-template-chip {
533 position: relative;
534 display: inline-flex;
535 align-items: center;
536 gap: 6px;
537 padding: 8px 14px;
538 background: var(--bg);
539 border: 1px solid var(--border);
540 border-radius: 999px;
541 font-size: 13px;
542 color: var(--text);
543 cursor: pointer;
544 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
545 }
546 .new-repo-template-chip input { position: absolute; opacity: 0; pointer-events: none; }
547 .new-repo-template-chip:hover {
548 border-color: var(--border-strong, var(--border));
549 color: var(--text-strong);
550 }
551 .new-repo-template-chip:has(input:checked) {
6fd5915Claude552 border-color: rgba(91,110,232,0.55);
553 background: rgba(91,110,232,0.10);
398a10cClaude554 color: var(--text-strong);
6fd5915Claude555 box-shadow: 0 0 0 1px rgba(91,110,232,0.25);
398a10cClaude556 }
557 .new-repo-template-chip-dot {
558 width: 8px; height: 8px;
559 border-radius: 999px;
560 background: var(--text-faint, var(--text-muted));
561 transition: background 140ms ease, box-shadow 140ms ease;
562 }
563 .new-repo-template-chip:has(input:checked) .new-repo-template-chip-dot {
6fd5915Claude564 background: linear-gradient(135deg, #5b6ee8, #5f8fa0);
565 box-shadow: 0 0 8px rgba(91,110,232,0.6);
398a10cClaude566 }
efb11c5Claude567 .new-repo-actions {
568 display: flex;
569 gap: var(--space-2);
570 margin-top: var(--space-2);
398a10cClaude571 align-items: center;
572 }
573 .new-repo-submit {
574 min-width: 180px;
6fd5915Claude575 border: 1px solid rgba(91,110,232,0.45);
576 background: linear-gradient(135deg, #5b6ee8 0%, #5f8fa0 100%);
398a10cClaude577 color: #fff;
578 font-weight: 700;
6fd5915Claude579 box-shadow: 0 8px 20px -8px rgba(91,110,232,0.55);
398a10cClaude580 transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
581 }
582 .new-repo-submit:hover {
583 transform: translateY(-1px);
6fd5915Claude584 box-shadow: 0 12px 24px -8px rgba(91,110,232,0.7);
398a10cClaude585 filter: brightness(1.06);
586 }
587 .new-repo-submit:focus-visible {
6fd5915Claude588 outline: 3px solid rgba(91,110,232,0.45);
398a10cClaude589 outline-offset: 2px;
efb11c5Claude590 }
591
592 /* ───────── profile ───────── */
593 .profile-hero {
594 position: relative;
595 margin-bottom: var(--space-5);
596 padding: var(--space-5) var(--space-6);
597 background: var(--bg-elevated);
598 border: 1px solid var(--border);
599 border-radius: 16px;
600 overflow: hidden;
601 }
602 .profile-hero-orb-wrap {
603 position: absolute;
604 inset: -25% -10% auto auto;
605 width: 360px;
606 height: 360px;
607 pointer-events: none;
608 z-index: 0;
609 }
610 .profile-hero-orb {
611 position: absolute;
612 inset: 0;
6fd5915Claude613 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.09) 45%, transparent 70%);
efb11c5Claude614 filter: blur(80px);
615 opacity: 0.7;
616 animation: cbHeroOrb 14s ease-in-out infinite;
617 }
618 .profile-hero-inner {
619 position: relative;
620 z-index: 1;
621 display: flex;
622 align-items: flex-start;
623 gap: var(--space-5);
624 }
625 .profile-hero-avatar {
626 flex: 0 0 auto;
627 width: 88px;
628 height: 88px;
629 border-radius: 50%;
6fd5915Claude630 background: linear-gradient(135deg, #5b6ee8 0%, #5f8fa0 100%);
efb11c5Claude631 color: #fff;
632 display: flex;
633 align-items: center;
634 justify-content: center;
635 font-size: 38px;
636 font-weight: 700;
637 font-family: var(--font-display);
6fd5915Claude638 box-shadow: 0 8px 24px -8px rgba(91,110,232,0.55);
efb11c5Claude639 }
640 .profile-hero-text { flex: 1; min-width: 0; }
641 .profile-eyebrow {
642 font-size: 12px;
643 font-family: var(--font-mono);
644 color: var(--text-muted);
645 letter-spacing: 0.1em;
646 text-transform: uppercase;
647 margin-bottom: var(--space-2);
648 }
649 .profile-eyebrow strong { color: var(--accent); font-weight: 600; }
650 .profile-name {
651 font-family: var(--font-display);
652 font-weight: 800;
653 letter-spacing: -0.028em;
654 font-size: clamp(28px, 3.6vw, 36px);
655 line-height: 1.05;
656 margin: 0 0 4px;
657 color: var(--text-strong);
658 }
659 .profile-handle {
660 font-family: var(--font-mono);
661 font-size: 13px;
662 color: var(--text-muted);
663 margin-bottom: var(--space-2);
664 }
665 .profile-bio {
666 font-size: 14.5px;
667 color: var(--text);
668 line-height: 1.55;
669 margin: 0 0 var(--space-3);
670 max-width: 640px;
671 }
672 .profile-meta {
673 display: flex;
674 align-items: center;
675 gap: var(--space-4);
676 flex-wrap: wrap;
677 font-size: 13px;
678 }
679 .profile-meta-link {
680 color: var(--text-muted);
681 transition: color var(--t-fast, 0.15s) ease;
682 }
683 .profile-meta-link:hover { color: var(--accent); text-decoration: none; }
684 .profile-meta-link strong {
685 color: var(--text-strong);
686 font-weight: 600;
687 font-variant-numeric: tabular-nums;
688 }
689 .profile-follow-form { margin: 0; }
690 @media (max-width: 600px) {
691 .profile-hero-inner { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
692 .profile-hero-avatar { width: 64px; height: 64px; font-size: 28px; }
693 }
694 .profile-readme {
695 margin-bottom: var(--space-6);
696 background: var(--bg-elevated);
697 border: 1px solid var(--border);
698 border-radius: 12px;
699 overflow: hidden;
700 }
701 .profile-readme-head {
702 display: flex;
703 align-items: center;
704 gap: 8px;
705 padding: 10px 16px;
706 background: var(--bg-secondary);
707 border-bottom: 1px solid var(--border);
708 font-size: 13px;
709 color: var(--text-muted);
710 }
711 .profile-readme-icon { color: var(--accent); font-size: 14px; }
712 .profile-readme-body { padding: var(--space-5) var(--space-6); }
713 .profile-section-head {
714 display: flex;
715 align-items: baseline;
716 gap: var(--space-2);
717 margin-bottom: var(--space-3);
718 }
719 .profile-section-title {
720 font-family: var(--font-display);
721 font-weight: 700;
722 font-size: 20px;
723 letter-spacing: -0.015em;
724 margin: 0;
725 color: var(--text-strong);
726 }
727 .profile-section-count {
728 font-family: var(--font-mono);
729 font-size: 12px;
730 color: var(--text-muted);
731 background: var(--bg-secondary);
732 border: 1px solid var(--border);
733 border-radius: 999px;
734 padding: 2px 10px;
735 font-variant-numeric: tabular-nums;
736 }
737 .profile-empty {
738 display: flex;
739 align-items: center;
740 justify-content: space-between;
741 gap: var(--space-3);
742 padding: var(--space-4) var(--space-5);
743 background: var(--bg-elevated);
744 border: 1px dashed var(--border);
745 border-radius: 12px;
746 }
747 .profile-empty-text { color: var(--text-muted); font-size: 14px; margin: 0; }
748
749 /* ───────── tree (file browser) ───────── */
750 .tree-header {
751 margin-bottom: var(--space-3);
752 display: flex;
753 flex-direction: column;
754 gap: var(--space-2);
755 }
756 .tree-header-row {
757 display: flex;
758 align-items: center;
759 justify-content: space-between;
760 gap: var(--space-3);
761 flex-wrap: wrap;
762 }
763 .tree-header-stats {
764 display: flex;
765 align-items: center;
766 gap: var(--space-3);
767 font-size: 12px;
768 color: var(--text-muted);
769 }
770 .tree-stat strong {
771 color: var(--text-strong);
772 font-weight: 600;
773 font-variant-numeric: tabular-nums;
774 }
775 .tree-stat-link {
776 color: var(--text-muted);
777 padding: 4px 10px;
778 border-radius: 999px;
779 border: 1px solid var(--border);
780 background: var(--bg-elevated);
781 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease;
782 }
783 .tree-stat-link:hover {
784 color: var(--accent);
6fd5915Claude785 border-color: rgba(91,110,232,0.45);
efb11c5Claude786 text-decoration: none;
787 }
788 .tree-breadcrumb-row {
789 font-size: 13px;
790 }
791
792 /* ───────── blob (file viewer) ───────── */
793 .blob-toolbar {
794 margin-bottom: var(--space-3);
795 display: flex;
796 flex-direction: column;
797 gap: var(--space-2);
798 }
799 .blob-breadcrumb { font-size: 13px; }
800 .blob-card {
801 background: var(--bg-elevated);
802 border: 1px solid var(--border);
803 border-radius: 12px;
804 overflow: hidden;
805 }
806 .blob-header-polished {
807 display: flex;
808 align-items: center;
809 justify-content: space-between;
810 gap: var(--space-3);
811 padding: 10px 14px;
812 background: var(--bg-secondary);
813 border-bottom: 1px solid var(--border);
814 }
815 .blob-header-meta {
816 display: flex;
817 align-items: center;
818 gap: var(--space-2);
819 min-width: 0;
820 flex: 1;
821 }
822 .blob-header-icon { font-size: 14px; opacity: 0.85; }
823 .blob-header-name {
824 font-family: var(--font-mono);
825 font-size: 13px;
826 color: var(--text-strong);
827 font-weight: 600;
828 overflow: hidden;
829 text-overflow: ellipsis;
830 white-space: nowrap;
831 }
832 .blob-header-size {
833 font-family: var(--font-mono);
834 font-size: 11.5px;
835 color: var(--text-muted);
836 font-variant-numeric: tabular-nums;
837 border-left: 1px solid var(--border);
838 padding-left: var(--space-2);
839 margin-left: 2px;
840 }
841 .blob-header-actions {
842 display: flex;
843 gap: 6px;
844 flex-shrink: 0;
845 }
846 .blob-pill {
847 display: inline-flex;
848 align-items: center;
849 padding: 4px 12px;
850 font-size: 12px;
851 font-weight: 500;
852 color: var(--text);
853 background: var(--bg-elevated);
854 border: 1px solid var(--border);
855 border-radius: 999px;
856 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
857 }
858 .blob-pill:hover {
859 color: var(--accent);
6fd5915Claude860 border-color: rgba(91,110,232,0.45);
efb11c5Claude861 text-decoration: none;
6fd5915Claude862 background: rgba(91,110,232,0.06);
efb11c5Claude863 }
864 .blob-pill-accent {
865 color: var(--accent);
6fd5915Claude866 border-color: rgba(91,110,232,0.35);
867 background: rgba(91,110,232,0.08);
efb11c5Claude868 }
869 .blob-pill-accent:hover {
6fd5915Claude870 background: rgba(91,110,232,0.14);
efb11c5Claude871 }
872 .blob-binary {
873 padding: var(--space-5);
874 color: var(--text-muted);
875 text-align: center;
876 font-size: 13px;
877 background: var(--bg);
878 }
879
880 /* ───────── commits list ───────── */
881 .commits-hero {
882 position: relative;
883 margin-bottom: var(--space-4);
884 padding: var(--space-5) var(--space-6);
885 background: var(--bg-elevated);
886 border: 1px solid var(--border);
887 border-radius: 16px;
888 overflow: hidden;
889 }
890 .commits-hero-orb-wrap {
891 position: absolute;
892 inset: -25% -10% auto auto;
893 width: 320px;
894 height: 320px;
895 pointer-events: none;
896 z-index: 0;
897 }
898 .commits-hero-orb {
899 position: absolute;
900 inset: 0;
6fd5915Claude901 background: radial-gradient(circle, rgba(91,110,232,0.16), rgba(95,143,160,0.08) 45%, transparent 70%);
efb11c5Claude902 filter: blur(80px);
903 opacity: 0.7;
904 animation: cbHeroOrb 14s ease-in-out infinite;
905 }
906 .commits-hero-inner { position: relative; z-index: 1; }
907 .commits-eyebrow {
908 font-size: 12px;
909 font-family: var(--font-mono);
910 color: var(--text-muted);
911 letter-spacing: 0.1em;
912 text-transform: uppercase;
913 margin-bottom: var(--space-2);
914 }
915 .commits-eyebrow strong { color: var(--accent); font-weight: 600; }
916 .commits-title {
917 font-family: var(--font-display);
918 font-weight: 800;
919 letter-spacing: -0.025em;
920 font-size: clamp(22px, 3vw, 30px);
921 line-height: 1.15;
922 margin: 0 0 var(--space-2);
923 color: var(--text-strong);
924 }
925 .commits-branch {
926 font-family: var(--font-mono);
927 font-size: 0.7em;
928 color: var(--text);
929 background: var(--bg-secondary);
930 border: 1px solid var(--border);
931 border-radius: 6px;
932 padding: 2px 8px;
933 font-weight: 500;
934 vertical-align: middle;
935 }
936 .commits-sub {
937 font-size: 14px;
938 color: var(--text-muted);
939 margin: 0;
940 line-height: 1.55;
941 max-width: 640px;
942 }
398a10cClaude943 .commits-toolbar {
944 display: flex;
945 justify-content: space-between;
946 align-items: center;
947 flex-wrap: wrap;
948 gap: var(--space-2);
949 margin-bottom: var(--space-3);
950 }
951 .commits-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
952 .commits-toolbar-link {
953 display: inline-flex;
954 align-items: center;
955 gap: 6px;
956 padding: 6px 12px;
957 font-size: 12.5px;
958 font-weight: 500;
959 color: var(--text-muted);
960 background: rgba(255,255,255,0.025);
961 border: 1px solid var(--border);
962 border-radius: 8px;
963 text-decoration: none;
964 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
965 }
966 .commits-toolbar-link:hover {
967 border-color: var(--border-strong);
968 color: var(--text-strong);
969 background: rgba(255,255,255,0.04);
970 text-decoration: none;
971 }
efb11c5Claude972 .commits-list-wrap {
973 background: var(--bg-elevated);
974 border: 1px solid var(--border);
398a10cClaude975 border-radius: 14px;
efb11c5Claude976 overflow: hidden;
398a10cClaude977 position: relative;
978 }
979 .commits-list-wrap::before {
980 content: '';
981 position: absolute;
982 top: 0; left: 0; right: 0;
983 height: 2px;
6fd5915Claude984 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude985 opacity: 0.55;
986 pointer-events: none;
987 }
988 .commits-day-head {
989 display: flex;
990 align-items: center;
991 gap: 10px;
992 padding: 10px 18px;
993 font-size: 11.5px;
994 font-family: var(--font-mono);
995 text-transform: uppercase;
996 letter-spacing: 0.08em;
997 color: var(--text-muted);
998 background: var(--bg-secondary);
999 border-bottom: 1px solid var(--border);
1000 }
1001 .commits-day-head:not(:first-child) { border-top: 1px solid var(--border); }
1002 .commits-day-head-dot {
1003 width: 6px; height: 6px;
1004 border-radius: 9999px;
6fd5915Claude1005 background: linear-gradient(135deg, #5b6ee8, #5f8fa0);
398a10cClaude1006 }
1007 .commits-row {
1008 display: flex;
1009 align-items: flex-start;
1010 gap: 14px;
1011 padding: 14px 18px;
1012 border-bottom: 1px solid var(--border-subtle);
1013 transition: background 120ms ease;
1014 }
1015 .commits-row:last-child { border-bottom: none; }
1016 .commits-row:hover { background: rgba(255,255,255,0.022); }
1017 .commits-avatar {
1018 width: 34px; height: 34px;
1019 border-radius: 9999px;
6fd5915Claude1020 background: linear-gradient(135deg, rgba(91,110,232,0.30), rgba(95,143,160,0.25));
398a10cClaude1021 color: #fff;
1022 display: inline-flex;
1023 align-items: center;
1024 justify-content: center;
1025 font-family: var(--font-display);
1026 font-weight: 700;
1027 font-size: 13.5px;
1028 flex-shrink: 0;
1029 box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
1030 }
1031 .commits-row-body { flex: 1; min-width: 0; }
1032 .commits-row-msg {
1033 display: flex;
1034 align-items: center;
1035 gap: 8px;
1036 flex-wrap: wrap;
1037 }
1038 .commits-row-msg a {
1039 font-family: var(--font-display);
1040 font-weight: 600;
1041 font-size: 14px;
1042 color: var(--text-strong);
1043 text-decoration: none;
1044 letter-spacing: -0.005em;
1045 }
1046 .commits-row-msg a:hover { color: var(--accent); text-decoration: none; }
1047 .commits-row-verified {
1048 font-size: 9.5px;
1049 padding: 1px 7px;
1050 border-radius: 9999px;
1051 background: rgba(52,211,153,0.16);
e589f77ccantynz-alt1052 color: var(--green);
398a10cClaude1053 box-shadow: inset 0 0 0 1px rgba(52,211,153,0.30);
1054 text-transform: uppercase;
1055 letter-spacing: 0.06em;
1056 font-weight: 700;
1057 }
1058 .commits-row-meta {
1059 margin-top: 4px;
1060 display: flex;
1061 align-items: center;
1062 gap: 8px;
1063 flex-wrap: wrap;
1064 font-size: 12.5px;
1065 color: var(--text-muted);
1066 }
1067 .commits-row-meta strong { color: var(--text); font-weight: 600; }
1068 .commits-row-meta .sep { opacity: 0.4; }
1069 .commits-row-time {
1070 font-variant-numeric: tabular-nums;
1071 }
1072 .commits-row-side {
1073 display: flex;
1074 align-items: center;
1075 gap: 8px;
1076 flex-shrink: 0;
1077 }
1078 .commits-row-sha {
1079 display: inline-flex;
1080 align-items: center;
1081 padding: 4px 10px;
1082 border-radius: 9999px;
1083 font-family: var(--font-mono);
1084 font-size: 11.5px;
1085 font-weight: 600;
1086 color: var(--text-strong);
1087 background: rgba(255,255,255,0.04);
1088 border: 1px solid var(--border);
1089 text-decoration: none;
1090 letter-spacing: 0.04em;
1091 transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
1092 }
1093 .commits-row-sha:hover {
6fd5915Claude1094 border-color: rgba(91,110,232,0.55);
398a10cClaude1095 color: var(--accent);
6fd5915Claude1096 background: rgba(91,110,232,0.08);
398a10cClaude1097 text-decoration: none;
1098 }
1099 .commits-row-copy {
1100 display: inline-flex;
1101 align-items: center;
1102 justify-content: center;
1103 width: 28px; height: 28px;
1104 padding: 0;
1105 border-radius: 8px;
1106 background: transparent;
1107 border: 1px solid var(--border);
1108 color: var(--text-muted);
1109 cursor: pointer;
1110 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
efb11c5Claude1111 }
398a10cClaude1112 .commits-row-copy:hover {
1113 border-color: var(--border-strong);
1114 color: var(--text);
1115 background: rgba(255,255,255,0.04);
1116 }
e589f77ccantynz-alt1117 .commits-row-copy.is-copied { color: var(--green); border-color: rgba(52,211,153,0.35); }
8c790e0Claude1118 /* Push Watch link — eye icon next to the SHA chip */
1119 .commits-row-watch {
1120 display: inline-flex;
1121 align-items: center;
1122 justify-content: center;
1123 width: 28px;
1124 height: 28px;
1125 border-radius: 6px;
1126 border: 1px solid var(--border);
1127 color: var(--text-muted);
1128 background: transparent;
1129 cursor: pointer;
1130 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1131 text-decoration: none !important;
1132 }
1133 .commits-row-watch:hover {
6fd5915Claude1134 border-color: rgba(91,110,232,0.45);
8c790e0Claude1135 color: var(--accent);
6fd5915Claude1136 background: rgba(91,110,232,0.08);
8c790e0Claude1137 text-decoration: none !important;
1138 }
efb11c5Claude1139 .commits-empty {
398a10cClaude1140 position: relative;
1141 overflow: hidden;
1142 padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 36px);
efb11c5Claude1143 text-align: center;
398a10cClaude1144 background: var(--bg-elevated);
1145 border: 1px dashed var(--border-strong);
1146 border-radius: 16px;
1147 }
1148 .commits-empty-orb {
1149 position: absolute;
1150 inset: -40% 30% auto 30%;
1151 height: 280px;
6fd5915Claude1152 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.10) 45%, transparent 70%);
398a10cClaude1153 filter: blur(70px);
1154 opacity: 0.7;
1155 pointer-events: none;
1156 z-index: 0;
1157 }
1158 .commits-empty-inner { position: relative; z-index: 1; }
1159 .commits-empty-icon {
1160 width: 56px; height: 56px;
1161 border-radius: 9999px;
6fd5915Claude1162 background: linear-gradient(135deg, rgba(91,110,232,0.25), rgba(95,143,160,0.20));
1163 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.40);
398a10cClaude1164 display: inline-flex;
1165 align-items: center;
1166 justify-content: center;
1167 color: #c4b5fd;
1168 margin: 0 auto 14px;
1169 }
1170 .commits-empty-title {
1171 font-family: var(--font-display);
1172 font-size: 18px;
1173 font-weight: 700;
1174 margin: 0 0 6px;
1175 color: var(--text-strong);
1176 }
1177 .commits-empty-sub {
1178 margin: 0 auto 0;
1179 font-size: 13.5px;
efb11c5Claude1180 color: var(--text-muted);
398a10cClaude1181 max-width: 420px;
1182 line-height: 1.5;
1183 }
1184
1185 /* ───────── branches list ───────── */
1186 .branches-list {
efb11c5Claude1187 background: var(--bg-elevated);
398a10cClaude1188 border: 1px solid var(--border);
1189 border-radius: 14px;
1190 overflow: hidden;
1191 position: relative;
1192 }
1193 .branches-list::before {
1194 content: '';
1195 position: absolute;
1196 top: 0; left: 0; right: 0;
1197 height: 2px;
6fd5915Claude1198 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude1199 opacity: 0.55;
1200 pointer-events: none;
1201 }
1202 .branches-row {
1203 display: flex;
1204 align-items: center;
1205 gap: var(--space-3);
1206 padding: 14px 18px;
1207 border-bottom: 1px solid var(--border-subtle);
1208 transition: background 120ms ease;
1209 flex-wrap: wrap;
1210 }
1211 .branches-row:last-child { border-bottom: none; }
1212 .branches-row:hover { background: rgba(255,255,255,0.022); }
1213 .branches-row-icon {
1214 width: 32px; height: 32px;
1215 border-radius: 8px;
6fd5915Claude1216 background: rgba(91,110,232,0.10);
398a10cClaude1217 color: #c4b5fd;
1218 display: inline-flex;
1219 align-items: center;
1220 justify-content: center;
1221 flex-shrink: 0;
6fd5915Claude1222 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.22);
398a10cClaude1223 }
1224 .branches-row-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
1225 .branches-row-name {
1226 display: inline-flex;
1227 align-items: center;
1228 gap: 8px;
1229 flex-wrap: wrap;
1230 }
1231 .branches-row-name a {
1232 font-family: var(--font-mono);
1233 font-size: 13.5px;
1234 color: var(--text-strong);
1235 font-weight: 600;
1236 text-decoration: none;
1237 }
1238 .branches-row-name a:hover { color: var(--accent); text-decoration: none; }
1239 .branches-row-default {
1240 font-size: 10px;
1241 padding: 2px 8px;
1242 border-radius: 9999px;
6fd5915Claude1243 background: rgba(91,110,232,0.14);
398a10cClaude1244 color: #c4b5fd;
6fd5915Claude1245 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.30);
398a10cClaude1246 text-transform: uppercase;
1247 letter-spacing: 0.08em;
1248 font-weight: 700;
1249 font-family: var(--font-mono);
1250 }
1251 .branches-row-meta {
1252 display: flex;
1253 align-items: center;
1254 gap: 8px;
1255 flex-wrap: wrap;
1256 font-size: 12.5px;
1257 color: var(--text-muted);
1258 font-variant-numeric: tabular-nums;
1259 }
1260 .branches-row-meta .sep { opacity: 0.4; }
1261 .branches-row-meta strong { color: var(--text); font-weight: 600; }
1262 .branches-row-side {
1263 display: flex;
1264 align-items: center;
1265 gap: 10px;
1266 flex-shrink: 0;
1267 flex-wrap: wrap;
1268 }
1269 .branches-row-divergence {
1270 display: inline-flex;
1271 align-items: center;
1272 gap: 8px;
1273 font-family: var(--font-mono);
1274 font-size: 11.5px;
1275 color: var(--text-muted);
1276 padding: 4px 10px;
1277 border-radius: 9999px;
1278 background: rgba(255,255,255,0.035);
1279 border: 1px solid var(--border);
1280 font-variant-numeric: tabular-nums;
1281 }
e589f77ccantynz-alt1282 .branches-row-divergence .ahead { color: var(--green); }
1283 .branches-row-divergence .behind { color: var(--red); }
398a10cClaude1284 .branches-row-actions {
1285 display: flex;
1286 align-items: center;
1287 gap: 6px;
1288 }
1289 .branches-btn {
1290 display: inline-flex;
1291 align-items: center;
1292 gap: 5px;
1293 padding: 6px 12px;
1294 border-radius: 9999px;
1295 font-size: 12px;
1296 font-weight: 600;
1297 text-decoration: none;
1298 border: 1px solid var(--border);
1299 background: transparent;
1300 color: var(--text-muted);
1301 cursor: pointer;
1302 font: inherit;
1303 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1304 }
1305 .branches-btn:hover {
1306 border-color: var(--border-strong);
1307 color: var(--text);
1308 background: rgba(255,255,255,0.04);
1309 text-decoration: none;
1310 }
1311 .branches-btn-danger {
e589f77ccantynz-alt1312 color: var(--red);
398a10cClaude1313 border-color: rgba(248,113,113,0.30);
1314 }
1315 .branches-btn-danger:hover {
1316 border-style: dashed;
1317 border-color: rgba(248,113,113,0.65);
1318 background: rgba(248,113,113,0.06);
1319 color: #fecaca;
1320 }
1321
1322 /* ───────── tags list ───────── */
1323 .tags-list {
1324 background: var(--bg-elevated);
1325 border: 1px solid var(--border);
1326 border-radius: 14px;
1327 overflow: hidden;
1328 position: relative;
1329 }
1330 .tags-list::before {
1331 content: '';
1332 position: absolute;
1333 top: 0; left: 0; right: 0;
1334 height: 2px;
6fd5915Claude1335 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude1336 opacity: 0.55;
1337 pointer-events: none;
1338 }
1339 .tags-row {
1340 display: flex;
1341 align-items: center;
1342 gap: var(--space-3);
1343 padding: 14px 18px;
1344 border-bottom: 1px solid var(--border-subtle);
1345 transition: background 120ms ease;
1346 flex-wrap: wrap;
1347 }
1348 .tags-row:last-child { border-bottom: none; }
1349 .tags-row:hover { background: rgba(255,255,255,0.022); }
1350 .tags-row-icon {
1351 width: 32px; height: 32px;
1352 border-radius: 8px;
6fd5915Claude1353 background: rgba(95,143,160,0.10);
398a10cClaude1354 color: #67e8f9;
1355 display: inline-flex;
1356 align-items: center;
1357 justify-content: center;
1358 flex-shrink: 0;
6fd5915Claude1359 box-shadow: inset 0 0 0 1px rgba(95,143,160,0.22);
398a10cClaude1360 }
1361 .tags-row-main { flex: 1; min-width: 240px; }
1362 .tags-row-name {
1363 display: inline-flex;
1364 align-items: center;
1365 gap: 8px;
1366 flex-wrap: wrap;
1367 }
1368 .tags-row-version {
1369 display: inline-flex;
1370 align-items: center;
1371 padding: 3px 11px;
1372 border-radius: 9999px;
1373 font-family: var(--font-mono);
1374 font-size: 13px;
1375 font-weight: 700;
1376 color: #67e8f9;
6fd5915Claude1377 background: rgba(95,143,160,0.12);
1378 box-shadow: inset 0 0 0 1px rgba(95,143,160,0.30);
398a10cClaude1379 letter-spacing: 0.01em;
1380 }
1381 .tags-row-meta {
1382 margin-top: 4px;
1383 display: flex;
1384 align-items: center;
1385 gap: 8px;
1386 flex-wrap: wrap;
1387 font-size: 12.5px;
1388 color: var(--text-muted);
1389 font-variant-numeric: tabular-nums;
1390 }
1391 .tags-row-meta .sep { opacity: 0.4; }
1392 .tags-row-sha {
1393 font-family: var(--font-mono);
1394 font-size: 11.5px;
1395 color: var(--text-strong);
1396 padding: 2px 8px;
1397 border-radius: 6px;
1398 background: rgba(255,255,255,0.04);
1399 border: 1px solid var(--border);
1400 text-decoration: none;
1401 letter-spacing: 0.04em;
1402 }
1403 .tags-row-sha:hover { border-color: var(--border-strong); color: var(--accent); text-decoration: none; }
1404 .tags-row-side {
1405 display: flex;
1406 align-items: center;
1407 gap: 6px;
1408 flex-shrink: 0;
1409 flex-wrap: wrap;
1410 }
1411 .tags-row-link {
1412 display: inline-flex;
1413 align-items: center;
1414 gap: 5px;
1415 padding: 6px 12px;
1416 border-radius: 9999px;
1417 font-size: 12px;
1418 font-weight: 600;
1419 text-decoration: none;
1420 color: var(--text-muted);
1421 background: rgba(255,255,255,0.025);
1422 border: 1px solid var(--border);
1423 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1424 }
1425 .tags-row-link:hover {
6fd5915Claude1426 border-color: rgba(91,110,232,0.45);
398a10cClaude1427 color: var(--text-strong);
6fd5915Claude1428 background: rgba(91,110,232,0.06);
398a10cClaude1429 text-decoration: none;
efb11c5Claude1430 }
1431
1432 /* ───────── commit detail ───────── */
1433 .commit-detail-card {
1434 position: relative;
1435 margin-bottom: var(--space-5);
1436 padding: var(--space-5) var(--space-5);
1437 background: var(--bg-elevated);
1438 border: 1px solid var(--border);
1439 border-radius: 14px;
1440 overflow: hidden;
1441 }
1442 .commit-detail-eyebrow {
1443 display: flex;
1444 align-items: center;
1445 gap: var(--space-2);
1446 font-size: 12px;
1447 font-family: var(--font-mono);
1448 text-transform: uppercase;
1449 letter-spacing: 0.1em;
1450 color: var(--text-muted);
1451 margin-bottom: var(--space-2);
1452 }
1453 .commit-detail-eyebrow strong { color: var(--accent); font-weight: 600; }
1454 .commit-detail-sha-pill {
1455 font-family: var(--font-mono);
1456 font-size: 11.5px;
1457 color: var(--text-strong);
1458 background: var(--bg-secondary);
1459 border: 1px solid var(--border);
1460 border-radius: 999px;
1461 padding: 2px 10px;
1462 letter-spacing: 0.04em;
1463 }
1464 .commit-detail-verify {
1465 font-size: 10px;
1466 padding: 2px 8px;
1467 border-radius: 999px;
1468 text-transform: uppercase;
1469 letter-spacing: 0.06em;
1470 font-weight: 700;
1471 color: #fff;
1472 }
1473 .commit-detail-verify-ok {
1474 background: linear-gradient(135deg, #2ea043, #34d399);
1475 }
1476 .commit-detail-verify-warn {
1477 background: linear-gradient(135deg, #d29922, #f59e0b);
1478 }
1479 .commit-detail-title {
1480 font-family: var(--font-display);
1481 font-weight: 700;
1482 letter-spacing: -0.018em;
1483 font-size: clamp(20px, 2.5vw, 26px);
1484 line-height: 1.25;
1485 margin: 0 0 var(--space-2);
1486 color: var(--text-strong);
1487 }
1488 .commit-detail-body {
1489 white-space: pre-wrap;
1490 color: var(--text-muted);
1491 font-size: 14px;
1492 line-height: 1.55;
1493 margin: 0 0 var(--space-3);
1494 font-family: var(--font-mono);
1495 background: var(--bg);
1496 border: 1px solid var(--border);
1497 border-radius: 8px;
1498 padding: var(--space-3) var(--space-4);
1499 max-height: 280px;
1500 overflow: auto;
1501 }
1502 .commit-detail-meta {
1503 display: flex;
1504 flex-wrap: wrap;
1505 gap: var(--space-3);
1506 font-size: 13px;
1507 color: var(--text-muted);
1508 margin-bottom: var(--space-3);
1509 }
1510 .commit-detail-author strong { color: var(--text-strong); font-weight: 600; }
1511 .commit-detail-parents { font-size: 13px; color: var(--text-muted); }
1512 .commit-detail-sha-link {
1513 font-family: var(--font-mono);
1514 font-size: 12.5px;
1515 color: var(--accent);
6fd5915Claude1516 background: rgba(91,110,232,0.08);
efb11c5Claude1517 border-radius: 6px;
1518 padding: 1px 6px;
1519 margin-left: 2px;
1520 }
6fd5915Claude1521 .commit-detail-sha-link:hover { background: rgba(91,110,232,0.16); text-decoration: none; }
efb11c5Claude1522 .commit-detail-stats {
1523 display: flex;
1524 flex-wrap: wrap;
1525 align-items: center;
1526 gap: var(--space-3);
1527 padding-top: var(--space-3);
1528 border-top: 1px solid var(--border);
1529 font-size: 13px;
1530 color: var(--text-muted);
1531 }
1532 .commit-detail-stat {
1533 display: inline-flex;
1534 align-items: center;
1535 gap: 4px;
1536 font-variant-numeric: tabular-nums;
1537 }
1538 .commit-detail-stat strong { color: var(--text-strong); font-weight: 600; }
e589f77ccantynz-alt1539 .commit-detail-stat-add strong { color: var(--green); }
1540 .commit-detail-stat-del strong { color: var(--red); }
efb11c5Claude1541 .commit-detail-stat-mark {
1542 font-family: var(--font-mono);
1543 font-weight: 700;
1544 font-size: 14px;
1545 }
e589f77ccantynz-alt1546 .commit-detail-stat-add .commit-detail-stat-mark { color: var(--green); }
1547 .commit-detail-stat-del .commit-detail-stat-mark { color: var(--red); }
efb11c5Claude1548 .commit-detail-sha-full {
1549 margin-left: auto;
1550 font-family: var(--font-mono);
1551 font-size: 11.5px;
1552 color: var(--text-faint);
1553 letter-spacing: 0.02em;
1554 overflow: hidden;
1555 text-overflow: ellipsis;
1556 white-space: nowrap;
1557 max-width: 100%;
1558 }
1559 .commit-detail-checks {
1560 margin-top: var(--space-3);
1561 padding-top: var(--space-3);
1562 border-top: 1px solid var(--border);
1563 }
1564 .commit-detail-checks-head {
1565 display: flex;
1566 align-items: center;
1567 gap: var(--space-2);
1568 font-size: 13px;
1569 color: var(--text-muted);
1570 margin-bottom: 8px;
1571 }
1572 .commit-detail-checks-head strong { color: var(--text-strong); font-weight: 600; }
e589f77ccantynz-alt1573 .commit-detail-check-state-success { color: var(--green); font-weight: 600; }
1574 .commit-detail-check-state-failure { color: var(--red); font-weight: 600; }
efb11c5Claude1575 .commit-detail-check-state-pending { color: #d29922; font-weight: 600; }
1576 .commit-detail-check-row { display: flex; flex-wrap: wrap; gap: 6px; }
1577 .commit-detail-check {
1578 font-size: 11px;
1579 padding: 2px 8px;
1580 border-radius: 999px;
1581 color: #fff;
1582 font-weight: 500;
1583 }
398a10cClaude1584 .commit-detail-check a { color: inherit; text-decoration: none; }
1585 .commit-detail-check-success { background: #2ea043; }
1586 .commit-detail-check-pending { background: #d29922; }
1587 .commit-detail-check-failure { background: #da3633; }
1588
1589 /* ───────── blame ───────── */
1590 .blame-head { margin-bottom: var(--space-5); }
1591 .blame-eyebrow {
1592 display: inline-flex;
1593 align-items: center;
1594 gap: 8px;
1595 text-transform: uppercase;
1596 font-family: var(--font-mono);
1597 font-size: 11px;
1598 letter-spacing: 0.16em;
1599 color: var(--text-muted);
1600 font-weight: 600;
1601 margin-bottom: 10px;
1602 }
1603 .blame-eyebrow-dot {
1604 width: 8px; height: 8px;
1605 border-radius: 9999px;
6fd5915Claude1606 background: linear-gradient(135deg, #5b6ee8, #5f8fa0);
1607 box-shadow: 0 0 0 3px rgba(91,110,232,0.18);
398a10cClaude1608 }
1609 .blame-title {
1610 font-family: var(--font-display);
1611 font-size: clamp(22px, 3vw, 30px);
1612 font-weight: 800;
1613 letter-spacing: -0.025em;
1614 line-height: 1.15;
1615 margin: 0 0 6px;
1616 color: var(--text-strong);
1617 }
1618 .blame-title code {
1619 font-family: var(--font-mono);
1620 font-size: 0.78em;
1621 color: var(--text-strong);
1622 font-weight: 700;
1623 }
1624 .blame-sub {
1625 margin: 0;
1626 font-size: 14px;
1627 color: var(--text-muted);
1628 line-height: 1.5;
1629 max-width: 700px;
1630 }
efb11c5Claude1631 .blame-toolbar {
398a10cClaude1632 display: flex;
1633 justify-content: space-between;
1634 align-items: center;
1635 gap: var(--space-3);
efb11c5Claude1636 margin-bottom: var(--space-3);
398a10cClaude1637 flex-wrap: wrap;
efb11c5Claude1638 font-size: 13px;
1639 }
398a10cClaude1640 .blame-toolbar-actions { display: flex; gap: 6px; }
1641 .blame-card {
1642 background: var(--bg-elevated);
1643 border: 1px solid var(--border);
1644 border-radius: 14px;
1645 overflow: hidden;
1646 position: relative;
1647 }
1648 .blame-card::before {
1649 content: '';
1650 position: absolute;
1651 top: 0; left: 0; right: 0;
1652 height: 2px;
6fd5915Claude1653 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude1654 opacity: 0.55;
1655 pointer-events: none;
1656 }
efb11c5Claude1657 .blame-header {
1658 display: flex;
1659 align-items: center;
1660 justify-content: space-between;
1661 gap: var(--space-3);
1662 padding: 10px 14px;
1663 background: var(--bg-secondary);
1664 border-bottom: 1px solid var(--border);
1665 }
1666 .blame-header-meta {
1667 display: flex;
1668 align-items: center;
1669 gap: var(--space-2);
1670 min-width: 0;
1671 flex-wrap: wrap;
1672 }
1673 .blame-header-icon { color: var(--accent); font-size: 14px; }
1674 .blame-header-name {
1675 font-family: var(--font-mono);
1676 font-size: 13px;
1677 color: var(--text-strong);
1678 font-weight: 600;
1679 }
1680 .blame-header-tag {
1681 font-size: 10.5px;
1682 text-transform: uppercase;
1683 letter-spacing: 0.08em;
1684 font-family: var(--font-mono);
6fd5915Claude1685 background: rgba(91,110,232,0.12);
efb11c5Claude1686 color: var(--accent);
1687 border-radius: 999px;
1688 padding: 2px 8px;
1689 font-weight: 600;
1690 }
1691 .blame-header-stats {
1692 font-family: var(--font-mono);
1693 font-size: 11.5px;
1694 color: var(--text-muted);
1695 font-variant-numeric: tabular-nums;
1696 border-left: 1px solid var(--border);
1697 padding-left: var(--space-2);
1698 }
1699 .blame-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
398a10cClaude1700 .blame-table {
1701 width: 100%;
1702 border-collapse: collapse;
1703 font-family: var(--font-mono);
1704 font-size: 12.5px;
1705 line-height: 1.6;
1706 }
1707 .blame-table tr { border-bottom: 1px solid transparent; }
1708 .blame-table tr.blame-row-first { border-top: 1px solid var(--border); }
1709 .blame-table tr:first-child.blame-row-first { border-top: 0; }
1710 .blame-table tr:hover .blame-line-content { background: rgba(255,255,255,0.025); }
1711 .blame-gutter {
1712 width: 220px;
1713 min-width: 220px;
1714 padding: 0 12px;
1715 vertical-align: top;
1716 background: rgba(255,255,255,0.012);
1717 border-right: 1px solid var(--border-subtle);
1718 font-variant-numeric: tabular-nums;
1719 color: var(--text-muted);
1720 font-size: 11px;
1721 white-space: nowrap;
1722 overflow: hidden;
1723 text-overflow: ellipsis;
1724 padding-top: 2px;
1725 padding-bottom: 2px;
1726 }
1727 .blame-gutter-inner {
1728 display: inline-flex;
1729 align-items: center;
1730 gap: 7px;
1731 max-width: 100%;
1732 overflow: hidden;
1733 }
1734 .blame-gutter-sha {
1735 font-family: var(--font-mono);
1736 font-size: 10.5px;
1737 font-weight: 600;
1738 color: #c4b5fd;
6fd5915Claude1739 background: rgba(91,110,232,0.10);
398a10cClaude1740 padding: 1px 7px;
1741 border-radius: 9999px;
6fd5915Claude1742 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.22);
398a10cClaude1743 text-decoration: none;
1744 letter-spacing: 0.04em;
1745 flex-shrink: 0;
1746 transition: background 120ms ease, box-shadow 120ms ease, color 120ms ease;
1747 }
1748 .blame-gutter-sha:hover {
6fd5915Claude1749 background: rgba(91,110,232,0.22);
398a10cClaude1750 color: #ddd6fe;
6fd5915Claude1751 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.50);
398a10cClaude1752 text-decoration: none;
1753 }
1754 .blame-gutter-author {
1755 color: var(--text);
1756 overflow: hidden;
1757 text-overflow: ellipsis;
1758 white-space: nowrap;
1759 font-size: 11px;
1760 font-family: var(--font-sans, inherit);
1761 }
1762 .blame-line-num {
1763 width: 1%;
1764 min-width: 50px;
1765 padding: 0 12px;
1766 text-align: right;
1767 color: var(--text-faint);
1768 user-select: none;
1769 border-right: 1px solid var(--border-subtle);
1770 font-variant-numeric: tabular-nums;
1771 }
1772 .blame-line-content {
1773 padding: 0 14px;
1774 white-space: pre;
1775 color: var(--text);
1776 transition: background 120ms ease;
1777 }
efb11c5Claude1778
1779 /* ───────── search ───────── */
1780 .search-hero {
1781 position: relative;
1782 margin-bottom: var(--space-4);
1783 padding: var(--space-5) var(--space-6);
1784 background: var(--bg-elevated);
1785 border: 1px solid var(--border);
1786 border-radius: 16px;
1787 overflow: hidden;
1788 }
1789 .search-eyebrow {
1790 font-size: 12px;
1791 font-family: var(--font-mono);
1792 color: var(--text-muted);
1793 letter-spacing: 0.1em;
1794 text-transform: uppercase;
1795 margin-bottom: var(--space-2);
1796 }
1797 .search-eyebrow strong { color: var(--accent); font-weight: 600; }
1798 .search-title {
1799 font-family: var(--font-display);
1800 font-weight: 800;
1801 letter-spacing: -0.025em;
1802 font-size: clamp(22px, 3vw, 30px);
1803 line-height: 1.15;
1804 margin: 0 0 var(--space-3);
1805 color: var(--text-strong);
1806 }
1807 .search-form {
1808 display: flex;
1809 gap: var(--space-2);
1810 align-items: stretch;
1811 }
1812 .search-input-wrap {
1813 position: relative;
1814 flex: 1;
1815 display: flex;
1816 align-items: center;
1817 }
1818 .search-input-icon {
1819 position: absolute;
1820 left: 12px;
1821 color: var(--text-muted);
1822 font-size: 15px;
1823 pointer-events: none;
1824 }
1825 .search-input {
1826 appearance: none;
1827 width: 100%;
1828 padding: 10px 12px 10px 34px;
1829 background: var(--bg);
1830 border: 1px solid var(--border);
1831 border-radius: 10px;
1832 color: var(--text-strong);
1833 font-size: 14px;
1834 font-family: inherit;
1835 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
1836 }
1837 .search-input:focus {
1838 outline: none;
1839 border-color: var(--accent);
6fd5915Claude1840 box-shadow: 0 0 0 3px rgba(91,110,232,0.18);
efb11c5Claude1841 }
1842 .search-submit { min-width: 96px; }
1843 .search-results-head {
1844 display: flex;
1845 align-items: baseline;
1846 gap: var(--space-2);
1847 margin-bottom: var(--space-3);
1848 font-size: 13px;
1849 color: var(--text-muted);
1850 }
1851 .search-results-count strong {
1852 color: var(--text-strong);
1853 font-weight: 600;
1854 font-variant-numeric: tabular-nums;
1855 }
1856 .search-results-q { color: var(--text-strong); font-weight: 600; }
1857 .search-results-head code {
1858 font-family: var(--font-mono);
1859 font-size: 12px;
1860 background: var(--bg-secondary);
1861 border: 1px solid var(--border);
1862 border-radius: 5px;
1863 padding: 1px 6px;
1864 color: var(--text);
1865 }
1866 .search-empty {
1867 padding: var(--space-5) var(--space-6);
1868 background: var(--bg-elevated);
1869 border: 1px dashed var(--border);
1870 border-radius: 12px;
1871 color: var(--text-muted);
1872 font-size: 14px;
1873 }
1874 .search-empty strong { color: var(--text-strong); }
1875 .search-results {
1876 display: flex;
1877 flex-direction: column;
1878 gap: var(--space-3);
1879 }
1880 .search-file-head {
1881 display: flex;
1882 align-items: center;
1883 justify-content: space-between;
1884 gap: var(--space-2);
1885 }
1886 .search-file-link {
1887 font-family: var(--font-mono);
1888 font-size: 13px;
1889 color: var(--text-strong);
1890 font-weight: 600;
1891 }
1892 .search-file-link:hover { color: var(--accent); text-decoration: none; }
1893 .search-file-count {
1894 font-family: var(--font-mono);
1895 font-size: 11.5px;
1896 color: var(--text-muted);
1897 font-variant-numeric: tabular-nums;
1898 }
1899`;
1900
fc1817aClaude1901// Home page
06d5ffeClaude1902web.get("/", async (c) => {
1903 const user = c.get("user");
1904
1905 if (user) {
0316dbbClaude1906 return c.redirect("/dashboard");
06d5ffeClaude1907 }
1908
8e9f1d9Claude1909 let stats: { publicRepos?: number; users?: number } | undefined;
52ad8b1Claude1910 let publicStats: PublicStats | null = null;
8e9f1d9Claude1911 try {
1912 const [repoRow] = await db
1913 .select({ n: sql<number>`count(*)::int` })
1914 .from(repositories)
1915 .where(eq(repositories.isPrivate, false));
1916 const [userRow] = await db
1917 .select({ n: sql<number>`count(*)::int` })
1918 .from(users);
1919 stats = {
1920 publicRepos: Number(repoRow?.n ?? 0),
1921 users: Number(userRow?.n ?? 0),
1922 };
1923 } catch {
1924 stats = undefined;
1925 }
1926
52ad8b1Claude1927 // Block L4 — public stats counters (5-min in-memory cache; never throws).
1928 try {
1929 publicStats = await computePublicStats();
1930 } catch {
1931 publicStats = null;
1932 }
1933
534f04aClaude1934 // Block M1 — initial SSR snapshot for the live-now demo feed.
1935 // The helpers in lib/demo-activity.ts never throw, but we still wrap
1936 // in try/catch so a freak module-level explosion can't take down /.
8ed88f2ccantynz-alt1937 let liveFeed: LandingProLiveFeed | null = null;
534f04aClaude1938 try {
1939 const [queued, merges, reviewList, reviewCount, feed] = await Promise.all([
1940 listQueuedAiBuildIssues(3),
1941 listRecentAutoMerges(3, 24),
1942 listRecentAiReviews(3, 24),
1943 countAiReviewsSince(24),
1944 listDemoActivityFeed(10),
1945 ]);
1946 liveFeed = {
1947 queued: queued.map((i) => ({
1948 repo: i.repo,
1949 number: i.number,
1950 title: i.title,
8ed88f2ccantynz-alt1951 createdAt: new Date(i.createdAt),
534f04aClaude1952 })),
1953 merges: merges.map((m) => ({
1954 repo: m.repo,
1955 number: m.number,
1956 title: m.title,
1957 mergedAt: m.mergedAt,
1958 })),
1959 reviews: reviewList.map((r) => ({
1960 repo: r.repo,
1961 prNumber: r.prNumber,
1962 commentSnippet: r.commentSnippet,
1963 createdAt: r.createdAt,
1964 })),
1965 reviewCount,
1966 feed: feed.map((e) => ({
1967 kind: e.kind,
1968 repo: e.repo,
1969 ref: e.ref,
1970 at: e.at,
1971 })),
1972 };
1973 } catch {
1974 liveFeed = null;
1975 }
1976
29924bcClaude1977 void LandingPage;
f8e5feaccanty labs1978 void Landing2030Page;
1979 return c.html(
1980 "<!DOCTYPE html>" +
1981 String(
1982 <LandingProPage
1983 stats={stats}
1984 publicStats={publicStats}
1985 liveFeed={liveFeed}
1986 />
1987 )
1988 );
fc1817aClaude1989});
1990
06d5ffeClaude1991// New repository form
1992web.get("/new", requireAuth, (c) => {
1993 const user = c.get("user")!;
1994 const error = c.req.query("error");
1995
1996 return c.html(
1997 <Layout title="New repository" user={user}>
efb11c5Claude1998 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
1999 <div class="new-repo-hero">
2000 <div class="new-repo-hero-orb-wrap" aria-hidden="true">
2001 <div class="new-repo-hero-orb" />
2002 </div>
2003 <div class="new-repo-hero-inner">
2004 <div class="new-repo-eyebrow">
2005 <strong>Create</strong> · {user.username}
2006 </div>
2007 <h1 class="new-repo-title">
2008 Spin up a <span class="gradient-text">repository</span>.
2009 </h1>
2010 <p class="new-repo-sub">
2011 Push your first commit, and Gluecron wires up gate checks, AI review,
2012 and auto-merge from the moment your branch lands.
2013 </p>
2014 </div>
2015 </div>
06d5ffeClaude2016 <div class="new-repo-form">
efb11c5Claude2017 {error && (
2018 <div class="new-repo-error" role="alert">
2019 {decodeURIComponent(error)}
2020 </div>
2021 )}
2022 <form method="post" action="/new" class="new-repo-form-grid">
2023 <div class="new-repo-row">
2024 <label class="new-repo-label">Owner</label>
2025 <input
2026 type="text"
2027 value={user.username}
2028 disabled
2029 aria-label="Owner"
2030 class="new-repo-input new-repo-input-disabled"
2031 />
06d5ffeClaude2032 </div>
efb11c5Claude2033 <div class="new-repo-row">
2034 <label class="new-repo-label" for="name">
2035 Repository name
2036 </label>
06d5ffeClaude2037 <input
2038 type="text"
2039 id="name"
2040 name="name"
2041 required
2042 pattern="^[a-zA-Z0-9._-]+$"
2043 placeholder="my-project"
2044 autocomplete="off"
efb11c5Claude2045 class="new-repo-input"
06d5ffeClaude2046 />
efb11c5Claude2047 <p class="new-repo-hint">
2048 Lowercase, numbers, dots, dashes, and underscores. The URL will be{" "}
2049 <code>{user.username}/&lt;name&gt;</code>.
2050 </p>
06d5ffeClaude2051 </div>
efb11c5Claude2052 <div class="new-repo-row">
2053 <label class="new-repo-label" for="description">
2054 Description{" "}
2055 <span class="new-repo-label-optional">(optional)</span>
2056 </label>
06d5ffeClaude2057 <input
2058 type="text"
2059 id="description"
2060 name="description"
2061 placeholder="A short description of your repository"
efb11c5Claude2062 class="new-repo-input"
06d5ffeClaude2063 />
2064 </div>
efb11c5Claude2065 <div class="new-repo-row">
2066 <span class="new-repo-label">Visibility</span>
2067 <div class="new-repo-visibility">
2068 <label class="new-repo-vis-card">
2069 <input
2070 type="radio"
2071 name="visibility"
2072 value="public"
2073 checked
2074 class="new-repo-vis-radio"
2075 />
2076 <span class="new-repo-vis-body">
2077 <span class="new-repo-vis-label">Public</span>
2078 <span class="new-repo-vis-desc">
2079 Anyone can see this repository. You choose who can commit.
2080 </span>
2081 </span>
2082 </label>
2083 <label class="new-repo-vis-card">
2084 <input
2085 type="radio"
2086 name="visibility"
2087 value="private"
2088 class="new-repo-vis-radio"
2089 />
2090 <span class="new-repo-vis-body">
2091 <span class="new-repo-vis-label">Private</span>
2092 <span class="new-repo-vis-desc">
2093 Only you (and collaborators you invite) can see this
2094 repository.
2095 </span>
2096 </span>
2097 </label>
2098 </div>
2099 </div>
398a10cClaude2100 <div class="new-repo-row">
2101 <span class="new-repo-label">
2102 Starter content{" "}
2103 <span class="new-repo-label-optional">(cosmetic — your first push wins)</span>
2104 </span>
2105 <div class="new-repo-templates" role="radiogroup" aria-label="Starter content">
2106 <label class="new-repo-template-chip">
2107 <input type="radio" name="starter" value="empty" checked />
2108 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2109 Empty
2110 </label>
2111 <label class="new-repo-template-chip">
2112 <input type="radio" name="starter" value="readme" />
2113 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2114 README
2115 </label>
2116 <label class="new-repo-template-chip">
2117 <input type="radio" name="starter" value="readme-mit" />
2118 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2119 README + MIT
2120 </label>
2121 <label class="new-repo-template-chip">
2122 <input type="radio" name="starter" value="node" />
2123 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2124 Node + .gitignore
2125 </label>
2126 </div>
2127 <p class="new-repo-hint">
2128 Just a UI hint — push your own commits to fill the repo.
2129 </p>
2130 </div>
44f1a02Claude2131 <div class="new-repo-row">
2132 <label class="new-repo-label" for="data_region">
2133 Data region
2134 </label>
2135 <select
2136 id="data_region"
2137 name="data_region"
2138 class="new-repo-input"
2139 style="cursor: pointer;"
2140 >
2141 <option value="us" selected>US (default)</option>
2142 <option value="eu">EU (Frankfurt)</option>
2143 </select>
2144 <p class="new-repo-hint">
2145 EU data residency requires a{" "}
2146 <a href="/pricing" style="color: var(--accent); text-decoration: none;">
2147 Pro plan or higher
2148 </a>
2149 . Repositories cannot be moved between regions after creation.
2150 </p>
2151 </div>
efb11c5Claude2152 <div class="new-repo-callout">
2153 <div class="new-repo-callout-eyebrow">AI-native by default</div>
2154 <p class="new-repo-callout-body">
2155 Every push is gate-checked and reviewed by Claude automatically.
2156 Label an issue <code>ai-build</code> and Gluecron will open the PR
2157 for you.
2158 </p>
2159 </div>
2160 <div class="new-repo-actions">
398a10cClaude2161 <button type="submit" class="btn new-repo-submit">
efb11c5Claude2162 Create repository
2163 </button>
2164 <a href="/dashboard" class="btn new-repo-cancel">
2165 Cancel
2166 </a>
06d5ffeClaude2167 </div>
2168 </form>
2169 </div>
2170 </Layout>
2171 );
2172});
2173
2174web.post("/new", requireAuth, async (c) => {
2175 const user = c.get("user")!;
2176 const body = await c.req.parseBody();
2177 const name = String(body.name || "").trim();
2178 const description = String(body.description || "").trim();
2179 const isPrivate = body.visibility === "private";
44f1a02Claude2180 const dataRegion = body.data_region === "eu" ? "eu" : "us";
06d5ffeClaude2181
2182 if (!name) {
2183 return c.redirect("/new?error=Repository+name+is+required");
2184 }
2185
c63b860Claude2186 // P4 — plan-quota gate. Fail-open inside the helper so a billing
2187 // outage never blocks repo creation.
2188 const { checkRepoCreateAllowed } = await import("../lib/repo-create-gate");
2189 const gate = await checkRepoCreateAllowed(user.id);
2190 if (!gate.ok) {
2191 return c.redirect(`/new?error=${encodeURIComponent(gate.reason)}`);
2192 }
2193
06d5ffeClaude2194 if (!/^[a-zA-Z0-9._-]+$/.test(name)) {
2195 return c.redirect("/new?error=Invalid+repository+name");
2196 }
2197
2198 if (await repoExists(user.username, name)) {
2199 return c.redirect("/new?error=Repository+already+exists");
2200 }
2201
2202 const diskPath = await initBareRepo(user.username, name);
2203
3ef4c9dClaude2204 const [newRepo] = await db
2205 .insert(repositories)
2206 .values({
2207 name,
2208 ownerId: user.id,
2209 description: description || null,
2210 isPrivate,
2211 diskPath,
44f1a02Claude2212 dataRegion,
3ef4c9dClaude2213 })
2214 .returning();
2215
2216 if (newRepo) {
2217 const { bootstrapRepository } = await import("../lib/repo-bootstrap");
2218 await bootstrapRepository({
2219 repositoryId: newRepo.id,
2220 ownerUserId: user.id,
2221 defaultBranch: "main",
2222 });
2223 }
06d5ffeClaude2224
2225 return c.redirect(`/${user.username}/${name}`);
2226});
2227
11c3ab6ccanty labs2228// Daily brief — GET /brief
2229web.get("/brief", (c) => {
2230 const user = c.get("user");
8ed88f2ccantynz-alt2231 return c.html(
2232 <DailyBrief
2233 user={user ? { name: user.displayName || user.username } : undefined}
2234 />
2235 );
11c3ab6ccanty labs2236});
2237
2238// Trust report — GET /trust (public)
2239web.get("/trust", (c) => {
2240 return c.html(<TrustReport />);
2241});
2242
2243// Production layers — GET /layers
2244web.get("/layers", (c) => {
2245 const user = c.get("user");
2246 return c.html(<ProductionLayers user={user} />);
2247});
2248
2249// Distribution — GET /distribute
2250web.get("/distribute", (c) => {
2251 const user = c.get("user");
2252 return c.html(<DistributionView user={user} />);
2253});
2254
06d5ffeClaude2255// User profile
fc1817aClaude2256web.get("/:owner", async (c) => {
06d5ffeClaude2257 const { owner: ownerName } = c.req.param();
2258 const user = c.get("user");
2259
2260 // Avoid clashing with fixed routes
2261 if (
2262 ["login", "register", "logout", "new", "settings", "api"].includes(
2263 ownerName
2264 )
2265 ) {
2266 return c.notFound();
2267 }
2268
2269 let ownerUser;
2270 try {
2271 const [found] = await db
2272 .select()
2273 .from(users)
2274 .where(eq(users.username, ownerName))
2275 .limit(1);
2276 ownerUser = found;
2277 } catch {
2278 // DB not available — check if repos exist on disk
2279 ownerUser = null;
2280 }
2281
2282 // Even without DB, show repos if they exist on disk
2283 let repos: any[] = [];
2284 if (ownerUser) {
2285 const allRepos = await db
2286 .select()
2287 .from(repositories)
2288 .where(eq(repositories.ownerId, ownerUser.id))
2289 .orderBy(desc(repositories.updatedAt));
2290
2291 // Show public repos to everyone, private only to owner
2292 repos =
2293 user?.id === ownerUser.id
2294 ? allRepos
2295 : allRepos.filter((r) => !r.isPrivate);
2296 }
2297
7aa8b99Claude2298 // Block J4 — follow counts + viewer's follow state
2299 let followState = {
2300 followers: 0,
2301 following: 0,
2302 viewerFollows: false,
2303 };
2304 if (ownerUser) {
2305 try {
2306 const { followCounts, isFollowing } = await import("../lib/follows");
2307 const counts = await followCounts(ownerUser.id);
2308 followState.followers = counts.followers;
2309 followState.following = counts.following;
2310 if (user && user.id !== ownerUser.id) {
2311 followState.viewerFollows = await isFollowing(user.id, ownerUser.id);
2312 }
2313 } catch {
2314 // DB hiccup — fall back to zeros.
2315 }
2316 }
2317 const canFollow = !!user && !!ownerUser && user.id !== ownerUser.id;
2318
d412586Claude2319 // Block J5 — profile README. Render owner/owner repo's README on the
2320 // profile page (GitHub convention). Tries "<user>/<user>" first, falling
2321 // back to "<user>/.github" for org-style profile repos.
2322 let profileReadmeHtml: string | null = null;
2323 try {
2324 const candidates = [ownerName, ".github"];
2325 for (const rname of candidates) {
2326 if (await repoExists(ownerName, rname)) {
2327 const ref = (await getDefaultBranch(ownerName, rname)) || "main";
2328 const md = await getReadme(ownerName, rname, ref);
2329 if (md) {
2330 profileReadmeHtml = renderMarkdown(md);
2331 break;
2332 }
2333 }
2334 }
2335 } catch {
2336 profileReadmeHtml = null;
2337 }
2338
efb11c5Claude2339 const displayName = ownerUser?.displayName || ownerName;
2340 const memberSince = ownerUser?.createdAt
2341 ? new Date(ownerUser.createdAt as unknown as string | number | Date)
2342 : null;
2343
fc1817aClaude2344 return c.html(
06d5ffeClaude2345 <Layout title={ownerName} user={user}>
efb11c5Claude2346 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
2347 <div class="profile-hero">
2348 <div class="profile-hero-orb-wrap" aria-hidden="true">
2349 <div class="profile-hero-orb" />
06d5ffeClaude2350 </div>
efb11c5Claude2351 <div class="profile-hero-inner">
2352 <div class="profile-hero-avatar" aria-hidden="true">
2353 {displayName[0].toUpperCase()}
2354 </div>
2355 <div class="profile-hero-text">
2356 <div class="profile-eyebrow">
2357 <strong>Developer</strong>
2358 {memberSince && !Number.isNaN(memberSince.getTime()) && (
2359 <>
2360 {" "}· Joined{" "}
2361 {memberSince.toLocaleDateString("en-US", {
2362 month: "short",
2363 year: "numeric",
2364 })}
2365 </>
2366 )}
2367 </div>
2368 <h1 class="profile-name">
2369 <span class="gradient-text">{displayName}</span>
2370 </h1>
2371 <div class="profile-handle">@{ownerName}</div>
2372 {ownerUser?.bio && <p class="profile-bio">{ownerUser.bio}</p>}
2373 <div class="profile-meta">
2374 <a href={`/${ownerName}/followers`} class="profile-meta-link">
2375 <strong>{followState.followers}</strong> follower
2376 {followState.followers === 1 ? "" : "s"}
2377 </a>
2378 <a href={`/${ownerName}/following`} class="profile-meta-link">
2379 <strong>{followState.following}</strong> following
2380 </a>
2381 <a href={`/${ownerName}`} class="profile-meta-link">
2382 <strong>{repos.length}</strong> repo
2383 {repos.length === 1 ? "" : "s"}
2384 </a>
2385 {canFollow && (
2386 <form
2387 method="post"
2388 action={`/${ownerName}/${
2389 followState.viewerFollows ? "unfollow" : "follow"
2390 }`}
2391 class="profile-follow-form"
7aa8b99Claude2392 >
efb11c5Claude2393 <button
2394 type="submit"
2395 class={`btn ${
2396 followState.viewerFollows ? "" : "btn-primary"
2397 } btn-sm`}
2398 >
2399 {followState.viewerFollows ? "Unfollow" : "Follow"}
2400 </button>
2401 </form>
2402 )}
2403 </div>
7aa8b99Claude2404 </div>
06d5ffeClaude2405 </div>
2406 </div>
d412586Claude2407 {profileReadmeHtml && (
efb11c5Claude2408 <div class="profile-readme">
2409 <div class="profile-readme-head">
2410 <span class="profile-readme-icon">{"☰"}</span>
2411 <span>{ownerName}/{ownerName} README.md</span>
2412 </div>
2413 <div
2414 class="markdown-body profile-readme-body"
2415 dangerouslySetInnerHTML={{ __html: profileReadmeHtml }}
2416 />
2417 </div>
d412586Claude2418 )}
efb11c5Claude2419 <div class="profile-section-head">
2420 <h2 class="profile-section-title">Repositories</h2>
2421 <span class="profile-section-count">{repos.length}</span>
2422 </div>
06d5ffeClaude2423 {repos.length === 0 ? (
efb11c5Claude2424 <div class="profile-empty">
2425 <p class="profile-empty-text">
2426 No repositories yet
2427 {user?.id === ownerUser?.id ? "." : ` — ${ownerName} is just getting started.`}
2428 </p>
2429 {user?.id === ownerUser?.id && (
2430 <a href="/new" class="btn btn-primary btn-sm">
2431 + Create your first
2432 </a>
2433 )}
2434 </div>
06d5ffeClaude2435 ) : (
2436 <div class="card-grid">
2437 {repos.map((repo) => (
2438 <RepoCard repo={repo} ownerName={ownerName} />
2439 ))}
2440 </div>
2441 )}
fc1817aClaude2442 </Layout>
2443 );
2444});
2445
06d5ffeClaude2446// Star/unstar a repo
2447web.post("/:owner/:repo/star", requireAuth, async (c) => {
2448 const { owner: ownerName, repo: repoName } = c.req.param();
2449 const user = c.get("user")!;
2450
2451 try {
2452 const [ownerUser] = await db
2453 .select()
2454 .from(users)
2455 .where(eq(users.username, ownerName))
2456 .limit(1);
2457 if (!ownerUser) return c.redirect(`/${ownerName}/${repoName}`);
2458
2459 const [repo] = await db
2460 .select()
2461 .from(repositories)
2462 .where(
2463 and(
2464 eq(repositories.ownerId, ownerUser.id),
2465 eq(repositories.name, repoName)
2466 )
2467 )
2468 .limit(1);
2469 if (!repo) return c.redirect(`/${ownerName}/${repoName}`);
2470
2471 // Toggle star
2472 const [existing] = await db
2473 .select()
2474 .from(stars)
2475 .where(
2476 and(eq(stars.userId, user.id), eq(stars.repositoryId, repo.id))
2477 )
2478 .limit(1);
2479
2480 if (existing) {
2481 await db.delete(stars).where(eq(stars.id, existing.id));
2482 await db
2483 .update(repositories)
2484 .set({ starCount: Math.max(0, repo.starCount - 1) })
2485 .where(eq(repositories.id, repo.id));
2486 } else {
2487 await db.insert(stars).values({
2488 userId: user.id,
2489 repositoryId: repo.id,
2490 });
2491 await db
2492 .update(repositories)
2493 .set({ starCount: repo.starCount + 1 })
2494 .where(eq(repositories.id, repo.id));
a74f4edccanty labs2495 void fireWebhooks(repo.id, "star", { action: "created" });
06d5ffeClaude2496 }
2497 } catch {
2498 // DB error — ignore
2499 }
2500
2501 return c.redirect(`/${ownerName}/${repoName}`);
2502});
2503
641aa42Claude2504// ---------------------------------------------------------------------------
2505// Onboarding card CSS (injected inline on repo home, scoped to .ob-*)
2506// ---------------------------------------------------------------------------
2507const obCss = `
2508 .ob-card {
2509 position: relative;
2510 margin: 14px 0 18px;
6fd5915Claude2511 background: linear-gradient(135deg, rgba(91,110,232,0.08), rgba(95,143,160,0.05));
2512 border: 1px solid rgba(91,110,232,0.30);
641aa42Claude2513 border-radius: 14px;
2514 overflow: hidden;
2515 }
2516 .ob-card::before {
2517 content: '';
2518 position: absolute;
2519 top: 0; left: 0; right: 0;
2520 height: 2px;
6fd5915Claude2521 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
641aa42Claude2522 pointer-events: none;
2523 }
2524 .ob-header {
2525 padding: 16px 20px 10px;
2526 border-bottom: 1px solid var(--border);
2527 }
2528 .ob-header h3 {
2529 font-size: 16px;
2530 font-weight: 700;
2531 margin: 0 0 4px;
2532 color: var(--text-strong);
2533 }
2534 .ob-header p {
2535 font-size: 13px;
2536 color: var(--text-muted);
2537 margin: 0;
2538 }
2539 .ob-sections {
2540 display: grid;
2541 grid-template-columns: repeat(3, 1fr);
2542 gap: 0;
2543 }
2544 @media (max-width: 760px) {
2545 .ob-sections { grid-template-columns: 1fr; }
2546 }
2547 .ob-section {
2548 padding: 14px 20px;
2549 border-right: 1px solid var(--border);
2550 }
2551 .ob-section:last-child { border-right: none; }
2552 .ob-section h4 {
2553 font-size: 12px;
2554 font-weight: 700;
2555 text-transform: uppercase;
2556 letter-spacing: 0.08em;
2557 color: var(--accent);
2558 margin: 0 0 8px;
2559 }
2560 .ob-preview {
2561 font-family: var(--font-mono);
2562 font-size: 11.5px;
2563 background: var(--bg);
2564 border: 1px solid var(--border);
2565 border-radius: 6px;
2566 padding: 8px 10px;
2567 color: var(--text-muted);
2568 line-height: 1.55;
2569 margin-bottom: 8px;
2570 white-space: pre-wrap;
2571 overflow: hidden;
2572 max-height: 80px;
2573 position: relative;
2574 }
2575 .ob-preview::after {
2576 content: '';
2577 position: absolute;
2578 bottom: 0; left: 0; right: 0;
2579 height: 24px;
2580 background: linear-gradient(transparent, var(--bg));
2581 pointer-events: none;
2582 }
2583 .ob-labels {
2584 display: flex;
2585 flex-wrap: wrap;
2586 gap: 5px;
2587 margin-bottom: 8px;
2588 }
2589 .ob-label-chip {
2590 display: inline-flex;
2591 align-items: center;
2592 padding: 2px 8px;
2593 border-radius: 9999px;
2594 font-size: 11.5px;
2595 font-weight: 600;
2596 line-height: 1.5;
2597 border: 1px solid transparent;
2598 }
2599 .ob-section ul {
2600 margin: 0;
2601 padding: 0 0 0 16px;
2602 font-size: 13px;
2603 color: var(--text-muted);
2604 line-height: 1.7;
2605 }
2606 .ob-section ul li { margin-bottom: 2px; }
2607 .ob-footer {
2608 display: flex;
2609 align-items: center;
2610 justify-content: flex-end;
2611 padding: 10px 20px;
2612 border-top: 1px solid var(--border);
2613 gap: 10px;
2614 }
2615 .ob-dismiss {
2616 appearance: none;
2617 background: transparent;
2618 border: 1px solid var(--border);
2619 color: var(--text-muted);
2620 border-radius: 6px;
2621 padding: 5px 12px;
2622 font-size: 12.5px;
2623 font-family: inherit;
2624 cursor: pointer;
2625 transition: background var(--t-fast), color var(--t-fast);
2626 }
2627 .ob-dismiss:hover { background: var(--bg-hover); color: var(--text); }
2628 .btn-sm {
2629 appearance: none;
2630 background: var(--bg-elevated);
2631 border: 1px solid var(--border);
2632 color: var(--text-strong);
2633 border-radius: 6px;
2634 padding: 5px 12px;
2635 font-size: 12.5px;
2636 font-weight: 600;
2637 font-family: inherit;
2638 cursor: pointer;
2639 text-decoration: none;
2640 display: inline-flex;
2641 align-items: center;
2642 transition: background var(--t-fast);
2643 }
2644 .btn-sm:hover { background: var(--bg-hover); }
2645 .btn-sm.btn-primary {
2646 background: var(--accent);
2647 color: #fff;
2648 border-color: var(--accent);
2649 }
2650 .btn-sm.btn-primary:hover { background: var(--accent-hover); }
2651`;
2652
2653// Onboarding card component — shown to repo owner until dismissed
2654function RepoOnboardingCard({
2655 owner,
2656 repo,
2657 data,
2658}: {
2659 owner: string;
2660 repo: string;
2661 data: typeof repoOnboardingData.$inferSelect;
2662}) {
2663 const labels = (data.suggestedLabels ?? []) as Array<{
2664 name: string;
2665 color: string;
2666 description: string;
2667 }>;
2668 const suggestions = (data.firstCommitSuggestions ?? []) as string[];
2669 const readmePreview = (data.suggestedReadme ?? "").slice(0, 200);
2670
2671 return (
2672 <>
2673 <style dangerouslySetInnerHTML={{ __html: obCss }} />
2674 <div class="ob-card" id="repo-onboarding">
2675 <div class="ob-header">
2676 <h3>Get started with {owner}/{repo}</h3>
2677 <p>
2678 Detected: {data.detectedLanguage ?? "Unknown"}
2679 {data.detectedFramework ? ` / ${data.detectedFramework}` : ""}.
2680 Here&rsquo;s what we suggest to hit the ground running.
2681 </p>
2682 </div>
2683 <div class="ob-sections">
2684 <div class="ob-section">
2685 <h4>Suggested README</h4>
2686 <div class="ob-preview">{readmePreview}</div>
2687 <button
2688 class="btn-sm"
2689 type="button"
2690 onclick={`(function(){var t=${JSON.stringify(data.suggestedReadme ?? "")};try{navigator.clipboard.writeText(t).then(function(){var b=document.querySelector('.ob-copy-btn');if(b){b.textContent='Copied!';setTimeout(function(){b.textContent='Copy to clipboard';},2000);}});}catch(_){};})()`}
2691 aria-label="Copy suggested README to clipboard"
2692 >
2693 Copy to clipboard
2694 </button>
2695 </div>
2696 <div class="ob-section">
2697 <h4>Suggested labels ({labels.length})</h4>
2698 <div class="ob-labels">
2699 {labels.slice(0, 6).map((l) => (
2700 <span
2701 class="ob-label-chip"
2702 style={`background:#${l.color}22;color:#${l.color};border-color:#${l.color}55`}
2703 title={l.description}
2704 >
2705 {l.name}
2706 </span>
2707 ))}
2708 </div>
2709 <form method="post" action={`/${owner}/${repo}/setup/labels`}>
2710 <button class="btn-sm btn-primary" type="submit">
2711 Create all labels
2712 </button>
2713 </form>
2714 </div>
2715 <div class="ob-section">
2716 <h4>First steps</h4>
2717 <ul>
2718 {suggestions.map((s) => (
2719 <li>{s}</li>
2720 ))}
2721 </ul>
2722 </div>
2723 </div>
2724 <div class="ob-footer">
2725 <form method="post" action={`/${owner}/${repo}/setup/dismiss`}>
2726 <button class="ob-dismiss" type="submit">
2727 Dismiss
2728 </button>
2729 </form>
2730 </div>
2731 <script
2732 dangerouslySetInnerHTML={{
2733 __html: `
2734 (function(){
2735 var card = document.getElementById('repo-onboarding');
2736 if (!card) return;
2737 document.addEventListener('keydown', function(e){
2738 if (e.key === 'Escape' && card && card.style.display !== 'none') {
2739 card.style.display = 'none';
2740 }
2741 });
2742 })();
2743 `,
2744 }}
2745 />
2746 </div>
2747 </>
2748 );
2749}
2750
2751// ---------------------------------------------------------------------------
2752// Setup routes — create suggested labels + dismiss onboarding
2753// ---------------------------------------------------------------------------
2754
2755// POST /:owner/:repo/setup/labels — creates all suggested labels for the repo.
2756// requireAuth + write access. Idempotent (label UPSERT by name).
2757web.post("/:owner/:repo/setup/labels", softAuth, requireAuth, async (c) => {
2758 const { owner, repo } = c.req.param();
2759 const user = c.get("user")!;
2760
2761 // Resolve repo + verify write access
2762 let repoRow: { id: string; ownerId: string } | null = null;
2763 try {
2764 const [ownerUser] = await db
2765 .select({ id: users.id })
2766 .from(users)
2767 .where(eq(users.username, owner))
2768 .limit(1);
2769 if (!ownerUser) return c.redirect(`/${owner}/${repo}?error=Not+found`);
2770 const [r] = await db
2771 .select({ id: repositories.id, ownerId: repositories.ownerId })
2772 .from(repositories)
2773 .where(
2774 and(
2775 eq(repositories.ownerId, ownerUser.id),
2776 eq(repositories.name, repo)
2777 )
2778 )
2779 .limit(1);
2780 repoRow = r ?? null;
2781 } catch {
2782 return c.redirect(`/${owner}/${repo}?error=Database+error`);
2783 }
2784 if (!repoRow) return c.redirect(`/${owner}/${repo}?error=Not+found`);
2785 if (repoRow.ownerId !== user.id) {
2786 return c.redirect(`/${owner}/${repo}?error=Forbidden`);
2787 }
2788
2789 // Fetch the onboarding data
2790 let obRow: (typeof repoOnboardingData.$inferSelect) | null = null;
2791 try {
2792 const [r] = await db
2793 .select()
2794 .from(repoOnboardingData)
2795 .where(eq(repoOnboardingData.repositoryId, repoRow.id))
2796 .limit(1);
2797 obRow = r ?? null;
2798 } catch {
2799 return c.redirect(`/${owner}/${repo}?error=Onboarding+data+not+found`);
2800 }
2801 if (!obRow) {
2802 return c.redirect(`/${owner}/${repo}?toast=info:No+onboarding+data+found`);
2803 }
2804
2805 const suggestedLabels = (obRow.suggestedLabels ?? []) as Array<{
2806 name: string;
2807 color: string;
2808 description: string;
2809 }>;
2810
2811 // Create labels — import the labels table which was already imported
2812 let created = 0;
2813 for (const l of suggestedLabels) {
2814 try {
2815 await db
2816 .insert(labels)
2817 .values({
2818 repositoryId: repoRow.id,
2819 name: l.name,
2820 color: l.color,
2821 description: l.description ?? "",
2822 })
2823 .onConflictDoNothing();
2824 created++;
2825 } catch {
2826 /* skip duplicates */
2827 }
2828 }
2829
2830 // Mark onboarding dismissed
2831 try {
2832 await db
2833 .update(repositories)
2834 .set({ onboardingShown: true })
2835 .where(eq(repositories.id, repoRow.id));
2836 } catch {
2837 /* ignore */
2838 }
2839
2840 return c.redirect(
2841 `/${owner}/${repo}?success=${encodeURIComponent(`Created ${created} labels`)}`
2842 );
2843});
2844
2845// POST /:owner/:repo/setup/dismiss — marks onboarding as shown.
2846web.post("/:owner/:repo/setup/dismiss", softAuth, requireAuth, async (c) => {
2847 const { owner, repo } = c.req.param();
2848 const user = c.get("user")!;
2849
2850 try {
2851 const [ownerUser] = await db
2852 .select({ id: users.id })
2853 .from(users)
2854 .where(eq(users.username, owner))
2855 .limit(1);
2856 if (ownerUser) {
2857 const [r] = await db
2858 .select({ id: repositories.id, ownerId: repositories.ownerId })
2859 .from(repositories)
2860 .where(
2861 and(
2862 eq(repositories.ownerId, ownerUser.id),
2863 eq(repositories.name, repo)
2864 )
2865 )
2866 .limit(1);
2867 if (r && r.ownerId === user.id) {
2868 await db
2869 .update(repositories)
2870 .set({ onboardingShown: true })
2871 .where(eq(repositories.id, r.id));
2872 }
2873 }
2874 } catch {
2875 /* swallow — dismiss should never fail visibly */
2876 }
2877
2878 return c.redirect(`/${owner}/${repo}`);
2879});
2880
11c3ab6ccanty labs2881// Agent workspace — GET /:owner/:repo/workspace
5bb52faccanty labs2882web.get("/:owner/:repo/workspace", async (c) => {
11c3ab6ccanty labs2883 const { owner, repo } = c.req.param();
2884 const user = c.get("user");
5bb52faccanty labs2885 const gate = await assertRepoReadable(c, owner, repo);
2886 if (gate) return gate;
11c3ab6ccanty labs2887 return c.html(<AgentWorkspace owner={owner} repo={repo} user={user} />);
2888});
2889
2890// Org memory — GET /:owner/:repo/memory
5bb52faccanty labs2891web.get("/:owner/:repo/memory", async (c) => {
11c3ab6ccanty labs2892 const { owner, repo } = c.req.param();
2893 const user = c.get("user");
5bb52faccanty labs2894 const gate = await assertRepoReadable(c, owner, repo);
2895 if (gate) return gate;
11c3ab6ccanty labs2896 return c.html(<OrgMemory owner={owner} repo={repo} user={user} />);
2897});
2898
fc1817aClaude2899// Repository overview — file tree at HEAD
2900web.get("/:owner/:repo", async (c) => {
2901 const { owner, repo } = c.req.param();
06d5ffeClaude2902 const user = c.get("user");
fc1817aClaude2903
5bb52faccanty labs2904 // SECURITY: gate private-repo content before any render (incl. skeleton).
2905 const gate = await assertRepoReadable(c, owner, repo);
2906 if (gate) return gate;
2907
f1dc7c7Claude2908 // ── Loading skeleton (flag-gated) ──
2909 // Renders an SSR'd shell with file-tree + README placeholders when
2910 // `?skeleton=1` is set. Lets the user see the page structure before
2911 // git ops finish. Behind a flag for now so we never flash before the
2912 // real content lands.
2913 if (c.req.query("skeleton") === "1") {
2914 return c.html(
2915 <Layout title={`${owner}/${repo}`} user={user}>
2916 <style
2917 dangerouslySetInnerHTML={{
2918 __html: `
2919 .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; }
2920 @keyframes repoSkelShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
2921 @media (prefers-reduced-motion: reduce) { .repo-skel { animation: none; } }
2922 .repo-skel-hero { height: 132px; border-radius: 16px; margin-bottom: var(--space-4); }
2923 .repo-skel-nav { height: 36px; border-radius: 8px; margin-bottom: var(--space-4); }
2924 .repo-skel-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--space-5); align-items: start; }
2925 @media (max-width: 960px) { .repo-skel-grid { grid-template-columns: minmax(0, 1fr); } }
2926 .repo-skel-branch { height: 32px; width: 200px; border-radius: 8px; margin-bottom: 12px; }
2927 .repo-skel-tree { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-5); }
2928 .repo-skel-tree-row { height: 36px; border-radius: 8px; }
2929 .repo-skel-readme { height: 320px; border-radius: 12px; }
2930 .repo-skel-side { display: flex; flex-direction: column; gap: var(--space-4); }
2931 .repo-skel-side-card { height: 180px; border-radius: 12px; }
2932 `,
2933 }}
2934 />
2935 <div class="repo-skel repo-skel-hero" aria-hidden="true" />
2936 <div class="repo-skel repo-skel-nav" aria-hidden="true" />
2937 <div class="repo-skel-grid" aria-hidden="true">
2938 <div>
2939 <div class="repo-skel repo-skel-branch" />
2940 <div class="repo-skel-tree">
2941 {Array.from({ length: 8 }).map(() => (
2942 <div class="repo-skel repo-skel-tree-row" />
2943 ))}
2944 </div>
2945 <div class="repo-skel repo-skel-readme" />
2946 </div>
2947 <aside class="repo-skel-side">
2948 <div class="repo-skel repo-skel-side-card" />
2949 <div class="repo-skel repo-skel-side-card" />
2950 </aside>
2951 </div>
2952 <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">
2953 Loading {owner}/{repo}…
2954 </span>
2955 </Layout>
2956 );
2957 }
2958
8f50ed0Claude2959 // F1 — fire-and-forget traffic tracking. Never awaits; never throws.
2960 trackByName(owner, repo, "view", {
2961 userId: user?.id || null,
2962 path: `/${owner}/${repo}`,
2963 ip: c.req.header("x-forwarded-for") || c.req.header("x-real-ip") || null,
2964 userAgent: c.req.header("user-agent") || null,
2965 referer: c.req.header("referer") || null,
a28cedeClaude2966 }).catch((err) => {
2967 console.warn(
2968 `[web] view tracking failed for ${owner}/${repo}:`,
2969 err instanceof Error ? err.message : err
2970 );
2971 });
8f50ed0Claude2972
fc1817aClaude2973 if (!(await repoExists(owner, repo))) {
2974 return c.html(
06d5ffeClaude2975 <Layout title="Not Found" user={user}>
fc1817aClaude2976 <div class="empty-state">
2977 <h2>Repository not found</h2>
2978 <p>
2979 {owner}/{repo} does not exist.
2980 </p>
2981 </div>
2982 </Layout>,
2983 404
2984 );
2985 }
2986
05b973eClaude2987 // Parallelize all independent operations
2988 const [defaultBranch, branches] = await Promise.all([
2989 getDefaultBranch(owner, repo).then((b) => b || "main"),
2990 listBranches(owner, repo),
2991 ]);
2992 const [tree, starInfo] = await Promise.all([
2993 getTree(owner, repo, defaultBranch),
2994 // Star info fetched in parallel with tree
2995 (async () => {
2996 try {
2997 const [ownerUser] = await db
2998 .select()
2999 .from(users)
3000 .where(eq(users.username, owner))
3001 .limit(1);
71cd5ecClaude3002 if (!ownerUser)
3003 return {
3004 starCount: 0,
3005 starred: false,
3006 archived: false,
3007 isTemplate: false,
544d842Claude3008 forkCount: 0,
3009 description: null as string | null,
3010 pushedAt: null as Date | null,
3011 createdAt: null as Date | null,
cb5a796Claude3012 repoId: null as string | null,
3013 repoOwnerId: null as string | null,
71cd5ecClaude3014 };
05b973eClaude3015 const [repoRow] = await db
3016 .select()
3017 .from(repositories)
3018 .where(
3019 and(
3020 eq(repositories.ownerId, ownerUser.id),
3021 eq(repositories.name, repo)
3022 )
06d5ffeClaude3023 )
05b973eClaude3024 .limit(1);
71cd5ecClaude3025 if (!repoRow)
3026 return {
3027 starCount: 0,
3028 starred: false,
3029 archived: false,
3030 isTemplate: false,
544d842Claude3031 forkCount: 0,
3032 description: null as string | null,
3033 pushedAt: null as Date | null,
3034 createdAt: null as Date | null,
cb5a796Claude3035 repoId: null as string | null,
3036 repoOwnerId: null as string | null,
71cd5ecClaude3037 };
05b973eClaude3038 let starred = false;
06d5ffeClaude3039 if (user) {
3040 const [star] = await db
3041 .select()
3042 .from(stars)
3043 .where(
3044 and(
3045 eq(stars.userId, user.id),
3046 eq(stars.repositoryId, repoRow.id)
3047 )
3048 )
3049 .limit(1);
3050 starred = !!star;
3051 }
71cd5ecClaude3052 return {
3053 starCount: repoRow.starCount,
3054 starred,
3055 archived: repoRow.isArchived,
3056 isTemplate: repoRow.isTemplate,
544d842Claude3057 forkCount: repoRow.forkCount,
3058 description: repoRow.description as string | null,
3059 pushedAt: (repoRow.pushedAt as Date | null) ?? null,
3060 createdAt: (repoRow.createdAt as Date | null) ?? null,
cb5a796Claude3061 repoId: repoRow.id as string,
3062 repoOwnerId: repoRow.ownerId as string,
71cd5ecClaude3063 };
05b973eClaude3064 } catch {
71cd5ecClaude3065 return {
3066 starCount: 0,
3067 starred: false,
3068 archived: false,
3069 isTemplate: false,
544d842Claude3070 forkCount: 0,
3071 description: null as string | null,
3072 pushedAt: null as Date | null,
3073 createdAt: null as Date | null,
cb5a796Claude3074 repoId: null as string | null,
3075 repoOwnerId: null as string | null,
71cd5ecClaude3076 };
06d5ffeClaude3077 }
05b973eClaude3078 })(),
3079 ]);
544d842Claude3080 const {
3081 starCount,
3082 starred,
3083 archived,
3084 isTemplate,
3085 forkCount,
3086 description,
3087 pushedAt,
3088 createdAt,
cb5a796Claude3089 repoId,
3090 repoOwnerId,
544d842Claude3091 } = starInfo;
3092
91a0204Claude3093 // Health score badge — fire-and-forget, best-effort. If the DB call fails
3094 // or repoId is null (anonymous view of non-DB repo), healthScore stays null
3095 // and the badge simply doesn't render.
3096 let healthScore: HealthScore | null = null;
3097 if (repoId) {
3098 try {
3099 healthScore = await computeHealthScore(repoId);
3100 } catch {
3101 // swallow — badge is optional
3102 }
3103 }
3104
cb5a796Claude3105 // Pending-comments banner data (lazy + best-effort). Only the repo
3106 // owner sees the banner, so non-owner views skip the DB hit entirely.
3107 let repoHomePendingCount = 0;
3108 if (user && repoOwnerId && user.id === repoOwnerId && repoId) {
3109 try {
3110 const { countPendingForRepo } = await import(
3111 "../lib/comment-moderation"
3112 );
3113 repoHomePendingCount = await countPendingForRepo(repoId);
3114 } catch {
3115 /* swallow */
3116 }
3117 }
3118
8c790e0Claude3119 // Push Watch discoverability — fetch the most recent push within 24 h.
3120 // Runs only when we have a repoId (i.e. the repo row was found in the DB).
3121 const recentPush: RecentPush | null = repoId
3122 ? await getRecentPush(repoId)
3123 : null;
3124
ebaae0fClaude3125 // AI stats strip — best-effort, fail-open to zero values.
3126 let aiStats: RepoAiStats = {
3127 mergedCount: 0,
3128 reviewCount: 0,
3129 securityAlertCount: 0,
3130 hoursSaved: "0.0",
3131 };
3132 if (repoId) {
3133 try {
3134 aiStats = await getRepoAiStats(repoId);
3135 } catch {
3136 /* swallow — show zero values */
3137 }
3138 }
3139
641aa42Claude3140 // Onboarding card — shown to repo owner until dismissed. Best-effort;
3141 // if the DB is down the card simply won't appear. Only the owner sees it.
3142 let onboardingRow: (typeof repoOnboardingData.$inferSelect) | null = null;
3143 let showOnboarding = false;
3144 if (repoId && user && repoOwnerId && user.id === repoOwnerId) {
3145 try {
3146 // Check if onboarding_shown is still false (not yet dismissed)
3147 const [repoRow2] = await db
3148 .select({ onboardingShown: repositories.onboardingShown })
3149 .from(repositories)
3150 .where(eq(repositories.id, repoId))
3151 .limit(1);
3152 if (repoRow2 && !repoRow2.onboardingShown) {
3153 const [obRow] = await db
3154 .select()
3155 .from(repoOnboardingData)
3156 .where(eq(repoOnboardingData.repositoryId, repoId))
3157 .limit(1);
3158 onboardingRow = obRow ?? null;
3159 showOnboarding = !!onboardingRow;
3160 }
3161 } catch {
3162 /* swallow — onboarding is optional */
3163 }
3164 }
3165
544d842Claude3166 // Repo-home polish — shared style block (Block 2.A — parallel session 2.A).
3167 // Scoped via .repo-home-* class prefix to prevent bleed into other surfaces.
3168 const repoHomeCss = `
3169 .repo-home-hero {
3170 position: relative;
3171 margin-bottom: var(--space-5);
3172 padding: var(--space-5) var(--space-6);
3173 background: var(--bg-elevated);
3174 border: 1px solid var(--border);
3175 border-radius: 16px;
3176 overflow: hidden;
3177 }
3178 .repo-home-hero::before {
3179 content: '';
3180 position: absolute;
3181 top: 0; left: 0; right: 0;
3182 height: 2px;
6fd5915Claude3183 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
544d842Claude3184 opacity: 0.7;
3185 pointer-events: none;
3186 }
3187 .repo-home-hero-orb-wrap {
3188 position: absolute;
3189 inset: -25% -10% auto auto;
3190 width: 360px;
3191 height: 360px;
3192 pointer-events: none;
3193 z-index: 0;
3194 }
3195 .repo-home-hero-orb {
3196 position: absolute;
3197 inset: 0;
6fd5915Claude3198 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.09) 45%, transparent 70%);
544d842Claude3199 filter: blur(80px);
3200 opacity: 0.7;
3201 animation: repoHomeOrb 14s ease-in-out infinite;
3202 }
3203 @keyframes repoHomeOrb {
3204 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
3205 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
3206 }
3207 @media (prefers-reduced-motion: reduce) {
3208 .repo-home-hero-orb { animation: none; }
3209 }
3210 .repo-home-hero-inner {
3211 position: relative;
3212 z-index: 1;
3213 }
3214 .repo-home-hero .repo-header { margin-bottom: var(--space-3); }
3215 .repo-home-eyebrow {
3216 font-size: 12px;
3217 font-family: var(--font-mono);
3218 color: var(--text-muted);
3219 letter-spacing: 0.1em;
3220 text-transform: uppercase;
3221 margin-bottom: var(--space-2);
3222 }
3223 .repo-home-eyebrow strong { color: var(--accent); font-weight: 600; }
3224 .repo-home-description {
3225 font-size: 15px;
3226 line-height: 1.55;
3227 color: var(--text);
3228 margin: 0;
3229 max-width: 720px;
3230 }
3231 .repo-home-description-empty {
3232 font-size: 14px;
3233 color: var(--text-muted);
3234 font-style: italic;
3235 margin: 0;
3236 }
3237 .repo-home-stat-row {
3238 display: flex;
3239 flex-wrap: wrap;
3240 gap: var(--space-4);
3241 margin-top: var(--space-3);
3242 font-size: 13px;
3243 color: var(--text-muted);
3244 }
3245 .repo-home-stat {
3246 display: inline-flex;
3247 align-items: center;
3248 gap: 6px;
3249 }
3250 .repo-home-stat strong {
3251 color: var(--text-strong);
3252 font-weight: 600;
3253 font-variant-numeric: tabular-nums;
3254 }
3255 .repo-home-stat .repo-home-stat-icon {
3256 color: var(--text-faint);
3257 font-size: 14px;
3258 line-height: 1;
3259 }
3260 .repo-home-stat a {
3261 color: var(--text-muted);
3262 transition: color var(--t-fast) var(--ease);
3263 }
3264 .repo-home-stat a:hover { color: var(--accent); text-decoration: none; }
3265
3266 /* Two-column layout: file tree + sidebar */
3267 .repo-home-grid {
3268 display: grid;
3269 grid-template-columns: minmax(0, 1fr) 280px;
3270 gap: var(--space-5);
3271 align-items: start;
3272 }
3273 @media (max-width: 960px) {
3274 .repo-home-grid { grid-template-columns: minmax(0, 1fr); }
3275 }
3276 .repo-home-main { min-width: 0; }
3277
3278 /* Sidebar card */
3279 .repo-home-side {
3280 display: flex;
3281 flex-direction: column;
3282 gap: var(--space-4);
3283 }
3284 .repo-home-side-card {
3285 background: var(--bg-elevated);
3286 border: 1px solid var(--border);
3287 border-radius: 12px;
3288 padding: var(--space-4);
3289 }
3290 .repo-home-side-title {
3291 font-size: 11px;
3292 font-family: var(--font-mono);
3293 letter-spacing: 0.12em;
3294 text-transform: uppercase;
3295 color: var(--text-muted);
3296 margin: 0 0 var(--space-3);
3297 font-weight: 600;
3298 }
3299 .repo-home-side-row {
3300 display: flex;
3301 justify-content: space-between;
3302 align-items: center;
3303 gap: var(--space-2);
3304 font-size: 13px;
3305 padding: 6px 0;
3306 border-top: 1px solid var(--border);
3307 }
3308 .repo-home-side-row:first-of-type { border-top: 0; padding-top: 0; }
3309 .repo-home-side-key {
3310 color: var(--text-muted);
3311 display: inline-flex;
3312 align-items: center;
3313 gap: 6px;
3314 }
3315 .repo-home-side-val {
3316 color: var(--text-strong);
3317 font-weight: 500;
3318 font-variant-numeric: tabular-nums;
3319 max-width: 60%;
3320 text-align: right;
3321 overflow: hidden;
3322 text-overflow: ellipsis;
3323 white-space: nowrap;
3324 }
3325 .repo-home-side-val a { color: var(--text-strong); }
3326 .repo-home-side-val a:hover { color: var(--accent); text-decoration: none; }
3327
3328 /* Clone / Code tabs */
3329 .repo-home-clone {
3330 background: var(--bg-elevated);
3331 border: 1px solid var(--border);
3332 border-radius: 12px;
3333 overflow: hidden;
3334 }
3335 .repo-home-clone-tabs {
3336 display: flex;
3337 gap: 0;
3338 background: var(--bg-secondary);
3339 border-bottom: 1px solid var(--border);
3340 padding: 0 var(--space-2);
3341 }
3342 .repo-home-clone-tab {
3343 appearance: none;
3344 background: transparent;
3345 border: 0;
3346 border-bottom: 2px solid transparent;
3347 padding: 9px 12px;
3348 font-size: 12px;
3349 font-weight: 500;
3350 color: var(--text-muted);
3351 cursor: pointer;
3352 transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
3353 font-family: inherit;
3354 margin-bottom: -1px;
3355 }
3356 .repo-home-clone-tab:hover { color: var(--text-strong); }
3357 .repo-home-clone-tab[aria-selected="true"] {
3358 color: var(--text-strong);
3359 border-bottom-color: var(--accent);
3360 }
3361 .repo-home-clone-body {
3362 padding: var(--space-3);
3363 display: flex;
3364 align-items: center;
3365 gap: var(--space-2);
3366 }
3367 .repo-home-clone-input {
3368 flex: 1;
3369 min-width: 0;
3370 font-family: var(--font-mono);
3371 font-size: 12px;
3372 background: var(--bg);
3373 border: 1px solid var(--border);
3374 border-radius: 8px;
3375 padding: 8px 10px;
3376 color: var(--text-strong);
3377 overflow: hidden;
3378 text-overflow: ellipsis;
3379 white-space: nowrap;
3380 }
3381 .repo-home-clone-copy {
3382 appearance: none;
3383 background: var(--bg-secondary);
3384 border: 1px solid var(--border);
3385 color: var(--text-strong);
3386 border-radius: 8px;
3387 padding: 8px 12px;
3388 font-size: 12px;
3389 font-weight: 600;
3390 cursor: pointer;
3391 transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
3392 font-family: inherit;
3393 }
3394 .repo-home-clone-copy:hover { background: var(--bg-hover); border-color: var(--border-strong, var(--border)); }
3395 .repo-home-clone-pane { display: none; }
3396 .repo-home-clone-pane[data-active="true"] { display: flex; }
3397
3398 /* README card */
3399 .repo-home-readme {
3400 margin-top: var(--space-5);
3401 background: var(--bg-elevated);
3402 border: 1px solid var(--border);
3403 border-radius: 12px;
3404 overflow: hidden;
3405 }
3406 .repo-home-readme-head {
3407 display: flex;
3408 align-items: center;
3409 gap: 8px;
3410 padding: 10px 16px;
3411 background: var(--bg-secondary);
3412 border-bottom: 1px solid var(--border);
3413 font-size: 13px;
3414 color: var(--text-muted);
3415 }
3416 .repo-home-readme-head .repo-home-readme-icon {
3417 color: var(--accent);
3418 font-size: 14px;
3419 }
3420 .repo-home-readme-body {
3421 padding: var(--space-5) var(--space-6);
3422 }
3423
3424 /* Empty-state CTA */
3425 .repo-home-empty {
3426 position: relative;
3427 margin-top: var(--space-4);
3428 background: var(--bg-elevated);
3429 border: 1px solid var(--border);
3430 border-radius: 16px;
3431 padding: var(--space-6);
3432 overflow: hidden;
3433 }
3434 .repo-home-empty::before {
3435 content: '';
3436 position: absolute;
3437 top: 0; left: 0; right: 0;
3438 height: 2px;
6fd5915Claude3439 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
544d842Claude3440 opacity: 0.7;
3441 pointer-events: none;
3442 }
3443 .repo-home-empty-eyebrow {
3444 font-size: 12px;
3445 font-family: var(--font-mono);
3446 color: var(--accent);
3447 letter-spacing: 0.12em;
3448 text-transform: uppercase;
3449 margin-bottom: var(--space-2);
3450 font-weight: 600;
3451 }
3452 .repo-home-empty-title {
3453 font-family: var(--font-display);
3454 font-weight: 800;
3455 letter-spacing: -0.025em;
3456 font-size: clamp(22px, 3vw, 30px);
3457 line-height: 1.1;
3458 margin: 0 0 var(--space-2);
3459 color: var(--text-strong);
3460 }
3461 .repo-home-empty-sub {
3462 color: var(--text-muted);
3463 font-size: 14px;
3464 line-height: 1.55;
3465 max-width: 640px;
3466 margin: 0 0 var(--space-4);
3467 }
3468 .repo-home-empty-snippet {
3469 background: var(--bg);
3470 border: 1px solid var(--border);
3471 border-radius: 10px;
3472 padding: var(--space-3) var(--space-4);
3473 font-family: var(--font-mono);
3474 font-size: 12.5px;
3475 line-height: 1.7;
3476 color: var(--text-strong);
3477 overflow-x: auto;
3478 white-space: pre;
3479 margin: 0;
3480 }
3481 .repo-home-empty-snippet .repo-home-cmt { color: var(--text-faint); }
3482 .repo-home-empty-snippet .repo-home-cmd { color: var(--accent); }
3483
91a0204Claude3484 /* Health score badge */
3485 .repo-health-badge {
3486 display: inline-flex;
3487 align-items: center;
3488 gap: 5px;
3489 padding: 3px 10px;
3490 border-radius: 999px;
3491 font-size: 11.5px;
3492 font-weight: 700;
3493 font-family: var(--font-mono);
3494 text-decoration: none;
3495 border: 1px solid transparent;
3496 transition: filter 120ms ease, opacity 120ms ease;
3497 vertical-align: middle;
3498 }
3499 .repo-health-badge:hover { filter: brightness(1.15); text-decoration: none; opacity: 0.9; }
3500 .repo-health-badge-elite {
3501 background: rgba(52,211,153,0.15);
e589f77ccantynz-alt3502 color: var(--green);
91a0204Claude3503 border-color: rgba(52,211,153,0.30);
3504 }
3505 .repo-health-badge-strong {
3506 background: rgba(96,165,250,0.15);
3507 color: #93c5fd;
3508 border-color: rgba(96,165,250,0.30);
3509 }
3510 .repo-health-badge-improving {
3511 background: rgba(251,191,36,0.15);
3512 color: #fde68a;
3513 border-color: rgba(251,191,36,0.30);
3514 }
3515 .repo-health-badge-needs-attention {
3516 background: rgba(248,113,113,0.15);
e589f77ccantynz-alt3517 color: var(--red);
91a0204Claude3518 border-color: rgba(248,113,113,0.30);
3519 }
3520
3521 /* Three-option empty-state panel */
3522 .repo-empty-options {
3523 display: grid;
3524 grid-template-columns: repeat(3, 1fr);
3525 gap: var(--space-3);
3526 margin-top: var(--space-5);
3527 }
3528 @media (max-width: 760px) {
3529 .repo-empty-options { grid-template-columns: 1fr; }
3530 }
3531 .repo-empty-option {
3532 position: relative;
3533 background: var(--bg-elevated);
3534 border: 1px solid var(--border);
3535 border-radius: 14px;
3536 padding: var(--space-4) var(--space-4);
3537 display: flex;
3538 flex-direction: column;
3539 gap: var(--space-2);
3540 overflow: hidden;
3541 transition: border-color 140ms ease, background 140ms ease;
3542 }
3543 .repo-empty-option:hover {
6fd5915Claude3544 border-color: rgba(91,110,232,0.45);
3545 background: rgba(91,110,232,0.04);
91a0204Claude3546 }
3547 .repo-empty-option::before {
3548 content: '';
3549 position: absolute;
3550 top: 0; left: 0; right: 0;
3551 height: 2px;
6fd5915Claude3552 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
91a0204Claude3553 opacity: 0.55;
3554 pointer-events: none;
3555 }
3556 .repo-empty-option-label {
3557 font-size: 10px;
3558 font-family: var(--font-mono);
3559 font-weight: 700;
3560 letter-spacing: 0.12em;
3561 text-transform: uppercase;
3562 color: var(--accent);
3563 margin-bottom: 2px;
3564 }
3565 .repo-empty-option-title {
3566 font-family: var(--font-display);
3567 font-weight: 700;
3568 font-size: 16px;
3569 letter-spacing: -0.01em;
3570 color: var(--text-strong);
3571 margin: 0;
3572 }
3573 .repo-empty-option-sub {
3574 font-size: 13px;
3575 color: var(--text-muted);
3576 line-height: 1.5;
3577 margin: 0;
3578 flex: 1;
3579 }
3580 .repo-empty-option-snippet {
3581 background: var(--bg);
3582 border: 1px solid var(--border);
3583 border-radius: 8px;
3584 padding: var(--space-2) var(--space-3);
3585 font-family: var(--font-mono);
3586 font-size: 11.5px;
3587 line-height: 1.75;
3588 color: var(--text-strong);
3589 overflow-x: auto;
3590 white-space: pre;
3591 margin: var(--space-1) 0 0;
3592 }
3593 .repo-empty-option-snippet .reo-cmt { color: var(--text-faint); }
3594 .repo-empty-option-snippet .reo-cmd { color: var(--accent); }
3595 .repo-empty-option-cta {
3596 display: inline-flex;
3597 align-items: center;
3598 gap: 6px;
3599 margin-top: auto;
3600 padding-top: var(--space-2);
3601 font-size: 13px;
3602 font-weight: 600;
3603 color: var(--accent);
3604 text-decoration: none;
3605 transition: color 120ms ease;
3606 }
3607 .repo-empty-option-cta:hover { color: var(--text-strong); text-decoration: none; }
3608
544d842Claude3609 @media (max-width: 720px) {
3610 .repo-home-hero { padding: var(--space-4) var(--space-4); }
3611 .repo-home-clone-body { flex-direction: column; align-items: stretch; }
3612 .repo-home-clone-copy { width: 100%; }
f1dc7c7Claude3613 .repo-home-stat-row { gap: var(--space-2) var(--space-3); font-size: 12.5px; }
3614 .repo-home-side-val { max-width: 55%; }
3615 .repo-home-clone-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
3616 .repo-home-clone-tab { min-height: 44px; padding: 11px 14px; }
3617 .repo-home-side-card { padding: var(--space-3); }
544d842Claude3618 }
ebaae0fClaude3619
3620 /* AI stats strip */
3621 .repo-ai-stats-strip {
3622 display: flex;
3623 align-items: center;
3624 gap: 6px;
3625 margin-top: 12px;
3626 margin-bottom: 4px;
3627 font-size: 12px;
3628 color: var(--text-muted);
3629 flex-wrap: wrap;
3630 }
3631 .repo-ai-stats-strip a {
3632 color: var(--text-muted);
3633 text-decoration: underline;
3634 text-decoration-color: transparent;
3635 transition: color 120ms ease, text-decoration-color 120ms ease;
3636 }
3637 .repo-ai-stats-strip a:hover {
3638 color: var(--accent);
3639 text-decoration-color: currentColor;
3640 }
3641 .repo-ai-stats-sep {
3642 opacity: 0.4;
3643 user-select: none;
3644 }
544d842Claude3645 `;
3646 const cloneHttpsUrl = `${config.appBaseUrl}/${owner}/${repo}.git`;
60323c5Claude3647 // SSH URL — port-aware:
3648 // Standard port 22 → git@host:owner/repo.git
3649 // Non-standard port → ssh://git@host:PORT/owner/repo.git
544d842Claude3650 let cloneSshUrl = `git@gluecron.com:${owner}/${repo}.git`;
3651 try {
3652 const host = new URL(config.appBaseUrl).hostname;
60323c5Claude3653 const sshHost = (host && host !== "localhost" && host !== "127.0.0.1")
3654 ? host
3655 : "localhost";
3656 const sshPort = config.sshPort;
3657 if (sshPort === 22) {
3658 cloneSshUrl = `git@${sshHost}:${owner}/${repo}.git`;
3659 } else {
3660 cloneSshUrl = `ssh://git@${sshHost}:${sshPort}/${owner}/${repo}.git`;
544d842Claude3661 }
3662 } catch {
3663 // Fall through to default.
3664 }
3665 const cloneCliCmd = `gluecron clone ${owner}/${repo}`;
3666 const formatRelative = (date: Date | null): string => {
3667 if (!date) return "never";
3668 const ms = Date.now() - date.getTime();
3669 const s = Math.max(0, Math.round(ms / 1000));
3670 if (s < 60) return "just now";
3671 const m = Math.round(s / 60);
3672 if (m < 60) return `${m} min ago`;
3673 const h = Math.round(m / 60);
3674 if (h < 24) return `${h}h ago`;
3675 const d = Math.round(h / 24);
3676 if (d < 30) return `${d}d ago`;
3677 const mo = Math.round(d / 30);
3678 if (mo < 12) return `${mo}mo ago`;
3679 const y = Math.round(d / 365);
3680 return `${y}y ago`;
3681 };
06d5ffeClaude3682
fc1817aClaude3683 if (tree.length === 0) {
5acce80Claude3684 const repoOgDesc = description
3685 ? `${owner}/${repo} on Gluecron — ${description}`
3686 : `${owner}/${repo} on Gluecron — AI-native git hosting with push-time gates and auto-merge.`;
fc1817aClaude3687 return c.html(
5acce80Claude3688 <Layout
3689 title={`${owner}/${repo}`}
3690 user={user}
3691 description={repoOgDesc}
3692 ogTitle={`${owner}/${repo} — Gluecron`}
3693 ogDescription={repoOgDesc}
3694 twitterCard="summary"
3695 >
544d842Claude3696 <style dangerouslySetInnerHTML={{ __html: repoHomeCss }} />
91a0204Claude3697 <style dangerouslySetInnerHTML={{ __html: `
3698 .empty-options-grid {
3699 display: grid;
3700 grid-template-columns: repeat(3, 1fr);
3701 gap: var(--space-4);
3702 margin-top: var(--space-4);
3703 }
3704 @media (max-width: 800px) {
3705 .empty-options-grid { grid-template-columns: 1fr; }
3706 }
3707 .empty-option-card {
3708 position: relative;
3709 background: var(--bg-elevated);
3710 border: 1px solid var(--border);
3711 border-radius: 14px;
3712 padding: var(--space-5);
3713 display: flex;
3714 flex-direction: column;
3715 gap: var(--space-3);
3716 overflow: hidden;
3717 transition: border-color 140ms ease, box-shadow 140ms ease;
3718 }
3719 .empty-option-card:hover {
6fd5915Claude3720 border-color: rgba(91,110,232,0.45);
3721 box-shadow: 0 8px 24px -8px rgba(91,110,232,0.18);
91a0204Claude3722 }
3723 .empty-option-card::before {
3724 content: '';
3725 position: absolute;
3726 top: 0; left: 0; right: 0;
3727 height: 2px;
6fd5915Claude3728 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
91a0204Claude3729 opacity: 0.55;
3730 pointer-events: none;
3731 }
3732 .empty-option-label {
3733 font-size: 10.5px;
3734 font-family: var(--font-mono);
3735 text-transform: uppercase;
3736 letter-spacing: 0.14em;
3737 color: var(--accent);
3738 font-weight: 700;
3739 }
3740 .empty-option-title {
3741 font-family: var(--font-display);
3742 font-weight: 700;
3743 font-size: 17px;
3744 letter-spacing: -0.01em;
3745 color: var(--text-strong);
3746 margin: 0;
3747 line-height: 1.25;
3748 }
3749 .empty-option-body {
3750 font-size: 13px;
3751 color: var(--text-muted);
3752 line-height: 1.55;
3753 margin: 0;
3754 flex: 1;
3755 }
3756 .empty-option-snippet {
3757 background: var(--bg);
3758 border: 1px solid var(--border);
3759 border-radius: 8px;
3760 padding: var(--space-3) var(--space-4);
3761 font-family: var(--font-mono);
3762 font-size: 11.5px;
3763 line-height: 1.75;
3764 color: var(--text-strong);
3765 overflow-x: auto;
3766 white-space: pre;
3767 margin: 0;
3768 }
3769 .empty-option-snippet .ec { color: var(--text-faint); }
3770 .empty-option-snippet .em { color: var(--accent); }
3771 ` }} />
f6730d0ccantynz-alt3772 <style dangerouslySetInnerHTML={{ __html: sharedComponentStyles }} />
544d842Claude3773 <div class="repo-home-hero">
3774 <div class="repo-home-hero-orb-wrap" aria-hidden="true">
3775 <div class="repo-home-hero-orb" />
3776 </div>
3777 <div class="repo-home-hero-inner">
3778 <div class="repo-home-eyebrow">
3779 <strong>Repository</strong> · {owner}
3780 </div>
91a0204Claude3781 <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;">
3782 <RepoHeader
3783 owner={owner}
3784 repo={repo}
3785 starCount={starCount}
3786 starred={starred}
3787 forkCount={forkCount}
3788 currentUser={user?.username}
3789 archived={archived}
3790 isTemplate={isTemplate}
8c790e0Claude3791 recentPush={recentPush}
91a0204Claude3792 />
3793 {healthScore && (() => {
3794 const gradeLabel: Record<string, string> = {
3795 elite: "Elite", strong: "Strong",
3796 improving: "Improving", "needs-attention": "Needs Attention",
3797 };
3798 return (
3799 <a
3800 href={`/${owner}/${repo}/insights/health`}
3801 class={`repo-health-badge repo-health-badge-${healthScore!.grade}`}
3802 title={`Health score: ${healthScore!.total}/100`}
3803 >
3804 {gradeLabel[healthScore!.grade] ?? healthScore!.grade}
3805 </a>
3806 );
3807 })()}
3808 </div>
544d842Claude3809 {description ? (
3810 <p class="repo-home-description">{description}</p>
3811 ) : (
3812 <p class="repo-home-description-empty">
3813 No description yet — push a README to tell the world what this
3814 ships.
3815 </p>
3816 )}
3817 </div>
3818 </div>
fc1817aClaude3819 <RepoNav owner={owner} repo={repo} active="code" />
91a0204Claude3820 <div style="margin-top:var(--space-4)">
3821 <div style="font-size:12px;font-family:var(--font-mono);color:var(--accent);letter-spacing:0.12em;text-transform:uppercase;font-weight:600;margin-bottom:var(--space-2)">
3822 Getting started
3823 </div>
544d842Claude3824 <h2 class="repo-home-empty-title">
91a0204Claude3825 <span class="gradient-text">{repo}</span> is ready — make your first move.
544d842Claude3826 </h2>
3827 <p class="repo-home-empty-sub">
91a0204Claude3828 Choose how you want to kick things off. Every push wires up gate
3829 checks and AI review automatically.
544d842Claude3830 </p>
91a0204Claude3831 <div class="empty-options-grid">
3832 <div class="empty-option-card">
3833 <div class="empty-option-label">Option A</div>
3834 <h3 class="empty-option-title">Push your first commit</h3>
3835 <p class="empty-option-body">
3836 Wire up an existing project in seconds. Run these commands from
3837 your project directory.
3838 </p>
3839 <pre class="empty-option-snippet"><span class="ec"># from your project directory</span>
3840<span class="em">git remote add</span> origin {cloneHttpsUrl}
3841<span class="em">git branch</span> -M main
3842<span class="em">git push</span> -u origin main</pre>
3843 </div>
3844 <div class="empty-option-card">
3845 <div class="empty-option-label">Option B</div>
3846 <h3 class="empty-option-title">Import from GitHub</h3>
3847 <p class="empty-option-body">
3848 Mirror an existing GitHub repository here in one click. Gluecron
3849 syncs the full history and branches.
3850 </p>
f6730d0ccantynz-alt3851 <Button href="/import" variant="secondary" style="align-self:flex-start">
91a0204Claude3852 Import repository
f6730d0ccantynz-alt3853 </Button>
91a0204Claude3854 </div>
3855 <div class="empty-option-card">
3856 <div class="empty-option-label">Option C</div>
3857 <h3 class="empty-option-title">Try Spec-to-PR</h3>
3858 <p class="empty-option-body">
3859 Let AI write your first feature. Describe what you want to build
3860 and Gluecron opens a pull request with the code.
3861 </p>
f6730d0ccantynz-alt3862 <Button href={`/${owner}/${repo}/specs`} variant="primary" style="align-self:flex-start">
91a0204Claude3863 Let AI write your first feature
f6730d0ccantynz-alt3864 </Button>
91a0204Claude3865 </div>
3866 </div>
fc1817aClaude3867 </div>
3868 </Layout>
3869 );
3870 }
3871
3872 const readme = await getReadme(owner, repo, defaultBranch);
3873
544d842Claude3874 // Sidebar facts — derived from data we already have.
3875 const fileCount = tree.filter((e: any) => e.type !== "tree").length;
3876 const dirCount = tree.filter((e: any) => e.type === "tree").length;
3877
5acce80Claude3878 const repoOgDesc = description
3879 ? `${owner}/${repo} on Gluecron — ${description}`
3880 : `${owner}/${repo} on Gluecron — AI-native git hosting with push-time gates and auto-merge.`;
3881
fc1817aClaude3882 return c.html(
5acce80Claude3883 <Layout
3884 title={`${owner}/${repo}`}
3885 user={user}
3886 description={repoOgDesc}
3887 ogTitle={`${owner}/${repo} — Gluecron`}
3888 ogDescription={repoOgDesc}
3889 twitterCard="summary"
3890 >
544d842Claude3891 <style dangerouslySetInnerHTML={{ __html: repoHomeCss }} />
641aa42Claude3892 {/* Repo-context commands for the command palette (Feature 2) */}
3893 <script
3894 id="cmdk-repo-context"
3895 dangerouslySetInnerHTML={{
3896 __html: `window.__CMDK_REPO_COMMANDS = ${JSON.stringify([
3897 { label: `New issue in ${repo}`, href: `/${owner}/${repo}/issues/new`, kw: "create add bug" },
3898 { label: `New pull request in ${repo}`, href: `/${owner}/${repo}/pulls/new`, kw: "pr branch merge" },
3899 { label: `Browse code — ${owner}/${repo}`, href: `/${owner}/${repo}`, kw: "files tree" },
3900 { label: `View commits — ${owner}/${repo}`, href: `/${owner}/${repo}/commits`, kw: "history log" },
3901 { label: `Search code — ${owner}/${repo}`, href: `/${owner}/${repo}/search`, kw: "grep find" },
3902 { label: `AI explain codebase — ${owner}/${repo}`, href: `/${owner}/${repo}/explain`, kw: "understand" },
3903 { label: `Debt map — ${owner}/${repo}`, href: `/${owner}/${repo}/debt-map`, kw: "technical debt" },
3904 { label: `Repo settings — ${owner}/${repo}`, href: `/${owner}/${repo}/settings`, kw: "config" },
3905 { label: `Issues — ${owner}/${repo}`, href: `/${owner}/${repo}/issues`, kw: "bugs tasks" },
3906 { label: `Pull requests — ${owner}/${repo}`, href: `/${owner}/${repo}/pulls`, kw: "prs reviews" },
3907 ])};`,
3908 }}
3909 />
544d842Claude3910 <div class="repo-home-hero">
3911 <div class="repo-home-hero-orb-wrap" aria-hidden="true">
3912 <div class="repo-home-hero-orb" />
3913 </div>
3914 <div class="repo-home-hero-inner">
3915 <div class="repo-home-eyebrow">
3916 <strong>Repository</strong> · {owner}
3917 </div>
91a0204Claude3918 <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;">
3919 <RepoHeader
3920 owner={owner}
3921 repo={repo}
3922 starCount={starCount}
3923 starred={starred}
3924 forkCount={forkCount}
3925 currentUser={user?.username}
3926 archived={archived}
3927 isTemplate={isTemplate}
8c790e0Claude3928 recentPush={recentPush}
91a0204Claude3929 />
3930 {healthScore && (() => {
3931 const gradeLabel: Record<string, string> = {
3932 elite: "Elite", strong: "Strong",
3933 improving: "Improving", "needs-attention": "Needs Attention",
3934 };
3935 return (
3936 <a
3937 href={`/${owner}/${repo}/insights/health`}
3938 class={`repo-health-badge repo-health-badge-${healthScore!.grade}`}
3939 title={`Health score: ${healthScore!.total}/100`}
3940 >
3941 {gradeLabel[healthScore!.grade] ?? healthScore!.grade}
3942 </a>
3943 );
3944 })()}
3945 </div>
544d842Claude3946 {description ? (
3947 <p class="repo-home-description">{description}</p>
3948 ) : (
3949 <p class="repo-home-description-empty">
3950 No description yet.
3951 </p>
3952 )}
3953 <div class="repo-home-stat-row" aria-label="Repository stats">
3954 <span class="repo-home-stat" title="Default branch">
3955 <span class="repo-home-stat-icon">{"⎇"}</span>
3956 <strong>{defaultBranch}</strong>
3957 </span>
3958 <a
3959 href={`/${owner}/${repo}/commits/${defaultBranch}`}
3960 class="repo-home-stat"
3961 title="Browse all branches"
3962 >
3963 <span class="repo-home-stat-icon">{"⊢"}</span>
3964 <strong>{branches.length}</strong>{" "}
3965 branch{branches.length === 1 ? "" : "es"}
3966 </a>
3967 <span class="repo-home-stat" title="Top-level entries">
3968 <span class="repo-home-stat-icon">{"■"}</span>
3969 <strong>{fileCount}</strong> file{fileCount === 1 ? "" : "s"}
3970 {dirCount > 0 && (
3971 <>
3972 {" · "}
3973 <strong>{dirCount}</strong> dir{dirCount === 1 ? "" : "s"}
3974 </>
3975 )}
3976 </span>
3977 {pushedAt && (
3978 <span class="repo-home-stat" title={`Last push: ${pushedAt.toISOString()}`}>
3979 <span class="repo-home-stat-icon">{"↻"}</span>
3980 Updated <strong>{formatRelative(pushedAt)}</strong>
3981 </span>
3982 )}
3983 </div>
3984 </div>
3985 </div>
71cd5ecClaude3986 {isTemplate && user && user.username !== owner && (
3987 <div
3988 class="panel"
dc26881CC LABS App3989 style="margin-bottom:var(--space-4);padding:var(--space-3);display:flex;align-items:center;justify-content:space-between;gap:var(--space-3)"
71cd5ecClaude3990 >
3991 <div style="font-size:13px">
3992 <strong>Template repository.</strong> Create a new repository from
3993 this template's files.
3994 </div>
3995 <form
001af43Claude3996 method="post"
71cd5ecClaude3997 action={`/${owner}/${repo}/use-template`}
dc26881CC LABS App3998 style="display:flex;gap:var(--space-2);align-items:center"
71cd5ecClaude3999 >
4000 <input
4001 type="text"
4002 name="name"
4003 placeholder="new-repo-name"
4004 required
2c3ba6ecopilot-swe-agent[bot]4005 aria-label="New repository name"
71cd5ecClaude4006 style="width:200px"
4007 />
4008 <button type="submit" class="btn btn-primary">
4009 Use this template
4010 </button>
4011 </form>
4012 </div>
4013 )}
fc1817aClaude4014 <RepoNav owner={owner} repo={repo} active="code" />
cb5a796Claude4015 <RepoHomePendingBanner
4016 owner={owner}
4017 repo={repo}
4018 count={repoHomePendingCount}
4019 />
641aa42Claude4020 {showOnboarding && onboardingRow && (
4021 <RepoOnboardingCard
4022 owner={owner}
4023 repo={repo}
4024 data={onboardingRow}
4025 />
4026 )}
c6018a5Claude4027 {/* ─── Per-repo AI surfaces — RepoNav is locked, so the discovery
4028 row sits just below the nav as a slim CTA strip. Scoped under
4029 `.repo-ai-cta-` so the styles can't bleed onto other pages. ─── */}
4030 <style
4031 dangerouslySetInnerHTML={{
4032 __html: `
4033 .repo-ai-cta-row {
4034 display: flex;
4035 flex-wrap: wrap;
4036 gap: 8px;
4037 margin: 12px 0 18px;
4038 padding: 10px 14px;
6fd5915Claude4039 background: linear-gradient(135deg, rgba(91,110,232,0.06), rgba(95,143,160,0.04));
c6018a5Claude4040 border: 1px solid var(--border);
4041 border-radius: 10px;
4042 position: relative;
4043 overflow: hidden;
4044 }
4045 .repo-ai-cta-row::before {
4046 content: '';
4047 position: absolute;
4048 top: 0; left: 0; right: 0;
4049 height: 1px;
6fd5915Claude4050 background: linear-gradient(90deg, transparent 0%, rgba(91,110,232,0.45) 30%, rgba(95,143,160,0.45) 70%, transparent 100%);
c6018a5Claude4051 opacity: 0.7;
4052 pointer-events: none;
4053 }
4054 .repo-ai-cta-label {
4055 font-size: 11px;
4056 font-weight: 600;
4057 letter-spacing: 0.06em;
4058 text-transform: uppercase;
4059 color: var(--accent);
4060 align-self: center;
4061 padding-right: 8px;
4062 border-right: 1px solid var(--border);
4063 margin-right: 4px;
4064 }
4065 .repo-ai-cta {
4066 display: inline-flex;
4067 align-items: center;
4068 gap: 6px;
4069 padding: 5px 10px;
4070 font-size: 12.5px;
4071 font-weight: 500;
4072 color: var(--text);
4073 background: var(--bg);
4074 border: 1px solid var(--border);
4075 border-radius: 7px;
4076 text-decoration: none;
4077 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
4078 }
4079 .repo-ai-cta:hover {
6fd5915Claude4080 border-color: rgba(91,110,232,0.45);
c6018a5Claude4081 color: var(--text-strong);
6fd5915Claude4082 background: rgba(91,110,232,0.06);
c6018a5Claude4083 text-decoration: none;
4084 }
4085 .repo-ai-cta-icon {
4086 opacity: 0.75;
4087 font-size: 12px;
4088 }
4089 @media (max-width: 640px) {
4090 .repo-ai-cta-row { flex-direction: column; align-items: stretch; }
4091 .repo-ai-cta-label { border-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-right: 0; }
4092 }
4093 `,
4094 }}
4095 />
4096 <nav class="repo-ai-cta-row" aria-label="AI surfaces for this repository">
4097 <span class="repo-ai-cta-label">AI surfaces</span>
4098 <a class="repo-ai-cta" href={`/${owner}/${repo}/chat`} title="Rubber-duck chat grounded in this repo">
4099 <span class="repo-ai-cta-icon" aria-hidden="true">{"\u{1F4AC}"}</span>
4100 Chat
4101 </a>
4102 <a class="repo-ai-cta" href={`/${owner}/${repo}/previews`} title="Ephemeral preview URLs per branch">
4103 <span class="repo-ai-cta-icon" aria-hidden="true">{"\u{1F30D}"}</span>
4104 Previews
4105 </a>
4106 <a class="repo-ai-cta" href={`/${owner}/${repo}/migrations/propose`} title="AI proposes the Drizzle migration for a schema change">
4107 <span class="repo-ai-cta-icon" aria-hidden="true">{"⛁"}</span>
4108 Migrations
4109 </a>
53c9249Claude4110 <a class="repo-ai-cta" href={`/${owner}/${repo}/search?mode=semantic`} title="AI-powered semantic code search — ask in plain English">
c6018a5Claude4111 <span class="repo-ai-cta-icon" aria-hidden="true">{"✨"}</span>
53c9249Claude4112 AI Search
c6018a5Claude4113 </a>
4114 <a class="repo-ai-cta" href={`/${owner}/${repo}/releases/new`} title="Draft release notes with AI">
4115 <span class="repo-ai-cta-icon" aria-hidden="true">{"\u{1F3F7}"}</span>
4116 AI release notes
4117 </a>
3646bfeClaude4118 <a class="repo-ai-cta" href={`/${owner}/${repo}/dev`} title="Open a hosted VS Code dev environment in the browser">
4119 <span class="repo-ai-cta-icon" aria-hidden="true">{"💻"}</span>
4120 Dev environment
4121 </a>
c6018a5Claude4122 </nav>
544d842Claude4123 <div class="repo-home-grid">
4124 <div class="repo-home-main">
4125 <BranchSwitcher
4126 owner={owner}
4127 repo={repo}
4128 currentRef={defaultBranch}
4129 branches={branches}
4130 pathType="tree"
4131 />
4132 <FileTable
4133 entries={tree}
4134 owner={owner}
4135 repo={repo}
4136 ref={defaultBranch}
4137 path=""
4138 />
ebaae0fClaude4139 {/* AI stats strip — one-line summary of AI value for this repo */}
4140 {(aiStats.mergedCount > 0 || aiStats.reviewCount > 0 || aiStats.securityAlertCount > 0) ? (
4141 <div class="repo-ai-stats-strip" aria-label="AI activity summary for this week">
4142 <span>{"⚡"}</span>
4143 {aiStats.mergedCount > 0 ? (
4144 <a href={`/${owner}/${repo}/pulls?state=merged`}>
4145 AI merged {aiStats.mergedCount} PR{aiStats.mergedCount === 1 ? "" : "s"} this week
4146 </a>
4147 ) : (
4148 <span>0 AI merges this week</span>
4149 )}
4150 <span class="repo-ai-stats-sep">{"·"}</span>
4151 <span>Saved ~{aiStats.hoursSaved} hrs</span>
4152 <span class="repo-ai-stats-sep">{"·"}</span>
4153 {aiStats.securityAlertCount > 0 ? (
4154 <a href={`/${owner}/${repo}/issues?label=security`}>
4155 {aiStats.securityAlertCount} open security alert{aiStats.securityAlertCount === 1 ? "" : "s"}
4156 </a>
4157 ) : (
4158 <span>0 open security alerts</span>
4159 )}
4160 </div>
4161 ) : (
4162 <div class="repo-ai-stats-strip" aria-label="AI activity summary for this week">
4163 <span>{"⚡"}</span>
4164 <span>AI is watching — no activity this week</span>
4165 </div>
4166 )}
544d842Claude4167 {readme && (() => {
4168 const readmeHtml = renderMarkdown(readme);
4169 return (
4170 <div class="repo-home-readme">
4171 <div class="repo-home-readme-head">
4172 <span class="repo-home-readme-icon">{"☰"}</span>
4173 <span>README.md</span>
4174 </div>
4175 <style>{markdownCss}</style>
4176 <div class="markdown-body repo-home-readme-body">
4177 {html([readmeHtml] as unknown as TemplateStringsArray)}
4178 </div>
4179 </div>
4180 );
4181 })()}
4182 </div>
4183 <aside class="repo-home-side" aria-label="Repository details">
4184 <div class="repo-home-clone">
4185 <div class="repo-home-clone-tabs" role="tablist" aria-label="Clone protocol">
4186 <button
4187 type="button"
4188 class="repo-home-clone-tab"
4189 role="tab"
4190 aria-selected="true"
4191 data-pane="https"
4192 data-repo-home-clone-tab
4193 >
4194 HTTPS
4195 </button>
4196 <button
4197 type="button"
4198 class="repo-home-clone-tab"
4199 role="tab"
4200 aria-selected="false"
4201 data-pane="ssh"
4202 data-repo-home-clone-tab
4203 >
4204 SSH
4205 </button>
4206 <button
4207 type="button"
4208 class="repo-home-clone-tab"
4209 role="tab"
4210 aria-selected="false"
4211 data-pane="cli"
4212 data-repo-home-clone-tab
4213 >
4214 CLI
4215 </button>
4216 </div>
4217 <div
4218 class="repo-home-clone-pane"
4219 data-pane="https"
4220 data-active="true"
4221 role="tabpanel"
4222 >
4223 <div class="repo-home-clone-body">
4224 <input
4225 class="repo-home-clone-input"
4226 type="text"
4227 value={cloneHttpsUrl}
4228 readonly
4229 aria-label="HTTPS clone URL"
4230 data-repo-home-clone-input
4231 />
4232 <button
4233 type="button"
4234 class="repo-home-clone-copy"
4235 data-repo-home-copy={cloneHttpsUrl}
4236 >
4237 Copy
4238 </button>
4239 </div>
4240 </div>
4241 <div
4242 class="repo-home-clone-pane"
4243 data-pane="ssh"
4244 data-active="false"
4245 role="tabpanel"
4246 >
4247 <div class="repo-home-clone-body">
4248 <input
4249 class="repo-home-clone-input"
4250 type="text"
4251 value={cloneSshUrl}
4252 readonly
4253 aria-label="SSH clone URL"
4254 data-repo-home-clone-input
4255 />
4256 <button
4257 type="button"
4258 class="repo-home-clone-copy"
4259 data-repo-home-copy={cloneSshUrl}
4260 >
4261 Copy
4262 </button>
4263 </div>
4264 </div>
4265 <div
4266 class="repo-home-clone-pane"
4267 data-pane="cli"
4268 data-active="false"
4269 role="tabpanel"
4270 >
4271 <div class="repo-home-clone-body">
4272 <input
4273 class="repo-home-clone-input"
4274 type="text"
4275 value={cloneCliCmd}
4276 readonly
4277 aria-label="Gluecron CLI clone command"
4278 data-repo-home-clone-input
4279 />
4280 <button
4281 type="button"
4282 class="repo-home-clone-copy"
4283 data-repo-home-copy={cloneCliCmd}
4284 >
4285 Copy
4286 </button>
4287 </div>
79136bbClaude4288 </div>
fc1817aClaude4289 </div>
544d842Claude4290 <div class="repo-home-side-card">
4291 <h3 class="repo-home-side-title">About</h3>
4292 <div class="repo-home-side-row">
4293 <span class="repo-home-side-key">Default branch</span>
4294 <span class="repo-home-side-val">{defaultBranch}</span>
4295 </div>
4296 <div class="repo-home-side-row">
4297 <span class="repo-home-side-key">Branches</span>
4298 <span class="repo-home-side-val">
4299 <a href={`/${owner}/${repo}/commits/${defaultBranch}`}>
4300 {branches.length}
4301 </a>
4302 </span>
4303 </div>
4304 <div class="repo-home-side-row">
4305 <span class="repo-home-side-key">Stars</span>
4306 <span class="repo-home-side-val">{starCount}</span>
4307 </div>
4308 <div class="repo-home-side-row">
4309 <span class="repo-home-side-key">Forks</span>
4310 <span class="repo-home-side-val">{forkCount}</span>
4311 </div>
4312 {pushedAt && (
4313 <div class="repo-home-side-row">
4314 <span class="repo-home-side-key">Last push</span>
4315 <span class="repo-home-side-val">
4316 {formatRelative(pushedAt)}
4317 </span>
4318 </div>
4319 )}
4320 {createdAt && (
4321 <div class="repo-home-side-row">
4322 <span class="repo-home-side-key">Created</span>
4323 <span class="repo-home-side-val">
4324 {formatRelative(createdAt)}
4325 </span>
4326 </div>
4327 )}
4328 {(archived || isTemplate) && (
4329 <div class="repo-home-side-row">
4330 <span class="repo-home-side-key">State</span>
4331 <span class="repo-home-side-val">
4332 {archived ? "Archived" : "Template"}
4333 </span>
4334 </div>
4335 )}
4336 </div>
f1dc38bClaude4337 {/* Claude AI — quick-access card for authenticated users */}
4338 {user && (
4339 <div class="repo-home-side-card" style="margin-top:12px">
4340 <h3 class="repo-home-side-title" style="margin-bottom:10px">
4341 ✨ Claude AI
4342 </h3>
4343 <a
4344 href={`/${owner}/${repo}/claude`}
e589f77ccantynz-alt4345 style="display:block;background:var(--accent);color:#fff;text-align:center;padding:8px 14px;border-radius:6px;text-decoration:none;font-size:14px;font-weight:600;margin-bottom:8px"
f1dc38bClaude4346 >
4347 Claude Code sessions
4348 </a>
4349 <a
4350 href={`/${owner}/${repo}/ask`}
4351 style="display:block;color:#9ca3af;text-align:center;padding:6px 14px;border-radius:6px;text-decoration:none;font-size:13px;border:1px solid #1f2937"
4352 >
4353 Ask AI about this repo
4354 </a>
4355 </div>
4356 )}
544d842Claude4357 </aside>
4358 </div>
4359 <script
4360 dangerouslySetInnerHTML={{
4361 __html: `
4362 (function(){
4363 var tabs = document.querySelectorAll('[data-repo-home-clone-tab]');
4364 tabs.forEach(function(tab){
4365 tab.addEventListener('click', function(){
4366 var target = tab.getAttribute('data-pane');
4367 tabs.forEach(function(t){
4368 t.setAttribute('aria-selected', t === tab ? 'true' : 'false');
4369 });
4370 var panes = document.querySelectorAll('.repo-home-clone-pane');
4371 panes.forEach(function(p){
4372 p.setAttribute('data-active', p.getAttribute('data-pane') === target ? 'true' : 'false');
4373 });
4374 });
4375 });
4376 var copyBtns = document.querySelectorAll('[data-repo-home-copy]');
4377 copyBtns.forEach(function(btn){
4378 btn.addEventListener('click', function(){
4379 var text = btn.getAttribute('data-repo-home-copy') || '';
4380 var done = function(){
4381 var prev = btn.textContent;
4382 btn.textContent = 'Copied';
4383 setTimeout(function(){ btn.textContent = prev; }, 1200);
4384 };
4385 if (navigator.clipboard && navigator.clipboard.writeText) {
4386 navigator.clipboard.writeText(text).then(done, done);
4387 } else {
4388 var ta = document.createElement('textarea');
4389 ta.value = text;
4390 document.body.appendChild(ta);
4391 ta.select();
4392 try { document.execCommand('copy'); } catch (e) {}
4393 document.body.removeChild(ta);
4394 done();
4395 }
4396 });
4397 });
4398 })();
4399 `,
4400 }}
4401 />
fc1817aClaude4402 </Layout>
4403 );
4404});
4405
4406// Browse tree at ref/path
4407web.get("/:owner/:repo/tree/:ref{.+$}", async (c) => {
4408 const { owner, repo } = c.req.param();
06d5ffeClaude4409 const user = c.get("user");
5bb52faccanty labs4410 const gate = await assertRepoReadable(c, owner, repo);
4411 if (gate) return gate;
fc1817aClaude4412 const refAndPath = c.req.param("ref");
4413
4414 const branches = await listBranches(owner, repo);
4415 let ref = "";
4416 let treePath = "";
4417
4418 for (const branch of branches) {
4419 if (refAndPath === branch || refAndPath.startsWith(branch + "/")) {
4420 ref = branch;
4421 treePath = refAndPath.slice(branch.length + 1);
4422 break;
4423 }
4424 }
4425
4426 if (!ref) {
4427 const slashIdx = refAndPath.indexOf("/");
4428 if (slashIdx === -1) {
4429 ref = refAndPath;
4430 } else {
4431 ref = refAndPath.slice(0, slashIdx);
4432 treePath = refAndPath.slice(slashIdx + 1);
4433 }
4434 }
4435
4436 const tree = await getTree(owner, repo, ref, treePath);
efb11c5Claude4437 const fileCount = tree.filter((e: any) => e.type !== "tree").length;
4438 const dirCount = tree.filter((e: any) => e.type === "tree").length;
fc1817aClaude4439
4440 return c.html(
06d5ffeClaude4441 <Layout title={`${treePath || "/"} — ${owner}/${repo}`} user={user}>
efb11c5Claude4442 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude4443 <RepoHeader owner={owner} repo={repo} />
4444 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude4445 <div class="tree-header">
4446 <div class="tree-header-row">
4447 <BranchSwitcher
4448 owner={owner}
4449 repo={repo}
4450 currentRef={ref}
4451 branches={branches}
4452 pathType="tree"
4453 subPath={treePath}
4454 />
4455 <div class="tree-header-stats">
4456 <span class="tree-stat" title="Entries in this directory">
4457 <strong>{fileCount}</strong> file{fileCount === 1 ? "" : "s"}
4458 {dirCount > 0 && (
4459 <>
4460 {" · "}
4461 <strong>{dirCount}</strong> dir{dirCount === 1 ? "" : "s"}
4462 </>
4463 )}
4464 </span>
4465 <a
4466 href={`/${owner}/${repo}/search`}
4467 class="tree-stat tree-stat-link"
4468 title="Search code in this repository"
4469 >
4470 {"⌕"} Search
4471 </a>
4472 </div>
4473 </div>
4474 <div class="tree-breadcrumb-row">
4475 <Breadcrumb owner={owner} repo={repo} ref={ref} path={treePath} />
4476 </div>
4477 </div>
fc1817aClaude4478 <FileTable
4479 entries={tree}
4480 owner={owner}
4481 repo={repo}
4482 ref={ref}
4483 path={treePath}
4484 />
4485 </Layout>
4486 );
4487});
4488
06d5ffeClaude4489// View file blob with syntax highlighting
fc1817aClaude4490web.get("/:owner/:repo/blob/:ref{.+$}", async (c) => {
4491 const { owner, repo } = c.req.param();
06d5ffeClaude4492 const user = c.get("user");
5bb52faccanty labs4493 const gate = await assertRepoReadable(c, owner, repo);
4494 if (gate) return gate;
fc1817aClaude4495 const refAndPath = c.req.param("ref");
4496
4497 const branches = await listBranches(owner, repo);
4498 let ref = "";
4499 let filePath = "";
4500
4501 for (const branch of branches) {
4502 if (refAndPath.startsWith(branch + "/")) {
4503 ref = branch;
4504 filePath = refAndPath.slice(branch.length + 1);
4505 break;
4506 }
4507 }
4508
4509 if (!ref) {
4510 const slashIdx = refAndPath.indexOf("/");
4511 if (slashIdx === -1) return c.text("Not found", 404);
4512 ref = refAndPath.slice(0, slashIdx);
4513 filePath = refAndPath.slice(slashIdx + 1);
4514 }
4515
4516 const blob = await getBlob(owner, repo, ref, filePath);
4517 if (!blob) {
4518 return c.html(
06d5ffeClaude4519 <Layout title="Not Found" user={user}>
fc1817aClaude4520 <div class="empty-state">
4521 <h2>File not found</h2>
4522 </div>
4523 </Layout>,
4524 404
4525 );
4526 }
4527
06d5ffeClaude4528 const fileName = filePath.split("/").pop() || filePath;
efb11c5Claude4529 const lineCount = blob.isBinary
4530 ? 0
4531 : (blob.content.endsWith("\n")
4532 ? blob.content.split("\n").length - 1
4533 : blob.content.split("\n").length);
4534 const formatBytes = (n: number): string => {
4535 if (n < 1024) return `${n} B`;
4536 if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
4537 return `${(n / (1024 * 1024)).toFixed(1)} MB`;
4538 };
fc1817aClaude4539
4540 return c.html(
06d5ffeClaude4541 <Layout title={`${filePath} — ${owner}/${repo}`} user={user}>
efb11c5Claude4542 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude4543 <RepoHeader owner={owner} repo={repo} />
4544 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude4545 <div class="blob-toolbar">
4546 <BranchSwitcher
4547 owner={owner}
4548 repo={repo}
4549 currentRef={ref}
4550 branches={branches}
4551 pathType="blob"
4552 subPath={filePath}
4553 />
4554 <div class="blob-breadcrumb">
4555 <Breadcrumb owner={owner} repo={repo} ref={ref} path={filePath} />
4556 </div>
4557 </div>
4558 <div class="blob-view blob-card">
4559 <div class="blob-header blob-header-polished">
4560 <div class="blob-header-meta">
4561 <span class="blob-header-icon" aria-hidden="true">
4562 {"📄"}
4563 </span>
4564 <span class="blob-header-name">{fileName}</span>
4565 <span class="blob-header-size">
4566 {formatBytes(blob.size)}
4567 {!blob.isBinary && (
4568 <>
4569 {" · "}
4570 {lineCount} line{lineCount === 1 ? "" : "s"}
4571 </>
4572 )}
4573 </span>
4574 </div>
4575 <div class="blob-header-actions">
4576 <a
4577 href={`/${owner}/${repo}/raw/${ref}/${filePath}`}
4578 class="blob-pill"
4579 >
79136bbClaude4580 Raw
4581 </a>
efb11c5Claude4582 <a
4583 href={`/${owner}/${repo}/blame/${ref}/${filePath}`}
4584 class="blob-pill"
4585 >
79136bbClaude4586 Blame
4587 </a>
efb11c5Claude4588 <a
4589 href={`/${owner}/${repo}/timeline/${ref}/${filePath}`}
4590 class="blob-pill"
4591 >
16b325cClaude4592 History
4593 </a>
0074234Claude4594 {user && (
efb11c5Claude4595 <a
4596 href={`/${owner}/${repo}/edit/${ref}/${filePath}`}
4597 class="blob-pill blob-pill-accent"
4598 >
0074234Claude4599 Edit
4600 </a>
4601 )}
efb11c5Claude4602 </div>
fc1817aClaude4603 </div>
4604 {blob.isBinary ? (
efb11c5Claude4605 <div class="blob-binary">
fc1817aClaude4606 Binary file not shown.
4607 </div>
06d5ffeClaude4608 ) : (() => {
4609 const { html: highlighted, language } = highlightCode(
4610 blob.content,
4611 fileName
4612 );
4613 if (language) {
4614 return (
4615 <HighlightedCode
4616 highlightedHtml={highlighted}
efb11c5Claude4617 lineCount={lineCount}
06d5ffeClaude4618 />
4619 );
4620 }
4621 const lines = blob.content.split("\n");
4622 if (lines[lines.length - 1] === "") lines.pop();
4623 return <PlainCode lines={lines} />;
4624 })()}
fc1817aClaude4625 </div>
4626 </Layout>
4627 );
4628});
4629
398a10cClaude4630// ─── Branches list ────────────────────────────────────────────────────────
4631// Lightweight `git for-each-ref` enrichment so each row shows last-commit
4632// author + relative time + ahead/behind vs the default branch. No DB. All
4633// data comes from git plumbing; failures degrade gracefully (counts omitted).
4634web.get("/:owner/:repo/branches", async (c) => {
4635 const { owner, repo } = c.req.param();
4636 const user = c.get("user");
5bb52faccanty labs4637 const gate = await assertRepoReadable(c, owner, repo);
4638 if (gate) return gate;
398a10cClaude4639
4640 if (!(await repoExists(owner, repo))) return c.notFound();
4641
4642 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
4643 const branches = await listBranches(owner, repo);
4644 const repoDir = getRepoPath(owner, repo);
4645
4646 type BranchRow = {
4647 name: string;
4648 isDefault: boolean;
4649 sha: string;
4650 subject: string;
4651 author: string;
4652 date: string;
4653 ahead: number;
4654 behind: number;
4655 };
4656
4657 const runGit = async (args: string[]): Promise<string> => {
4658 try {
4659 const proc = Bun.spawn(["git", ...args], {
4660 cwd: repoDir,
4661 stdout: "pipe",
4662 stderr: "pipe",
4663 });
4664 const out = await new Response(proc.stdout).text();
4665 await proc.exited;
4666 return out;
4667 } catch {
4668 return "";
4669 }
4670 };
4671
4672 const meta = await runGit([
4673 "for-each-ref",
4674 "--sort=-committerdate",
4675 "--format=%(refname:short)%00%(objectname)%00%(subject)%00%(authorname)%00%(committerdate:iso-strict)",
4676 "refs/heads/",
4677 ]);
4678 const metaByName: Record<
4679 string,
4680 { sha: string; subject: string; author: string; date: string }
4681 > = {};
4682 for (const line of meta.split("\n").filter(Boolean)) {
4683 const [name, sha, subject, author, date] = line.split("\0");
4684 metaByName[name] = { sha, subject, author, date };
4685 }
4686
4687 const branchOrder = [...branches].sort((a, b) => {
4688 if (a === defaultBranch) return -1;
4689 if (b === defaultBranch) return 1;
4690 const aDate = metaByName[a]?.date || "";
4691 const bDate = metaByName[b]?.date || "";
4692 return bDate.localeCompare(aDate);
4693 });
4694
4695 const rows: BranchRow[] = [];
4696 for (const name of branchOrder) {
4697 const m = metaByName[name] || { sha: "", subject: "", author: "", date: "" };
4698 let ahead = 0;
4699 let behind = 0;
4700 if (name !== defaultBranch && metaByName[defaultBranch]) {
4701 const out = await runGit([
4702 "rev-list",
4703 "--left-right",
4704 "--count",
4705 `${defaultBranch}...${name}`,
4706 ]);
4707 const parts = out.trim().split(/\s+/);
4708 if (parts.length === 2) {
4709 behind = parseInt(parts[0], 10) || 0;
4710 ahead = parseInt(parts[1], 10) || 0;
4711 }
4712 }
4713 rows.push({
4714 name,
4715 isDefault: name === defaultBranch,
4716 sha: m.sha,
4717 subject: m.subject,
4718 author: m.author,
4719 date: m.date,
4720 ahead,
4721 behind,
4722 });
4723 }
4724
4725 const relative = (iso: string): string => {
4726 if (!iso) return "—";
4727 const d = new Date(iso);
4728 if (Number.isNaN(d.getTime())) return "—";
4729 const diff = Date.now() - d.getTime();
4730 const m = Math.floor(diff / 60000);
4731 if (m < 1) return "just now";
4732 if (m < 60) return `${m} min ago`;
4733 const h = Math.floor(m / 60);
4734 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
4735 const dd = Math.floor(h / 24);
4736 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
4737 return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
4738 };
4739
4740 const success = c.req.query("success");
4741 const error = c.req.query("error");
4742
4743 return c.html(
4744 <Layout title={`Branches — ${owner}/${repo}`} user={user}>
4745 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
4746 <RepoHeader owner={owner} repo={repo} />
4747 <RepoNav owner={owner} repo={repo} active="code" />
4748 <div
4749 class="branches-wrap"
eed4684Claude4750 style="max-width:1680px;margin:0 auto;padding:var(--space-5) var(--space-4) var(--space-8)"
398a10cClaude4751 >
4752 <header class="branches-head" style="margin-bottom:var(--space-5)">
4753 <div
4754 class="branches-eyebrow"
4755 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"
4756 >
4757 <span
4758 class="branches-eyebrow-dot"
4759 aria-hidden="true"
6fd5915Claude4760 style="width:8px;height:8px;border-radius:9999px;background:linear-gradient(135deg,#5b6ee8,#5f8fa0);box-shadow:0 0 0 3px rgba(91,110,232,0.18)"
398a10cClaude4761 />
4762 Repository · Branches
4763 </div>
4764 <h1
4765 class="branches-title"
4766 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)"
4767 >
4768 <span class="gradient-text">{rows.length}</span>{" "}
4769 branch{rows.length === 1 ? "" : "es"}
4770 </h1>
4771 <p
4772 class="branches-sub"
4773 style="margin:0;font-size:14px;color:var(--text-muted);line-height:1.5;max-width:700px"
4774 >
4775 All work-in-progress lines for{" "}
4776 <code style="font-size:12.5px">{owner}/{repo}</code>. Ahead/behind
4777 counts are relative to{" "}
4778 <code style="font-size:12.5px">{defaultBranch}</code>.
4779 </p>
4780 </header>
4781
4782 {success && (
4783 <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">
4784 {decodeURIComponent(success)}
4785 </div>
4786 )}
4787 {error && (
4788 <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">
4789 {decodeURIComponent(error)}
4790 </div>
4791 )}
4792
4793 {rows.length === 0 ? (
4794 <div class="commits-empty">
4795 <div class="commits-empty-orb" aria-hidden="true" />
4796 <div class="commits-empty-inner">
4797 <div class="commits-empty-icon" aria-hidden="true">
4798 <svg
4799 width="22"
4800 height="22"
4801 viewBox="0 0 24 24"
4802 fill="none"
4803 stroke="currentColor"
4804 stroke-width="2"
4805 stroke-linecap="round"
4806 stroke-linejoin="round"
4807 >
4808 <line x1="6" y1="3" x2="6" y2="15" />
4809 <circle cx="18" cy="6" r="3" />
4810 <circle cx="6" cy="18" r="3" />
4811 <path d="M18 9a9 9 0 0 1-9 9" />
4812 </svg>
4813 </div>
4814 <h3 class="commits-empty-title">No branches yet</h3>
4815 <p class="commits-empty-sub">
4816 Push your first commit to create the default branch.
4817 </p>
4818 </div>
4819 </div>
4820 ) : (
4821 <div class="branches-list">
4822 {rows.map((r) => (
4823 <div class="branches-row">
4824 <div class="branches-row-icon" aria-hidden="true">
4825 <svg
4826 width="14"
4827 height="14"
4828 viewBox="0 0 24 24"
4829 fill="none"
4830 stroke="currentColor"
4831 stroke-width="2"
4832 stroke-linecap="round"
4833 stroke-linejoin="round"
4834 >
4835 <line x1="6" y1="3" x2="6" y2="15" />
4836 <circle cx="18" cy="6" r="3" />
4837 <circle cx="6" cy="18" r="3" />
4838 <path d="M18 9a9 9 0 0 1-9 9" />
4839 </svg>
4840 </div>
4841 <div class="branches-row-main">
4842 <div class="branches-row-name">
4843 <a href={`/${owner}/${repo}/tree/${r.name}`}>{r.name}</a>
4844 {r.isDefault && (
4845 <span
4846 class="branches-row-default"
4847 title="Default branch"
4848 >
4849 Default
4850 </span>
4851 )}
4852 </div>
4853 <div class="branches-row-meta">
4854 {r.subject ? (
4855 <>
4856 <strong>{r.author || "—"}</strong>
4857 <span class="sep">·</span>
4858 <span
4859 title={r.date ? new Date(r.date).toISOString() : ""}
4860 >
4861 updated {relative(r.date)}
4862 </span>
4863 {r.sha && (
4864 <>
4865 <span class="sep">·</span>
4866 <a
4867 href={`/${owner}/${repo}/commit/${r.sha}`}
4868 style="font-family:var(--font-mono);font-size:11.5px;color:var(--text-muted);text-decoration:none"
4869 >
4870 {r.sha.slice(0, 7)}
4871 </a>
4872 </>
4873 )}
4874 </>
4875 ) : (
4876 <span>No commit metadata</span>
4877 )}
4878 </div>
4879 </div>
4880 <div class="branches-row-side">
4881 {!r.isDefault && (r.ahead > 0 || r.behind > 0) && (
4882 <span
4883 class="branches-row-divergence"
4884 title={`${r.ahead} ahead, ${r.behind} behind ${defaultBranch}`}
4885 >
4886 <span class="ahead">{r.ahead} ahead</span>
4887 <span style="opacity:0.4">|</span>
4888 <span class="behind">{r.behind} behind</span>
4889 </span>
4890 )}
4891 <div class="branches-row-actions">
4892 <a
4893 href={`/${owner}/${repo}/commits/${r.name}`}
4894 class="branches-btn"
4895 title="View commits on this branch"
4896 >
4897 Commits
4898 </a>
4899 {!r.isDefault &&
4900 user &&
4901 user.username === owner && (
4902 <form
4903 method="post"
4904 action={`/${owner}/${repo}/branches/${encodeURIComponent(r.name)}/delete`}
4905 style="margin:0"
4906 onsubmit={`return confirm('Delete branch \\'${r.name}\\'? This cannot be undone.')`}
4907 >
4908 <button
4909 type="submit"
4910 class="branches-btn branches-btn-danger"
4911 >
4912 Delete
4913 </button>
4914 </form>
4915 )}
4916 </div>
4917 </div>
4918 </div>
4919 ))}
4920 </div>
4921 )}
4922 </div>
4923 </Layout>
4924 );
4925});
4926
4927// Delete a branch (owner only). Uses `git branch -D` so we can drop refs
4928// that are not merged into the default branch — matches the explicit
4929// confirmation on the row's delete button.
4930web.post("/:owner/:repo/branches/:name/delete", requireAuth, async (c) => {
4931 const { owner, repo } = c.req.param();
4932 const branchName = decodeURIComponent(c.req.param("name"));
4933 const user = c.get("user")!;
4934
4935 // Owner-only check (mirrors collaborators.tsx pattern).
4936 const [ownerRow] = await db
4937 .select()
4938 .from(users)
4939 .where(eq(users.username, owner))
4940 .limit(1);
4941 if (!ownerRow || ownerRow.id !== user.id) {
4942 return c.redirect(
4943 `/${owner}/${repo}/branches?error=Only+the+owner+can+delete+branches`
4944 );
4945 }
4946
4947 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
4948 if (branchName === defaultBranch) {
4949 return c.redirect(
4950 `/${owner}/${repo}/branches?error=Cannot+delete+the+default+branch`
4951 );
4952 }
4953
4954 const branches = await listBranches(owner, repo);
4955 if (!branches.includes(branchName)) {
4956 return c.redirect(
4957 `/${owner}/${repo}/branches?error=Branch+not+found`
4958 );
4959 }
4960
4961 try {
4962 const repoDir = getRepoPath(owner, repo);
4963 const proc = Bun.spawn(["git", "branch", "-D", branchName], {
4964 cwd: repoDir,
4965 stdout: "pipe",
4966 stderr: "pipe",
4967 });
4968 await proc.exited;
4969 if (proc.exitCode !== 0) {
4970 return c.redirect(
4971 `/${owner}/${repo}/branches?error=Delete+failed`
4972 );
4973 }
4974 } catch {
4975 return c.redirect(`/${owner}/${repo}/branches?error=Delete+failed`);
4976 }
4977
4978 return c.redirect(`/${owner}/${repo}/branches?success=Branch+deleted`);
4979});
4980
4981// ─── Tags list ────────────────────────────────────────────────────────────
4982// Pulls from `listTags` (sorted newest first). For each tag we look up an
4983// associated release row so the "View release" CTA can deep-link directly
4984// without making the user hunt for it.
4985web.get("/:owner/:repo/tags", async (c) => {
4986 const { owner, repo } = c.req.param();
4987 const user = c.get("user");
5bb52faccanty labs4988 const gate = await assertRepoReadable(c, owner, repo);
4989 if (gate) return gate;
398a10cClaude4990
4991 if (!(await repoExists(owner, repo))) return c.notFound();
4992
4993 const tags = await listTags(owner, repo);
4994
4995 // Map tags -> releases. Best-effort; releases table may not exist in
4996 // every test setup, so any error falls through with an empty set.
4997 const tagsWithReleases = new Set<string>();
4998 try {
4999 const [ownerRow] = await db
5000 .select()
5001 .from(users)
5002 .where(eq(users.username, owner))
5003 .limit(1);
5004 if (ownerRow) {
5005 const [repoRow] = await db
5006 .select()
5007 .from(repositories)
5008 .where(
5009 and(
5010 eq(repositories.ownerId, ownerRow.id),
5011 eq(repositories.name, repo)
5012 )
5013 )
5014 .limit(1);
5015 if (repoRow) {
5016 // Raw SQL so we don't need to import the releases schema here.
5017 const result = await db.execute(
5018 sql`SELECT tag FROM releases WHERE repository_id = ${repoRow.id}`
5019 );
5020 const rows: any[] = (result as any).rows || (result as any) || [];
5021 for (const row of rows) {
5022 const tag = row?.tag;
5023 if (typeof tag === "string") tagsWithReleases.add(tag);
5024 }
5025 }
5026 }
5027 } catch {
5028 // No releases table or DB error — leave set empty.
5029 }
5030
5031 const relative = (iso: string): string => {
5032 if (!iso) return "—";
5033 const d = new Date(iso);
5034 if (Number.isNaN(d.getTime())) return "—";
5035 const diff = Date.now() - d.getTime();
5036 const m = Math.floor(diff / 60000);
5037 if (m < 1) return "just now";
5038 if (m < 60) return `${m} min ago`;
5039 const h = Math.floor(m / 60);
5040 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
5041 const dd = Math.floor(h / 24);
5042 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
5043 return d.toLocaleDateString("en-US", {
5044 month: "short",
5045 day: "numeric",
5046 year: "numeric",
5047 });
5048 };
5049
5050 return c.html(
5051 <Layout title={`Tags — ${owner}/${repo}`} user={user}>
5052 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
5053 <RepoHeader owner={owner} repo={repo} />
5054 <RepoNav owner={owner} repo={repo} active="code" />
5055 <div
5056 class="tags-wrap"
eed4684Claude5057 style="max-width:1680px;margin:0 auto;padding:var(--space-5) var(--space-4) var(--space-8)"
398a10cClaude5058 >
5059 <header class="tags-head" style="margin-bottom:var(--space-5)">
5060 <div
5061 class="tags-eyebrow"
5062 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"
5063 >
5064 <span
5065 class="tags-eyebrow-dot"
5066 aria-hidden="true"
6fd5915Claude5067 style="width:8px;height:8px;border-radius:9999px;background:linear-gradient(135deg,#5b6ee8,#5f8fa0);box-shadow:0 0 0 3px rgba(91,110,232,0.18)"
398a10cClaude5068 />
5069 Repository · Tags
5070 </div>
5071 <h1
5072 class="tags-title"
5073 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)"
5074 >
5075 <span class="gradient-text">{tags.length}</span>{" "}
5076 tag{tags.length === 1 ? "" : "s"}
5077 </h1>
5078 <p
5079 class="tags-sub"
5080 style="margin:0;font-size:14px;color:var(--text-muted);line-height:1.5;max-width:700px"
5081 >
5082 Named points in the history — typically releases, milestones,
5083 or shipped versions. Click a tag to browse the tree at that
5084 revision.
5085 </p>
5086 </header>
5087
5088 {tags.length === 0 ? (
5089 <div class="commits-empty">
5090 <div class="commits-empty-orb" aria-hidden="true" />
5091 <div class="commits-empty-inner">
5092 <div class="commits-empty-icon" aria-hidden="true">
5093 <svg
5094 width="22"
5095 height="22"
5096 viewBox="0 0 24 24"
5097 fill="none"
5098 stroke="currentColor"
5099 stroke-width="2"
5100 stroke-linecap="round"
5101 stroke-linejoin="round"
5102 >
5103 <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" />
5104 <line x1="7" y1="7" x2="7.01" y2="7" />
5105 </svg>
5106 </div>
5107 <h3 class="commits-empty-title">No tags yet</h3>
5108 <p class="commits-empty-sub">
5109 Tag a commit to mark a release or milestone. From the CLI:{" "}
5110 <code>git tag v0.1.0 &amp;&amp; git push --tags</code>.
5111 </p>
5112 </div>
5113 </div>
5114 ) : (
5115 <div class="tags-list">
5116 {tags.map((t) => {
5117 const hasRelease = tagsWithReleases.has(t.name);
5118 return (
5119 <div class="tags-row">
5120 <div class="tags-row-icon" aria-hidden="true">
5121 <svg
5122 width="14"
5123 height="14"
5124 viewBox="0 0 24 24"
5125 fill="none"
5126 stroke="currentColor"
5127 stroke-width="2"
5128 stroke-linecap="round"
5129 stroke-linejoin="round"
5130 >
5131 <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" />
5132 <line x1="7" y1="7" x2="7.01" y2="7" />
5133 </svg>
5134 </div>
5135 <div class="tags-row-main">
5136 <div class="tags-row-name">
5137 <a
5138 href={`/${owner}/${repo}/tree/${t.name}`}
5139 style="text-decoration:none"
5140 >
5141 <span class="tags-row-version">{t.name}</span>
5142 </a>
5143 </div>
5144 <div class="tags-row-meta">
5145 <span
5146 title={t.date ? new Date(t.date).toISOString() : ""}
5147 >
5148 Tagged {relative(t.date)}
5149 </span>
5150 <span class="sep">·</span>
5151 <a
5152 href={`/${owner}/${repo}/commit/${t.sha}`}
5153 class="tags-row-sha"
5154 title={t.sha}
5155 >
5156 {t.sha.slice(0, 7)}
5157 </a>
5158 </div>
5159 </div>
5160 <div class="tags-row-side">
5161 <a
5162 href={`/${owner}/${repo}/tree/${t.name}`}
5163 class="tags-row-link"
5164 >
5165 Browse files
5166 </a>
5167 {hasRelease && (
5168 <a
5169 href={`/${owner}/${repo}/releases/tag/${t.name}`}
5170 class="tags-row-link"
6fd5915Claude5171 style="color:#67e8f9;border-color:rgba(95,143,160,0.35);background:rgba(95,143,160,0.06)"
398a10cClaude5172 >
5173 View release
5174 </a>
5175 )}
5176 </div>
5177 </div>
5178 );
5179 })}
5180 </div>
5181 )}
5182 </div>
5183 </Layout>
5184 );
5185});
5186
fc1817aClaude5187// Commit log
5188web.get("/:owner/:repo/commits/:ref?", async (c) => {
5189 const { owner, repo } = c.req.param();
06d5ffeClaude5190 const user = c.get("user");
5bb52faccanty labs5191 const gate = await assertRepoReadable(c, owner, repo);
5192 if (gate) return gate;
fc1817aClaude5193 const ref =
5194 c.req.param("ref") || (await getDefaultBranch(owner, repo)) || "main";
06d5ffeClaude5195 const branches = await listBranches(owner, repo);
fc1817aClaude5196
5197 const commits = await listCommits(owner, repo, ref, 50);
5198
3951454Claude5199 // Block J3 — batch-fetch cached verification results for the page.
8c790e0Claude5200 // Also resolve repoId here so we can query the recent push for the
5201 // Push Watch live/watch indicator in the header.
3951454Claude5202 let verifications: Record<string, { verified: boolean; reason: string }> = {};
8c790e0Claude5203 let commitsPageRecentPush: RecentPush | null = null;
3951454Claude5204 try {
5205 const [ownerRow] = await db
5206 .select()
5207 .from(users)
5208 .where(eq(users.username, owner))
5209 .limit(1);
5210 if (ownerRow) {
5211 const [repoRow] = await db
5212 .select()
5213 .from(repositories)
5214 .where(
5215 and(
5216 eq(repositories.ownerId, ownerRow.id),
5217 eq(repositories.name, repo)
5218 )
5219 )
5220 .limit(1);
8c790e0Claude5221 if (repoRow) {
5222 // Fetch verifications and recent push in parallel.
5223 const [verRows, rp] = await Promise.all([
5224 commits.length > 0
5225 ? db
5226 .select()
5227 .from(commitVerifications)
5228 .where(
5229 and(
5230 eq(commitVerifications.repositoryId, repoRow.id),
5231 inArray(
5232 commitVerifications.commitSha,
5233 commits.map((c) => c.sha)
5234 )
5235 )
5236 )
5237 : Promise.resolve([]),
5238 getRecentPush(repoRow.id),
5239 ]);
5240 for (const r of verRows) {
3951454Claude5241 verifications[r.commitSha] = {
5242 verified: r.verified,
5243 reason: r.reason,
5244 };
5245 }
8c790e0Claude5246 commitsPageRecentPush = rp;
3951454Claude5247 }
5248 }
5249 } catch {
5250 // DB unavailable — skip the badges gracefully.
5251 }
5252
fc1817aClaude5253 return c.html(
06d5ffeClaude5254 <Layout title={`Commits — ${owner}/${repo}`} user={user}>
efb11c5Claude5255 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
8c790e0Claude5256 <RepoHeader owner={owner} repo={repo} recentPush={commitsPageRecentPush} />
fc1817aClaude5257 <RepoNav owner={owner} repo={repo} active="commits" />
efb11c5Claude5258 <div class="commits-hero">
5259 <div class="commits-hero-orb-wrap" aria-hidden="true">
5260 <div class="commits-hero-orb" />
fc1817aClaude5261 </div>
efb11c5Claude5262 <div class="commits-hero-inner">
5263 <div class="commits-eyebrow">
5264 <strong>History</strong> · {owner}/{repo}
5265 </div>
5266 <h1 class="commits-title">
5267 <span class="gradient-text">{commits.length}</span> recent commit
5268 {commits.length === 1 ? "" : "s"} on{" "}
5269 <span class="commits-branch">{ref}</span>
5270 </h1>
5271 <p class="commits-sub">
5272 Browse the project's history. Click any commit to see the full
5273 diff, AI review notes, and signature status.
5274 </p>
5275 </div>
5276 </div>
5277 <div class="commits-toolbar">
5278 <BranchSwitcher
3951454Claude5279 owner={owner}
5280 repo={repo}
efb11c5Claude5281 currentRef={ref}
5282 branches={branches}
5283 pathType="commits"
3951454Claude5284 />
398a10cClaude5285 <div class="commits-toolbar-actions">
5286 <a href={`/${owner}/${repo}/branches`} class="commits-toolbar-link">
5287 {"⊢"} Branches
5288 </a>
5289 <a href={`/${owner}/${repo}/tags`} class="commits-toolbar-link">
5290 {"#"} Tags
5291 </a>
5292 </div>
efb11c5Claude5293 </div>
5294 {commits.length === 0 ? (
5295 <div class="commits-empty">
398a10cClaude5296 <div class="commits-empty-orb" aria-hidden="true" />
5297 <div class="commits-empty-inner">
5298 <div class="commits-empty-icon" aria-hidden="true">
5299 <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
5300 <circle cx="12" cy="12" r="4" />
5301 <line x1="1.05" y1="12" x2="7" y2="12" />
5302 <line x1="17.01" y1="12" x2="22.96" y2="12" />
5303 </svg>
5304 </div>
5305 <h3 class="commits-empty-title">No commits yet</h3>
5306 <p class="commits-empty-sub">
5307 This branch is empty. Push your first commit, or use the
5308 web editor to create a file.
5309 </p>
5310 </div>
efb11c5Claude5311 </div>
5312 ) : (
5313 <div class="commits-list-wrap">
398a10cClaude5314 {(() => {
5315 // Group commits by day for the section headers.
5316 const dayLabel = (iso: string): string => {
5317 const d = new Date(iso);
5318 if (Number.isNaN(d.getTime())) return "Unknown";
5319 const today = new Date();
5320 const yesterday = new Date(today);
5321 yesterday.setDate(today.getDate() - 1);
5322 const sameDay = (a: Date, b: Date) =>
5323 a.getFullYear() === b.getFullYear() &&
5324 a.getMonth() === b.getMonth() &&
5325 a.getDate() === b.getDate();
5326 if (sameDay(d, today)) return "Today";
5327 if (sameDay(d, yesterday)) return "Yesterday";
5328 return d.toLocaleDateString("en-US", {
5329 month: "long",
5330 day: "numeric",
5331 year: today.getFullYear() === d.getFullYear() ? undefined : "numeric",
5332 });
5333 };
5334 const relative = (iso: string): string => {
5335 const d = new Date(iso);
5336 if (Number.isNaN(d.getTime())) return "";
5337 const diff = Date.now() - d.getTime();
5338 const m = Math.floor(diff / 60000);
5339 if (m < 1) return "just now";
5340 if (m < 60) return `${m} min ago`;
5341 const h = Math.floor(m / 60);
5342 if (h < 24) return `${h} hr${h === 1 ? "" : "s"} ago`;
5343 const dd = Math.floor(h / 24);
5344 if (dd < 30) return `${dd} day${dd === 1 ? "" : "s"} ago`;
5345 return d.toLocaleDateString("en-US", {
5346 month: "short",
5347 day: "numeric",
5348 });
5349 };
5350 const initial = (name: string): string =>
5351 (name || "?").trim().charAt(0).toUpperCase() || "?";
5352 // Build groups preserving order.
5353 const groups: Array<{ label: string; items: typeof commits }> = [];
5354 let lastLabel = "";
5355 for (const cm of commits) {
5356 const label = dayLabel(cm.date);
5357 if (label !== lastLabel) {
5358 groups.push({ label, items: [] });
5359 lastLabel = label;
5360 }
5361 groups[groups.length - 1].items.push(cm);
5362 }
5363 return groups.map((g) => (
5364 <>
5365 <div class="commits-day-head">
5366 <span class="commits-day-head-dot" aria-hidden="true" />
5367 Commits on {g.label}
5368 </div>
5369 {g.items.map((cm) => {
5370 const v = verifications[cm.sha];
5371 return (
5372 <div class="commits-row">
5373 <div class="commits-avatar" aria-hidden="true">
5374 {initial(cm.author)}
5375 </div>
5376 <div class="commits-row-body">
5377 <div class="commits-row-msg">
5378 <a href={`/${owner}/${repo}/commit/${cm.sha}`}>
5379 {cm.message}
5380 </a>
5381 {v?.verified && (
5382 <span
5383 class="commits-row-verified"
5384 title="Signed with a registered key"
5385 >
5386 Verified
5387 </span>
5388 )}
5389 </div>
5390 <div class="commits-row-meta">
5391 <strong>{cm.author}</strong>
5392 <span class="sep">·</span>
5393 <span
5394 class="commits-row-time"
5395 title={new Date(cm.date).toISOString()}
5396 >
5397 committed {relative(cm.date)}
5398 </span>
5399 {cm.parentShas.length > 1 && (
5400 <>
5401 <span class="sep">·</span>
5402 <span>merge of {cm.parentShas.length} parents</span>
5403 </>
5404 )}
5405 </div>
5406 </div>
5407 <div class="commits-row-side">
5408 <a
5409 href={`/${owner}/${repo}/commit/${cm.sha}`}
5410 class="commits-row-sha"
5411 title={cm.sha}
5412 >
5413 {cm.sha.slice(0, 7)}
5414 </a>
8c790e0Claude5415 <a
5416 href={`/${owner}/${repo}/push/${cm.sha}`}
5417 class="commits-row-watch"
5418 title="Watch gate + deploy results for this push"
5419 aria-label={`Watch push ${cm.sha.slice(0, 7)}`}
5420 >
5421 <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
5422 <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
5423 <circle cx="12" cy="12" r="3" />
5424 </svg>
5425 </a>
398a10cClaude5426 <button
5427 type="button"
5428 class="commits-row-copy"
5429 data-copy-sha={cm.sha}
5430 title="Copy full SHA"
5431 aria-label={`Copy SHA ${cm.sha}`}
5432 >
5433 <svg width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true">
5434 <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" />
5435 <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" />
5436 </svg>
5437 </button>
5438 </div>
5439 </div>
5440 );
5441 })}
5442 </>
5443 ));
5444 })()}
efb11c5Claude5445 </div>
fc1817aClaude5446 )}
398a10cClaude5447 <script
5448 dangerouslySetInnerHTML={{
5449 __html: `
5450 (function(){
5451 document.addEventListener('click', function(e){
5452 var t = e.target; if (!t) return;
5453 var btn = t.closest && t.closest('[data-copy-sha]');
5454 if (!btn) return;
5455 e.preventDefault();
5456 var sha = btn.getAttribute('data-copy-sha') || '';
5457 if (!navigator.clipboard) return;
5458 navigator.clipboard.writeText(sha).then(function(){
5459 btn.classList.add('is-copied');
5460 setTimeout(function(){ btn.classList.remove('is-copied'); }, 1200);
5461 }).catch(function(){});
5462 });
5463 })();
5464 `,
5465 }}
5466 />
fc1817aClaude5467 </Layout>
5468 );
5469});
5470
5471// Single commit with diff
5472web.get("/:owner/:repo/commit/:sha", async (c) => {
5473 const { owner, repo, sha } = c.req.param();
06d5ffeClaude5474 const user = c.get("user");
5bb52faccanty labs5475 const gate = await assertRepoReadable(c, owner, repo);
5476 if (gate) return gate;
fc1817aClaude5477
05b973eClaude5478 // Fetch commit, full message, and diff in parallel
5479 const [commit, fullMessage, diffResult] = await Promise.all([
5480 getCommit(owner, repo, sha),
5481 getCommitFullMessage(owner, repo, sha),
5482 getDiff(owner, repo, sha),
5483 ]);
fc1817aClaude5484 if (!commit) {
5485 return c.html(
06d5ffeClaude5486 <Layout title="Not Found" user={user}>
fc1817aClaude5487 <div class="empty-state">
5488 <h2>Commit not found</h2>
5489 </div>
5490 </Layout>,
5491 404
5492 );
5493 }
5494
3951454Claude5495 // Block J3 — try to verify this commit's signature.
5496 let verification:
5497 | { verified: boolean; reason: string; signatureType: string | null }
5498 | null = null;
0cdfd89Claude5499 // Block J8 — external CI commit statuses rollup.
5500 let statusCombined:
5501 | {
5502 state: "pending" | "success" | "failure";
5503 total: number;
5504 contexts: Array<{
5505 context: string;
5506 state: string;
5507 description: string | null;
5508 targetUrl: string | null;
5509 }>;
5510 }
5511 | null = null;
3951454Claude5512 try {
5513 const [ownerRow] = await db
5514 .select()
5515 .from(users)
5516 .where(eq(users.username, owner))
5517 .limit(1);
5518 if (ownerRow) {
5519 const [repoRow] = await db
5520 .select()
5521 .from(repositories)
5522 .where(
5523 and(
5524 eq(repositories.ownerId, ownerRow.id),
5525 eq(repositories.name, repo)
5526 )
5527 )
5528 .limit(1);
5529 if (repoRow) {
5530 const { verifyCommit } = await import("../lib/signatures");
5531 const v = await verifyCommit(repoRow.id, owner, repo, commit.sha);
5532 verification = {
5533 verified: v.verified,
5534 reason: v.reason,
5535 signatureType: v.signatureType,
5536 };
0cdfd89Claude5537 try {
5538 const { combinedStatus } = await import("../lib/commit-statuses");
5539 const combined = await combinedStatus(repoRow.id, commit.sha);
5540 if (combined.total > 0) {
5541 statusCombined = {
5542 state: combined.state as any,
5543 total: combined.total,
5544 contexts: combined.contexts.map((c) => ({
5545 context: c.context,
5546 state: c.state,
5547 description: c.description,
5548 targetUrl: c.targetUrl,
5549 })),
5550 };
5551 }
5552 } catch {
5553 statusCombined = null;
5554 }
3951454Claude5555 }
5556 }
5557 } catch {
5558 verification = null;
5559 }
5560
05b973eClaude5561 const { files, raw } = diffResult;
fc1817aClaude5562
efb11c5Claude5563 // Diff stats: count additions / deletions across all files for the
5564 // header summary bar. Computed here from the parsed diff so we don't
5565 // touch the DiffView component.
5566 let additions = 0;
5567 let deletions = 0;
5568 for (const f of files) {
5569 const hunks = (f as any).hunks as Array<any> | undefined;
5570 if (Array.isArray(hunks)) {
5571 for (const h of hunks) {
5572 const lines = (h?.lines || []) as Array<any>;
5573 for (const ln of lines) {
5574 const t = ln?.type || ln?.kind;
5575 if (t === "add" || t === "added" || t === "+") additions += 1;
5576 else if (t === "del" || t === "deleted" || t === "delete" || t === "-")
5577 deletions += 1;
5578 }
5579 }
5580 }
5581 }
5582 // Fall back: scan raw if file-level counting yielded zero (it's just a
5583 // header polish — never let a parsing miss break the page).
5584 if (additions === 0 && deletions === 0 && typeof raw === "string") {
5585 for (const line of raw.split("\n")) {
5586 if (line.startsWith("+") && !line.startsWith("+++")) additions += 1;
5587 else if (line.startsWith("-") && !line.startsWith("---")) deletions += 1;
5588 }
5589 }
5590 const fileCount = files.length;
5591
fc1817aClaude5592 return c.html(
06d5ffeClaude5593 <Layout title={`${commit.message} — ${owner}/${repo}`} user={user}>
efb11c5Claude5594 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
fc1817aClaude5595 <RepoHeader owner={owner} repo={repo} />
efb11c5Claude5596 <div class="commit-detail-card">
5597 <div class="commit-detail-eyebrow">
5598 <strong>Commit</strong>
5599 <span class="commit-detail-sha-pill" title={commit.sha}>
5600 {commit.sha.slice(0, 7)}
5601 </span>
3951454Claude5602 {verification && verification.reason !== "unsigned" && (
5603 <span
efb11c5Claude5604 class={`commit-detail-verify ${
3951454Claude5605 verification.verified
efb11c5Claude5606 ? "commit-detail-verify-ok"
5607 : "commit-detail-verify-warn"
3951454Claude5608 }`}
5609 title={`${verification.signatureType?.toUpperCase() || ""} · ${verification.reason}`}
5610 >
5611 {verification.verified ? "Verified" : verification.reason}
5612 </span>
5613 )}
fc1817aClaude5614 </div>
efb11c5Claude5615 <h1 class="commit-detail-title">{commit.message}</h1>
5616 {fullMessage !== commit.message && (
5617 <pre class="commit-detail-body">{fullMessage}</pre>
5618 )}
5619 <div class="commit-detail-meta">
5620 <span class="commit-detail-author">
5621 <strong>{commit.author}</strong> committed on{" "}
5622 {new Date(commit.date).toLocaleDateString("en-US", {
5623 month: "long",
5624 day: "numeric",
5625 year: "numeric",
5626 })}
5627 </span>
fc1817aClaude5628 {commit.parentShas.length > 0 && (
efb11c5Claude5629 <span class="commit-detail-parents">
5630 {commit.parentShas.length === 1 ? "Parent" : "Parents"}:{" "}
5631 {commit.parentShas.map((p, idx) => (
5632 <>
5633 {idx > 0 && " "}
5634 <a
5635 href={`/${owner}/${repo}/commit/${p}`}
5636 class="commit-detail-sha-link"
5637 >
5638 {p.slice(0, 7)}
5639 </a>
5640 </>
fc1817aClaude5641 ))}
5642 </span>
5643 )}
5644 </div>
efb11c5Claude5645 <div class="commit-detail-stats">
5646 <span class="commit-detail-stat">
5647 <strong>{fileCount}</strong>{" "}
5648 file{fileCount === 1 ? "" : "s"} changed
5649 </span>
5650 <span class="commit-detail-stat commit-detail-stat-add">
5651 <span class="commit-detail-stat-mark">+</span>
5652 <strong>{additions}</strong>
5653 </span>
5654 <span class="commit-detail-stat commit-detail-stat-del">
5655 <span class="commit-detail-stat-mark">−</span>
5656 <strong>{deletions}</strong>
5657 </span>
5658 <span class="commit-detail-sha-full" title="Full SHA">
5659 {commit.sha}
5660 </span>
5661 </div>
0cdfd89Claude5662 {statusCombined && (
efb11c5Claude5663 <div class="commit-detail-checks">
5664 <div class="commit-detail-checks-head">
5665 <strong>Checks</strong>
5666 <span class="commit-detail-checks-summary">
5667 {statusCombined.total} total ·{" "}
5668 <span
5669 class={`commit-detail-check-state commit-detail-check-state-${statusCombined.state}`}
5670 >
5671 {statusCombined.state}
5672 </span>
0cdfd89Claude5673 </span>
efb11c5Claude5674 </div>
5675 <div class="commit-detail-check-row">
0cdfd89Claude5676 {statusCombined.contexts.map((cx) => (
5677 <span
efb11c5Claude5678 class={`commit-detail-check commit-detail-check-${cx.state}`}
0cdfd89Claude5679 title={cx.description || cx.context}
5680 >
5681 {cx.targetUrl ? (
efb11c5Claude5682 <a href={cx.targetUrl} rel="noopener">
0cdfd89Claude5683 {cx.context}: {cx.state}
5684 </a>
5685 ) : (
5686 <>
5687 {cx.context}: {cx.state}
5688 </>
5689 )}
5690 </span>
5691 ))}
5692 </div>
5693 </div>
5694 )}
fc1817aClaude5695 </div>
ea9ed4cClaude5696 <DiffView
5697 raw={raw}
5698 files={files}
5699 viewFileBase={`/${owner}/${repo}/blob/${commit.sha}`}
5700 />
fc1817aClaude5701 </Layout>
5702 );
5703});
5704
79136bbClaude5705// Raw file download
5706web.get("/:owner/:repo/raw/:ref{.+$}", async (c) => {
5707 const { owner, repo } = c.req.param();
5bb52faccanty labs5708 const gate = await assertRepoReadable(c, owner, repo);
5709 if (gate) return gate;
79136bbClaude5710 const refAndPath = c.req.param("ref");
5711
5712 const branches = await listBranches(owner, repo);
5713 let ref = "";
5714 let filePath = "";
5715
5716 for (const branch of branches) {
5717 if (refAndPath.startsWith(branch + "/")) {
5718 ref = branch;
5719 filePath = refAndPath.slice(branch.length + 1);
5720 break;
5721 }
5722 }
5723
5724 if (!ref) {
5725 const slashIdx = refAndPath.indexOf("/");
5726 if (slashIdx === -1) return c.text("Not found", 404);
5727 ref = refAndPath.slice(0, slashIdx);
5728 filePath = refAndPath.slice(slashIdx + 1);
5729 }
5730
5731 const data = await getRawBlob(owner, repo, ref, filePath);
5732 if (!data) return c.text("Not found", 404);
5733
5734 const fileName = filePath.split("/").pop() || "file";
772a24fClaude5735 return new Response(data as BodyInit, {
79136bbClaude5736 headers: {
5737 "Content-Type": "application/octet-stream",
5738 "Content-Disposition": `attachment; filename="${fileName}"`,
05b973eClaude5739 "Cache-Control": "public, max-age=300, stale-while-revalidate=60",
79136bbClaude5740 },
5741 });
5742});
5743
5744// Blame view
5745web.get("/:owner/:repo/blame/:ref{.+$}", async (c) => {
5746 const { owner, repo } = c.req.param();
5747 const user = c.get("user");
5bb52faccanty labs5748 const gate = await assertRepoReadable(c, owner, repo);
5749 if (gate) return gate;
79136bbClaude5750 const refAndPath = c.req.param("ref");
5751
5752 const branches = await listBranches(owner, repo);
5753 let ref = "";
5754 let filePath = "";
5755
5756 for (const branch of branches) {
5757 if (refAndPath.startsWith(branch + "/")) {
5758 ref = branch;
5759 filePath = refAndPath.slice(branch.length + 1);
5760 break;
5761 }
5762 }
5763
5764 if (!ref) {
5765 const slashIdx = refAndPath.indexOf("/");
5766 if (slashIdx === -1) return c.text("Not found", 404);
5767 ref = refAndPath.slice(0, slashIdx);
5768 filePath = refAndPath.slice(slashIdx + 1);
5769 }
5770
5771 const blameLines = await getBlame(owner, repo, ref, filePath);
5772 if (blameLines.length === 0) {
5773 return c.html(
5774 <Layout title="Not Found" user={user}>
5775 <div class="empty-state">
5776 <h2>File not found</h2>
5777 </div>
5778 </Layout>,
5779 404
5780 );
5781 }
5782
5783 const fileName = filePath.split("/").pop() || filePath;
efb11c5Claude5784 // Unique contributors (by author) tracked once for the header chip.
5785 const blameAuthors = new Set<string>();
5786 for (const ln of blameLines) blameAuthors.add(ln.author);
79136bbClaude5787
5788 return c.html(
5789 <Layout title={`Blame: ${filePath} — ${owner}/${repo}`} user={user}>
efb11c5Claude5790 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
79136bbClaude5791 <RepoHeader owner={owner} repo={repo} />
5792 <RepoNav owner={owner} repo={repo} active="code" />
398a10cClaude5793 <header class="blame-head">
5794 <div class="blame-eyebrow">
5795 <span class="blame-eyebrow-dot" aria-hidden="true" />
5796 Blame · Line-by-line history
5797 </div>
5798 <h1 class="blame-title">
5799 <code>{fileName}</code>
5800 </h1>
5801 <p class="blame-sub">
5802 Each line is annotated with the commit that last touched it.
5803 Click any SHA to jump to that commit and see the surrounding
5804 change.
5805 </p>
5806 </header>
efb11c5Claude5807 <div class="blame-toolbar">
5808 <Breadcrumb owner={owner} repo={repo} ref={ref} path={filePath} />
5809 </div>
398a10cClaude5810 <div class="blame-card">
5811 <div class="blame-header">
efb11c5Claude5812 <div class="blame-header-meta">
5813 <span class="blame-header-icon" aria-hidden="true">{"⎙"}</span>
5814 <span class="blame-header-name">{fileName}</span>
5815 <span class="blame-header-tag">Blame</span>
5816 <span class="blame-header-stats">
5817 {blameLines.length} line{blameLines.length === 1 ? "" : "s"} ·{" "}
5818 {blameAuthors.size} contributor
5819 {blameAuthors.size === 1 ? "" : "s"}
5820 </span>
5821 </div>
5822 <div class="blame-header-actions">
5823 <a
5824 href={`/${owner}/${repo}/blob/${ref}/${filePath}`}
5825 class="blob-pill"
5826 >
5827 Normal view
5828 </a>
5829 <a
5830 href={`/${owner}/${repo}/raw/${ref}/${filePath}`}
5831 class="blob-pill"
5832 >
5833 Raw
5834 </a>
5835 </div>
79136bbClaude5836 </div>
398a10cClaude5837 <div style="overflow-x:auto">
5838 <table class="blame-table">
79136bbClaude5839 <tbody>
5840 {blameLines.map((line, i) => {
5841 const showInfo =
5842 i === 0 || blameLines[i - 1].sha !== line.sha;
5843 return (
398a10cClaude5844 <tr class={showInfo ? "blame-row-first" : ""}>
5845 <td class="blame-gutter">
79136bbClaude5846 {showInfo && (
398a10cClaude5847 <span class="blame-gutter-inner">
79136bbClaude5848 <a
5849 href={`/${owner}/${repo}/commit/${line.sha}`}
398a10cClaude5850 class="blame-gutter-sha"
5851 title={`Commit ${line.sha}`}
79136bbClaude5852 >
5853 {line.sha.slice(0, 7)}
398a10cClaude5854 </a>
5855 <span class="blame-gutter-author" title={line.author}>
5856 {line.author}
5857 </span>
5858 </span>
79136bbClaude5859 )}
5860 </td>
398a10cClaude5861 <td class="blame-line-num">{line.lineNum}</td>
5862 <td class="blame-line-content">{line.content}</td>
79136bbClaude5863 </tr>
5864 );
5865 })}
5866 </tbody>
5867 </table>
5868 </div>
5869 </div>
5870 </Layout>
5871 );
5872});
5873
53c9249Claude5874// Search — keyword + optional Claude semantic mode
79136bbClaude5875web.get("/:owner/:repo/search", async (c) => {
5876 const { owner, repo } = c.req.param();
5877 const user = c.get("user");
5bb52faccanty labs5878 const gate = await assertRepoReadable(c, owner, repo);
5879 if (gate) return gate;
79136bbClaude5880 const q = c.req.query("q") || "";
53c9249Claude5881 const aiAvailable = isAiAvailable();
5882 // Default to semantic when Claude is available and no explicit mode set.
5883 const modeParam = c.req.query("mode");
5884 const mode: "semantic" | "keyword" =
5885 modeParam === "keyword"
5886 ? "keyword"
5887 : modeParam === "semantic"
5888 ? "semantic"
5889 : aiAvailable
5890 ? "semantic"
5891 : "keyword";
5892 const isSemantic = mode === "semantic" && aiAvailable;
79136bbClaude5893
5894 if (!(await repoExists(owner, repo))) return c.notFound();
5895
5896 const defaultBranch = (await getDefaultBranch(owner, repo)) || "main";
53c9249Claude5897
5898 // Keyword results (always available as fallback / when in keyword mode)
5899 let keywordResults: Array<{ file: string; lineNum: number; line: string }> = [];
5900 // Semantic results (Claude-powered)
5901 type SemanticHit = import("../lib/claude-semantic-search").SemanticSearchResult;
5902 let semanticHits: SemanticHit[] = [];
5903 let semanticMode: "semantic" | "keyword" = "semantic";
5904 let quotaExceeded = false;
79136bbClaude5905
5906 if (q.trim()) {
53c9249Claude5907 if (isSemantic) {
5908 // Resolve repo DB id for caching
5909 const [ownerRow] = await db
5910 .select({ id: users.id })
5911 .from(users)
5912 .where(eq(users.username, owner))
5913 .limit(1);
5914 const [repoRow] = ownerRow
5915 ? await db
5916 .select({ id: repositories.id })
5917 .from(repositories)
5918 .where(
5919 and(
5920 eq(repositories.ownerId, ownerRow.id),
5921 eq(repositories.name, repo)
5922 )
5923 )
5924 .limit(1)
5925 : [];
5926
5927 const rateLimitKey = user
5928 ? `user:${user.id}`
5929 : (c.req.header("x-forwarded-for")?.split(",")[0]?.trim() ?? "anon");
5930
5931 const searchResult = await claudeSemanticSearch(
5932 owner,
5933 repo,
5934 repoRow?.id ?? `${owner}/${repo}`,
5935 q.trim(),
5936 { branch: defaultBranch, rateLimitKey }
5937 );
5938 semanticHits = searchResult.results;
5939 semanticMode = searchResult.mode;
5940 quotaExceeded = searchResult.quotaExceeded;
5941 } else {
5942 keywordResults = await searchCode(owner, repo, defaultBranch, q.trim());
5943 }
79136bbClaude5944 }
5945
53c9249Claude5946 const aiSearchCss = `
5947 /* ─── Semantic search mode toggle ─── */
5948 .search-mode-bar {
5949 display: flex;
5950 align-items: center;
5951 gap: 8px;
5952 margin-bottom: 14px;
5953 flex-wrap: wrap;
5954 }
5955 .search-mode-label {
5956 font-size: 12.5px;
5957 color: var(--text-muted);
5958 font-weight: 500;
5959 }
5960 .search-mode-toggle {
5961 display: inline-flex;
5962 background: var(--bg-elevated);
5963 border: 1px solid var(--border);
5964 border-radius: 9999px;
5965 padding: 3px;
5966 gap: 2px;
5967 }
5968 .search-mode-btn {
5969 display: inline-flex;
5970 align-items: center;
5971 gap: 5px;
5972 padding: 5px 12px;
5973 border-radius: 9999px;
5974 font-size: 12.5px;
5975 font-weight: 500;
5976 color: var(--text-muted);
5977 text-decoration: none;
5978 transition: color 120ms ease, background 120ms ease;
5979 cursor: pointer;
5980 border: none;
5981 background: none;
5982 font: inherit;
5983 }
5984 .search-mode-btn:hover { color: var(--text-strong); text-decoration: none; }
5985 .search-mode-btn.active {
6fd5915Claude5986 background: rgba(91,110,232,0.15);
53c9249Claude5987 color: var(--text-strong);
5988 }
5989 .search-mode-ai-badge {
5990 display: inline-flex;
5991 align-items: center;
5992 gap: 4px;
5993 padding: 2px 8px;
5994 border-radius: 9999px;
5995 font-size: 11px;
5996 font-weight: 600;
6fd5915Claude5997 background: linear-gradient(135deg, rgba(91,110,232,0.20), rgba(95,143,160,0.15));
53c9249Claude5998 color: #c4b5fd;
6fd5915Claude5999 border: 1px solid rgba(91,110,232,0.30);
53c9249Claude6000 margin-left: 2px;
6001 }
6002 .search-quota-warn {
6003 font-size: 12.5px;
6004 color: var(--text-muted);
6005 padding: 6px 12px;
6006 background: rgba(255,200,0,0.06);
6007 border: 1px solid rgba(255,200,0,0.20);
6008 border-radius: 8px;
6009 }
6010
6011 /* ─── Semantic result cards ─── */
6012 .sem-results { display: flex; flex-direction: column; gap: 10px; }
6013 .sem-result {
6014 padding: 14px 16px;
6015 background: var(--bg-elevated);
6016 border: 1px solid var(--border);
6017 border-radius: 12px;
6018 transition: border-color 120ms ease;
6019 }
6020 .sem-result:hover { border-color: var(--border-strong); }
6021 .sem-result-head {
6022 display: flex;
6023 align-items: flex-start;
6024 justify-content: space-between;
6025 gap: 10px;
6026 flex-wrap: wrap;
6027 margin-bottom: 6px;
6028 }
6029 .sem-result-path {
6030 font-family: var(--font-mono);
6031 font-size: 13px;
6032 font-weight: 600;
6033 color: var(--text-strong);
6034 text-decoration: none;
6035 word-break: break-all;
6036 }
6037 .sem-result-path:hover { color: #c4b5fd; text-decoration: none; }
6038 .sem-result-conf {
6039 display: inline-flex;
6040 align-items: center;
6041 gap: 4px;
6042 padding: 2px 9px;
6043 border-radius: 9999px;
6044 font-size: 11.5px;
6045 font-weight: 600;
6046 white-space: nowrap;
6047 flex-shrink: 0;
6048 }
e589f77ccantynz-alt6049 .sem-conf-strong { background: rgba(52,211,153,0.12); color: var(--green); border: 1px solid rgba(52,211,153,0.30); }
6050 .sem-conf-possible { background: rgba(91,110,232,0.12); color: var(--accent); border: 1px solid rgba(91,110,232,0.30); }
53c9249Claude6051 .sem-conf-weak { background: rgba(255,255,255,0.04); color: var(--text-muted); border: 1px solid var(--border); }
6052 .sem-result-reason {
6053 font-size: 12.5px;
6054 color: var(--text-muted);
6055 margin-bottom: 8px;
6056 line-height: 1.5;
6057 }
6058 .sem-result-snippet {
6059 margin: 0;
6060 padding: 10px 12px;
6061 background: rgba(0,0,0,0.22);
6062 border: 1px solid var(--border);
6063 border-radius: 8px;
6064 font-family: var(--font-mono);
6065 font-size: 12px;
6066 line-height: 1.55;
6067 color: var(--text);
6068 overflow-x: auto;
6069 white-space: pre-wrap;
6070 word-break: break-word;
6071 max-height: 240px;
6072 overflow-y: auto;
6073 }
6074 `;
6075
6076 const semanticBaseUrl = `/${owner}/${repo}/search?mode=semantic`;
6077 const keywordBaseUrl = `/${owner}/${repo}/search?mode=keyword`;
6078
79136bbClaude6079 return c.html(
6080 <Layout title={`Search — ${owner}/${repo}`} user={user}>
53c9249Claude6081 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss + aiSearchCss }} />
79136bbClaude6082 <RepoHeader owner={owner} repo={repo} />
6083 <RepoNav owner={owner} repo={repo} active="code" />
efb11c5Claude6084 <div class="search-hero">
6085 <div class="search-eyebrow">
6086 <strong>Search</strong> · {owner}/{repo}
6087 </div>
6088 <h1 class="search-title">
53c9249Claude6089 {isSemantic ? (
6090 <>{"Ask "}<span class="gradient-text">{repo}</span>{" anything."}</>
6091 ) : (
6092 <>{"Find any line in "}<span class="gradient-text">{repo}</span></>
6093 )}
efb11c5Claude6094 </h1>
6095 <form
6096 method="get"
6097 action={`/${owner}/${repo}/search`}
6098 class="search-form"
6099 role="search"
6100 >
53c9249Claude6101 <input type="hidden" name="mode" value={mode} />
efb11c5Claude6102 <div class="search-input-wrap">
6103 <span class="search-input-icon" aria-hidden="true">{"⌕"}</span>
6104 <input
6105 type="text"
6106 name="q"
6107 value={q}
53c9249Claude6108 placeholder={
6109 isSemantic
6110 ? "Ask a question or describe what you're looking for…"
6111 : "Search code on the default branch…"
6112 }
efb11c5Claude6113 aria-label="Search code"
6114 class="search-input"
6115 autocomplete="off"
6116 autofocus
6117 />
6118 </div>
6119 <button type="submit" class="btn btn-primary search-submit">
79136bbClaude6120 Search
6121 </button>
efb11c5Claude6122 </form>
6123 </div>
53c9249Claude6124
6125 {/* Mode toggle */}
6126 <div class="search-mode-bar">
6127 <span class="search-mode-label">Mode:</span>
6128 <div class="search-mode-toggle" role="group" aria-label="Search mode">
6129 {aiAvailable ? (
6130 <a
6131 href={q ? `${semanticBaseUrl}&q=${encodeURIComponent(q)}` : semanticBaseUrl}
6132 class={`search-mode-btn${isSemantic ? " active" : ""}`}
6133 aria-pressed={isSemantic ? "true" : "false"}
6134 >
6135 {"✨"} Semantic AI
6136 <span class="search-mode-ai-badge">AI-powered</span>
6137 </a>
6138 ) : null}
6139 <a
6140 href={q ? `${keywordBaseUrl}&q=${encodeURIComponent(q)}` : keywordBaseUrl}
6141 class={`search-mode-btn${!isSemantic ? " active" : ""}`}
6142 aria-pressed={!isSemantic ? "true" : "false"}
6143 >
6144 {"⌕"} Keyword
6145 </a>
6146 </div>
6147 {isSemantic && aiAvailable && (
6148 <span style="font-size:12px;color:var(--text-muted)">
6149 Ask in plain English — finds code by meaning, not just exact words
efb11c5Claude6150 </span>
53c9249Claude6151 )}
6152 {quotaExceeded && (
6153 <span class="search-quota-warn">
6154 Semantic search quota reached — showing keyword results
efb11c5Claude6155 </span>
53c9249Claude6156 )}
6157 </div>
6158
6159 {/* ─── Semantic results ─── */}
6160 {isSemantic && q && (
6161 <>
6162 {semanticMode === "keyword" && !quotaExceeded && semanticHits.length > 0 && (
6163 <div class="search-quota-warn" style="margin-bottom:10px">
6164 Falling back to keyword search — Claude found no relevant files.
6165 </div>
6166 )}
6167 {semanticHits.length === 0 ? (
6168 <div class="search-empty">
6169 <p>
6170 No matches for <strong>"{q}"</strong>.{" "}
6171 Try a different phrasing or{" "}
6172 <a href={`${keywordBaseUrl}&q=${encodeURIComponent(q)}`}>
6173 switch to keyword search
6174 </a>.
6175 </p>
6176 </div>
6177 ) : (
6178 <>
6179 <div class="search-results-head">
6180 <span class="search-results-count">
6181 <strong>{semanticHits.length}</strong> result
6182 {semanticHits.length !== 1 ? "s" : ""}
6183 </span>
6184 <span class="search-results-query">
6185 {semanticMode === "semantic" ? "AI-ranked files for" : "keyword matches for"}{" "}
6186 <span class="search-results-q">"{q}"</span>
6187 </span>
6188 </div>
6189 <div class="sem-results">
6190 {semanticHits.map((h) => {
6191 const confClass =
6192 h.confidence > 0.7
6193 ? "sem-conf-strong"
6194 : h.confidence > 0.4
6195 ? "sem-conf-possible"
6196 : "sem-conf-weak";
6197 const confLabel =
6198 h.confidence > 0.7
6199 ? "Strong match"
6200 : h.confidence > 0.4
6201 ? "Possible match"
6202 : "Weak match";
6203 const href = `/${owner}/${repo}/blob/${defaultBranch}/${h.file}${h.lineNumber ? `#L${h.lineNumber}` : ""}`;
6204 const preview =
6205 h.snippet.length > 800
6206 ? h.snippet.slice(0, 800) + "\n…"
6207 : h.snippet;
6208 return (
6209 <div class="sem-result">
6210 <div class="sem-result-head">
6211 <a href={href} class="sem-result-path">
6212 {h.file}
6213 {h.lineNumber ? (
6214 <span style="color:var(--text-muted);font-weight:500">
6215 :{h.lineNumber}
6216 </span>
6217 ) : null}
6218 </a>
6219 <span class={`sem-result-conf ${confClass}`}>
6220 {confLabel}
6221 </span>
6222 </div>
6223 {h.reason && (
6224 <p class="sem-result-reason">{h.reason}</p>
6225 )}
6226 {preview && (
6227 <pre class="sem-result-snippet">{preview}</pre>
6228 )}
6229 </div>
6230 );
6231 })}
6232 </div>
6233 </>
6234 )}
6235 </>
79136bbClaude6236 )}
53c9249Claude6237
6238 {/* ─── Keyword results ─── */}
6239 {!isSemantic && q && (
6240 <>
6241 <div class="search-results-head">
6242 <span class="search-results-count">
6243 <strong>{keywordResults.length}</strong> result
6244 {keywordResults.length !== 1 ? "s" : ""}
6245 </span>
6246 <span class="search-results-query">
6247 for <span class="search-results-q">"{q}"</span> on{" "}
6248 <code>{defaultBranch}</code>
6249 </span>
6250 </div>
6251 {keywordResults.length === 0 ? (
6252 <div class="search-empty">
6253 <p>
6254 No matches for <strong>"{q}"</strong>. Try a shorter query or{" "}
6255 {aiAvailable && (
6256 <a href={`${semanticBaseUrl}&q=${encodeURIComponent(q)}`}>
6257 try AI semantic search
79136bbClaude6258 </a>
53c9249Claude6259 )}.
6260 </p>
6261 </div>
6262 ) : (
6263 <div class="search-results">
6264 {(() => {
6265 const grouped: Record<
6266 string,
6267 Array<{ lineNum: number; line: string }>
6268 > = {};
6269 for (const r of keywordResults) {
6270 if (!grouped[r.file]) grouped[r.file] = [];
6271 grouped[r.file].push({ lineNum: r.lineNum, line: r.line });
6272 }
6273 return Object.entries(grouped).map(([file, matches]) => (
6274 <div class="search-file diff-file">
6275 <div class="search-file-head diff-file-header">
6276 <a
6277 href={`/${owner}/${repo}/blob/${defaultBranch}/${file}`}
6278 class="search-file-link"
6279 >
6280 {file}
6281 </a>
6282 <span class="search-file-count">
6283 {matches.length} match{matches.length === 1 ? "" : "es"}
6284 </span>
6285 </div>
6286 <div class="blob-code">
6287 <table>
6288 <tbody>
6289 {matches.map((m) => (
6290 <tr>
6291 <td class="line-num">{m.lineNum}</td>
6292 <td class="line-content">{m.line}</td>
6293 </tr>
6294 ))}
6295 </tbody>
6296 </table>
6297 </div>
6298 </div>
6299 ));
6300 })()}
6301 </div>
6302 )}
6303 </>
6304 )}
79136bbClaude6305 </Layout>
6306 );
6307});
6308
fc1817aClaude6309export default web;