Skip to content

feat(examples): five showcase apps, each deployable in one click - #333

Merged
prisis merged 11 commits into
alphafrom
examples/showcase-apps
Aug 3, 2026
Merged

prisis merged 11 commits into
alphafrom
examples/showcase-apps

Conversation

@prisis

@prisis prisis commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Five runnable apps, one per area of the framework, each with a Deploy-to-Cloudflare button in its README.

Stacked on #332. Based on fix/shard-error-identity rather than alpha because examples/tanstack-start annotates a handler with an exported return type, which only codegens to compilable output with that PR's discover-functions fix. Merge #332 first and this retargets cleanly to alpha.

Example What it demonstrates
kanban-board Fractional index ordering; the client sends a drop index and the mutation mints the key inside the transaction, so a stale board still lands right. Multi-query optimistic updates. No drag library.
feedback-board A unique index as the actual one-vote-per-person constraint (not a read-then-check); a denormalised counter read through by_upvotes; ctx.ai summarising the board from an action.
team-chat A Durable Object per channel; all three data tiers in one schema (sharded / root-scoped / .global()); authorizeShard; per-shard .searchIndex(); uploads straight to R2 behind a signed URL.
chess A server-authoritative rules engine; serialized mutations as the turn order; Elo settled in the transaction that ends the game; spectating as nothing more than a subscription.
tanstack-start An SSR route loader sharing a cache key with the live useQuery, so server markup survives hydration with no refetch — one worker serving both SSR and RPC.

Verified by running them, not by compiling them

Cards dragged across and within columns and the order re-checked after reload; a summary generated against real Workers AI; a chat message sent with an attachment and the exact bytes round-tripped through R2; a full game played to checkmate by two authenticated sessions with Elo settling 1216/1184; the SSR HTML checked for the data being present in the served bytes.

That mattered — it found four defects that compiling could not, all fixed here: a missing isValidMove call that let a knight teleport, ctx.db.patch rejecting explicit undefined, a .global() table read through the legacy query().withIndex() reader that D1 does not serve, and a worker missing its .global() binding entirely.

Security posture

These are reference apps, so an insecure pattern propagates by being copied. After a security review pass:

  • Uploads store the HMAC-pinned content type, never the request header. Otherwise the allowlist gates only the URL mint: mint for image/png, PUT text/html, and the worker serves attacker HTML from the origin its own session cookie is scoped to. Served with nosniff + content-disposition: attachment behind that, and a size cap.
  • Attachment keys are checked, not trusted — a message can only reference an object this caller uploaded to this channel, and the URL-signing action refuses keys outside the channel.
  • No hard-coded baseURL. @lunora/auth reads its production posture from it: an explicit http://… origin turns off useSecureCookies and downgrades the weak-secret guard. With a deploy button attached, that would ship insecure cookies over HTTPS.
  • No hard-coded storage origin. vars deploy verbatim while secrets get prompted, and the signed-URL HMAC binds the host — a shipped http://localhost:5173 would 403 every attachment on the deployed origin. Derived per request instead.
  • The three examples with no auth say so in a callout above their deploy button, not three screens below it.
  • Every string input carries a length bound; the schema advisories for the five went from 28 to 0.

Also worth knowing

team-chat and chess compose their worker with the generated defineApp() builder; the two with no bindings use createWorker directly. examples/README.md explains which to reach for and why, since the repo previously showed both shapes with no guidance.

Signed URLs are minted from actions rather than returned by live queries — a signed URL carries an expiry and a fresh HMAC, so it differs on every evaluation and defeats the shard's push suppression. It is a Date.now() in disguise.

Not verified: I could not click a deploy button (needs a Cloudflare account and GitHub OAuth). Cloudflare documents that a subdirectory app must be self-contained, and these use workspace:*; each README carries the two-command CLI fallback, which I did verify.

Checks

All five type-check, 14 unit tests pass, prettier and package.json key order clean, no secrets or build artifacts staged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf

Summary by CodeRabbit

  • Tests
    • Added automated end-to-end coverage for showcase examples.
    • Expanded change detection to run relevant checks when playground or example content is updated.
    • Improved failure reporting by including artifacts from both standard and showcase test runs.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (8)
  • examples/chess/lunora/games.ts is excluded by none and included by none
  • packages/studio/__tests__/app/studio.test.tsx is excluded by !**/__tests__/** and included by packages/**
  • packages/studio/__tests__/features/data/data-browser.test.tsx is excluded by !**/__tests__/** and included by packages/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by none
  • tests/e2e/examples-setup.ts is excluded by none and included by none
  • tests/e2e/examples/chess.spec.ts is excluded by !**/*.spec.ts and included by none
  • tests/e2e/examples/team-chat.spec.ts is excluded by !**/*.spec.ts and included by none
  • tests/e2e/playwright.examples.config.ts is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a75fa0c3-ddd0-46f5-ae63-4d7ba9b7bc58

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The CI configuration now triggers E2E jobs for examples/** changes, runs pnpm run e2e:examples in CI mode, and uploads both standard and examples Playwright reports on failure.

Changes

Showcase examples E2E coverage

Layer / File(s) Summary
Examples E2E workflow and reporting
.github/file-filters.yml, .github/workflows/test.yml
The E2E filter includes examples/** changes. The workflow runs the showcase examples suite and uploads both Playwright report directories on failure.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant E2EPathFilter
  participant GitHubActions
  participant ExamplesE2ESuite
  participant PlaywrightReports
  E2EPathFilter->>GitHubActions: trigger E2E jobs for examples/** changes
  GitHubActions->>ExamplesE2ESuite: run pnpm run e2e:examples with CI enabled
  ExamplesE2ESuite->>PlaywrightReports: write examples report
  GitHubActions->>PlaywrightReports: upload standard and examples reports on failure
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: five showcase applications with one-click deployment.
Description check ✅ Passed The description is detailed and relevant, covering scope, testing, security, limitations, and the stacked dependency, but it omits several template headings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch examples/showcase-apps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for confirming the Contributor License Agreement! 🙏

@github-actions

github-actions Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 0ae2876.

Five runnable apps, each built around a different part of the framework, and
each deployable to a reader's own Cloudflare account from a button in its
README.

- kanban-board   — fractional index ordering, server-resolved drop positions,
                   multi-query optimistic updates, native drag and drop.
- feedback-board — a unique index as the actual one-vote constraint, a
                   denormalised counter read through an index, and `ctx.ai`
                   summarising the board from an action.
- team-chat      — a Durable Object per channel, all three data tiers in one
                   schema, `authorizeShard`, per-shard full-text search, and
                   uploads that go straight to R2.
- chess          — a server-authoritative rules engine, serialized mutations as
                   the turn order, Elo settled inside the transaction that ends
                   the game, and spectating as nothing more than a subscription.
- tanstack-start — an SSR route loader sharing a cache key with the live
                   `useQuery`, on one worker serving both SSR and RPC.

Every example was driven end to end rather than only compiled: cards dragged
and reordered, a summary generated against Workers AI, a chat message sent with
an attachment round-tripped through R2, a full game played to checkmate by two
authenticated sessions, and the SSR markup checked for the data in the served
HTML.

Two engine invariants are covered by unit tests where reading the code is not
enough: the fractional-index midpoint (including 200 consecutive inserts into
one gap, which is what breaks float ordering) and the chess move generator.

The `.dev.vars.example` files are what the deploy flow prompts for; `vars` are
deployed verbatim, so nothing environment-specific is hard-coded — the storage
origin and the auth base URL are both derived from the request.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
@prisis
prisis force-pushed the examples/showcase-apps branch from 5bb0f77 to a6edf23 Compare August 2, 2026 20:19
@prisis
prisis changed the base branch from fix/shard-error-identity to alpha August 2, 2026 20:19
@netlify

netlify Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for lunorash ready!

Name Link
🔨 Latest commit 0ae2876
🔍 Latest deploy log https://app.netlify.com/projects/lunorash/deploys/6a7071ee46d7bf000834ab9e
😎 Deploy Preview https://deploy-preview-333--lunorash.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread examples/chess/lunora/games.ts Fixed
React Doctor reported 13 issues across the five apps. Each was real, and three
were user-visible bugs rather than style.

**Five compiler bailouts, all `try` shapes it cannot lower.** Reproduced locally
against `babel-plugin-react-compiler` to get the exact reasons rather than
guess: a `try` with no `catch`, a `try` with a `finally`, a `throw` inside a
`try`, and a value block (ternary, `??`, optional chain) inside a `try`. Any one
of them makes the compiler skip optimizing the whole component silently.

Fixing them fixed real behaviour. Every `try`/`finally` here was resetting a
spinner with no `catch`, so a failed sign-in, a failed AI summary, and a failed
attachment upload each left the UI quiet — the summary path even discarded the
coded error the server had gone to the trouble of producing. The conditionals
now live in named helpers so the `try` body is a single call, which reads better
than what it replaced.

**Reading the clock during render.** The chat's presence roster filtered on
`Date.now()` while rendering — impure, unoptimizable, and inconsistent between a
server render and its hydration. The heartbeat that already runs every 15s now
advances a `now` in state instead.

**A locale-formatted timestamp during SSR.** `toLocaleTimeString()` resolves
against the renderer's locale and time zone, so the server's string and the
browser's disagree — a hydration mismatch in the one example whose whole point
is server rendering. Renders a deterministic UTC `<time>` instead.

Also: the two hand-rolled modals become real `<dialog>` elements opened with
`showModal()`, so focus trapping, page inertness, Escape and `::backdrop` come
from the platform; `posts.map` looks votes up in a `Set` rather than rescanning
an array per row; and three `useMemo`s the React Compiler already covers are
gone.

No workflow change: React Doctor suggested adding `fetch-depth: 0` to its own
job, but that is already configured (react-doctor.yml:28). Its baseline failed
because the PR's base at scan time was a stacked branch that has since merged
and been deleted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
@codspeed

codspeed Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 13.04%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 251 untouched benchmarks
⏩ 10 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ 1 shard × 1000 rows (single round-trip) 3.1 ms 2.7 ms +15.22%
⚡ baseline (Object.keys + toInternal + path spread per field) 72.1 µs 65 µs +10.91%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing examples/showcase-apps (0ae2876) with alpha (b52bcac)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on alpha (e3d7b69) during the generation of this report, so b52bcac was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

The scanner reads the standard HTML autocomplete tokens
`"new-password"` / `"current-password"` as credentials. They are neither, and
dropping them would be a real regression: they are what tells a password manager
whether to offer a saved credential or generate a new one.

Hoisted out of the JSX because a comment is not valid in attribute position, so
the suppression had nowhere to live — and the marker has to sit on the finding's
own line, not the one above it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
The advisor scored these between 88 and 97; the two rules doing the damage were
`public_mutation_without_ratelimit` and `procedure_without_structured_event`,
firing on all 32 public procedures.

Rate limits matter most where there is no sign-in. kanban-board,
feedback-board and tanstack-start ship a deploy button and no auth, so a limit
is the only thing between a deployed instance and a script — those key on caller
IP, since there is no user to key on. team-chat and chess key on the user, so
one person behind a shared address cannot exhaust another's budget. Buckets are
sized per operation rather than shared: dragging cards is a burst of legitimate
writes, a heartbeat runs every 15s per open tab, and inference costs money per
call, so the AI summary gets a far tighter window than the board's writes.

Each app gains the standard `lunora/ratelimit/schema.ts` plugin that `lunora
init` scaffolds — these were hand-built, so they never had it. Counters live in
the shard's own `ratelimit_buckets`, so they are the same counters every request
sees rather than per-isolate memory.

Also fixed, all reported by the same pass:

- Four storage actions in team-chat had no error handling, so an object-store
  failure surfaced to the caller unexplained. They now name the dependency.
- The public AI generation was unbounded; a board summary has no business being
  long, and an unbounded public generation is an invitation to burn tokens.
- The AI run is logged either side of the call.

Left alone: `nondeterministic_query_mutation` on the mutations that stamp a
timestamp. The rule is INFO and its own text says no action is needed for an
ordinary mutation — it matters only inside a workflow step or queue consumer
that can replay. Removing the timestamps to chase a round number would make the
code worse.

Scores now 100 / 100 / 98 / 98 / 97.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
Comment thread examples/chess/lunora/games.ts Fixed
UI: a shared design chassis across all five examples — layered near-black
surfaces, hairline rules, mono-forward chrome, focus-visible rings, staggered
entry, dialog transitions and a `prefers-reduced-motion` opt-out — with one
accent per app so they stay distinguishable. No web fonts and no new
dependencies, so each example is still a copy-one-directory standalone that
runs offline under Miniflare. The kanban theme toggle now opts into light
instead of dark, matching the palette the design was drawn for.

Tests: every example now boots its real schema and real procedures on the
in-memory harness, so a broken example fails CI rather than a broken helper.
This covers what the previous pure-logic unit tests could not — the chess suite
asserts the server rejects an illegal move and refuses to mint two games from
one lobby, both of which were live defects that a browser client could not
surface. `feedback-board`, `team-chat` and `tanstack-start` had no test script
at all; all five are now in the `vis run test` rotation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
Adds a Playwright suite that boots all five examples and exercises them the way
a visitor would — 12 specs covering the claims the server-side harness cannot
reach: a card reaching a second tab live, an optimistic vote settling on the
server's count, a message arriving in another member's open window, a chess move
repainting both boards, and SSR markup that is already populated with
JavaScript disabled.

It runs on Playwright's own `webServer` array rather than a second hand-rolled
boot script, and only starts the servers the selected projects need — five Vite
plus workerd trees at once is enough to get a run OOM killed. `.dev.vars` is
created only when absent: writing it unconditionally restarts every dev server
mid-boot, because Vite watches the file and Playwright re-imports the config in
each worker process.

Three defects surfaced while writing it:

- The TanStack example hardcoded `localhost:5173` for its server-side fetch, so
  it returned 500 on any other port. The port now comes from Vite's resolved
  config, and `VITE_LUNORA_URL` still overrides.
- Every example let the Cloudflare plugin pick the first free inspector port,
  which two apps starting together can both claim; one then died with
  EADDRINUSE. Each pins its own, so running several side by side works.
- Two controls announced nothing useful: the upvote button read as "▲ 3" and
  board squares as "e2 white P". Both now carry a spelled-out label.

The SSR example also gained a connection indicator — the one thing a server
render cannot tell you is whether the socket is up, which is worth showing in an
example built around that handover.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
Three CI failures from the previous commit:

- The Workers AI binding is proxied to Cloudflare even under `vite dev`, so
  `feedback-board` cannot boot on a runner with no account and took the whole
  suite down at startup rather than failing one project. It is now dropped when
  CI has no `CLOUDFLARE_API_TOKEN`, with a line saying so. Locally it still runs.
- The literal password two specs type into a sign-up form tripped the secret
  scan; suppressed on the finding's own line.
- `offerDraw` bound the result of its authorization call and never read it. The
  call is the point, so only the binding goes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
Both fail only in CI and both assume timing rather than waiting for the
condition they care about.

`data-browser` snapshots the read count as soon as the first debounced search
lands, but a legitimate follow-up read can still be in flight at that moment on
a loaded runner — so the "no re-seed loop" assertion was really measuring
machine speed. It now waits for the reads to go quiet first, which a re-seed
loop can never do, so the property under test is unchanged.

`studio`'s migrations panel is lazily mounted and was left on the default 1s
findBy window; the schedule panel next to it already carries a 5s window and a
comment explaining why. This gives it the same.

Neither reproduces locally, so neither fix is verified against the failure —
they replace a timing assumption with a condition, which cannot regress the
assertion either way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
The CI-only failures were not timing noise around the assertions — both tests
reach for an element that is not in the DOM yet.

`data-browser` read the search box with a synchronous `getByTestId` right after
the first row painted, but the toolbar mounts after it: seven interactions now
go through a helper that awaits the input, which says why once instead of at
each call site. The read-count quiescence loop from the previous commit is
reverted — it addressed a race that was never the failure.

`studio`'s migrations panel timed out on the default 1s findBy window; it is
lazily mounted, and the schedule panel beside it already carries a 5s window for
that reason.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYvgKochPxnrCCtKB1tXGf
@prisis
prisis merged commit b52bcac into alpha Aug 3, 2026
15 of 16 checks passed
@prisis
prisis deleted the examples/showcase-apps branch August 3, 2026 10:48
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using our GitHub Discussions tab for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 8, 2026

This branch was previously deployed

1 inactive deployment
benchmarks — 0ae28762 Deployed Aug 3, 2026 by prisis via Benchmarks #1406
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant