Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
claude/adoring-hopper-5x74bqclaude/affectionate-feynman-ykrf1hclaude/architecture-audit-design-wxprenclaude/build-status-update-3MXsfclaude/charming-meitner-mllb5rclaude/compare-gate-gluecron-s4mFQclaude/confident-faraday-tikcwbclaude/continue-work-XMTlIclaude/crontech-gluecron-deploy-7MIECclaude/crontech-platform-setup-SeKfwclaude/design-2026claude/ecstatic-ptolemy-jMdigclaude/enhance-github-integration-QNHdGclaude/fix-aa-loop-issue-PonMQclaude/fix-actions-and-processclaude/fix-desktop-errors-XqoW8claude/fix-red-workflowsclaude/fix-website-access-6FKJNclaude/gatetest-integration-hardeningclaude/github-audit-improvements-bDFr9claude/gluecron-launch-status-FoMRlclaude/hopeful-lamport-olfCTclaude/issue-to-pr-and-protectionsclaude/jolly-heisenberg-2sg1Qclaude/launch-preparation-QmTb6claude/new-session-xk1l7claude/plan-platform-architecture-kkN4yclaude/platform-analysis-roadmap-1nUGLclaude/platform-launch-assessment-8dWV8claude/polish-platform-release-AeDrUclaude/resume-previous-work-KzyLwclaude/review-crontech-handoff-qYEVqclaude/review-project-completeness-lHhS2claude/review-readme-docs-ulqPKclaude/serene-edison-rj87weclaude/setup-multi-repo-dev-BCwNQclaude/ship-fixes-and-tests-Jvz1cclaude/site-audit-competitive-pctlwgclaude/site-migration-vercel-XstpKclaude/standalone-product-repos-XHFTDcopilot/feat-smart-empty-states-keyboard-first-enhancementcopilot/feat-smart-morning-digest-review-context-restorecopilot/fix-and-process-workflowscopilot/update-ai-powered-code-reviewfeat/debt-mapfeat/push-policy-codeowners-hardeningfeat/smart-digest-contextfeat/stage-impactfeat/t1-secret-migrationfeat/u-polishfeat/w-self-hostfeat/w2-claude-configfix/agent-journey-orphan-sweepgatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
playground.tsx11.8 KB · 366 lines
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
/**
 * Block Q3 — Anonymous playground routes.
 *
 * GET  /play         — landing page; one-button start.
 * POST /play         — mint a playground account, set the cookie,
 *                      redirect to the sandbox.
 * GET  /play/claim   — render the "Save your work" form. requireAuth.
 * POST /play/claim   — call claimPlaygroundAccount, redirect to dashboard.
 *
 * POST /play is rate-limited at 3/min/IP via the shared rate-limit
 * middleware so a bot can't hammer the endpoint and mint accounts +
 * repos by the thousand.
 */

import { Hono } from "hono";
import { setCookie } from "hono/cookie";
import { Layout } from "../views/layout";
import { softAuth, requireAuth } from "../middleware/auth";
import type { AuthEnv } from "../middleware/auth";
import {
  Form,
  FormGroup,
  Input,
  Button,
  Text,
} from "../views/ui";
import { rateLimit } from "../middleware/rate-limit";
import {
  createPlaygroundAccount,
  claimPlaygroundAccount,
  PLAYGROUND_TTL_MS,
} from "../lib/playground";
import { sessionCookieOptions } from "../lib/auth";

const playgroundRoutes = new Hono<AuthEnv>();

// ── 3 req / min / IP cap on POST /play. The shared rate-limit
//    middleware no-ops in test env (so the 1756-test suite isn't fragile)
//    but enforces in prod / dev.
const playgroundCreateRateLimit = rateLimit(3, 60_000, "playground-create");

// ---------------------------------------------------------------------------
// GET /play — landing page
// ---------------------------------------------------------------------------

playgroundRoutes.get("/play", softAuth, (c) => {
  const user = c.get("user");
  const csrf = c.get("csrfToken") as string | undefined;
  const err = c.req.query("error");
  const hours = Math.round(PLAYGROUND_TTL_MS / (60 * 60 * 1000));
  return c.html(
    <Layout
      title="Try Gluecron — no signup"
      user={user ?? null}
      description={`Try Gluecron for ${hours} hours, no signup. Get a sandbox repo and watch Claude work.`}
      ogTitle="Try Gluecron — no signup"
      ogDescription="A 24-hour public sandbox. Push, open issues, watch Claude work."
    >
      <div class="play-landing">
        <div class="play-card">
          <div class="play-eyebrow">PLAYGROUND</div>
          <h1 class="play-title">
            Try Gluecron for {hours} hours.
            <br />
            <span class="play-title-accent">No signup.</span>
          </h1>
          <p class="play-sub">
            One click and you're inside the product — a public sandbox
            repo, real git, real issues, Claude already working on the
            first one. Decide later whether to keep it.
          </p>

          {err && (
            <div class="auth-error" role="alert">
              {decodeURIComponent(err)}
            </div>
          )}

          <Form
            method="post"
            action="/play"
            csrfToken={csrf}
            class="play-form"
          >
            <Button type="submit" variant="primary">
              Start playing &rarr;
            </Button>
          </Form>

          <ul class="play-bullets" aria-label="What you get">
            <li>
              <strong>A sandbox repo</strong> &mdash; public, real git, real
              push, real issues.
            </li>
            <li>
              <strong>Claude is already working</strong> &mdash; one issue
              is labelled <code>ai:build</code> so the autopilot picks it
              up within minutes.
            </li>
            <li>
              <strong>{hours} hours to try every feature</strong> &mdash;
              gates, branch protection, AI review, the lot.
            </li>
            <li>
              <strong>Save your work</strong> &mdash; one button converts
              the playground account into a real one. Otherwise: poof.
            </li>
          </ul>

          <p class="play-footnote">
            Already have an account?{" "}
            <a href="/login">Sign in</a> or{" "}
            <a href="/register">create one</a> the normal way.
          </p>
        </div>
      </div>

      <style
        dangerouslySetInnerHTML={{
          __html: /* css */ `
          .play-landing {
            max-width: 720px;
            margin: 48px auto;
            padding: 0 24px;
          }
          .play-card {
            background: var(--panel, #161b22);
            border: 1px solid var(--border, #30363d);
            border-radius: 16px;
            padding: 40px;
            text-align: center;
          }
          .play-eyebrow {
            font-family: var(--font-mono, ui-monospace, monospace);
            font-size: 11px;
            letter-spacing: 0.18em;
            color: var(--yellow, #fbbf24);
            margin-bottom: 12px;
          }
          .play-title {
            margin: 0 0 16px;
            font-size: 36px;
            line-height: 1.15;
            font-weight: 700;
            color: var(--text-strong, #e6edf3);
          }
          .play-title-accent {
            background: linear-gradient(135deg, #8c6dff 0%, #36c5d6 100%);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
          }
          .play-sub {
            margin: 0 auto 24px;
            max-width: 480px;
            font-size: 15px;
            line-height: 1.55;
            color: var(--text-muted, #8b949e);
          }
          .play-form {
            margin: 24px 0;
            display: inline-block;
          }
          .play-form button[type="submit"] {
            font-size: 16px;
            padding: 14px 28px;
          }
          .play-bullets {
            margin: 24px auto 0;
            max-width: 520px;
            padding-left: 20px;
            text-align: left;
            font-size: 14px;
            line-height: 1.7;
            color: var(--text, #c9d1d9);
          }
          .play-bullets li { margin-bottom: 6px; }
          .play-bullets code {
            font-family: var(--font-mono, ui-monospace, monospace);
            font-size: 12px;
            padding: 1px 6px;
            border-radius: 4px;
            background: rgba(140,109,255,0.16);
            color: #c8b6ff;
          }
          .play-footnote {
            margin: 24px 0 0;
            font-size: 13px;
            color: var(--text-muted, #8b949e);
          }
        `,
        }}
      />
    </Layout>
  );
});

// ---------------------------------------------------------------------------
// POST /play — mint
// ---------------------------------------------------------------------------

playgroundRoutes.post("/play", playgroundCreateRateLimit, async (c) => {
  const ip =
    c.req.header("x-forwarded-for")?.split(",")[0]?.trim() ||
    c.req.header("x-real-ip") ||
    undefined;
  let result;
  try {
    result = await createPlaygroundAccount({ requestIp: ip });
  } catch (err) {
    // createPlaygroundAccount is supposed to never throw, but if a
    // freshly-deployed migration is missing or anything else goes
    // sideways, fall back to a graceful redirect.
    console.error("[playground] /play POST threw:", err);
    return c.redirect(
      "/play?error=Could+not+create+playground+account.+Try+again."
    );
  }

  if (!result.sessionToken || !result.user.id) {
    return c.redirect(
      "/play?error=Could+not+create+playground+account.+Try+again."
    );
  }

  // 24h cookie matches the playground TTL so the cookie can't outlive
  // the account in the DB. `sessionCookieOptions()` defaults to 30d
  // maxAge; override here.
  const base = sessionCookieOptions();
  setCookie(c, "session", result.sessionToken, {
    ...base,
    maxAge: Math.floor(PLAYGROUND_TTL_MS / 1000),
  });

  return c.redirect(
    `/${result.user.username}/sandbox?welcome=1`
  );
});

// ---------------------------------------------------------------------------
// GET /play/claim — render the "Save your work" form
// ---------------------------------------------------------------------------

playgroundRoutes.get("/play/claim", requireAuth, (c) => {
  const user = c.get("user")!;
  const csrf = c.get("csrfToken") as string | undefined;
  const err = c.req.query("error");

  // Already-real users: bounce home with a hint.
  if (!(user as any).isPlayground) {
    return c.redirect("/dashboard?info=Your+account+is+already+saved");
  }

  return c.html(
    <Layout title="Save your playground" user={user}>
      <div class="auth-container">
        <h2>Save your work</h2>
        <p class="auth-switch" style="margin-bottom: 16px; margin-top: 0">
          Convert{" "}
          <code class="mono">{user.username}</code>{" "}
          into a permanent account. We'll send a verification link to your
          email; nothing is changed about the repo you've been working in.
        </p>
        {err && (
          <div class="auth-error" role="alert">
            {decodeURIComponent(err)}
          </div>
        )}
        <Form
          method="post"
          action="/play/claim"
          csrfToken={csrf}
        >
          <FormGroup label="Email" htmlFor="email">
            <Input
              type="email"
              name="email"
              required
              placeholder="you@example.com"
              autocomplete="email"
              aria-label="Email"
            />
          </FormGroup>
          <FormGroup label="Password" htmlFor="password">
            <Input
              type="password"
              name="password"
              required
              minLength={8}
              placeholder="Min 8 characters"
              autocomplete="new-password"
              aria-label="Password"
            />
          </FormGroup>
          <FormGroup
            label="Pick a new username (optional)"
            htmlFor="username"
          >
            <Input
              type="text"
              name="username"
              pattern="^[a-zA-Z0-9_-]+$"
              minLength={2}
              maxLength={39}
              placeholder={user.username}
              autocomplete="username"
            />
          </FormGroup>
          <Button type="submit" variant="primary">
            Save my account
          </Button>
        </Form>
        <p class="auth-switch">
          <Text>
            Changed your mind?{" "}
            <a href={`/${user.username}/sandbox`}>Back to the sandbox</a>
          </Text>
        </p>
      </div>
    </Layout>
  );
});

// ---------------------------------------------------------------------------
// POST /play/claim — convert to real account
// ---------------------------------------------------------------------------

const CLAIM_REASON_TO_MSG: Record<string, string> = {
  invalid_email: "That doesn't look like a valid email.",
  password_too_short: "Password must be at least 8 characters.",
  invalid_username:
    "Usernames may only contain letters, numbers, hyphens and underscores (2–39 chars).",
  email_taken: "That email is already registered.",
  username_taken: "That username is already taken.",
  not_a_playground_account: "Your account is already saved.",
  user_not_found: "Account not found. Please sign in again.",
  lookup_failed: "Service unavailable. Please try again.",
  update_failed: "Service unavailable. Please try again.",
};

playgroundRoutes.post("/play/claim", requireAuth, async (c) => {
  const user = c.get("user")!;
  const body = await c.req.parseBody();
  const email = String(body.email || "");
  const password = String(body.password || "");
  const usernameRaw = String(body.username || "").trim();

  const result = await claimPlaygroundAccount(user.id, {
    email,
    password,
    username: usernameRaw ? usernameRaw : undefined,
  });

  if (!result.ok) {
    const msg =
      (result.reason && CLAIM_REASON_TO_MSG[result.reason]) ||
      "Could not save account. Try again.";
    return c.redirect(
      `/play/claim?error=${encodeURIComponent(msg)}`
    );
  }

  return c.redirect("/dashboard?info=Account+saved.+Check+your+email+to+verify.");
});

export default playgroundRoutes;