feat(examples): managed session queue client reference - #190
Merged
Conversation
commit: |
…se discarded tickets
A join that answers granted directly left the UI in idle while fetchSession ran — a slow token endpoint looked like a dead click.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 01bda8c. Configure here.
| if (epoch !== this.epoch) return; | ||
| if (body.state === "granted") { | ||
| await this.claim(epoch); | ||
| return; |
There was a problem hiding this comment.
Stale position after poll grant
Low Severity
When grant arrives from pollLoop, claim runs without first setting waiting to position 1. The join-granted path does update to “you’re next” so a slow fetchSession does not look stuck; the poll path leaves the previous place-in-line UI until ready.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 01bda8c. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Client reference for Decart's managed session queue: when an account's realtime concurrency is at its limit, users wait in a fair line with live position feedback. The queue manages the line only — it never mints, holds, or sees credentials. On
granted, the app fetches a token from your own token endpoint (the standard realtime integration; seeexamples/express-proxyfor the pattern) and connects within the claim window.The whole client contract is three rules — poll every ~2s while waiting (stop polling or
DELETEto leave), ongrantedfetch your token and connect within the claim window, and if a connect is ever refused, join again:The queue state machine lives in a framework-free
QueueClientclass (plain fetch + timers, no React dependencies — unit-testable and portable as-is) with a thinuseSyncExternalStorehook binding; the camera/render component is the only platform-specific part. Same try-on UI and preloaded sample garment as the siblingrealtime-session-queueexample, which remains the self-hosted variant of the pattern for customers who want to own queueing themselves.Verified end-to-end in a real browser against a live queue and a stand-in customer token endpoint: join → granted → own-token fetch → live session with output frames; with capacity saturated, a second tab waits with live position and inherits the slot when it frees.
Note
Low Risk
Documentation and example-only code; no production SDK or service changes.
Overview
Adds
examples/realtime-session-queue-managed, a Vite/React reference app for Decart’s managed session queue (sibling to the self-hostedrealtime-session-queueexample).The integration centers on a framework-free
QueueClientthat talks to/v1/queues/{id}/ticketswith the publishable queue key, polls about every 2s while waiting, and on granted calls the app’s ownfetchSession(your token endpoint — queue never mints credentials). A thinuseQueuehook wires it withuseSyncExternalStore;TryOnSessionconnects via@decartai/sdkand rejoins on refused connect.The UI covers idle → waiting (position) → live try-on with a preloaded sample garment, plus README,
.env.example, andpnpm-lock.yamlworkspace entries.Reviewed by Cursor Bugbot for commit 01bda8c. Bugbot is set up for automated code reviews on this repo. Configure here.