CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | /**
* Block L3 — public `/demo` landing page + companion JSON endpoints.
*
* Anonymous-friendly. Demonstrates Gluecron's AI features in real time by
* surfacing live counts off the audit log + `pr_comments` table for the
* seeded demo repos.
*
* Routes mounted from `src/app.tsx`. Must come BEFORE `routes/admin.tsx`
* in mount order so this handler wins over the legacy `/demo` redirect.
*
* GET /demo → SSR landing page (graceful no-JS,
* polls JSON endpoints every 30s
* when JS is available)
* GET /api/v2/demo/activity → combined activity feed JSON
* GET /api/v2/demo/queued → queued ai:build issues JSON
* GET /api/v2/demo/merges → recent auto-merges JSON
* GET /api/v2/demo/reviews → recent AI reviews JSON
*
* All JSON endpoints serve `Cache-Control: public, max-age=30` so the demo
* page is cheap to refresh and external dashboards can embed safely.
*/
import { Hono } from "hono";
import { Layout } from "../views/layout";
import { softAuth } from "../middleware/auth";
import type { AuthEnv } from "../middleware/auth";
import { DEMO_USERNAME } from "../lib/demo-seed";
import {
countAiReviewsSince,
listDemoActivityFeed,
listQueuedAiBuildIssues,
listRecentAiReviews,
listRecentAutoMerges,
type DemoActivityEntry,
} from "../lib/demo-activity";
const app = new Hono<AuthEnv>();
const POLL_INTERVAL_MS = 30_000;
function jsonCacheHeaders(): Record<string, string> {
return {
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "public, max-age=30",
};
}
// ───────────────────────────────────────────────────────────────────
// JSON endpoints — cheap, public, cacheable.
// ───────────────────────────────────────────────────────────────────
app.get("/api/v2/demo/activity", async (c) => {
const feed = await listDemoActivityFeed(20);
return new Response(
JSON.stringify({
entries: feed.map((e) => ({
kind: e.kind,
repo: e.repo,
ref: e.ref,
at: e.at.toISOString(),
})),
}),
{ status: 200, headers: jsonCacheHeaders() }
);
});
app.get("/api/v2/demo/queued", async (c) => {
const items = await listQueuedAiBuildIssues(5);
return new Response(
JSON.stringify({
items: items.map((i) => ({
repo: i.repo,
number: i.number,
title: i.title,
createdAt: i.createdAt.toISOString(),
})),
}),
{ status: 200, headers: jsonCacheHeaders() }
);
});
app.get("/api/v2/demo/merges", async (c) => {
const items = await listRecentAutoMerges(5, 24);
return new Response(
JSON.stringify({
items: items.map((m) => ({
repo: m.repo,
number: m.number,
title: m.title,
mergedAt: m.mergedAt.toISOString(),
})),
}),
{ status: 200, headers: jsonCacheHeaders() }
);
});
app.get("/api/v2/demo/reviews", async (c) => {
const [items, count] = await Promise.all([
listRecentAiReviews(5, 24),
countAiReviewsSince(24),
]);
return new Response(
JSON.stringify({
count,
items: items.map((r) => ({
repo: r.repo,
prNumber: r.prNumber,
commentSnippet: r.commentSnippet,
createdAt: r.createdAt.toISOString(),
})),
}),
{ status: 200, headers: jsonCacheHeaders() }
);
});
// ───────────────────────────────────────────────────────────────────
// HTML landing page.
// ───────────────────────────────────────────────────────────────────
function escapeHtml(s: string): string {
return String(s).replace(/[&<>"']/g, (c) =>
c === "&"
? "&"
: c === "<"
? "<"
: c === ">"
? ">"
: c === '"'
? """
: "'"
);
}
function relativeTime(d: Date): string {
const ms = Date.now() - d.getTime();
const s = Math.max(0, Math.floor(ms / 1000));
if (s < 60) return `${s}s ago`;
const m = Math.floor(s / 60);
if (m < 60) return `${m}m ago`;
const h = Math.floor(m / 60);
if (h < 48) return `${h}h ago`;
const days = Math.floor(h / 24);
return `${days}d ago`;
}
function activityLabel(kind: DemoActivityEntry["kind"]): string {
switch (kind) {
case "auto_merge.merged":
return "auto-merged";
case "ai_build.dispatched":
return "AI-build dispatched";
case "ai_review.posted":
return "AI review posted";
}
}
app.get("/demo", softAuth, async (c) => {
const user = c.get("user") ?? null;
// Server-side render the initial snapshot. The JS poller refreshes it
// every 30s but the no-JS experience still works.
const [queued, merges, reviewsCountAndList, feed] = await Promise.all([
listQueuedAiBuildIssues(5),
listRecentAutoMerges(5, 24),
Promise.all([listRecentAiReviews(5, 24), countAiReviewsSince(24)]),
listDemoActivityFeed(20),
]);
const [reviews, reviewCount] = reviewsCountAndList;
const demoUserUrl = `/${DEMO_USERNAME}`;
const demoRepos: { name: string; tagline: string }[] = [
{ name: "hello-python", tagline: "Tiny Python app — labels, issues, gates." },
{ name: "todo-api", tagline: "Hono todo API — PRs, AI review, auto-merge." },
{ name: "design-docs", tagline: "ADRs + architecture docs." },
];
// Poller — refreshes the four tiles every 30s. Plain vanilla JS, no
// framework. Mirrors the same pattern as `src/lib/sse-client.ts`.
const pollerScript = `
(function(){try{
var INTERVAL=${POLL_INTERVAL_MS};
function esc(s){return String(s==null?'':s).replace(/[&<>"']/g,function(c){return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c];});}
function rel(iso){try{var ms=Date.now()-new Date(iso).getTime();var s=Math.max(0,Math.floor(ms/1000));if(s<60)return s+'s ago';var m=Math.floor(s/60);if(m<60)return m+'m ago';var h=Math.floor(m/60);if(h<48)return h+'h ago';return Math.floor(h/24)+'d ago';}catch(e){return '';}}
function pollQueued(){fetch('/api/v2/demo/queued').then(function(r){return r.json();}).then(function(d){
var el=document.getElementById('tile-queued-list');if(!el)return;
if(!d.items||d.items.length===0){el.innerHTML='<li class="demo-empty">No queued AI builds — quiet right now.</li>';return;}
el.innerHTML=d.items.map(function(i){return '<li><a href="/${DEMO_USERNAME}/'+esc(i.repo)+'/issues/'+i.number+'">#'+i.number+' '+esc(i.title)+'</a> <span class="demo-meta">'+esc(i.repo)+' · '+rel(i.createdAt)+'</span></li>';}).join('');
}).catch(function(){});}
function pollMerges(){fetch('/api/v2/demo/merges').then(function(r){return r.json();}).then(function(d){
var el=document.getElementById('tile-merges-list');if(!el)return;
if(!d.items||d.items.length===0){el.innerHTML='<li class="demo-empty">No auto-merges in the last 24h.</li>';return;}
el.innerHTML=d.items.map(function(i){return '<li><a href="/${DEMO_USERNAME}/'+esc(i.repo)+'/pulls/'+i.number+'">#'+i.number+' '+esc(i.title)+'</a> <span class="demo-meta">'+esc(i.repo)+' · '+rel(i.mergedAt)+'</span></li>';}).join('');
}).catch(function(){});}
function pollReviews(){fetch('/api/v2/demo/reviews').then(function(r){return r.json();}).then(function(d){
var c=document.getElementById('tile-reviews-count');if(c)c.textContent=String(d.count||0);
var el=document.getElementById('tile-reviews-list');if(!el)return;
if(!d.items||d.items.length===0){el.innerHTML='<li class="demo-empty">No AI reviews in the last 24h.</li>';return;}
el.innerHTML=d.items.map(function(i){return '<li><a href="/${DEMO_USERNAME}/'+esc(i.repo)+'/pulls/'+i.prNumber+'">#'+i.prNumber+'</a> <span class="demo-snippet">'+esc(i.commentSnippet)+'</span> <span class="demo-meta">'+esc(i.repo)+' · '+rel(i.createdAt)+'</span></li>';}).join('');
}).catch(function(){});}
function pollFeed(){fetch('/api/v2/demo/activity').then(function(r){return r.json();}).then(function(d){
var el=document.getElementById('demo-feed-list');if(!el)return;
if(!d.entries||d.entries.length===0){el.innerHTML='<li class="demo-empty">Quiet right now — push a commit to a demo repo to see live updates.</li>';return;}
el.innerHTML=d.entries.map(function(e){var label=e.kind==='auto_merge.merged'?'auto-merged':(e.kind==='ai_build.dispatched'?'AI-build dispatched':'AI review posted');var path=e.ref.type==='pr'?'pulls':'issues';return '<li><span class="demo-kind demo-kind-'+esc(e.kind.replace(/\\./g,'-'))+'">'+esc(label)+'</span> <a href="/${DEMO_USERNAME}/'+esc(e.repo)+'/'+path+'/'+e.ref.number+'">'+esc(e.repo)+' #'+e.ref.number+'</a> <span class="demo-meta">'+rel(e.at)+'</span></li>';}).join('');
}).catch(function(){});}
function tick(){pollQueued();pollMerges();pollReviews();pollFeed();}
// Initial refresh after a short delay so the SSR snapshot stays visible
// a beat — keeps the page from "flashing" identical content on load.
setInterval(tick,INTERVAL);
}catch(e){}})();
`.trim();
return c.html(
<Layout title="Live demo" user={user}>
<style dangerouslySetInnerHTML={{ __html: DEMO_CSS }} />
<div class="demo-page">
<div class="demo-hero">
<div class="demo-hero-inner">
<div class="eyebrow">
<span class="demo-pulse" />
Live · pulled from production · refreshes every 30s
</div>
<h1 class="demo-title">
Watch Claude <span class="gradient-text">build software, live.</span>
</h1>
<p class="demo-sub">
Every tile below is real audit data from the seeded demo repos.
File an issue tagged <code>ai:build</code> and the gluecron autopilot
opens a PR. Land an AI review. Merge it automatically when gates
go green. No human in the loop for the routine cases.
</p>
</div>
<div class="demo-hero-cta">
<a href="/register" class="btn btn-primary btn-lg">
Sign up free <span aria-hidden="true">{"→"}</span>
</a>
</div>
</div>
<div class="demo-tiles">
<section class="demo-tile" aria-labelledby="tile-queued-h">
<h2 id="tile-queued-h" class="demo-tile-title">
Issues queued for AI build
</h2>
<ul id="tile-queued-list" class="demo-list">
{queued.length === 0 ? (
<li class="demo-empty">No queued AI builds — quiet right now.</li>
) : (
queued.map((i) => (
<li>
<a href={`/${DEMO_USERNAME}/${i.repo}/issues/${i.number}`}>
#{i.number} {i.title}
</a>{" "}
<span class="demo-meta">
{i.repo} · {relativeTime(i.createdAt)}
</span>
</li>
))
)}
</ul>
</section>
<section class="demo-tile" aria-labelledby="tile-merges-h">
<h2 id="tile-merges-h" class="demo-tile-title">
PRs auto-merged in the last 24h
</h2>
<ul id="tile-merges-list" class="demo-list">
{merges.length === 0 ? (
<li class="demo-empty">
No auto-merges in the last 24h.
</li>
) : (
merges.map((m) => (
<li>
<a href={`/${DEMO_USERNAME}/${m.repo}/pulls/${m.number}`}>
#{m.number} {m.title}
</a>{" "}
<span class="demo-meta">
{m.repo} · {relativeTime(m.mergedAt)}
</span>
</li>
))
)}
</ul>
</section>
<section class="demo-tile" aria-labelledby="tile-reviews-h">
<h2 id="tile-reviews-h" class="demo-tile-title">
AI reviews posted today
</h2>
<div class="demo-bigcount">
<span id="tile-reviews-count">{reviewCount}</span>
<span class="demo-bigcount-label">in the last 24h</span>
</div>
<ul id="tile-reviews-list" class="demo-list demo-list-small">
{reviews.length === 0 ? (
<li class="demo-empty">
No AI reviews in the last 24h.
</li>
) : (
reviews.map((r) => (
<li>
<a href={`/${DEMO_USERNAME}/${r.repo}/pulls/${r.prNumber}`}>
#{r.prNumber}
</a>{" "}
<span class="demo-snippet">{r.commentSnippet}</span>{" "}
<span class="demo-meta">
{r.repo} · {relativeTime(r.createdAt)}
</span>
</li>
))
)}
</ul>
</section>
</div>
<section class="demo-repos" aria-labelledby="demo-repos-h">
<h2 id="demo-repos-h" class="demo-section-title">
Dig into the demo repos
</h2>
<div class="demo-repos-grid">
{demoRepos.map((r) => (
<a class="demo-repo-card" href={`${demoUserUrl}/${r.name}`}>
<div class="demo-repo-name">
{DEMO_USERNAME}/{r.name}
</div>
<div class="demo-repo-tag">{r.tagline}</div>
</a>
))}
</div>
</section>
<section class="demo-feed" aria-labelledby="demo-feed-h">
<h2 id="demo-feed-h" class="demo-section-title">
Live activity
</h2>
<ul id="demo-feed-list" class="demo-feed-list">
{feed.length === 0 ? (
<li class="demo-empty">
Quiet right now — push a commit to a demo repo to see live updates.
</li>
) : (
feed.map((e) => {
const path = e.ref.type === "pr" ? "pulls" : "issues";
return (
<li>
<span
class={`demo-kind demo-kind-${e.kind.replace(/\./g, "-")}`}
>
{activityLabel(e.kind)}
</span>{" "}
<a href={`/${DEMO_USERNAME}/${e.repo}/${path}/${e.ref.number}`}>
{e.repo} #{e.ref.number}
</a>{" "}
<span class="demo-meta">{relativeTime(e.at)}</span>
</li>
);
})
)}
</ul>
</section>
</div>
<script dangerouslySetInnerHTML={{ __html: pollerScript }} />
);
});
// Minimal CSS, scoped under .demo-page so it doesn't bleed into other views.
const DEMO_CSS = `
.demo-page { max-width: 1100px; margin: 0 auto; padding: 32px 20px 64px; }
.demo-hero { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; justify-content: space-between; margin-bottom: 32px; }
.demo-hero-inner { flex: 1 1 480px; }
.demo-pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 8px rgba(52,211,153,0.7); margin-right: 8px; vertical-align: middle; animation: demo-pulse 1.6s infinite; }
@keyframes demo-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.demo-title { font-size: 36px; line-height: 1.1; margin: 12px 0 16px; }
.demo-sub { color: var(--text-muted); max-width: 640px; font-size: 15px; line-height: 1.55; }
.demo-sub code { background: var(--bg-secondary); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.demo-hero-cta { flex: 0 0 auto; }
.demo-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 32px; }
.demo-tile { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.demo-tile-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin: 0 0 12px; }
.demo-list { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 1.5; }
.demo-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.demo-list li:last-child { border-bottom: 0; }
.demo-list-small li { font-size: 13px; }
.demo-list a { color: var(--text-strong); text-decoration: none; }
.demo-list a:hover { text-decoration: underline; }
.demo-meta { color: var(--text-muted); font-size: 12px; }
.demo-snippet { color: var(--text-muted); font-style: italic; font-size: 12px; }
.demo-empty { color: var(--text-muted); font-size: 13px; padding: 6px 0; }
.demo-bigcount { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.demo-bigcount span:first-child { font-size: 32px; font-weight: 700; color: var(--text-strong); }
.demo-bigcount-label { color: var(--text-muted); font-size: 12px; }
.demo-section-title { font-size: 18px; margin: 16px 0 12px; }
.demo-repos { margin-bottom: 32px; }
.demo-repos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.demo-repo-card { display: block; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; transition: border-color 0.15s; }
.demo-repo-card:hover { border-color: var(--accent, #8c6dff); }
.demo-repo-name { font-weight: 600; font-size: 14px; color: var(--text-strong); margin-bottom: 4px; }
.demo-repo-tag { font-size: 12px; color: var(--text-muted); }
.demo-feed { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.demo-feed-list { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.6; }
.demo-feed-list li { padding: 4px 0; }
.demo-kind { display: inline-block; padding: 1px 7px; border-radius: 9999px; font-size: 11px; font-weight: 500; }
.demo-kind-auto_merge-merged, .demo-kind-auto-merge-merged { background: rgba(52,211,153,0.12); color: #34d399; }
.demo-kind-ai_build-dispatched, .demo-kind-ai-build-dispatched { background: rgba(140,109,255,0.15); color: #8c6dff; }
.demo-kind-ai_review-posted, .demo-kind-ai-review-posted { background: rgba(54,197,214,0.15); color: #36c5d6; }
`;
export default app;
|