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 · 4 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,
8c790e0Claude36 type RecentPush,
fc1817aClaude37} from "../views/components";
ea9ed4cClaude38import { DiffView } from "../views/diff-view";
fc1817aClaude39import {
40 getTree,
41 getBlob,
42 listCommits,
43 getCommit,
44 getCommitFullMessage,
45 getDiff,
46 getReadme,
47 getDefaultBranch,
48 listBranches,
398a10cClaude49 listTags,
fc1817aClaude50 repoExists,
06d5ffeClaude51 initBareRepo,
79136bbClaude52 getBlame,
53 getRawBlob,
54 searchCode,
398a10cClaude55 getRepoPath,
fc1817aClaude56} from "../git/repository";
79136bbClaude57import { renderMarkdown, markdownCss } from "../lib/markdown";
06d5ffeClaude58import { highlightCode } from "../lib/highlight";
91a0204Claude59import { computeHealthScore } from "../lib/health-score";
60import type { HealthScore } from "../lib/health-score";
06d5ffeClaude61import { softAuth, requireAuth } from "../middleware/auth";
62import type { AuthEnv } from "../middleware/auth";
5bb52faccanty labs63import { resolveRepoAccess, satisfiesAccess } from "../middleware/repo-access";
53c9249Claude64import { claudeSemanticSearch } from "../lib/claude-semantic-search";
65import { isAiAvailable } from "../lib/ai-client";
8f50ed0Claude66import { trackByName } from "../lib/traffic";
534f04aClaude67import { LandingPage, type LandingLiveFeed } from "../views/landing";
29924bcClaude68import { Landing2030Page } from "../views/landing-2030";
f8e5feaccanty labs69import { LandingProPage } from "../views/landing-pro";
52ad8b1Claude70import { computePublicStats, type PublicStats } from "../lib/public-stats";
534f04aClaude71import {
72 listQueuedAiBuildIssues,
73 listRecentAutoMerges,
74 listRecentAiReviews,
75 countAiReviewsSince,
76 listDemoActivityFeed,
77} from "../lib/demo-activity";
11c3ab6ccanty labs78import { AgentWorkspace } from "../views/agent-workspace";
79import { DailyBrief } from "../views/daily-brief";
80import { TrustReport } from "../views/trust-report";
81import { ProductionLayers } from "../views/production-layers";
82import { DistributionView } from "../views/distribution";
83import { OrgMemory } from "../views/org-memory";
fc1817aClaude84
06d5ffeClaude85const web = new Hono<AuthEnv>();
86
87// Soft auth on all web routes — c.get("user") available but may be null
88web.use("*", softAuth);
fc1817aClaude89
5bb52faccanty labs90// ---------------------------------------------------------------------------
91// SECURITY: repo-content access gate.
92//
93// Every route that serves repository CONTENT (file tree, blobs, raw files,
94// blame, commits, diffs, branches, tags, code search, repo overview) MUST call
95// this before touching git-on-disk. Public repos resolve to "read" for
96// anonymous viewers (so public browsing stays fully anonymous); private repos
97// require a logged-in viewer with at least read access.
98//
99// Returns a 404 Response when the repo is missing OR the viewer lacks read
100// access — deliberately 404 (not 403) so we never leak the existence of a
101// private repo. Returns `null` when access is granted; callers proceed as
102// normal. The owner-username → user → repositories lookup mirrors the pattern
103// used by `requireRepoAccess` in ../middleware/repo-access.
104// ---------------------------------------------------------------------------
105async function assertRepoReadable(
106 c: any,
107 owner: string,
108 repo: string
109): Promise<Response | null> {
110 const user = c.get("user") ?? null;
111
112 const notFound = () =>
113 c.html(
114 <Layout title="Not Found" user={user}>
115 <div class="empty-state">
116 <h2>Repository not found</h2>
117 <p>
118 {owner}/{repo} does not exist.
119 </p>
120 </div>
121 </Layout>,
122 404
123 );
124
6b75ac1ccanty labs125 // Explicit dev/test bypass: when no database is configured at all there are
126 // no persisted repositories to protect (private repos only exist as DB rows),
127 // and the browse routes render purely from git-on-disk. This is a positively
128 // established condition (DATABASE_URL unset), NOT an error inference — so the
129 // access gate below can safely fail CLOSED on any runtime error. In
130 // production DATABASE_URL is always set, so this branch never runs there.
131 if (!config.databaseUrl) return null;
132
5bb52faccanty labs133 try {
134 const [ownerRow] = await db
135 .select({ id: users.id })
136 .from(users)
137 .where(eq(users.username, owner))
138 .limit(1);
139 if (!ownerRow) return notFound();
140
141 const [repoRow] = await db
142 .select({ id: repositories.id, isPrivate: repositories.isPrivate })
143 .from(repositories)
144 .where(
145 and(eq(repositories.ownerId, ownerRow.id), eq(repositories.name, repo))
146 )
147 .limit(1);
148 if (!repoRow) return notFound();
149
150 const access = await resolveRepoAccess({
151 repoId: repoRow.id,
152 userId: user?.id ?? null,
153 isPublic: !repoRow.isPrivate,
154 });
155 // Positive denial: the repo exists and the viewer lacks read access.
156 // Return 404 (not 403) so we never confirm a private repo's existence.
157 if (!satisfiesAccess(access, "read")) return notFound();
158
159 return null;
160 } catch (err) {
6b75ac1ccanty labs161 // Fail CLOSED. A DB is configured (checked above) but the privacy-flag
162 // lookup errored, so we cannot positively establish that this repo is
163 // public. Denying is the only safe choice for an access-control gate —
164 // failing open here would re-expose private repos during a DB hiccup,
165 // which is the exact vulnerability this function exists to close.
5bb52faccanty labs166 console.warn(
6b75ac1ccanty labs167 `[web] assertRepoReadable: access check failed for ${owner}/${repo} — denying:`,
5bb52faccanty labs168 err instanceof Error ? err.message : err
169 );
6b75ac1ccanty labs170 return notFound();
5bb52faccanty labs171 }
172}
173
ebaae0fClaude174// ---------------------------------------------------------------------------
175// Repo AI stats — computed once per repo home page load, best-effort.
176// Fast because every WHERE clause is bounded to a 7-day window.
177// ---------------------------------------------------------------------------
178interface RepoAiStats {
179 mergedCount: number;
180 reviewCount: number;
181 securityAlertCount: number;
182 hoursSaved: string;
183}
184
185async function getRepoAiStats(repoId: string): Promise<RepoAiStats> {
186 const since = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
187
188 // 1. AI-merged PRs this week: activity_feed entries with action =
189 // 'auto_merge.merged' in the last 7 days for this repo.
190 // This is cheaper than a JOIN on pull_requests and covers both the
191 // `mergedBy = botUser` pattern and the autopilot auto-merge path.
192 const [mergedRow] = await db
193 .select({ n: count() })
194 .from(activityFeed)
195 .where(
196 and(
197 eq(activityFeed.repositoryId, repoId),
198 eq(activityFeed.action, "auto_merge.merged"),
199 gte(activityFeed.createdAt, since)
200 )
201 );
202 const mergedCount = Number(mergedRow?.n ?? 0);
203
204 // 2. AI reviews this week: pr_comments where is_ai_review = true in
205 // the last 7 days, joined through pull_requests to scope to this repo.
206 const [reviewRow] = await db
207 .select({ n: count() })
208 .from(prComments)
209 .innerJoin(pullRequests, eq(prComments.pullRequestId, pullRequests.id))
210 .where(
211 and(
212 eq(pullRequests.repositoryId, repoId),
213 eq(prComments.isAiReview, true),
214 gte(prComments.createdAt, since)
215 )
216 );
217 const reviewCount = Number(reviewRow?.n ?? 0);
218
219 // 3. Open security alerts: open issues that carry a label whose name
220 // contains 'security' (case-insensitive) for this repo.
221 const [secRow] = await db
222 .select({ n: count() })
223 .from(issues)
224 .innerJoin(issueLabels, eq(issueLabels.issueId, issues.id))
225 .innerJoin(labels, eq(issueLabels.labelId, labels.id))
226 .where(
227 and(
228 eq(issues.repositoryId, repoId),
229 eq(issues.state, "open"),
230 sql`lower(${labels.name}) like '%security%'`
231 )
232 );
233 const securityAlertCount = Number(secRow?.n ?? 0);
234
235 // Hours saved: each AI-merged PR ~ 1.5 h, each AI review ~ 0.5 h.
236 const hours = mergedCount * 1.5 + reviewCount * 0.5;
237 const hoursSaved = hours.toFixed(1);
238
239 return { mergedCount, reviewCount, securityAlertCount, hoursSaved };
240}
241
8c790e0Claude242/**
243 * Query the most recent push to a repo from the activity_feed table.
244 * Returns a RecentPush if there's been a push in the last 24 hours,
245 * or null otherwise. Used by the RepoHeader live/watch indicator.
246 *
247 * Queries activity_feed where action='push' and targetId holds the commit SHA.
248 */
249async function getRecentPush(repoId: string): Promise<RecentPush | null> {
250 try {
251 const cutoff = new Date(Date.now() - 24 * 60 * 60 * 1000);
252 const [row] = await db
253 .select({
254 targetId: activityFeed.targetId,
255 createdAt: activityFeed.createdAt,
256 })
257 .from(activityFeed)
258 .where(
259 and(
260 eq(activityFeed.repositoryId, repoId),
261 eq(activityFeed.action, "push"),
262 sql`${activityFeed.createdAt} >= ${cutoff.toISOString()}`
263 )
264 )
265 .orderBy(desc(activityFeed.createdAt))
266 .limit(1);
267 if (!row || !row.targetId) return null;
268 return {
269 sha: row.targetId,
270 ageMs: Date.now() - new Date(row.createdAt).getTime(),
271 };
272 } catch {
273 // DB unavailable or schema mismatch — degrade gracefully.
274 return null;
275 }
276}
277
efb11c5Claude278/**
279 * Shared CSS for the polished code-browse surfaces (parallel session 3.E).
280 *
281 * Inlined here rather than in `src/views/layout.tsx` because session 3.E's
282 * scope is route-local and `layout.tsx` is locked. Each polished handler
283 * injects this via a `<style>` tag; the rules are namespaced by surface
284 * prefix (`.new-repo-*`, `.profile-*`, `.tree-*`, `.blob-*`, `.commits-*`,
285 * `.commit-detail-*`, `.blame-*`, `.search-*`) so nothing bleeds into the
286 * `.repo-home-*` styling Agent A already shipped.
287 */
288const codeBrowseCss = `
289 /* ───────── shared primitives ───────── */
290 .cb-hairline::before,
291 .new-repo-hero::before,
292 .profile-hero::before,
293 .commits-hero::before,
294 .commit-detail-card::before,
295 .search-hero::before {
296 content: '';
297 position: absolute;
298 top: 0; left: 0; right: 0;
299 height: 2px;
6fd5915Claude300 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
efb11c5Claude301 opacity: 0.7;
302 pointer-events: none;
303 }
304 @keyframes cbHeroOrb {
305 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
306 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
307 }
308 @media (prefers-reduced-motion: reduce) {
309 .new-repo-hero-orb,
310 .profile-hero-orb,
311 .commits-hero-orb { animation: none; }
312 }
313
314 /* ───────── new-repo ───────── */
315 .new-repo-hero {
316 position: relative;
317 margin-bottom: var(--space-5);
318 padding: var(--space-5) var(--space-6);
319 background: var(--bg-elevated);
320 border: 1px solid var(--border);
321 border-radius: 16px;
322 overflow: hidden;
323 }
324 .new-repo-hero-orb-wrap {
325 position: absolute;
326 inset: -25% -10% auto auto;
327 width: 360px;
328 height: 360px;
329 pointer-events: none;
330 z-index: 0;
331 }
332 .new-repo-hero-orb {
333 position: absolute;
334 inset: 0;
6fd5915Claude335 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.09) 45%, transparent 70%);
efb11c5Claude336 filter: blur(80px);
337 opacity: 0.7;
338 animation: cbHeroOrb 14s ease-in-out infinite;
339 }
340 .new-repo-hero-inner { position: relative; z-index: 1; }
341 .new-repo-eyebrow {
342 font-size: 12px;
343 font-family: var(--font-mono);
344 color: var(--text-muted);
345 letter-spacing: 0.1em;
346 text-transform: uppercase;
347 margin-bottom: var(--space-2);
348 }
349 .new-repo-eyebrow strong { color: var(--accent); font-weight: 600; }
350 .new-repo-title {
351 font-family: var(--font-display);
352 font-weight: 800;
353 letter-spacing: -0.028em;
354 font-size: clamp(28px, 4vw, 40px);
355 line-height: 1.05;
356 margin: 0 0 var(--space-2);
357 color: var(--text-strong);
358 }
359 .new-repo-sub {
360 font-size: 15px;
361 color: var(--text-muted);
362 margin: 0;
363 line-height: 1.55;
364 max-width: 620px;
365 }
366 .new-repo-form {
367 max-width: 680px;
368 }
369 .new-repo-error {
370 background: rgba(218, 54, 51, 0.12);
371 border: 1px solid rgba(218, 54, 51, 0.35);
372 color: #ffb3b3;
373 padding: 10px 14px;
374 border-radius: 10px;
375 margin-bottom: var(--space-4);
376 font-size: 14px;
377 }
378 .new-repo-form-grid {
379 display: flex;
380 flex-direction: column;
381 gap: var(--space-4);
382 }
383 .new-repo-row { display: flex; flex-direction: column; gap: 6px; }
384 .new-repo-label {
385 font-size: 13px;
386 color: var(--text-strong);
387 font-weight: 600;
388 }
389 .new-repo-label-optional {
390 color: var(--text-muted);
391 font-weight: 400;
392 font-size: 12px;
393 }
394 .new-repo-input {
395 appearance: none;
396 width: 100%;
397 background: var(--bg);
398 border: 1px solid var(--border);
399 color: var(--text-strong);
400 border-radius: 10px;
401 padding: 10px 12px;
402 font-size: 14px;
403 font-family: inherit;
404 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
405 }
406 .new-repo-input:focus {
407 outline: none;
408 border-color: var(--accent);
6fd5915Claude409 box-shadow: 0 0 0 3px rgba(91,110,232,0.18);
efb11c5Claude410 }
411 .new-repo-input-disabled {
412 color: var(--text-muted);
413 background: var(--bg-secondary);
414 cursor: not-allowed;
415 }
416 .new-repo-hint {
417 font-size: 12px;
418 color: var(--text-muted);
419 margin: 4px 0 0;
420 }
421 .new-repo-hint code {
422 font-family: var(--font-mono);
423 font-size: 11.5px;
424 background: var(--bg-secondary);
425 border: 1px solid var(--border);
426 border-radius: 5px;
427 padding: 1px 5px;
428 color: var(--text-strong);
429 }
430 .new-repo-visibility {
431 display: grid;
432 grid-template-columns: 1fr 1fr;
433 gap: var(--space-2);
434 }
435 @media (max-width: 600px) {
436 .new-repo-visibility { grid-template-columns: 1fr; }
437 }
438 .new-repo-vis-card {
439 display: flex;
440 gap: 10px;
441 padding: 14px;
442 background: var(--bg);
443 border: 1px solid var(--border);
444 border-radius: 12px;
445 cursor: pointer;
446 transition: border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
447 }
448 .new-repo-vis-card:hover { border-color: var(--border-strong, var(--border)); }
449 .new-repo-vis-card:has(input:checked) {
6fd5915Claude450 border-color: rgba(91,110,232,0.55);
451 background: rgba(91,110,232,0.06);
452 box-shadow: 0 0 0 1px rgba(91,110,232,0.25);
efb11c5Claude453 }
454 .new-repo-vis-radio {
455 margin-top: 3px;
456 accent-color: var(--accent);
457 }
458 .new-repo-vis-body { display: flex; flex-direction: column; gap: 4px; }
459 .new-repo-vis-label {
460 font-size: 14px;
461 font-weight: 600;
462 color: var(--text-strong);
463 }
464 .new-repo-vis-desc {
465 font-size: 12.5px;
466 color: var(--text-muted);
467 line-height: 1.45;
468 }
469 .new-repo-callout {
470 margin-top: var(--space-2);
471 padding: var(--space-3) var(--space-4);
6fd5915Claude472 background: var(--accent-gradient-faint, rgba(91,110,232,0.06));
473 border: 1px solid rgba(91,110,232,0.2);
efb11c5Claude474 border-radius: 12px;
475 }
476 .new-repo-callout-eyebrow {
477 font-size: 11px;
478 font-family: var(--font-mono);
479 text-transform: uppercase;
480 letter-spacing: 0.12em;
481 color: var(--accent);
482 font-weight: 700;
483 margin-bottom: 4px;
484 }
485 .new-repo-callout-body {
486 font-size: 13px;
487 color: var(--text);
488 line-height: 1.5;
489 margin: 0;
490 }
491 .new-repo-callout-body code {
492 font-family: var(--font-mono);
493 font-size: 12px;
494 color: var(--accent);
6fd5915Claude495 background: rgba(91,110,232,0.1);
efb11c5Claude496 border-radius: 4px;
497 padding: 1px 5px;
498 }
398a10cClaude499 .new-repo-templates {
500 display: flex;
501 flex-wrap: wrap;
502 gap: 8px;
503 margin-top: 4px;
504 }
505 .new-repo-template-chip {
506 position: relative;
507 display: inline-flex;
508 align-items: center;
509 gap: 6px;
510 padding: 8px 14px;
511 background: var(--bg);
512 border: 1px solid var(--border);
513 border-radius: 999px;
514 font-size: 13px;
515 color: var(--text);
516 cursor: pointer;
517 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
518 }
519 .new-repo-template-chip input { position: absolute; opacity: 0; pointer-events: none; }
520 .new-repo-template-chip:hover {
521 border-color: var(--border-strong, var(--border));
522 color: var(--text-strong);
523 }
524 .new-repo-template-chip:has(input:checked) {
6fd5915Claude525 border-color: rgba(91,110,232,0.55);
526 background: rgba(91,110,232,0.10);
398a10cClaude527 color: var(--text-strong);
6fd5915Claude528 box-shadow: 0 0 0 1px rgba(91,110,232,0.25);
398a10cClaude529 }
530 .new-repo-template-chip-dot {
531 width: 8px; height: 8px;
532 border-radius: 999px;
533 background: var(--text-faint, var(--text-muted));
534 transition: background 140ms ease, box-shadow 140ms ease;
535 }
536 .new-repo-template-chip:has(input:checked) .new-repo-template-chip-dot {
6fd5915Claude537 background: linear-gradient(135deg, #5b6ee8, #5f8fa0);
538 box-shadow: 0 0 8px rgba(91,110,232,0.6);
398a10cClaude539 }
efb11c5Claude540 .new-repo-actions {
541 display: flex;
542 gap: var(--space-2);
543 margin-top: var(--space-2);
398a10cClaude544 align-items: center;
545 }
546 .new-repo-submit {
547 min-width: 180px;
6fd5915Claude548 border: 1px solid rgba(91,110,232,0.45);
549 background: linear-gradient(135deg, #5b6ee8 0%, #5f8fa0 100%);
398a10cClaude550 color: #fff;
551 font-weight: 700;
6fd5915Claude552 box-shadow: 0 8px 20px -8px rgba(91,110,232,0.55);
398a10cClaude553 transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
554 }
555 .new-repo-submit:hover {
556 transform: translateY(-1px);
6fd5915Claude557 box-shadow: 0 12px 24px -8px rgba(91,110,232,0.7);
398a10cClaude558 filter: brightness(1.06);
559 }
560 .new-repo-submit:focus-visible {
6fd5915Claude561 outline: 3px solid rgba(91,110,232,0.45);
398a10cClaude562 outline-offset: 2px;
efb11c5Claude563 }
564
565 /* ───────── profile ───────── */
566 .profile-hero {
567 position: relative;
568 margin-bottom: var(--space-5);
569 padding: var(--space-5) var(--space-6);
570 background: var(--bg-elevated);
571 border: 1px solid var(--border);
572 border-radius: 16px;
573 overflow: hidden;
574 }
575 .profile-hero-orb-wrap {
576 position: absolute;
577 inset: -25% -10% auto auto;
578 width: 360px;
579 height: 360px;
580 pointer-events: none;
581 z-index: 0;
582 }
583 .profile-hero-orb {
584 position: absolute;
585 inset: 0;
6fd5915Claude586 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.09) 45%, transparent 70%);
efb11c5Claude587 filter: blur(80px);
588 opacity: 0.7;
589 animation: cbHeroOrb 14s ease-in-out infinite;
590 }
591 .profile-hero-inner {
592 position: relative;
593 z-index: 1;
594 display: flex;
595 align-items: flex-start;
596 gap: var(--space-5);
597 }
598 .profile-hero-avatar {
599 flex: 0 0 auto;
600 width: 88px;
601 height: 88px;
602 border-radius: 50%;
6fd5915Claude603 background: linear-gradient(135deg, #5b6ee8 0%, #5f8fa0 100%);
efb11c5Claude604 color: #fff;
605 display: flex;
606 align-items: center;
607 justify-content: center;
608 font-size: 38px;
609 font-weight: 700;
610 font-family: var(--font-display);
6fd5915Claude611 box-shadow: 0 8px 24px -8px rgba(91,110,232,0.55);
efb11c5Claude612 }
613 .profile-hero-text { flex: 1; min-width: 0; }
614 .profile-eyebrow {
615 font-size: 12px;
616 font-family: var(--font-mono);
617 color: var(--text-muted);
618 letter-spacing: 0.1em;
619 text-transform: uppercase;
620 margin-bottom: var(--space-2);
621 }
622 .profile-eyebrow strong { color: var(--accent); font-weight: 600; }
623 .profile-name {
624 font-family: var(--font-display);
625 font-weight: 800;
626 letter-spacing: -0.028em;
627 font-size: clamp(28px, 3.6vw, 36px);
628 line-height: 1.05;
629 margin: 0 0 4px;
630 color: var(--text-strong);
631 }
632 .profile-handle {
633 font-family: var(--font-mono);
634 font-size: 13px;
635 color: var(--text-muted);
636 margin-bottom: var(--space-2);
637 }
638 .profile-bio {
639 font-size: 14.5px;
640 color: var(--text);
641 line-height: 1.55;
642 margin: 0 0 var(--space-3);
643 max-width: 640px;
644 }
645 .profile-meta {
646 display: flex;
647 align-items: center;
648 gap: var(--space-4);
649 flex-wrap: wrap;
650 font-size: 13px;
651 }
652 .profile-meta-link {
653 color: var(--text-muted);
654 transition: color var(--t-fast, 0.15s) ease;
655 }
656 .profile-meta-link:hover { color: var(--accent); text-decoration: none; }
657 .profile-meta-link strong {
658 color: var(--text-strong);
659 font-weight: 600;
660 font-variant-numeric: tabular-nums;
661 }
662 .profile-follow-form { margin: 0; }
663 @media (max-width: 600px) {
664 .profile-hero-inner { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
665 .profile-hero-avatar { width: 64px; height: 64px; font-size: 28px; }
666 }
667 .profile-readme {
668 margin-bottom: var(--space-6);
669 background: var(--bg-elevated);
670 border: 1px solid var(--border);
671 border-radius: 12px;
672 overflow: hidden;
673 }
674 .profile-readme-head {
675 display: flex;
676 align-items: center;
677 gap: 8px;
678 padding: 10px 16px;
679 background: var(--bg-secondary);
680 border-bottom: 1px solid var(--border);
681 font-size: 13px;
682 color: var(--text-muted);
683 }
684 .profile-readme-icon { color: var(--accent); font-size: 14px; }
685 .profile-readme-body { padding: var(--space-5) var(--space-6); }
686 .profile-section-head {
687 display: flex;
688 align-items: baseline;
689 gap: var(--space-2);
690 margin-bottom: var(--space-3);
691 }
692 .profile-section-title {
693 font-family: var(--font-display);
694 font-weight: 700;
695 font-size: 20px;
696 letter-spacing: -0.015em;
697 margin: 0;
698 color: var(--text-strong);
699 }
700 .profile-section-count {
701 font-family: var(--font-mono);
702 font-size: 12px;
703 color: var(--text-muted);
704 background: var(--bg-secondary);
705 border: 1px solid var(--border);
706 border-radius: 999px;
707 padding: 2px 10px;
708 font-variant-numeric: tabular-nums;
709 }
710 .profile-empty {
711 display: flex;
712 align-items: center;
713 justify-content: space-between;
714 gap: var(--space-3);
715 padding: var(--space-4) var(--space-5);
716 background: var(--bg-elevated);
717 border: 1px dashed var(--border);
718 border-radius: 12px;
719 }
720 .profile-empty-text { color: var(--text-muted); font-size: 14px; margin: 0; }
721
722 /* ───────── tree (file browser) ───────── */
723 .tree-header {
724 margin-bottom: var(--space-3);
725 display: flex;
726 flex-direction: column;
727 gap: var(--space-2);
728 }
729 .tree-header-row {
730 display: flex;
731 align-items: center;
732 justify-content: space-between;
733 gap: var(--space-3);
734 flex-wrap: wrap;
735 }
736 .tree-header-stats {
737 display: flex;
738 align-items: center;
739 gap: var(--space-3);
740 font-size: 12px;
741 color: var(--text-muted);
742 }
743 .tree-stat strong {
744 color: var(--text-strong);
745 font-weight: 600;
746 font-variant-numeric: tabular-nums;
747 }
748 .tree-stat-link {
749 color: var(--text-muted);
750 padding: 4px 10px;
751 border-radius: 999px;
752 border: 1px solid var(--border);
753 background: var(--bg-elevated);
754 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease;
755 }
756 .tree-stat-link:hover {
757 color: var(--accent);
6fd5915Claude758 border-color: rgba(91,110,232,0.45);
efb11c5Claude759 text-decoration: none;
760 }
761 .tree-breadcrumb-row {
762 font-size: 13px;
763 }
764
765 /* ───────── blob (file viewer) ───────── */
766 .blob-toolbar {
767 margin-bottom: var(--space-3);
768 display: flex;
769 flex-direction: column;
770 gap: var(--space-2);
771 }
772 .blob-breadcrumb { font-size: 13px; }
773 .blob-card {
774 background: var(--bg-elevated);
775 border: 1px solid var(--border);
776 border-radius: 12px;
777 overflow: hidden;
778 }
779 .blob-header-polished {
780 display: flex;
781 align-items: center;
782 justify-content: space-between;
783 gap: var(--space-3);
784 padding: 10px 14px;
785 background: var(--bg-secondary);
786 border-bottom: 1px solid var(--border);
787 }
788 .blob-header-meta {
789 display: flex;
790 align-items: center;
791 gap: var(--space-2);
792 min-width: 0;
793 flex: 1;
794 }
795 .blob-header-icon { font-size: 14px; opacity: 0.85; }
796 .blob-header-name {
797 font-family: var(--font-mono);
798 font-size: 13px;
799 color: var(--text-strong);
800 font-weight: 600;
801 overflow: hidden;
802 text-overflow: ellipsis;
803 white-space: nowrap;
804 }
805 .blob-header-size {
806 font-family: var(--font-mono);
807 font-size: 11.5px;
808 color: var(--text-muted);
809 font-variant-numeric: tabular-nums;
810 border-left: 1px solid var(--border);
811 padding-left: var(--space-2);
812 margin-left: 2px;
813 }
814 .blob-header-actions {
815 display: flex;
816 gap: 6px;
817 flex-shrink: 0;
818 }
819 .blob-pill {
820 display: inline-flex;
821 align-items: center;
822 padding: 4px 12px;
823 font-size: 12px;
824 font-weight: 500;
825 color: var(--text);
826 background: var(--bg-elevated);
827 border: 1px solid var(--border);
828 border-radius: 999px;
829 transition: color var(--t-fast, 0.15s) ease, border-color var(--t-fast, 0.15s) ease, background var(--t-fast, 0.15s) ease;
830 }
831 .blob-pill:hover {
832 color: var(--accent);
6fd5915Claude833 border-color: rgba(91,110,232,0.45);
efb11c5Claude834 text-decoration: none;
6fd5915Claude835 background: rgba(91,110,232,0.06);
efb11c5Claude836 }
837 .blob-pill-accent {
838 color: var(--accent);
6fd5915Claude839 border-color: rgba(91,110,232,0.35);
840 background: rgba(91,110,232,0.08);
efb11c5Claude841 }
842 .blob-pill-accent:hover {
6fd5915Claude843 background: rgba(91,110,232,0.14);
efb11c5Claude844 }
845 .blob-binary {
846 padding: var(--space-5);
847 color: var(--text-muted);
848 text-align: center;
849 font-size: 13px;
850 background: var(--bg);
851 }
852
853 /* ───────── commits list ───────── */
854 .commits-hero {
855 position: relative;
856 margin-bottom: var(--space-4);
857 padding: var(--space-5) var(--space-6);
858 background: var(--bg-elevated);
859 border: 1px solid var(--border);
860 border-radius: 16px;
861 overflow: hidden;
862 }
863 .commits-hero-orb-wrap {
864 position: absolute;
865 inset: -25% -10% auto auto;
866 width: 320px;
867 height: 320px;
868 pointer-events: none;
869 z-index: 0;
870 }
871 .commits-hero-orb {
872 position: absolute;
873 inset: 0;
6fd5915Claude874 background: radial-gradient(circle, rgba(91,110,232,0.16), rgba(95,143,160,0.08) 45%, transparent 70%);
efb11c5Claude875 filter: blur(80px);
876 opacity: 0.7;
877 animation: cbHeroOrb 14s ease-in-out infinite;
878 }
879 .commits-hero-inner { position: relative; z-index: 1; }
880 .commits-eyebrow {
881 font-size: 12px;
882 font-family: var(--font-mono);
883 color: var(--text-muted);
884 letter-spacing: 0.1em;
885 text-transform: uppercase;
886 margin-bottom: var(--space-2);
887 }
888 .commits-eyebrow strong { color: var(--accent); font-weight: 600; }
889 .commits-title {
890 font-family: var(--font-display);
891 font-weight: 800;
892 letter-spacing: -0.025em;
893 font-size: clamp(22px, 3vw, 30px);
894 line-height: 1.15;
895 margin: 0 0 var(--space-2);
896 color: var(--text-strong);
897 }
898 .commits-branch {
899 font-family: var(--font-mono);
900 font-size: 0.7em;
901 color: var(--text);
902 background: var(--bg-secondary);
903 border: 1px solid var(--border);
904 border-radius: 6px;
905 padding: 2px 8px;
906 font-weight: 500;
907 vertical-align: middle;
908 }
909 .commits-sub {
910 font-size: 14px;
911 color: var(--text-muted);
912 margin: 0;
913 line-height: 1.55;
914 max-width: 640px;
915 }
398a10cClaude916 .commits-toolbar {
917 display: flex;
918 justify-content: space-between;
919 align-items: center;
920 flex-wrap: wrap;
921 gap: var(--space-2);
922 margin-bottom: var(--space-3);
923 }
924 .commits-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
925 .commits-toolbar-link {
926 display: inline-flex;
927 align-items: center;
928 gap: 6px;
929 padding: 6px 12px;
930 font-size: 12.5px;
931 font-weight: 500;
932 color: var(--text-muted);
933 background: rgba(255,255,255,0.025);
934 border: 1px solid var(--border);
935 border-radius: 8px;
936 text-decoration: none;
937 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
938 }
939 .commits-toolbar-link:hover {
940 border-color: var(--border-strong);
941 color: var(--text-strong);
942 background: rgba(255,255,255,0.04);
943 text-decoration: none;
944 }
efb11c5Claude945 .commits-list-wrap {
946 background: var(--bg-elevated);
947 border: 1px solid var(--border);
398a10cClaude948 border-radius: 14px;
efb11c5Claude949 overflow: hidden;
398a10cClaude950 position: relative;
951 }
952 .commits-list-wrap::before {
953 content: '';
954 position: absolute;
955 top: 0; left: 0; right: 0;
956 height: 2px;
6fd5915Claude957 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude958 opacity: 0.55;
959 pointer-events: none;
960 }
961 .commits-day-head {
962 display: flex;
963 align-items: center;
964 gap: 10px;
965 padding: 10px 18px;
966 font-size: 11.5px;
967 font-family: var(--font-mono);
968 text-transform: uppercase;
969 letter-spacing: 0.08em;
970 color: var(--text-muted);
971 background: var(--bg-secondary);
972 border-bottom: 1px solid var(--border);
973 }
974 .commits-day-head:not(:first-child) { border-top: 1px solid var(--border); }
975 .commits-day-head-dot {
976 width: 6px; height: 6px;
977 border-radius: 9999px;
6fd5915Claude978 background: linear-gradient(135deg, #5b6ee8, #5f8fa0);
398a10cClaude979 }
980 .commits-row {
981 display: flex;
982 align-items: flex-start;
983 gap: 14px;
984 padding: 14px 18px;
985 border-bottom: 1px solid var(--border-subtle);
986 transition: background 120ms ease;
987 }
988 .commits-row:last-child { border-bottom: none; }
989 .commits-row:hover { background: rgba(255,255,255,0.022); }
990 .commits-avatar {
991 width: 34px; height: 34px;
992 border-radius: 9999px;
6fd5915Claude993 background: linear-gradient(135deg, rgba(91,110,232,0.30), rgba(95,143,160,0.25));
398a10cClaude994 color: #fff;
995 display: inline-flex;
996 align-items: center;
997 justify-content: center;
998 font-family: var(--font-display);
999 font-weight: 700;
1000 font-size: 13.5px;
1001 flex-shrink: 0;
1002 box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
1003 }
1004 .commits-row-body { flex: 1; min-width: 0; }
1005 .commits-row-msg {
1006 display: flex;
1007 align-items: center;
1008 gap: 8px;
1009 flex-wrap: wrap;
1010 }
1011 .commits-row-msg a {
1012 font-family: var(--font-display);
1013 font-weight: 600;
1014 font-size: 14px;
1015 color: var(--text-strong);
1016 text-decoration: none;
1017 letter-spacing: -0.005em;
1018 }
1019 .commits-row-msg a:hover { color: var(--accent); text-decoration: none; }
1020 .commits-row-verified {
1021 font-size: 9.5px;
1022 padding: 1px 7px;
1023 border-radius: 9999px;
1024 background: rgba(52,211,153,0.16);
1025 color: #6ee7b7;
1026 box-shadow: inset 0 0 0 1px rgba(52,211,153,0.30);
1027 text-transform: uppercase;
1028 letter-spacing: 0.06em;
1029 font-weight: 700;
1030 }
1031 .commits-row-meta {
1032 margin-top: 4px;
1033 display: flex;
1034 align-items: center;
1035 gap: 8px;
1036 flex-wrap: wrap;
1037 font-size: 12.5px;
1038 color: var(--text-muted);
1039 }
1040 .commits-row-meta strong { color: var(--text); font-weight: 600; }
1041 .commits-row-meta .sep { opacity: 0.4; }
1042 .commits-row-time {
1043 font-variant-numeric: tabular-nums;
1044 }
1045 .commits-row-side {
1046 display: flex;
1047 align-items: center;
1048 gap: 8px;
1049 flex-shrink: 0;
1050 }
1051 .commits-row-sha {
1052 display: inline-flex;
1053 align-items: center;
1054 padding: 4px 10px;
1055 border-radius: 9999px;
1056 font-family: var(--font-mono);
1057 font-size: 11.5px;
1058 font-weight: 600;
1059 color: var(--text-strong);
1060 background: rgba(255,255,255,0.04);
1061 border: 1px solid var(--border);
1062 text-decoration: none;
1063 letter-spacing: 0.04em;
1064 transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
1065 }
1066 .commits-row-sha:hover {
6fd5915Claude1067 border-color: rgba(91,110,232,0.55);
398a10cClaude1068 color: var(--accent);
6fd5915Claude1069 background: rgba(91,110,232,0.08);
398a10cClaude1070 text-decoration: none;
1071 }
1072 .commits-row-copy {
1073 display: inline-flex;
1074 align-items: center;
1075 justify-content: center;
1076 width: 28px; height: 28px;
1077 padding: 0;
1078 border-radius: 8px;
1079 background: transparent;
1080 border: 1px solid var(--border);
1081 color: var(--text-muted);
1082 cursor: pointer;
1083 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
efb11c5Claude1084 }
398a10cClaude1085 .commits-row-copy:hover {
1086 border-color: var(--border-strong);
1087 color: var(--text);
1088 background: rgba(255,255,255,0.04);
1089 }
1090 .commits-row-copy.is-copied { color: #6ee7b7; border-color: rgba(52,211,153,0.35); }
8c790e0Claude1091 /* Push Watch link — eye icon next to the SHA chip */
1092 .commits-row-watch {
1093 display: inline-flex;
1094 align-items: center;
1095 justify-content: center;
1096 width: 28px;
1097 height: 28px;
1098 border-radius: 6px;
1099 border: 1px solid var(--border);
1100 color: var(--text-muted);
1101 background: transparent;
1102 cursor: pointer;
1103 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1104 text-decoration: none !important;
1105 }
1106 .commits-row-watch:hover {
6fd5915Claude1107 border-color: rgba(91,110,232,0.45);
8c790e0Claude1108 color: var(--accent);
6fd5915Claude1109 background: rgba(91,110,232,0.08);
8c790e0Claude1110 text-decoration: none !important;
1111 }
efb11c5Claude1112 .commits-empty {
398a10cClaude1113 position: relative;
1114 overflow: hidden;
1115 padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 36px);
efb11c5Claude1116 text-align: center;
398a10cClaude1117 background: var(--bg-elevated);
1118 border: 1px dashed var(--border-strong);
1119 border-radius: 16px;
1120 }
1121 .commits-empty-orb {
1122 position: absolute;
1123 inset: -40% 30% auto 30%;
1124 height: 280px;
6fd5915Claude1125 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.10) 45%, transparent 70%);
398a10cClaude1126 filter: blur(70px);
1127 opacity: 0.7;
1128 pointer-events: none;
1129 z-index: 0;
1130 }
1131 .commits-empty-inner { position: relative; z-index: 1; }
1132 .commits-empty-icon {
1133 width: 56px; height: 56px;
1134 border-radius: 9999px;
6fd5915Claude1135 background: linear-gradient(135deg, rgba(91,110,232,0.25), rgba(95,143,160,0.20));
1136 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.40);
398a10cClaude1137 display: inline-flex;
1138 align-items: center;
1139 justify-content: center;
1140 color: #c4b5fd;
1141 margin: 0 auto 14px;
1142 }
1143 .commits-empty-title {
1144 font-family: var(--font-display);
1145 font-size: 18px;
1146 font-weight: 700;
1147 margin: 0 0 6px;
1148 color: var(--text-strong);
1149 }
1150 .commits-empty-sub {
1151 margin: 0 auto 0;
1152 font-size: 13.5px;
efb11c5Claude1153 color: var(--text-muted);
398a10cClaude1154 max-width: 420px;
1155 line-height: 1.5;
1156 }
1157
1158 /* ───────── branches list ───────── */
1159 .branches-list {
efb11c5Claude1160 background: var(--bg-elevated);
398a10cClaude1161 border: 1px solid var(--border);
1162 border-radius: 14px;
1163 overflow: hidden;
1164 position: relative;
1165 }
1166 .branches-list::before {
1167 content: '';
1168 position: absolute;
1169 top: 0; left: 0; right: 0;
1170 height: 2px;
6fd5915Claude1171 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude1172 opacity: 0.55;
1173 pointer-events: none;
1174 }
1175 .branches-row {
1176 display: flex;
1177 align-items: center;
1178 gap: var(--space-3);
1179 padding: 14px 18px;
1180 border-bottom: 1px solid var(--border-subtle);
1181 transition: background 120ms ease;
1182 flex-wrap: wrap;
1183 }
1184 .branches-row:last-child { border-bottom: none; }
1185 .branches-row:hover { background: rgba(255,255,255,0.022); }
1186 .branches-row-icon {
1187 width: 32px; height: 32px;
1188 border-radius: 8px;
6fd5915Claude1189 background: rgba(91,110,232,0.10);
398a10cClaude1190 color: #c4b5fd;
1191 display: inline-flex;
1192 align-items: center;
1193 justify-content: center;
1194 flex-shrink: 0;
6fd5915Claude1195 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.22);
398a10cClaude1196 }
1197 .branches-row-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
1198 .branches-row-name {
1199 display: inline-flex;
1200 align-items: center;
1201 gap: 8px;
1202 flex-wrap: wrap;
1203 }
1204 .branches-row-name a {
1205 font-family: var(--font-mono);
1206 font-size: 13.5px;
1207 color: var(--text-strong);
1208 font-weight: 600;
1209 text-decoration: none;
1210 }
1211 .branches-row-name a:hover { color: var(--accent); text-decoration: none; }
1212 .branches-row-default {
1213 font-size: 10px;
1214 padding: 2px 8px;
1215 border-radius: 9999px;
6fd5915Claude1216 background: rgba(91,110,232,0.14);
398a10cClaude1217 color: #c4b5fd;
6fd5915Claude1218 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.30);
398a10cClaude1219 text-transform: uppercase;
1220 letter-spacing: 0.08em;
1221 font-weight: 700;
1222 font-family: var(--font-mono);
1223 }
1224 .branches-row-meta {
1225 display: flex;
1226 align-items: center;
1227 gap: 8px;
1228 flex-wrap: wrap;
1229 font-size: 12.5px;
1230 color: var(--text-muted);
1231 font-variant-numeric: tabular-nums;
1232 }
1233 .branches-row-meta .sep { opacity: 0.4; }
1234 .branches-row-meta strong { color: var(--text); font-weight: 600; }
1235 .branches-row-side {
1236 display: flex;
1237 align-items: center;
1238 gap: 10px;
1239 flex-shrink: 0;
1240 flex-wrap: wrap;
1241 }
1242 .branches-row-divergence {
1243 display: inline-flex;
1244 align-items: center;
1245 gap: 8px;
1246 font-family: var(--font-mono);
1247 font-size: 11.5px;
1248 color: var(--text-muted);
1249 padding: 4px 10px;
1250 border-radius: 9999px;
1251 background: rgba(255,255,255,0.035);
1252 border: 1px solid var(--border);
1253 font-variant-numeric: tabular-nums;
1254 }
1255 .branches-row-divergence .ahead { color: #6ee7b7; }
1256 .branches-row-divergence .behind { color: #fca5a5; }
1257 .branches-row-actions {
1258 display: flex;
1259 align-items: center;
1260 gap: 6px;
1261 }
1262 .branches-btn {
1263 display: inline-flex;
1264 align-items: center;
1265 gap: 5px;
1266 padding: 6px 12px;
1267 border-radius: 9999px;
1268 font-size: 12px;
1269 font-weight: 600;
1270 text-decoration: none;
1271 border: 1px solid var(--border);
1272 background: transparent;
1273 color: var(--text-muted);
1274 cursor: pointer;
1275 font: inherit;
1276 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1277 }
1278 .branches-btn:hover {
1279 border-color: var(--border-strong);
1280 color: var(--text);
1281 background: rgba(255,255,255,0.04);
1282 text-decoration: none;
1283 }
1284 .branches-btn-danger {
1285 color: #fca5a5;
1286 border-color: rgba(248,113,113,0.30);
1287 }
1288 .branches-btn-danger:hover {
1289 border-style: dashed;
1290 border-color: rgba(248,113,113,0.65);
1291 background: rgba(248,113,113,0.06);
1292 color: #fecaca;
1293 }
1294
1295 /* ───────── tags list ───────── */
1296 .tags-list {
1297 background: var(--bg-elevated);
1298 border: 1px solid var(--border);
1299 border-radius: 14px;
1300 overflow: hidden;
1301 position: relative;
1302 }
1303 .tags-list::before {
1304 content: '';
1305 position: absolute;
1306 top: 0; left: 0; right: 0;
1307 height: 2px;
6fd5915Claude1308 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude1309 opacity: 0.55;
1310 pointer-events: none;
1311 }
1312 .tags-row {
1313 display: flex;
1314 align-items: center;
1315 gap: var(--space-3);
1316 padding: 14px 18px;
1317 border-bottom: 1px solid var(--border-subtle);
1318 transition: background 120ms ease;
1319 flex-wrap: wrap;
1320 }
1321 .tags-row:last-child { border-bottom: none; }
1322 .tags-row:hover { background: rgba(255,255,255,0.022); }
1323 .tags-row-icon {
1324 width: 32px; height: 32px;
1325 border-radius: 8px;
6fd5915Claude1326 background: rgba(95,143,160,0.10);
398a10cClaude1327 color: #67e8f9;
1328 display: inline-flex;
1329 align-items: center;
1330 justify-content: center;
1331 flex-shrink: 0;
6fd5915Claude1332 box-shadow: inset 0 0 0 1px rgba(95,143,160,0.22);
398a10cClaude1333 }
1334 .tags-row-main { flex: 1; min-width: 240px; }
1335 .tags-row-name {
1336 display: inline-flex;
1337 align-items: center;
1338 gap: 8px;
1339 flex-wrap: wrap;
1340 }
1341 .tags-row-version {
1342 display: inline-flex;
1343 align-items: center;
1344 padding: 3px 11px;
1345 border-radius: 9999px;
1346 font-family: var(--font-mono);
1347 font-size: 13px;
1348 font-weight: 700;
1349 color: #67e8f9;
6fd5915Claude1350 background: rgba(95,143,160,0.12);
1351 box-shadow: inset 0 0 0 1px rgba(95,143,160,0.30);
398a10cClaude1352 letter-spacing: 0.01em;
1353 }
1354 .tags-row-meta {
1355 margin-top: 4px;
1356 display: flex;
1357 align-items: center;
1358 gap: 8px;
1359 flex-wrap: wrap;
1360 font-size: 12.5px;
1361 color: var(--text-muted);
1362 font-variant-numeric: tabular-nums;
1363 }
1364 .tags-row-meta .sep { opacity: 0.4; }
1365 .tags-row-sha {
1366 font-family: var(--font-mono);
1367 font-size: 11.5px;
1368 color: var(--text-strong);
1369 padding: 2px 8px;
1370 border-radius: 6px;
1371 background: rgba(255,255,255,0.04);
1372 border: 1px solid var(--border);
1373 text-decoration: none;
1374 letter-spacing: 0.04em;
1375 }
1376 .tags-row-sha:hover { border-color: var(--border-strong); color: var(--accent); text-decoration: none; }
1377 .tags-row-side {
1378 display: flex;
1379 align-items: center;
1380 gap: 6px;
1381 flex-shrink: 0;
1382 flex-wrap: wrap;
1383 }
1384 .tags-row-link {
1385 display: inline-flex;
1386 align-items: center;
1387 gap: 5px;
1388 padding: 6px 12px;
1389 border-radius: 9999px;
1390 font-size: 12px;
1391 font-weight: 600;
1392 text-decoration: none;
1393 color: var(--text-muted);
1394 background: rgba(255,255,255,0.025);
1395 border: 1px solid var(--border);
1396 transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
1397 }
1398 .tags-row-link:hover {
6fd5915Claude1399 border-color: rgba(91,110,232,0.45);
398a10cClaude1400 color: var(--text-strong);
6fd5915Claude1401 background: rgba(91,110,232,0.06);
398a10cClaude1402 text-decoration: none;
efb11c5Claude1403 }
1404
1405 /* ───────── commit detail ───────── */
1406 .commit-detail-card {
1407 position: relative;
1408 margin-bottom: var(--space-5);
1409 padding: var(--space-5) var(--space-5);
1410 background: var(--bg-elevated);
1411 border: 1px solid var(--border);
1412 border-radius: 14px;
1413 overflow: hidden;
1414 }
1415 .commit-detail-eyebrow {
1416 display: flex;
1417 align-items: center;
1418 gap: var(--space-2);
1419 font-size: 12px;
1420 font-family: var(--font-mono);
1421 text-transform: uppercase;
1422 letter-spacing: 0.1em;
1423 color: var(--text-muted);
1424 margin-bottom: var(--space-2);
1425 }
1426 .commit-detail-eyebrow strong { color: var(--accent); font-weight: 600; }
1427 .commit-detail-sha-pill {
1428 font-family: var(--font-mono);
1429 font-size: 11.5px;
1430 color: var(--text-strong);
1431 background: var(--bg-secondary);
1432 border: 1px solid var(--border);
1433 border-radius: 999px;
1434 padding: 2px 10px;
1435 letter-spacing: 0.04em;
1436 }
1437 .commit-detail-verify {
1438 font-size: 10px;
1439 padding: 2px 8px;
1440 border-radius: 999px;
1441 text-transform: uppercase;
1442 letter-spacing: 0.06em;
1443 font-weight: 700;
1444 color: #fff;
1445 }
1446 .commit-detail-verify-ok {
1447 background: linear-gradient(135deg, #2ea043, #34d399);
1448 }
1449 .commit-detail-verify-warn {
1450 background: linear-gradient(135deg, #d29922, #f59e0b);
1451 }
1452 .commit-detail-title {
1453 font-family: var(--font-display);
1454 font-weight: 700;
1455 letter-spacing: -0.018em;
1456 font-size: clamp(20px, 2.5vw, 26px);
1457 line-height: 1.25;
1458 margin: 0 0 var(--space-2);
1459 color: var(--text-strong);
1460 }
1461 .commit-detail-body {
1462 white-space: pre-wrap;
1463 color: var(--text-muted);
1464 font-size: 14px;
1465 line-height: 1.55;
1466 margin: 0 0 var(--space-3);
1467 font-family: var(--font-mono);
1468 background: var(--bg);
1469 border: 1px solid var(--border);
1470 border-radius: 8px;
1471 padding: var(--space-3) var(--space-4);
1472 max-height: 280px;
1473 overflow: auto;
1474 }
1475 .commit-detail-meta {
1476 display: flex;
1477 flex-wrap: wrap;
1478 gap: var(--space-3);
1479 font-size: 13px;
1480 color: var(--text-muted);
1481 margin-bottom: var(--space-3);
1482 }
1483 .commit-detail-author strong { color: var(--text-strong); font-weight: 600; }
1484 .commit-detail-parents { font-size: 13px; color: var(--text-muted); }
1485 .commit-detail-sha-link {
1486 font-family: var(--font-mono);
1487 font-size: 12.5px;
1488 color: var(--accent);
6fd5915Claude1489 background: rgba(91,110,232,0.08);
efb11c5Claude1490 border-radius: 6px;
1491 padding: 1px 6px;
1492 margin-left: 2px;
1493 }
6fd5915Claude1494 .commit-detail-sha-link:hover { background: rgba(91,110,232,0.16); text-decoration: none; }
efb11c5Claude1495 .commit-detail-stats {
1496 display: flex;
1497 flex-wrap: wrap;
1498 align-items: center;
1499 gap: var(--space-3);
1500 padding-top: var(--space-3);
1501 border-top: 1px solid var(--border);
1502 font-size: 13px;
1503 color: var(--text-muted);
1504 }
1505 .commit-detail-stat {
1506 display: inline-flex;
1507 align-items: center;
1508 gap: 4px;
1509 font-variant-numeric: tabular-nums;
1510 }
1511 .commit-detail-stat strong { color: var(--text-strong); font-weight: 600; }
1512 .commit-detail-stat-add strong { color: #34d399; }
1513 .commit-detail-stat-del strong { color: #f87171; }
1514 .commit-detail-stat-mark {
1515 font-family: var(--font-mono);
1516 font-weight: 700;
1517 font-size: 14px;
1518 }
1519 .commit-detail-stat-add .commit-detail-stat-mark { color: #34d399; }
1520 .commit-detail-stat-del .commit-detail-stat-mark { color: #f87171; }
1521 .commit-detail-sha-full {
1522 margin-left: auto;
1523 font-family: var(--font-mono);
1524 font-size: 11.5px;
1525 color: var(--text-faint);
1526 letter-spacing: 0.02em;
1527 overflow: hidden;
1528 text-overflow: ellipsis;
1529 white-space: nowrap;
1530 max-width: 100%;
1531 }
1532 .commit-detail-checks {
1533 margin-top: var(--space-3);
1534 padding-top: var(--space-3);
1535 border-top: 1px solid var(--border);
1536 }
1537 .commit-detail-checks-head {
1538 display: flex;
1539 align-items: center;
1540 gap: var(--space-2);
1541 font-size: 13px;
1542 color: var(--text-muted);
1543 margin-bottom: 8px;
1544 }
1545 .commit-detail-checks-head strong { color: var(--text-strong); font-weight: 600; }
1546 .commit-detail-check-state-success { color: #34d399; font-weight: 600; }
1547 .commit-detail-check-state-failure { color: #f87171; font-weight: 600; }
1548 .commit-detail-check-state-pending { color: #d29922; font-weight: 600; }
1549 .commit-detail-check-row { display: flex; flex-wrap: wrap; gap: 6px; }
1550 .commit-detail-check {
1551 font-size: 11px;
1552 padding: 2px 8px;
1553 border-radius: 999px;
1554 color: #fff;
1555 font-weight: 500;
1556 }
398a10cClaude1557 .commit-detail-check a { color: inherit; text-decoration: none; }
1558 .commit-detail-check-success { background: #2ea043; }
1559 .commit-detail-check-pending { background: #d29922; }
1560 .commit-detail-check-failure { background: #da3633; }
1561
1562 /* ───────── blame ───────── */
1563 .blame-head { margin-bottom: var(--space-5); }
1564 .blame-eyebrow {
1565 display: inline-flex;
1566 align-items: center;
1567 gap: 8px;
1568 text-transform: uppercase;
1569 font-family: var(--font-mono);
1570 font-size: 11px;
1571 letter-spacing: 0.16em;
1572 color: var(--text-muted);
1573 font-weight: 600;
1574 margin-bottom: 10px;
1575 }
1576 .blame-eyebrow-dot {
1577 width: 8px; height: 8px;
1578 border-radius: 9999px;
6fd5915Claude1579 background: linear-gradient(135deg, #5b6ee8, #5f8fa0);
1580 box-shadow: 0 0 0 3px rgba(91,110,232,0.18);
398a10cClaude1581 }
1582 .blame-title {
1583 font-family: var(--font-display);
1584 font-size: clamp(22px, 3vw, 30px);
1585 font-weight: 800;
1586 letter-spacing: -0.025em;
1587 line-height: 1.15;
1588 margin: 0 0 6px;
1589 color: var(--text-strong);
1590 }
1591 .blame-title code {
1592 font-family: var(--font-mono);
1593 font-size: 0.78em;
1594 color: var(--text-strong);
1595 font-weight: 700;
1596 }
1597 .blame-sub {
1598 margin: 0;
1599 font-size: 14px;
1600 color: var(--text-muted);
1601 line-height: 1.5;
1602 max-width: 700px;
1603 }
efb11c5Claude1604 .blame-toolbar {
398a10cClaude1605 display: flex;
1606 justify-content: space-between;
1607 align-items: center;
1608 gap: var(--space-3);
efb11c5Claude1609 margin-bottom: var(--space-3);
398a10cClaude1610 flex-wrap: wrap;
efb11c5Claude1611 font-size: 13px;
1612 }
398a10cClaude1613 .blame-toolbar-actions { display: flex; gap: 6px; }
1614 .blame-card {
1615 background: var(--bg-elevated);
1616 border: 1px solid var(--border);
1617 border-radius: 14px;
1618 overflow: hidden;
1619 position: relative;
1620 }
1621 .blame-card::before {
1622 content: '';
1623 position: absolute;
1624 top: 0; left: 0; right: 0;
1625 height: 2px;
6fd5915Claude1626 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
398a10cClaude1627 opacity: 0.55;
1628 pointer-events: none;
1629 }
efb11c5Claude1630 .blame-header {
1631 display: flex;
1632 align-items: center;
1633 justify-content: space-between;
1634 gap: var(--space-3);
1635 padding: 10px 14px;
1636 background: var(--bg-secondary);
1637 border-bottom: 1px solid var(--border);
1638 }
1639 .blame-header-meta {
1640 display: flex;
1641 align-items: center;
1642 gap: var(--space-2);
1643 min-width: 0;
1644 flex-wrap: wrap;
1645 }
1646 .blame-header-icon { color: var(--accent); font-size: 14px; }
1647 .blame-header-name {
1648 font-family: var(--font-mono);
1649 font-size: 13px;
1650 color: var(--text-strong);
1651 font-weight: 600;
1652 }
1653 .blame-header-tag {
1654 font-size: 10.5px;
1655 text-transform: uppercase;
1656 letter-spacing: 0.08em;
1657 font-family: var(--font-mono);
6fd5915Claude1658 background: rgba(91,110,232,0.12);
efb11c5Claude1659 color: var(--accent);
1660 border-radius: 999px;
1661 padding: 2px 8px;
1662 font-weight: 600;
1663 }
1664 .blame-header-stats {
1665 font-family: var(--font-mono);
1666 font-size: 11.5px;
1667 color: var(--text-muted);
1668 font-variant-numeric: tabular-nums;
1669 border-left: 1px solid var(--border);
1670 padding-left: var(--space-2);
1671 }
1672 .blame-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
398a10cClaude1673 .blame-table {
1674 width: 100%;
1675 border-collapse: collapse;
1676 font-family: var(--font-mono);
1677 font-size: 12.5px;
1678 line-height: 1.6;
1679 }
1680 .blame-table tr { border-bottom: 1px solid transparent; }
1681 .blame-table tr.blame-row-first { border-top: 1px solid var(--border); }
1682 .blame-table tr:first-child.blame-row-first { border-top: 0; }
1683 .blame-table tr:hover .blame-line-content { background: rgba(255,255,255,0.025); }
1684 .blame-gutter {
1685 width: 220px;
1686 min-width: 220px;
1687 padding: 0 12px;
1688 vertical-align: top;
1689 background: rgba(255,255,255,0.012);
1690 border-right: 1px solid var(--border-subtle);
1691 font-variant-numeric: tabular-nums;
1692 color: var(--text-muted);
1693 font-size: 11px;
1694 white-space: nowrap;
1695 overflow: hidden;
1696 text-overflow: ellipsis;
1697 padding-top: 2px;
1698 padding-bottom: 2px;
1699 }
1700 .blame-gutter-inner {
1701 display: inline-flex;
1702 align-items: center;
1703 gap: 7px;
1704 max-width: 100%;
1705 overflow: hidden;
1706 }
1707 .blame-gutter-sha {
1708 font-family: var(--font-mono);
1709 font-size: 10.5px;
1710 font-weight: 600;
1711 color: #c4b5fd;
6fd5915Claude1712 background: rgba(91,110,232,0.10);
398a10cClaude1713 padding: 1px 7px;
1714 border-radius: 9999px;
6fd5915Claude1715 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.22);
398a10cClaude1716 text-decoration: none;
1717 letter-spacing: 0.04em;
1718 flex-shrink: 0;
1719 transition: background 120ms ease, box-shadow 120ms ease, color 120ms ease;
1720 }
1721 .blame-gutter-sha:hover {
6fd5915Claude1722 background: rgba(91,110,232,0.22);
398a10cClaude1723 color: #ddd6fe;
6fd5915Claude1724 box-shadow: inset 0 0 0 1px rgba(91,110,232,0.50);
398a10cClaude1725 text-decoration: none;
1726 }
1727 .blame-gutter-author {
1728 color: var(--text);
1729 overflow: hidden;
1730 text-overflow: ellipsis;
1731 white-space: nowrap;
1732 font-size: 11px;
1733 font-family: var(--font-sans, inherit);
1734 }
1735 .blame-line-num {
1736 width: 1%;
1737 min-width: 50px;
1738 padding: 0 12px;
1739 text-align: right;
1740 color: var(--text-faint);
1741 user-select: none;
1742 border-right: 1px solid var(--border-subtle);
1743 font-variant-numeric: tabular-nums;
1744 }
1745 .blame-line-content {
1746 padding: 0 14px;
1747 white-space: pre;
1748 color: var(--text);
1749 transition: background 120ms ease;
1750 }
efb11c5Claude1751
1752 /* ───────── search ───────── */
1753 .search-hero {
1754 position: relative;
1755 margin-bottom: var(--space-4);
1756 padding: var(--space-5) var(--space-6);
1757 background: var(--bg-elevated);
1758 border: 1px solid var(--border);
1759 border-radius: 16px;
1760 overflow: hidden;
1761 }
1762 .search-eyebrow {
1763 font-size: 12px;
1764 font-family: var(--font-mono);
1765 color: var(--text-muted);
1766 letter-spacing: 0.1em;
1767 text-transform: uppercase;
1768 margin-bottom: var(--space-2);
1769 }
1770 .search-eyebrow strong { color: var(--accent); font-weight: 600; }
1771 .search-title {
1772 font-family: var(--font-display);
1773 font-weight: 800;
1774 letter-spacing: -0.025em;
1775 font-size: clamp(22px, 3vw, 30px);
1776 line-height: 1.15;
1777 margin: 0 0 var(--space-3);
1778 color: var(--text-strong);
1779 }
1780 .search-form {
1781 display: flex;
1782 gap: var(--space-2);
1783 align-items: stretch;
1784 }
1785 .search-input-wrap {
1786 position: relative;
1787 flex: 1;
1788 display: flex;
1789 align-items: center;
1790 }
1791 .search-input-icon {
1792 position: absolute;
1793 left: 12px;
1794 color: var(--text-muted);
1795 font-size: 15px;
1796 pointer-events: none;
1797 }
1798 .search-input {
1799 appearance: none;
1800 width: 100%;
1801 padding: 10px 12px 10px 34px;
1802 background: var(--bg);
1803 border: 1px solid var(--border);
1804 border-radius: 10px;
1805 color: var(--text-strong);
1806 font-size: 14px;
1807 font-family: inherit;
1808 transition: border-color var(--t-fast, 0.15s) ease, box-shadow var(--t-fast, 0.15s) ease;
1809 }
1810 .search-input:focus {
1811 outline: none;
1812 border-color: var(--accent);
6fd5915Claude1813 box-shadow: 0 0 0 3px rgba(91,110,232,0.18);
efb11c5Claude1814 }
1815 .search-submit { min-width: 96px; }
1816 .search-results-head {
1817 display: flex;
1818 align-items: baseline;
1819 gap: var(--space-2);
1820 margin-bottom: var(--space-3);
1821 font-size: 13px;
1822 color: var(--text-muted);
1823 }
1824 .search-results-count strong {
1825 color: var(--text-strong);
1826 font-weight: 600;
1827 font-variant-numeric: tabular-nums;
1828 }
1829 .search-results-q { color: var(--text-strong); font-weight: 600; }
1830 .search-results-head code {
1831 font-family: var(--font-mono);
1832 font-size: 12px;
1833 background: var(--bg-secondary);
1834 border: 1px solid var(--border);
1835 border-radius: 5px;
1836 padding: 1px 6px;
1837 color: var(--text);
1838 }
1839 .search-empty {
1840 padding: var(--space-5) var(--space-6);
1841 background: var(--bg-elevated);
1842 border: 1px dashed var(--border);
1843 border-radius: 12px;
1844 color: var(--text-muted);
1845 font-size: 14px;
1846 }
1847 .search-empty strong { color: var(--text-strong); }
1848 .search-results {
1849 display: flex;
1850 flex-direction: column;
1851 gap: var(--space-3);
1852 }
1853 .search-file-head {
1854 display: flex;
1855 align-items: center;
1856 justify-content: space-between;
1857 gap: var(--space-2);
1858 }
1859 .search-file-link {
1860 font-family: var(--font-mono);
1861 font-size: 13px;
1862 color: var(--text-strong);
1863 font-weight: 600;
1864 }
1865 .search-file-link:hover { color: var(--accent); text-decoration: none; }
1866 .search-file-count {
1867 font-family: var(--font-mono);
1868 font-size: 11.5px;
1869 color: var(--text-muted);
1870 font-variant-numeric: tabular-nums;
1871 }
1872`;
1873
fc1817aClaude1874// Home page
06d5ffeClaude1875web.get("/", async (c) => {
1876 const user = c.get("user");
1877
1878 if (user) {
0316dbbClaude1879 return c.redirect("/dashboard");
06d5ffeClaude1880 }
1881
8e9f1d9Claude1882 let stats: { publicRepos?: number; users?: number } | undefined;
52ad8b1Claude1883 let publicStats: PublicStats | null = null;
8e9f1d9Claude1884 try {
1885 const [repoRow] = await db
1886 .select({ n: sql<number>`count(*)::int` })
1887 .from(repositories)
1888 .where(eq(repositories.isPrivate, false));
1889 const [userRow] = await db
1890 .select({ n: sql<number>`count(*)::int` })
1891 .from(users);
1892 stats = {
1893 publicRepos: Number(repoRow?.n ?? 0),
1894 users: Number(userRow?.n ?? 0),
1895 };
1896 } catch {
1897 stats = undefined;
1898 }
1899
52ad8b1Claude1900 // Block L4 — public stats counters (5-min in-memory cache; never throws).
1901 try {
1902 publicStats = await computePublicStats();
1903 } catch {
1904 publicStats = null;
1905 }
1906
534f04aClaude1907 // Block M1 — initial SSR snapshot for the live-now demo feed.
1908 // The helpers in lib/demo-activity.ts never throw, but we still wrap
1909 // in try/catch so a freak module-level explosion can't take down /.
1910 let liveFeed: LandingLiveFeed | null = null;
1911 try {
1912 const [queued, merges, reviewList, reviewCount, feed] = await Promise.all([
1913 listQueuedAiBuildIssues(3),
1914 listRecentAutoMerges(3, 24),
1915 listRecentAiReviews(3, 24),
1916 countAiReviewsSince(24),
1917 listDemoActivityFeed(10),
1918 ]);
1919 liveFeed = {
1920 queued: queued.map((i) => ({
1921 repo: i.repo,
1922 number: i.number,
1923 title: i.title,
1924 createdAt: i.createdAt,
1925 })),
1926 merges: merges.map((m) => ({
1927 repo: m.repo,
1928 number: m.number,
1929 title: m.title,
1930 mergedAt: m.mergedAt,
1931 })),
1932 reviews: reviewList.map((r) => ({
1933 repo: r.repo,
1934 prNumber: r.prNumber,
1935 commentSnippet: r.commentSnippet,
1936 createdAt: r.createdAt,
1937 })),
1938 reviewCount,
1939 feed: feed.map((e) => ({
1940 kind: e.kind,
1941 repo: e.repo,
1942 ref: e.ref,
1943 at: e.at,
1944 })),
1945 };
1946 } catch {
1947 liveFeed = null;
1948 }
1949
29924bcClaude1950 void LandingPage;
f8e5feaccanty labs1951 void Landing2030Page;
1952 return c.html(
1953 "<!DOCTYPE html>" +
1954 String(
1955 <LandingProPage
1956 stats={stats}
1957 publicStats={publicStats}
1958 liveFeed={liveFeed}
1959 />
1960 )
1961 );
fc1817aClaude1962});
1963
06d5ffeClaude1964// New repository form
1965web.get("/new", requireAuth, (c) => {
1966 const user = c.get("user")!;
1967 const error = c.req.query("error");
1968
1969 return c.html(
1970 <Layout title="New repository" user={user}>
efb11c5Claude1971 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
1972 <div class="new-repo-hero">
1973 <div class="new-repo-hero-orb-wrap" aria-hidden="true">
1974 <div class="new-repo-hero-orb" />
1975 </div>
1976 <div class="new-repo-hero-inner">
1977 <div class="new-repo-eyebrow">
1978 <strong>Create</strong> · {user.username}
1979 </div>
1980 <h1 class="new-repo-title">
1981 Spin up a <span class="gradient-text">repository</span>.
1982 </h1>
1983 <p class="new-repo-sub">
1984 Push your first commit, and Gluecron wires up gate checks, AI review,
1985 and auto-merge from the moment your branch lands.
1986 </p>
1987 </div>
1988 </div>
06d5ffeClaude1989 <div class="new-repo-form">
efb11c5Claude1990 {error && (
1991 <div class="new-repo-error" role="alert">
1992 {decodeURIComponent(error)}
1993 </div>
1994 )}
1995 <form method="post" action="/new" class="new-repo-form-grid">
1996 <div class="new-repo-row">
1997 <label class="new-repo-label">Owner</label>
1998 <input
1999 type="text"
2000 value={user.username}
2001 disabled
2002 aria-label="Owner"
2003 class="new-repo-input new-repo-input-disabled"
2004 />
06d5ffeClaude2005 </div>
efb11c5Claude2006 <div class="new-repo-row">
2007 <label class="new-repo-label" for="name">
2008 Repository name
2009 </label>
06d5ffeClaude2010 <input
2011 type="text"
2012 id="name"
2013 name="name"
2014 required
2015 pattern="^[a-zA-Z0-9._-]+$"
2016 placeholder="my-project"
2017 autocomplete="off"
efb11c5Claude2018 class="new-repo-input"
06d5ffeClaude2019 />
efb11c5Claude2020 <p class="new-repo-hint">
2021 Lowercase, numbers, dots, dashes, and underscores. The URL will be{" "}
2022 <code>{user.username}/&lt;name&gt;</code>.
2023 </p>
06d5ffeClaude2024 </div>
efb11c5Claude2025 <div class="new-repo-row">
2026 <label class="new-repo-label" for="description">
2027 Description{" "}
2028 <span class="new-repo-label-optional">(optional)</span>
2029 </label>
06d5ffeClaude2030 <input
2031 type="text"
2032 id="description"
2033 name="description"
2034 placeholder="A short description of your repository"
efb11c5Claude2035 class="new-repo-input"
06d5ffeClaude2036 />
2037 </div>
efb11c5Claude2038 <div class="new-repo-row">
2039 <span class="new-repo-label">Visibility</span>
2040 <div class="new-repo-visibility">
2041 <label class="new-repo-vis-card">
2042 <input
2043 type="radio"
2044 name="visibility"
2045 value="public"
2046 checked
2047 class="new-repo-vis-radio"
2048 />
2049 <span class="new-repo-vis-body">
2050 <span class="new-repo-vis-label">Public</span>
2051 <span class="new-repo-vis-desc">
2052 Anyone can see this repository. You choose who can commit.
2053 </span>
2054 </span>
2055 </label>
2056 <label class="new-repo-vis-card">
2057 <input
2058 type="radio"
2059 name="visibility"
2060 value="private"
2061 class="new-repo-vis-radio"
2062 />
2063 <span class="new-repo-vis-body">
2064 <span class="new-repo-vis-label">Private</span>
2065 <span class="new-repo-vis-desc">
2066 Only you (and collaborators you invite) can see this
2067 repository.
2068 </span>
2069 </span>
2070 </label>
2071 </div>
2072 </div>
398a10cClaude2073 <div class="new-repo-row">
2074 <span class="new-repo-label">
2075 Starter content{" "}
2076 <span class="new-repo-label-optional">(cosmetic — your first push wins)</span>
2077 </span>
2078 <div class="new-repo-templates" role="radiogroup" aria-label="Starter content">
2079 <label class="new-repo-template-chip">
2080 <input type="radio" name="starter" value="empty" checked />
2081 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2082 Empty
2083 </label>
2084 <label class="new-repo-template-chip">
2085 <input type="radio" name="starter" value="readme" />
2086 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2087 README
2088 </label>
2089 <label class="new-repo-template-chip">
2090 <input type="radio" name="starter" value="readme-mit" />
2091 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2092 README + MIT
2093 </label>
2094 <label class="new-repo-template-chip">
2095 <input type="radio" name="starter" value="node" />
2096 <span class="new-repo-template-chip-dot" aria-hidden="true" />
2097 Node + .gitignore
2098 </label>
2099 </div>
2100 <p class="new-repo-hint">
2101 Just a UI hint — push your own commits to fill the repo.
2102 </p>
2103 </div>
44f1a02Claude2104 <div class="new-repo-row">
2105 <label class="new-repo-label" for="data_region">
2106 Data region
2107 </label>
2108 <select
2109 id="data_region"
2110 name="data_region"
2111 class="new-repo-input"
2112 style="cursor: pointer;"
2113 >
2114 <option value="us" selected>US (default)</option>
2115 <option value="eu">EU (Frankfurt)</option>
2116 </select>
2117 <p class="new-repo-hint">
2118 EU data residency requires a{" "}
2119 <a href="/pricing" style="color: var(--accent); text-decoration: none;">
2120 Pro plan or higher
2121 </a>
2122 . Repositories cannot be moved between regions after creation.
2123 </p>
2124 </div>
efb11c5Claude2125 <div class="new-repo-callout">
2126 <div class="new-repo-callout-eyebrow">AI-native by default</div>
2127 <p class="new-repo-callout-body">
2128 Every push is gate-checked and reviewed by Claude automatically.
2129 Label an issue <code>ai-build</code> and Gluecron will open the PR
2130 for you.
2131 </p>
2132 </div>
2133 <div class="new-repo-actions">
398a10cClaude2134 <button type="submit" class="btn new-repo-submit">
efb11c5Claude2135 Create repository
2136 </button>
2137 <a href="/dashboard" class="btn new-repo-cancel">
2138 Cancel
2139 </a>
06d5ffeClaude2140 </div>
2141 </form>
2142 </div>
2143 </Layout>
2144 );
2145});
2146
2147web.post("/new", requireAuth, async (c) => {
2148 const user = c.get("user")!;
2149 const body = await c.req.parseBody();
2150 const name = String(body.name || "").trim();
2151 const description = String(body.description || "").trim();
2152 const isPrivate = body.visibility === "private";
44f1a02Claude2153 const dataRegion = body.data_region === "eu" ? "eu" : "us";
06d5ffeClaude2154
2155 if (!name) {
2156 return c.redirect("/new?error=Repository+name+is+required");
2157 }
2158
c63b860Claude2159 // P4 — plan-quota gate. Fail-open inside the helper so a billing
2160 // outage never blocks repo creation.
2161 const { checkRepoCreateAllowed } = await import("../lib/repo-create-gate");
2162 const gate = await checkRepoCreateAllowed(user.id);
2163 if (!gate.ok) {
2164 return c.redirect(`/new?error=${encodeURIComponent(gate.reason)}`);
2165 }
2166
06d5ffeClaude2167 if (!/^[a-zA-Z0-9._-]+$/.test(name)) {
2168 return c.redirect("/new?error=Invalid+repository+name");
2169 }
2170
2171 if (await repoExists(user.username, name)) {
2172 return c.redirect("/new?error=Repository+already+exists");
2173 }
2174
2175 const diskPath = await initBareRepo(user.username, name);
2176
3ef4c9dClaude2177 const [newRepo] = await db
2178 .insert(repositories)
2179 .values({
2180 name,
2181 ownerId: user.id,
2182 description: description || null,
2183 isPrivate,
2184 diskPath,
44f1a02Claude2185 dataRegion,
3ef4c9dClaude2186 })
2187 .returning();
2188
2189 if (newRepo) {
2190 const { bootstrapRepository } = await import("../lib/repo-bootstrap");
2191 await bootstrapRepository({
2192 repositoryId: newRepo.id,
2193 ownerUserId: user.id,
2194 defaultBranch: "main",
2195 });
2196 }
06d5ffeClaude2197
2198 return c.redirect(`/${user.username}/${name}`);
2199});
2200
11c3ab6ccanty labs2201// Daily brief — GET /brief
2202web.get("/brief", (c) => {
2203 const user = c.get("user");
2204 return c.html(<DailyBrief user={user} />);
2205});
2206
2207// Trust report — GET /trust (public)
2208web.get("/trust", (c) => {
2209 return c.html(<TrustReport />);
2210});
2211
2212// Production layers — GET /layers
2213web.get("/layers", (c) => {
2214 const user = c.get("user");
2215 return c.html(<ProductionLayers user={user} />);
2216});
2217
2218// Distribution — GET /distribute
2219web.get("/distribute", (c) => {
2220 const user = c.get("user");
2221 return c.html(<DistributionView user={user} />);
2222});
2223
06d5ffeClaude2224// User profile
fc1817aClaude2225web.get("/:owner", async (c) => {
06d5ffeClaude2226 const { owner: ownerName } = c.req.param();
2227 const user = c.get("user");
2228
2229 // Avoid clashing with fixed routes
2230 if (
2231 ["login", "register", "logout", "new", "settings", "api"].includes(
2232 ownerName
2233 )
2234 ) {
2235 return c.notFound();
2236 }
2237
2238 let ownerUser;
2239 try {
2240 const [found] = await db
2241 .select()
2242 .from(users)
2243 .where(eq(users.username, ownerName))
2244 .limit(1);
2245 ownerUser = found;
2246 } catch {
2247 // DB not available — check if repos exist on disk
2248 ownerUser = null;
2249 }
2250
2251 // Even without DB, show repos if they exist on disk
2252 let repos: any[] = [];
2253 if (ownerUser) {
2254 const allRepos = await db
2255 .select()
2256 .from(repositories)
2257 .where(eq(repositories.ownerId, ownerUser.id))
2258 .orderBy(desc(repositories.updatedAt));
2259
2260 // Show public repos to everyone, private only to owner
2261 repos =
2262 user?.id === ownerUser.id
2263 ? allRepos
2264 : allRepos.filter((r) => !r.isPrivate);
2265 }
2266
7aa8b99Claude2267 // Block J4 — follow counts + viewer's follow state
2268 let followState = {
2269 followers: 0,
2270 following: 0,
2271 viewerFollows: false,
2272 };
2273 if (ownerUser) {
2274 try {
2275 const { followCounts, isFollowing } = await import("../lib/follows");
2276 const counts = await followCounts(ownerUser.id);
2277 followState.followers = counts.followers;
2278 followState.following = counts.following;
2279 if (user && user.id !== ownerUser.id) {
2280 followState.viewerFollows = await isFollowing(user.id, ownerUser.id);
2281 }
2282 } catch {
2283 // DB hiccup — fall back to zeros.
2284 }
2285 }
2286 const canFollow = !!user && !!ownerUser && user.id !== ownerUser.id;
2287
d412586Claude2288 // Block J5 — profile README. Render owner/owner repo's README on the
2289 // profile page (GitHub convention). Tries "<user>/<user>" first, falling
2290 // back to "<user>/.github" for org-style profile repos.
2291 let profileReadmeHtml: string | null = null;
2292 try {
2293 const candidates = [ownerName, ".github"];
2294 for (const rname of candidates) {
2295 if (await repoExists(ownerName, rname)) {
2296 const ref = (await getDefaultBranch(ownerName, rname)) || "main";
2297 const md = await getReadme(ownerName, rname, ref);
2298 if (md) {
2299 profileReadmeHtml = renderMarkdown(md);
2300 break;
2301 }
2302 }
2303 }
2304 } catch {
2305 profileReadmeHtml = null;
2306 }
2307
efb11c5Claude2308 const displayName = ownerUser?.displayName || ownerName;
2309 const memberSince = ownerUser?.createdAt
2310 ? new Date(ownerUser.createdAt as unknown as string | number | Date)
2311 : null;
2312
fc1817aClaude2313 return c.html(
06d5ffeClaude2314 <Layout title={ownerName} user={user}>
efb11c5Claude2315 <style dangerouslySetInnerHTML={{ __html: codeBrowseCss }} />
2316 <div class="profile-hero">
2317 <div class="profile-hero-orb-wrap" aria-hidden="true">
2318 <div class="profile-hero-orb" />
06d5ffeClaude2319 </div>
efb11c5Claude2320 <div class="profile-hero-inner">
2321 <div class="profile-hero-avatar" aria-hidden="true">
2322 {displayName[0].toUpperCase()}
2323 </div>
2324 <div class="profile-hero-text">
2325 <div class="profile-eyebrow">
2326 <strong>Developer</strong>
2327 {memberSince && !Number.isNaN(memberSince.getTime()) && (
2328 <>
2329 {" "}· Joined{" "}
2330 {memberSince.toLocaleDateString("en-US", {
2331 month: "short",
2332 year: "numeric",
2333 })}
2334 </>
2335 )}
2336 </div>
2337 <h1 class="profile-name">
2338 <span class="gradient-text">{displayName}</span>
2339 </h1>
2340 <div class="profile-handle">@{ownerName}</div>
2341 {ownerUser?.bio && <p class="profile-bio">{ownerUser.bio}</p>}
2342 <div class="profile-meta">
2343 <a href={`/${ownerName}/followers`} class="profile-meta-link">
2344 <strong>{followState.followers}</strong> follower
2345 {followState.followers === 1 ? "" : "s"}
2346 </a>
2347 <a href={`/${ownerName}/following`} class="profile-meta-link">
2348 <strong>{followState.following}</strong> following
2349 </a>
2350 <a href={`/${ownerName}`} class="profile-meta-link">
2351 <strong>{repos.length}</strong> repo
2352 {repos.length === 1 ? "" : "s"}
2353 </a>
2354 {canFollow && (
2355 <form
2356 method="post"
2357 action={`/${ownerName}/${
2358 followState.viewerFollows ? "unfollow" : "follow"
2359 }`}
2360 class="profile-follow-form"
7aa8b99Claude2361 >
efb11c5Claude2362 <button
2363 type="submit"
2364 class={`btn ${
2365 followState.viewerFollows ? "" : "btn-primary"
2366 } btn-sm`}
2367 >
2368 {followState.viewerFollows ? "Unfollow" : "Follow"}
2369 </button>
2370 </form>
2371 )}
2372 </div>
7aa8b99Claude2373 </div>
06d5ffeClaude2374 </div>
2375 </div>
d412586Claude2376 {profileReadmeHtml && (
efb11c5Claude2377 <div class="profile-readme">
2378 <div class="profile-readme-head">
2379 <span class="profile-readme-icon">{"☰"}</span>
2380 <span>{ownerName}/{ownerName} README.md</span>
2381 </div>
2382 <div
2383 class="markdown-body profile-readme-body"
2384 dangerouslySetInnerHTML={{ __html: profileReadmeHtml }}
2385 />
2386 </div>
d412586Claude2387 )}
efb11c5Claude2388 <div class="profile-section-head">
2389 <h2 class="profile-section-title">Repositories</h2>
2390 <span class="profile-section-count">{repos.length}</span>
2391 </div>
06d5ffeClaude2392 {repos.length === 0 ? (
efb11c5Claude2393 <div class="profile-empty">
2394 <p class="profile-empty-text">
2395 No repositories yet
2396 {user?.id === ownerUser?.id ? "." : ` — ${ownerName} is just getting started.`}
2397 </p>
2398 {user?.id === ownerUser?.id && (
2399 <a href="/new" class="btn btn-primary btn-sm">
2400 + Create your first
2401 </a>
2402 )}
2403 </div>
06d5ffeClaude2404 ) : (
2405 <div class="card-grid">
2406 {repos.map((repo) => (
2407 <RepoCard repo={repo} ownerName={ownerName} />
2408 ))}
2409 </div>
2410 )}
fc1817aClaude2411 </Layout>
2412 );
2413});
2414
06d5ffeClaude2415// Star/unstar a repo
2416web.post("/:owner/:repo/star", requireAuth, async (c) => {
2417 const { owner: ownerName, repo: repoName } = c.req.param();
2418 const user = c.get("user")!;
2419
2420 try {
2421 const [ownerUser] = await db
2422 .select()
2423 .from(users)
2424 .where(eq(users.username, ownerName))
2425 .limit(1);
2426 if (!ownerUser) return c.redirect(`/${ownerName}/${repoName}`);
2427
2428 const [repo] = await db
2429 .select()
2430 .from(repositories)
2431 .where(
2432 and(
2433 eq(repositories.ownerId, ownerUser.id),
2434 eq(repositories.name, repoName)
2435 )
2436 )
2437 .limit(1);
2438 if (!repo) return c.redirect(`/${ownerName}/${repoName}`);
2439
2440 // Toggle star
2441 const [existing] = await db
2442 .select()
2443 .from(stars)
2444 .where(
2445 and(eq(stars.userId, user.id), eq(stars.repositoryId, repo.id))
2446 )
2447 .limit(1);
2448
2449 if (existing) {
2450 await db.delete(stars).where(eq(stars.id, existing.id));
2451 await db
2452 .update(repositories)
2453 .set({ starCount: Math.max(0, repo.starCount - 1) })
2454 .where(eq(repositories.id, repo.id));
2455 } else {
2456 await db.insert(stars).values({
2457 userId: user.id,
2458 repositoryId: repo.id,
2459 });
2460 await db
2461 .update(repositories)
2462 .set({ starCount: repo.starCount + 1 })
2463 .where(eq(repositories.id, repo.id));
a74f4edccanty labs2464 void fireWebhooks(repo.id, "star", { action: "created" });
06d5ffeClaude2465 }
2466 } catch {
2467 // DB error — ignore
2468 }
2469
2470 return c.redirect(`/${ownerName}/${repoName}`);
2471});
2472
641aa42Claude2473// ---------------------------------------------------------------------------
2474// Onboarding card CSS (injected inline on repo home, scoped to .ob-*)
2475// ---------------------------------------------------------------------------
2476const obCss = `
2477 .ob-card {
2478 position: relative;
2479 margin: 14px 0 18px;
6fd5915Claude2480 background: linear-gradient(135deg, rgba(91,110,232,0.08), rgba(95,143,160,0.05));
2481 border: 1px solid rgba(91,110,232,0.30);
641aa42Claude2482 border-radius: 14px;
2483 overflow: hidden;
2484 }
2485 .ob-card::before {
2486 content: '';
2487 position: absolute;
2488 top: 0; left: 0; right: 0;
2489 height: 2px;
6fd5915Claude2490 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
641aa42Claude2491 pointer-events: none;
2492 }
2493 .ob-header {
2494 padding: 16px 20px 10px;
2495 border-bottom: 1px solid var(--border);
2496 }
2497 .ob-header h3 {
2498 font-size: 16px;
2499 font-weight: 700;
2500 margin: 0 0 4px;
2501 color: var(--text-strong);
2502 }
2503 .ob-header p {
2504 font-size: 13px;
2505 color: var(--text-muted);
2506 margin: 0;
2507 }
2508 .ob-sections {
2509 display: grid;
2510 grid-template-columns: repeat(3, 1fr);
2511 gap: 0;
2512 }
2513 @media (max-width: 760px) {
2514 .ob-sections { grid-template-columns: 1fr; }
2515 }
2516 .ob-section {
2517 padding: 14px 20px;
2518 border-right: 1px solid var(--border);
2519 }
2520 .ob-section:last-child { border-right: none; }
2521 .ob-section h4 {
2522 font-size: 12px;
2523 font-weight: 700;
2524 text-transform: uppercase;
2525 letter-spacing: 0.08em;
2526 color: var(--accent);
2527 margin: 0 0 8px;
2528 }
2529 .ob-preview {
2530 font-family: var(--font-mono);
2531 font-size: 11.5px;
2532 background: var(--bg);
2533 border: 1px solid var(--border);
2534 border-radius: 6px;
2535 padding: 8px 10px;
2536 color: var(--text-muted);
2537 line-height: 1.55;
2538 margin-bottom: 8px;
2539 white-space: pre-wrap;
2540 overflow: hidden;
2541 max-height: 80px;
2542 position: relative;
2543 }
2544 .ob-preview::after {
2545 content: '';
2546 position: absolute;
2547 bottom: 0; left: 0; right: 0;
2548 height: 24px;
2549 background: linear-gradient(transparent, var(--bg));
2550 pointer-events: none;
2551 }
2552 .ob-labels {
2553 display: flex;
2554 flex-wrap: wrap;
2555 gap: 5px;
2556 margin-bottom: 8px;
2557 }
2558 .ob-label-chip {
2559 display: inline-flex;
2560 align-items: center;
2561 padding: 2px 8px;
2562 border-radius: 9999px;
2563 font-size: 11.5px;
2564 font-weight: 600;
2565 line-height: 1.5;
2566 border: 1px solid transparent;
2567 }
2568 .ob-section ul {
2569 margin: 0;
2570 padding: 0 0 0 16px;
2571 font-size: 13px;
2572 color: var(--text-muted);
2573 line-height: 1.7;
2574 }
2575 .ob-section ul li { margin-bottom: 2px; }
2576 .ob-footer {
2577 display: flex;
2578 align-items: center;
2579 justify-content: flex-end;
2580 padding: 10px 20px;
2581 border-top: 1px solid var(--border);
2582 gap: 10px;
2583 }
2584 .ob-dismiss {
2585 appearance: none;
2586 background: transparent;
2587 border: 1px solid var(--border);
2588 color: var(--text-muted);
2589 border-radius: 6px;
2590 padding: 5px 12px;
2591 font-size: 12.5px;
2592 font-family: inherit;
2593 cursor: pointer;
2594 transition: background var(--t-fast), color var(--t-fast);
2595 }
2596 .ob-dismiss:hover { background: var(--bg-hover); color: var(--text); }
2597 .btn-sm {
2598 appearance: none;
2599 background: var(--bg-elevated);
2600 border: 1px solid var(--border);
2601 color: var(--text-strong);
2602 border-radius: 6px;
2603 padding: 5px 12px;
2604 font-size: 12.5px;
2605 font-weight: 600;
2606 font-family: inherit;
2607 cursor: pointer;
2608 text-decoration: none;
2609 display: inline-flex;
2610 align-items: center;
2611 transition: background var(--t-fast);
2612 }
2613 .btn-sm:hover { background: var(--bg-hover); }
2614 .btn-sm.btn-primary {
2615 background: var(--accent);
2616 color: #fff;
2617 border-color: var(--accent);
2618 }
2619 .btn-sm.btn-primary:hover { background: var(--accent-hover); }
2620`;
2621
2622// Onboarding card component — shown to repo owner until dismissed
2623function RepoOnboardingCard({
2624 owner,
2625 repo,
2626 data,
2627}: {
2628 owner: string;
2629 repo: string;
2630 data: typeof repoOnboardingData.$inferSelect;
2631}) {
2632 const labels = (data.suggestedLabels ?? []) as Array<{
2633 name: string;
2634 color: string;
2635 description: string;
2636 }>;
2637 const suggestions = (data.firstCommitSuggestions ?? []) as string[];
2638 const readmePreview = (data.suggestedReadme ?? "").slice(0, 200);
2639
2640 return (
2641 <>
2642 <style dangerouslySetInnerHTML={{ __html: obCss }} />
2643 <div class="ob-card" id="repo-onboarding">
2644 <div class="ob-header">
2645 <h3>Get started with {owner}/{repo}</h3>
2646 <p>
2647 Detected: {data.detectedLanguage ?? "Unknown"}
2648 {data.detectedFramework ? ` / ${data.detectedFramework}` : ""}.
2649 Here&rsquo;s what we suggest to hit the ground running.
2650 </p>
2651 </div>
2652 <div class="ob-sections">
2653 <div class="ob-section">
2654 <h4>Suggested README</h4>
2655 <div class="ob-preview">{readmePreview}</div>
2656 <button
2657 class="btn-sm"
2658 type="button"
2659 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(_){};})()`}
2660 aria-label="Copy suggested README to clipboard"
2661 >
2662 Copy to clipboard
2663 </button>
2664 </div>
2665 <div class="ob-section">
2666 <h4>Suggested labels ({labels.length})</h4>
2667 <div class="ob-labels">
2668 {labels.slice(0, 6).map((l) => (
2669 <span
2670 class="ob-label-chip"
2671 style={`background:#${l.color}22;color:#${l.color};border-color:#${l.color}55`}
2672 title={l.description}
2673 >
2674 {l.name}
2675 </span>
2676 ))}
2677 </div>
2678 <form method="post" action={`/${owner}/${repo}/setup/labels`}>
2679 <button class="btn-sm btn-primary" type="submit">
2680 Create all labels
2681 </button>
2682 </form>
2683 </div>
2684 <div class="ob-section">
2685 <h4>First steps</h4>
2686 <ul>
2687 {suggestions.map((s) => (
2688 <li>{s}</li>
2689 ))}
2690 </ul>
2691 </div>
2692 </div>
2693 <div class="ob-footer">
2694 <form method="post" action={`/${owner}/${repo}/setup/dismiss`}>
2695 <button class="ob-dismiss" type="submit">
2696 Dismiss
2697 </button>
2698 </form>
2699 </div>
2700 <script
2701 dangerouslySetInnerHTML={{
2702 __html: `
2703 (function(){
2704 var card = document.getElementById('repo-onboarding');
2705 if (!card) return;
2706 document.addEventListener('keydown', function(e){
2707 if (e.key === 'Escape' && card && card.style.display !== 'none') {
2708 card.style.display = 'none';
2709 }
2710 });
2711 })();
2712 `,
2713 }}
2714 />
2715 </div>
2716 </>
2717 );
2718}
2719
2720// ---------------------------------------------------------------------------
2721// Setup routes — create suggested labels + dismiss onboarding
2722// ---------------------------------------------------------------------------
2723
2724// POST /:owner/:repo/setup/labels — creates all suggested labels for the repo.
2725// requireAuth + write access. Idempotent (label UPSERT by name).
2726web.post("/:owner/:repo/setup/labels", softAuth, requireAuth, async (c) => {
2727 const { owner, repo } = c.req.param();
2728 const user = c.get("user")!;
2729
2730 // Resolve repo + verify write access
2731 let repoRow: { id: string; ownerId: string } | null = null;
2732 try {
2733 const [ownerUser] = await db
2734 .select({ id: users.id })
2735 .from(users)
2736 .where(eq(users.username, owner))
2737 .limit(1);
2738 if (!ownerUser) return c.redirect(`/${owner}/${repo}?error=Not+found`);
2739 const [r] = await db
2740 .select({ id: repositories.id, ownerId: repositories.ownerId })
2741 .from(repositories)
2742 .where(
2743 and(
2744 eq(repositories.ownerId, ownerUser.id),
2745 eq(repositories.name, repo)
2746 )
2747 )
2748 .limit(1);
2749 repoRow = r ?? null;
2750 } catch {
2751 return c.redirect(`/${owner}/${repo}?error=Database+error`);
2752 }
2753 if (!repoRow) return c.redirect(`/${owner}/${repo}?error=Not+found`);
2754 if (repoRow.ownerId !== user.id) {
2755 return c.redirect(`/${owner}/${repo}?error=Forbidden`);
2756 }
2757
2758 // Fetch the onboarding data
2759 let obRow: (typeof repoOnboardingData.$inferSelect) | null = null;
2760 try {
2761 const [r] = await db
2762 .select()
2763 .from(repoOnboardingData)
2764 .where(eq(repoOnboardingData.repositoryId, repoRow.id))
2765 .limit(1);
2766 obRow = r ?? null;
2767 } catch {
2768 return c.redirect(`/${owner}/${repo}?error=Onboarding+data+not+found`);
2769 }
2770 if (!obRow) {
2771 return c.redirect(`/${owner}/${repo}?toast=info:No+onboarding+data+found`);
2772 }
2773
2774 const suggestedLabels = (obRow.suggestedLabels ?? []) as Array<{
2775 name: string;
2776 color: string;
2777 description: string;
2778 }>;
2779
2780 // Create labels — import the labels table which was already imported
2781 let created = 0;
2782 for (const l of suggestedLabels) {
2783 try {
2784 await db
2785 .insert(labels)
2786 .values({
2787 repositoryId: repoRow.id,
2788 name: l.name,
2789 color: l.color,
2790 description: l.description ?? "",
2791 })
2792 .onConflictDoNothing();
2793 created++;
2794 } catch {
2795 /* skip duplicates */
2796 }
2797 }
2798
2799 // Mark onboarding dismissed
2800 try {
2801 await db
2802 .update(repositories)
2803 .set({ onboardingShown: true })
2804 .where(eq(repositories.id, repoRow.id));
2805 } catch {
2806 /* ignore */
2807 }
2808
2809 return c.redirect(
2810 `/${owner}/${repo}?success=${encodeURIComponent(`Created ${created} labels`)}`
2811 );
2812});
2813
2814// POST /:owner/:repo/setup/dismiss — marks onboarding as shown.
2815web.post("/:owner/:repo/setup/dismiss", softAuth, requireAuth, async (c) => {
2816 const { owner, repo } = c.req.param();
2817 const user = c.get("user")!;
2818
2819 try {
2820 const [ownerUser] = await db
2821 .select({ id: users.id })
2822 .from(users)
2823 .where(eq(users.username, owner))
2824 .limit(1);
2825 if (ownerUser) {
2826 const [r] = await db
2827 .select({ id: repositories.id, ownerId: repositories.ownerId })
2828 .from(repositories)
2829 .where(
2830 and(
2831 eq(repositories.ownerId, ownerUser.id),
2832 eq(repositories.name, repo)
2833 )
2834 )
2835 .limit(1);
2836 if (r && r.ownerId === user.id) {
2837 await db
2838 .update(repositories)
2839 .set({ onboardingShown: true })
2840 .where(eq(repositories.id, r.id));
2841 }
2842 }
2843 } catch {
2844 /* swallow — dismiss should never fail visibly */
2845 }
2846
2847 return c.redirect(`/${owner}/${repo}`);
2848});
2849
11c3ab6ccanty labs2850// Agent workspace — GET /:owner/:repo/workspace
5bb52faccanty labs2851web.get("/:owner/:repo/workspace", async (c) => {
11c3ab6ccanty labs2852 const { owner, repo } = c.req.param();
2853 const user = c.get("user");
5bb52faccanty labs2854 const gate = await assertRepoReadable(c, owner, repo);
2855 if (gate) return gate;
11c3ab6ccanty labs2856 return c.html(<AgentWorkspace owner={owner} repo={repo} user={user} />);
2857});
2858
2859// Org memory — GET /:owner/:repo/memory
5bb52faccanty labs2860web.get("/:owner/:repo/memory", async (c) => {
11c3ab6ccanty labs2861 const { owner, repo } = c.req.param();
2862 const user = c.get("user");
5bb52faccanty labs2863 const gate = await assertRepoReadable(c, owner, repo);
2864 if (gate) return gate;
11c3ab6ccanty labs2865 return c.html(<OrgMemory owner={owner} repo={repo} user={user} />);
2866});
2867
fc1817aClaude2868// Repository overview — file tree at HEAD
2869web.get("/:owner/:repo", async (c) => {
2870 const { owner, repo } = c.req.param();
06d5ffeClaude2871 const user = c.get("user");
fc1817aClaude2872
5bb52faccanty labs2873 // SECURITY: gate private-repo content before any render (incl. skeleton).
2874 const gate = await assertRepoReadable(c, owner, repo);
2875 if (gate) return gate;
2876
f1dc7c7Claude2877 // ── Loading skeleton (flag-gated) ──
2878 // Renders an SSR'd shell with file-tree + README placeholders when
2879 // `?skeleton=1` is set. Lets the user see the page structure before
2880 // git ops finish. Behind a flag for now so we never flash before the
2881 // real content lands.
2882 if (c.req.query("skeleton") === "1") {
2883 return c.html(
2884 <Layout title={`${owner}/${repo}`} user={user}>
2885 <style
2886 dangerouslySetInnerHTML={{
2887 __html: `
2888 .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; }
2889 @keyframes repoSkelShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
2890 @media (prefers-reduced-motion: reduce) { .repo-skel { animation: none; } }
2891 .repo-skel-hero { height: 132px; border-radius: 16px; margin-bottom: var(--space-4); }
2892 .repo-skel-nav { height: 36px; border-radius: 8px; margin-bottom: var(--space-4); }
2893 .repo-skel-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--space-5); align-items: start; }
2894 @media (max-width: 960px) { .repo-skel-grid { grid-template-columns: minmax(0, 1fr); } }
2895 .repo-skel-branch { height: 32px; width: 200px; border-radius: 8px; margin-bottom: 12px; }
2896 .repo-skel-tree { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-5); }
2897 .repo-skel-tree-row { height: 36px; border-radius: 8px; }
2898 .repo-skel-readme { height: 320px; border-radius: 12px; }
2899 .repo-skel-side { display: flex; flex-direction: column; gap: var(--space-4); }
2900 .repo-skel-side-card { height: 180px; border-radius: 12px; }
2901 `,
2902 }}
2903 />
2904 <div class="repo-skel repo-skel-hero" aria-hidden="true" />
2905 <div class="repo-skel repo-skel-nav" aria-hidden="true" />
2906 <div class="repo-skel-grid" aria-hidden="true">
2907 <div>
2908 <div class="repo-skel repo-skel-branch" />
2909 <div class="repo-skel-tree">
2910 {Array.from({ length: 8 }).map(() => (
2911 <div class="repo-skel repo-skel-tree-row" />
2912 ))}
2913 </div>
2914 <div class="repo-skel repo-skel-readme" />
2915 </div>
2916 <aside class="repo-skel-side">
2917 <div class="repo-skel repo-skel-side-card" />
2918 <div class="repo-skel repo-skel-side-card" />
2919 </aside>
2920 </div>
2921 <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">
2922 Loading {owner}/{repo}…
2923 </span>
2924 </Layout>
2925 );
2926 }
2927
8f50ed0Claude2928 // F1 — fire-and-forget traffic tracking. Never awaits; never throws.
2929 trackByName(owner, repo, "view", {
2930 userId: user?.id || null,
2931 path: `/${owner}/${repo}`,
2932 ip: c.req.header("x-forwarded-for") || c.req.header("x-real-ip") || null,
2933 userAgent: c.req.header("user-agent") || null,
2934 referer: c.req.header("referer") || null,
a28cedeClaude2935 }).catch((err) => {
2936 console.warn(
2937 `[web] view tracking failed for ${owner}/${repo}:`,
2938 err instanceof Error ? err.message : err
2939 );
2940 });
8f50ed0Claude2941
fc1817aClaude2942 if (!(await repoExists(owner, repo))) {
2943 return c.html(
06d5ffeClaude2944 <Layout title="Not Found" user={user}>
fc1817aClaude2945 <div class="empty-state">
2946 <h2>Repository not found</h2>
2947 <p>
2948 {owner}/{repo} does not exist.
2949 </p>
2950 </div>
2951 </Layout>,
2952 404
2953 );
2954 }
2955
05b973eClaude2956 // Parallelize all independent operations
2957 const [defaultBranch, branches] = await Promise.all([
2958 getDefaultBranch(owner, repo).then((b) => b || "main"),
2959 listBranches(owner, repo),
2960 ]);
2961 const [tree, starInfo] = await Promise.all([
2962 getTree(owner, repo, defaultBranch),
2963 // Star info fetched in parallel with tree
2964 (async () => {
2965 try {
2966 const [ownerUser] = await db
2967 .select()
2968 .from(users)
2969 .where(eq(users.username, owner))
2970 .limit(1);
71cd5ecClaude2971 if (!ownerUser)
2972 return {
2973 starCount: 0,
2974 starred: false,
2975 archived: false,
2976 isTemplate: false,
544d842Claude2977 forkCount: 0,
2978 description: null as string | null,
2979 pushedAt: null as Date | null,
2980 createdAt: null as Date | null,
cb5a796Claude2981 repoId: null as string | null,
2982 repoOwnerId: null as string | null,
71cd5ecClaude2983 };
05b973eClaude2984 const [repoRow] = await db
2985 .select()
2986 .from(repositories)
2987 .where(
2988 and(
2989 eq(repositories.ownerId, ownerUser.id),
2990 eq(repositories.name, repo)
2991 )
06d5ffeClaude2992 )
05b973eClaude2993 .limit(1);
71cd5ecClaude2994 if (!repoRow)
2995 return {
2996 starCount: 0,
2997 starred: false,
2998 archived: false,
2999 isTemplate: false,
544d842Claude3000 forkCount: 0,
3001 description: null as string | null,
3002 pushedAt: null as Date | null,
3003 createdAt: null as Date | null,
cb5a796Claude3004 repoId: null as string | null,
3005 repoOwnerId: null as string | null,
71cd5ecClaude3006 };
05b973eClaude3007 let starred = false;
06d5ffeClaude3008 if (user) {
3009 const [star] = await db
3010 .select()
3011 .from(stars)
3012 .where(
3013 and(
3014 eq(stars.userId, user.id),
3015 eq(stars.repositoryId, repoRow.id)
3016 )
3017 )
3018 .limit(1);
3019 starred = !!star;
3020 }
71cd5ecClaude3021 return {
3022 starCount: repoRow.starCount,
3023 starred,
3024 archived: repoRow.isArchived,
3025 isTemplate: repoRow.isTemplate,
544d842Claude3026 forkCount: repoRow.forkCount,
3027 description: repoRow.description as string | null,
3028 pushedAt: (repoRow.pushedAt as Date | null) ?? null,
3029 createdAt: (repoRow.createdAt as Date | null) ?? null,
cb5a796Claude3030 repoId: repoRow.id as string,
3031 repoOwnerId: repoRow.ownerId as string,
71cd5ecClaude3032 };
05b973eClaude3033 } catch {
71cd5ecClaude3034 return {
3035 starCount: 0,
3036 starred: false,
3037 archived: false,
3038 isTemplate: false,
544d842Claude3039 forkCount: 0,
3040 description: null as string | null,
3041 pushedAt: null as Date | null,
3042 createdAt: null as Date | null,
cb5a796Claude3043 repoId: null as string | null,
3044 repoOwnerId: null as string | null,
71cd5ecClaude3045 };
06d5ffeClaude3046 }
05b973eClaude3047 })(),
3048 ]);
544d842Claude3049 const {
3050 starCount,
3051 starred,
3052 archived,
3053 isTemplate,
3054 forkCount,
3055 description,
3056 pushedAt,
3057 createdAt,
cb5a796Claude3058 repoId,
3059 repoOwnerId,
544d842Claude3060 } = starInfo;
3061
91a0204Claude3062 // Health score badge — fire-and-forget, best-effort. If the DB call fails
3063 // or repoId is null (anonymous view of non-DB repo), healthScore stays null
3064 // and the badge simply doesn't render.
3065 let healthScore: HealthScore | null = null;
3066 if (repoId) {
3067 try {
3068 healthScore = await computeHealthScore(repoId);
3069 } catch {
3070 // swallow — badge is optional
3071 }
3072 }
3073
cb5a796Claude3074 // Pending-comments banner data (lazy + best-effort). Only the repo
3075 // owner sees the banner, so non-owner views skip the DB hit entirely.
3076 let repoHomePendingCount = 0;
3077 if (user && repoOwnerId && user.id === repoOwnerId && repoId) {
3078 try {
3079 const { countPendingForRepo } = await import(
3080 "../lib/comment-moderation"
3081 );
3082 repoHomePendingCount = await countPendingForRepo(repoId);
3083 } catch {
3084 /* swallow */
3085 }
3086 }
3087
8c790e0Claude3088 // Push Watch discoverability — fetch the most recent push within 24 h.
3089 // Runs only when we have a repoId (i.e. the repo row was found in the DB).
3090 const recentPush: RecentPush | null = repoId
3091 ? await getRecentPush(repoId)
3092 : null;
3093
ebaae0fClaude3094 // AI stats strip — best-effort, fail-open to zero values.
3095 let aiStats: RepoAiStats = {
3096 mergedCount: 0,
3097 reviewCount: 0,
3098 securityAlertCount: 0,
3099 hoursSaved: "0.0",
3100 };
3101 if (repoId) {
3102 try {
3103 aiStats = await getRepoAiStats(repoId);
3104 } catch {
3105 /* swallow — show zero values */
3106 }
3107 }
3108
641aa42Claude3109 // Onboarding card — shown to repo owner until dismissed. Best-effort;
3110 // if the DB is down the card simply won't appear. Only the owner sees it.
3111 let onboardingRow: (typeof repoOnboardingData.$inferSelect) | null = null;
3112 let showOnboarding = false;
3113 if (repoId && user && repoOwnerId && user.id === repoOwnerId) {
3114 try {
3115 // Check if onboarding_shown is still false (not yet dismissed)
3116 const [repoRow2] = await db
3117 .select({ onboardingShown: repositories.onboardingShown })
3118 .from(repositories)
3119 .where(eq(repositories.id, repoId))
3120 .limit(1);
3121 if (repoRow2 && !repoRow2.onboardingShown) {
3122 const [obRow] = await db
3123 .select()
3124 .from(repoOnboardingData)
3125 .where(eq(repoOnboardingData.repositoryId, repoId))
3126 .limit(1);
3127 onboardingRow = obRow ?? null;
3128 showOnboarding = !!onboardingRow;
3129 }
3130 } catch {
3131 /* swallow — onboarding is optional */
3132 }
3133 }
3134
544d842Claude3135 // Repo-home polish — shared style block (Block 2.A — parallel session 2.A).
3136 // Scoped via .repo-home-* class prefix to prevent bleed into other surfaces.
3137 const repoHomeCss = `
3138 .repo-home-hero {
3139 position: relative;
3140 margin-bottom: var(--space-5);
3141 padding: var(--space-5) var(--space-6);
3142 background: var(--bg-elevated);
3143 border: 1px solid var(--border);
3144 border-radius: 16px;
3145 overflow: hidden;
3146 }
3147 .repo-home-hero::before {
3148 content: '';
3149 position: absolute;
3150 top: 0; left: 0; right: 0;
3151 height: 2px;
6fd5915Claude3152 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
544d842Claude3153 opacity: 0.7;
3154 pointer-events: none;
3155 }
3156 .repo-home-hero-orb-wrap {
3157 position: absolute;
3158 inset: -25% -10% auto auto;
3159 width: 360px;
3160 height: 360px;
3161 pointer-events: none;
3162 z-index: 0;
3163 }
3164 .repo-home-hero-orb {
3165 position: absolute;
3166 inset: 0;
6fd5915Claude3167 background: radial-gradient(circle, rgba(91,110,232,0.18), rgba(95,143,160,0.09) 45%, transparent 70%);
544d842Claude3168 filter: blur(80px);
3169 opacity: 0.7;
3170 animation: repoHomeOrb 14s ease-in-out infinite;
3171 }
3172 @keyframes repoHomeOrb {
3173 0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.55; }
3174 50% { transform: scale(1.1) translate(-10px, 8px); opacity: 0.8; }
3175 }
3176 @media (prefers-reduced-motion: reduce) {
3177 .repo-home-hero-orb { animation: none; }
3178 }
3179 .repo-home-hero-inner {
3180 position: relative;
3181 z-index: 1;
3182 }
3183 .repo-home-hero .repo-header { margin-bottom: var(--space-3); }
3184 .repo-home-eyebrow {
3185 font-size: 12px;
3186 font-family: var(--font-mono);
3187 color: var(--text-muted);
3188 letter-spacing: 0.1em;
3189 text-transform: uppercase;
3190 margin-bottom: var(--space-2);
3191 }
3192 .repo-home-eyebrow strong { color: var(--accent); font-weight: 600; }
3193 .repo-home-description {
3194 font-size: 15px;
3195 line-height: 1.55;
3196 color: var(--text);
3197 margin: 0;
3198 max-width: 720px;
3199 }
3200 .repo-home-description-empty {
3201 font-size: 14px;
3202 color: var(--text-muted);
3203 font-style: italic;
3204 margin: 0;
3205 }
3206 .repo-home-stat-row {
3207 display: flex;
3208 flex-wrap: wrap;
3209 gap: var(--space-4);
3210 margin-top: var(--space-3);
3211 font-size: 13px;
3212 color: var(--text-muted);
3213 }
3214 .repo-home-stat {
3215 display: inline-flex;
3216 align-items: center;
3217 gap: 6px;
3218 }
3219 .repo-home-stat strong {
3220 color: var(--text-strong);
3221 font-weight: 600;
3222 font-variant-numeric: tabular-nums;
3223 }
3224 .repo-home-stat .repo-home-stat-icon {
3225 color: var(--text-faint);
3226 font-size: 14px;
3227 line-height: 1;
3228 }
3229 .repo-home-stat a {
3230 color: var(--text-muted);
3231 transition: color var(--t-fast) var(--ease);
3232 }
3233 .repo-home-stat a:hover { color: var(--accent); text-decoration: none; }
3234
3235 /* Two-column layout: file tree + sidebar */
3236 .repo-home-grid {
3237 display: grid;
3238 grid-template-columns: minmax(0, 1fr) 280px;
3239 gap: var(--space-5);
3240 align-items: start;
3241 }
3242 @media (max-width: 960px) {
3243 .repo-home-grid { grid-template-columns: minmax(0, 1fr); }
3244 }
3245 .repo-home-main { min-width: 0; }
3246
3247 /* Sidebar card */
3248 .repo-home-side {
3249 display: flex;
3250 flex-direction: column;
3251 gap: var(--space-4);
3252 }
3253 .repo-home-side-card {
3254 background: var(--bg-elevated);
3255 border: 1px solid var(--border);
3256 border-radius: 12px;
3257 padding: var(--space-4);
3258 }
3259 .repo-home-side-title {
3260 font-size: 11px;
3261 font-family: var(--font-mono);
3262 letter-spacing: 0.12em;
3263 text-transform: uppercase;
3264 color: var(--text-muted);
3265 margin: 0 0 var(--space-3);
3266 font-weight: 600;
3267 }
3268 .repo-home-side-row {
3269 display: flex;
3270 justify-content: space-between;
3271 align-items: center;
3272 gap: var(--space-2);
3273 font-size: 13px;
3274 padding: 6px 0;
3275 border-top: 1px solid var(--border);
3276 }
3277 .repo-home-side-row:first-of-type { border-top: 0; padding-top: 0; }
3278 .repo-home-side-key {
3279 color: var(--text-muted);
3280 display: inline-flex;
3281 align-items: center;
3282 gap: 6px;
3283 }
3284 .repo-home-side-val {
3285 color: var(--text-strong);
3286 font-weight: 500;
3287 font-variant-numeric: tabular-nums;
3288 max-width: 60%;
3289 text-align: right;
3290 overflow: hidden;
3291 text-overflow: ellipsis;
3292 white-space: nowrap;
3293 }
3294 .repo-home-side-val a { color: var(--text-strong); }
3295 .repo-home-side-val a:hover { color: var(--accent); text-decoration: none; }
3296
3297 /* Clone / Code tabs */
3298 .repo-home-clone {
3299 background: var(--bg-elevated);
3300 border: 1px solid var(--border);
3301 border-radius: 12px;
3302 overflow: hidden;
3303 }
3304 .repo-home-clone-tabs {
3305 display: flex;
3306 gap: 0;
3307 background: var(--bg-secondary);
3308 border-bottom: 1px solid var(--border);
3309 padding: 0 var(--space-2);
3310 }
3311 .repo-home-clone-tab {
3312 appearance: none;
3313 background: transparent;
3314 border: 0;
3315 border-bottom: 2px solid transparent;
3316 padding: 9px 12px;
3317 font-size: 12px;
3318 font-weight: 500;
3319 color: var(--text-muted);
3320 cursor: pointer;
3321 transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
3322 font-family: inherit;
3323 margin-bottom: -1px;
3324 }
3325 .repo-home-clone-tab:hover { color: var(--text-strong); }
3326 .repo-home-clone-tab[aria-selected="true"] {
3327 color: var(--text-strong);
3328 border-bottom-color: var(--accent);
3329 }
3330 .repo-home-clone-body {
3331 padding: var(--space-3);
3332 display: flex;
3333 align-items: center;
3334 gap: var(--space-2);
3335 }
3336 .repo-home-clone-input {
3337 flex: 1;
3338 min-width: 0;
3339 font-family: var(--font-mono);
3340 font-size: 12px;
3341 background: var(--bg);
3342 border: 1px solid var(--border);
3343 border-radius: 8px;
3344 padding: 8px 10px;
3345 color: var(--text-strong);
3346 overflow: hidden;
3347 text-overflow: ellipsis;
3348 white-space: nowrap;
3349 }
3350 .repo-home-clone-copy {
3351 appearance: none;
3352 background: var(--bg-secondary);
3353 border: 1px solid var(--border);
3354 color: var(--text-strong);
3355 border-radius: 8px;
3356 padding: 8px 12px;
3357 font-size: 12px;
3358 font-weight: 600;
3359 cursor: pointer;
3360 transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
3361 font-family: inherit;
3362 }
3363 .repo-home-clone-copy:hover { background: var(--bg-hover); border-color: var(--border-strong, var(--border)); }
3364 .repo-home-clone-pane { display: none; }
3365 .repo-home-clone-pane[data-active="true"] { display: flex; }
3366
3367 /* README card */
3368 .repo-home-readme {
3369 margin-top: var(--space-5);
3370 background: var(--bg-elevated);
3371 border: 1px solid var(--border);
3372 border-radius: 12px;
3373 overflow: hidden;
3374 }
3375 .repo-home-readme-head {
3376 display: flex;
3377 align-items: center;
3378 gap: 8px;
3379 padding: 10px 16px;
3380 background: var(--bg-secondary);
3381 border-bottom: 1px solid var(--border);
3382 font-size: 13px;
3383 color: var(--text-muted);
3384 }
3385 .repo-home-readme-head .repo-home-readme-icon {
3386 color: var(--accent);
3387 font-size: 14px;
3388 }
3389 .repo-home-readme-body {
3390 padding: var(--space-5) var(--space-6);
3391 }
3392
3393 /* Empty-state CTA */
3394 .repo-home-empty {
3395 position: relative;
3396 margin-top: var(--space-4);
3397 background: var(--bg-elevated);
3398 border: 1px solid var(--border);
3399 border-radius: 16px;
3400 padding: var(--space-6);
3401 overflow: hidden;
3402 }
3403 .repo-home-empty::before {
3404 content: '';
3405 position: absolute;
3406 top: 0; left: 0; right: 0;
3407 height: 2px;
6fd5915Claude3408 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
544d842Claude3409 opacity: 0.7;
3410 pointer-events: none;
3411 }
3412 .repo-home-empty-eyebrow {
3413 font-size: 12px;
3414 font-family: var(--font-mono);
3415 color: var(--accent);
3416 letter-spacing: 0.12em;
3417 text-transform: uppercase;
3418 margin-bottom: var(--space-2);
3419 font-weight: 600;
3420 }
3421 .repo-home-empty-title {
3422 font-family: var(--font-display);
3423 font-weight: 800;
3424 letter-spacing: -0.025em;
3425 font-size: clamp(22px, 3vw, 30px);
3426 line-height: 1.1;
3427 margin: 0 0 var(--space-2);
3428 color: var(--text-strong);
3429 }
3430 .repo-home-empty-sub {
3431 color: var(--text-muted);
3432 font-size: 14px;
3433 line-height: 1.55;
3434 max-width: 640px;
3435 margin: 0 0 var(--space-4);
3436 }
3437 .repo-home-empty-snippet {
3438 background: var(--bg);
3439 border: 1px solid var(--border);
3440 border-radius: 10px;
3441 padding: var(--space-3) var(--space-4);
3442 font-family: var(--font-mono);
3443 font-size: 12.5px;
3444 line-height: 1.7;
3445 color: var(--text-strong);
3446 overflow-x: auto;
3447 white-space: pre;
3448 margin: 0;
3449 }
3450 .repo-home-empty-snippet .repo-home-cmt { color: var(--text-faint); }
3451 .repo-home-empty-snippet .repo-home-cmd { color: var(--accent); }
3452
91a0204Claude3453 /* Health score badge */
3454 .repo-health-badge {
3455 display: inline-flex;
3456 align-items: center;
3457 gap: 5px;
3458 padding: 3px 10px;
3459 border-radius: 999px;
3460 font-size: 11.5px;
3461 font-weight: 700;
3462 font-family: var(--font-mono);
3463 text-decoration: none;
3464 border: 1px solid transparent;
3465 transition: filter 120ms ease, opacity 120ms ease;
3466 vertical-align: middle;
3467 }
3468 .repo-health-badge:hover { filter: brightness(1.15); text-decoration: none; opacity: 0.9; }
3469 .repo-health-badge-elite {
3470 background: rgba(52,211,153,0.15);
3471 color: #6ee7b7;
3472 border-color: rgba(52,211,153,0.30);
3473 }
3474 .repo-health-badge-strong {
3475 background: rgba(96,165,250,0.15);
3476 color: #93c5fd;
3477 border-color: rgba(96,165,250,0.30);
3478 }
3479 .repo-health-badge-improving {
3480 background: rgba(251,191,36,0.15);
3481 color: #fde68a;
3482 border-color: rgba(251,191,36,0.30);
3483 }
3484 .repo-health-badge-needs-attention {
3485 background: rgba(248,113,113,0.15);
3486 color: #fca5a5;
3487 border-color: rgba(248,113,113,0.30);
3488 }
3489
3490 /* Three-option empty-state panel */
3491 .repo-empty-options {
3492 display: grid;
3493 grid-template-columns: repeat(3, 1fr);
3494 gap: var(--space-3);
3495 margin-top: var(--space-5);
3496 }
3497 @media (max-width: 760px) {
3498 .repo-empty-options { grid-template-columns: 1fr; }
3499 }
3500 .repo-empty-option {
3501 position: relative;
3502 background: var(--bg-elevated);
3503 border: 1px solid var(--border);
3504 border-radius: 14px;
3505 padding: var(--space-4) var(--space-4);
3506 display: flex;
3507 flex-direction: column;
3508 gap: var(--space-2);
3509 overflow: hidden;
3510 transition: border-color 140ms ease, background 140ms ease;
3511 }
3512 .repo-empty-option:hover {
6fd5915Claude3513 border-color: rgba(91,110,232,0.45);
3514 background: rgba(91,110,232,0.04);
91a0204Claude3515 }
3516 .repo-empty-option::before {
3517 content: '';
3518 position: absolute;
3519 top: 0; left: 0; right: 0;
3520 height: 2px;
6fd5915Claude3521 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
91a0204Claude3522 opacity: 0.55;
3523 pointer-events: none;
3524 }
3525 .repo-empty-option-label {
3526 font-size: 10px;
3527 font-family: var(--font-mono);
3528 font-weight: 700;
3529 letter-spacing: 0.12em;
3530 text-transform: uppercase;
3531 color: var(--accent);
3532 margin-bottom: 2px;
3533 }
3534 .repo-empty-option-title {
3535 font-family: var(--font-display);
3536 font-weight: 700;
3537 font-size: 16px;
3538 letter-spacing: -0.01em;
3539 color: var(--text-strong);
3540 margin: 0;
3541 }
3542 .repo-empty-option-sub {
3543 font-size: 13px;
3544 color: var(--text-muted);
3545 line-height: 1.5;
3546 margin: 0;
3547 flex: 1;
3548 }
3549 .repo-empty-option-snippet {
3550 background: var(--bg);
3551 border: 1px solid var(--border);
3552 border-radius: 8px;
3553 padding: var(--space-2) var(--space-3);
3554 font-family: var(--font-mono);
3555 font-size: 11.5px;
3556 line-height: 1.75;
3557 color: var(--text-strong);
3558 overflow-x: auto;
3559 white-space: pre;
3560 margin: var(--space-1) 0 0;
3561 }
3562 .repo-empty-option-snippet .reo-cmt { color: var(--text-faint); }
3563 .repo-empty-option-snippet .reo-cmd { color: var(--accent); }
3564 .repo-empty-option-cta {
3565 display: inline-flex;
3566 align-items: center;
3567 gap: 6px;
3568 margin-top: auto;
3569 padding-top: var(--space-2);
3570 font-size: 13px;
3571 font-weight: 600;
3572 color: var(--accent);
3573 text-decoration: none;
3574 transition: color 120ms ease;
3575 }
3576 .repo-empty-option-cta:hover { color: var(--text-strong); text-decoration: none; }
3577
544d842Claude3578 @media (max-width: 720px) {
3579 .repo-home-hero { padding: var(--space-4) var(--space-4); }
3580 .repo-home-clone-body { flex-direction: column; align-items: stretch; }
3581 .repo-home-clone-copy { width: 100%; }
f1dc7c7Claude3582 .repo-home-stat-row { gap: var(--space-2) var(--space-3); font-size: 12.5px; }
3583 .repo-home-side-val { max-width: 55%; }
3584 .repo-home-clone-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
3585 .repo-home-clone-tab { min-height: 44px; padding: 11px 14px; }
3586 .repo-home-side-card { padding: var(--space-3); }
544d842Claude3587 }
ebaae0fClaude3588
3589 /* AI stats strip */
3590 .repo-ai-stats-strip {
3591 display: flex;
3592 align-items: center;
3593 gap: 6px;
3594 margin-top: 12px;
3595 margin-bottom: 4px;
3596 font-size: 12px;
3597 color: var(--text-muted);
3598 flex-wrap: wrap;
3599 }
3600 .repo-ai-stats-strip a {
3601 color: var(--text-muted);
3602 text-decoration: underline;
3603 text-decoration-color: transparent;
3604 transition: color 120ms ease, text-decoration-color 120ms ease;
3605 }
3606 .repo-ai-stats-strip a:hover {
3607 color: var(--accent);
3608 text-decoration-color: currentColor;
3609 }
3610 .repo-ai-stats-sep {
3611 opacity: 0.4;
3612 user-select: none;
3613 }
544d842Claude3614 `;
3615 const cloneHttpsUrl = `${config.appBaseUrl}/${owner}/${repo}.git`;
60323c5Claude3616 // SSH URL — port-aware:
3617 // Standard port 22 → git@host:owner/repo.git
3618 // Non-standard port → ssh://git@host:PORT/owner/repo.git
544d842Claude3619 let cloneSshUrl = `git@gluecron.com:${owner}/${repo}.git`;
3620 try {
3621 const host = new URL(config.appBaseUrl).hostname;
60323c5Claude3622 const sshHost = (host && host !== "localhost" && host !== "127.0.0.1")
3623 ? host
3624 : "localhost";
3625 const sshPort = config.sshPort;
3626 if (sshPort === 22) {
3627 cloneSshUrl = `git@${sshHost}:${owner}/${repo}.git`;
3628 } else {
3629 cloneSshUrl = `ssh://git@${sshHost}:${sshPort}/${owner}/${repo}.git`;
544d842Claude3630 }
3631 } catch {
3632 // Fall through to default.
3633 }
3634 const cloneCliCmd = `gluecron clone ${owner}/${repo}`;
3635 const formatRelative = (date: Date | null): string => {
3636 if (!date) return "never";
3637 const ms = Date.now() - date.getTime();
3638 const s = Math.max(0, Math.round(ms / 1000));
3639 if (s < 60) return "just now";
3640 const m = Math.round(s / 60);
3641 if (m < 60) return `${m} min ago`;
3642 const h = Math.round(m / 60);
3643 if (h < 24) return `${h}h ago`;
3644 const d = Math.round(h / 24);
3645 if (d < 30) return `${d}d ago`;
3646 const mo = Math.round(d / 30);
3647 if (mo < 12) return `${mo}mo ago`;
3648 const y = Math.round(d / 365);
3649 return `${y}y ago`;
3650 };
06d5ffeClaude3651
fc1817aClaude3652 if (tree.length === 0) {
5acce80Claude3653 const repoOgDesc = description
3654 ? `${owner}/${repo} on Gluecron — ${description}`
3655 : `${owner}/${repo} on Gluecron — AI-native git hosting with push-time gates and auto-merge.`;
fc1817aClaude3656 return c.html(
5acce80Claude3657 <Layout
3658 title={`${owner}/${repo}`}
3659 user={user}
3660 description={repoOgDesc}
3661 ogTitle={`${owner}/${repo} — Gluecron`}
3662 ogDescription={repoOgDesc}
3663 twitterCard="summary"
3664 >
544d842Claude3665 <style dangerouslySetInnerHTML={{ __html: repoHomeCss }} />
91a0204Claude3666 <style dangerouslySetInnerHTML={{ __html: `
3667 .empty-options-grid {
3668 display: grid;
3669 grid-template-columns: repeat(3, 1fr);
3670 gap: var(--space-4);
3671 margin-top: var(--space-4);
3672 }
3673 @media (max-width: 800px) {
3674 .empty-options-grid { grid-template-columns: 1fr; }
3675 }
3676 .empty-option-card {
3677 position: relative;
3678 background: var(--bg-elevated);
3679 border: 1px solid var(--border);
3680 border-radius: 14px;
3681 padding: var(--space-5);
3682 display: flex;
3683 flex-direction: column;
3684 gap: var(--space-3);
3685 overflow: hidden;
3686 transition: border-color 140ms ease, box-shadow 140ms ease;
3687 }
3688 .empty-option-card:hover {
6fd5915Claude3689 border-color: rgba(91,110,232,0.45);
3690 box-shadow: 0 8px 24px -8px rgba(91,110,232,0.18);
91a0204Claude3691 }
3692 .empty-option-card::before {
3693 content: '';
3694 position: absolute;
3695 top: 0; left: 0; right: 0;
3696 height: 2px;
6fd5915Claude3697 background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
91a0204Claude3698 opacity: 0.55;
3699 pointer-events: none;
3700 }
3701 .empty-option-label {
3702 font-size: 10.5px;
3703 font-family: var(--font-mono);
3704 text-transform: uppercase;
3705 letter-spacing: 0.14em;
3706 color: var(--accent);
3707 font-weight: 700;
3708 }
3709 .empty-option-title {
3710 font-family: var(--font-display);
3711 font-weight: 700;
3712 font-size: 17px;
3713 letter-spacing: -0.01em;
3714 color: var(--text-strong);
3715 margin: 0;
3716 line-height: 1.25;
3717 }
3718 .empty-option-body {
3719 font-size: 13px;
3720 color: var(--text-muted);
3721 line-height: 1.55;
3722 margin: 0;
3723 flex: 1;
3724 }
3725 .empty-option-snippet {
3726 background: var(--bg);
3727 border: 1px solid var(--border);
3728 border-radius: 8px;
3729 padding: var(--space-3) var(--space-4);
3730 font-family: var(--font-mono);
3731 font-size: 11.5px;
3732 line-height: 1.75;
3733 color: var(--text-strong);
3734 overflow-x: auto;
3735 white-space: pre;
3736 margin: 0;
3737 }
3738 .empty-option-snippet .ec { color: var(--text-faint); }
3739 .empty-option-snippet .em { color: var(--accent); }
3740 .empty-option-cta {
3741 display: inline-flex;
3742 align-items: center;
3743 gap: 6px;
3744 padding: 8px 16px;
3745 font-size: 13px;
3746 font-weight: 600;
3747 color: var(--text-strong);
3748 background: var(--bg-secondary);
3749 border: 1px solid var(--border);
3750 border-radius: 9999px;
3751 text-decoration: none;
3752 align-self: flex-start;
3753 transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
3754 }
3755 .empty-option-cta:hover {
6fd5915Claude3756 border-color: rgba(91,110,232,0.55);
3757 background: rgba(91,110,232,0.08);
91a0204Claude3758 color: var(--accent);
3759 text-decoration: none;
3760 }
3761 .empty-option-cta-accent {
6fd5915Claude3762 background: linear-gradient(135deg, #5b6ee8, #5f8fa0);
91a0204Claude3763 border-color: transparent;
3764 color: #fff;
3765 }
3766 .empty-option-cta-accent:hover {
3767 background: linear-gradient(135deg, #7c5df0, #28b4c8);
3768 border-color: transparent;
3769 color: #fff;
6fd5915Claude3770 box-shadow: 0 6px 18px -6px rgba(91,110,232,0.55);
91a0204Claude3771 }
3772 ` }} />
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>
3851 <a href="/import" class="empty-option-cta">
3852 Import repository
3853 </a>
3854 </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>
3862 <a href={`/${owner}/${repo}/specs`} class="empty-option-cta empty-option-cta-accent">
3863 Let AI write your first feature
3864 </a>
3865 </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`}
4345 style="display:block;background:#1f6feb;color:#fff;text-align:center;padding:8px 14px;border-radius:6px;text-decoration:none;font-size:14px;font-weight:600;margin-bottom:8px"
4346 >
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 }
6049 .sem-conf-strong { background: rgba(52,211,153,0.12); color: #34d399; border: 1px solid rgba(52,211,153,0.30); }
6fd5915Claude6050 .sem-conf-possible { background: rgba(91,110,232,0.12); color: #5b6ee8; 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;