Skip to content

Add Pub/Sub "Live voting" example (message annotations)#3394

Open
SimonWoolf wants to merge 2 commits into
mainfrom
live-voting
Open

Add Pub/Sub "Live voting" example (message annotations)#3394
SimonWoolf wants to merge 2 commits into
mainfrom
live-voting

Conversation

@SimonWoolf
Copy link
Copy Markdown
Member

@SimonWoolf SimonWoolf commented Jun 3, 2026

What

Adds an interactive Live voting example at /examples/pub-sub-live-voting, focused on message annotations: a poll is a message, each vote is a vote:unique.v1 annotation, and Ably aggregates votes into a summary — no database, no client-side tallying.

The live widget shows voter + presenter panes side by side. On load a sandbox-only bootstrap auto-starts the d-pad poll and seeds a few votes so the presenter (heatmap + leader badge + vote bubbles) is alive immediately; the voter pane then votes live on top.

live-voting-example-readme

Structure

Everything for the full app lives under examples/pub-sub-live-voting/javascript/ so the in-page Open in CodeSandbox export is complete:

  • client at the javascript/ root (voter/presenter/admin views, branched by ?role=)
  • server/ — Express: role-scoped JWT /auth, shows API, static SHOWS_FILE and Postgres stores
  • data/ (static poll data) and database/ (schema + migrations)

Sandbox vs. clone: the live widget has no backend, so it falls back to a raw key (loudly commented as demo-only) and a per-role channel mode split; a real clone uses the server's token auth. The canonical runnable source lives in the standalone ably-demos/live-voting-with-annotations, which the README and the new "View on GitHub" override point to.

Shared-infra touches (kept minimal / backward-compatible)

  • ExamplesRenderer: per-id start routes (?role=voter / ?role=presenter&demo=1) + Voter/Presenter pane labels; add qrcode dependency.
  • examples.tsx + Example type: optional githubUrl to override the "View on GitHub" target (defaults unchanged for every other example).
  • gatsby-config: ignore node_modules/dist on the examples source — required now that a nested server/ can have its own installed deps under a sourced language dir.

Verification

yarn lint clean (0 errors); standalone server npm install + tsc clean; client vite build clean. Live behaviour (two panes, voting → heatmap/bubbles) should be eyeballed on the review app — it needs the Message annotations channel rule on the voting:* namespace of the demo app.

🤖 Generated with Claude Code

SimonWoolf and others added 2 commits June 3, 2026 16:19
Add an interactive "Live voting" example at /examples/pub-sub-live-voting
demonstrating message annotations: a poll is a message, each vote is a
`vote:unique.v1` annotation, and Ably aggregates votes into a summary.

The live widget shows voter + presenter panes side by side (d-pad poll
auto-started via a sandbox-only bootstrap that seeds a few votes). The full
app — admin/voter/presenter client plus an Express server (role-scoped JWT
auth, shows API, static SHOWS_FILE and Postgres stores) — ships under the
example so it can be cloned and run as a real voting app.

Wiring: register the example, give its two preview panes per-role start
routes and Voter/Presenter labels, and add the qrcode dependency.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add an optional `githubUrl` to example metadata so the "View on GitHub" button
can target a canonical home other than the docs repo, and set it for
pub-sub-live-voting to ably-demos/live-voting-with-annotations. Repoint the
README's clone/source links to the same standalone repo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4e729769-6473-4108-b445-0f5ca65453e5

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch live-voting

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 and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

2 participants