Skip to content

Graceful capacity handling: request queue + visible waiting state#109

Merged
jheller1212 merged 1 commit into
mainfrom
feat/request-queue-wait-status
Jun 24, 2026
Merged

Graceful capacity handling: request queue + visible waiting state#109
jheller1212 merged 1 commit into
mainfrom
feat/request-queue-wait-status

Conversation

@jheller1212

Copy link
Copy Markdown
Owner

Builds on the jittered backoff (#108) so that when the shared key is near its limit, turns wait gracefully instead of failing — the user's requested 'queue / loading' mechanism.

What's new:

  • requestGate.ts — per-browser FIFO concurrency cap (4 in-flight). One participant running 2–3 conversations no longer fans out a burst; excess turns queue.
  • generateResponse emits a WaitStatus via onWait: queued (waiting for a slot) or rate-limited (sleeping through a 429 retry). Slot is held only during the actual request, freed during backoff.
  • The engine exposes waitStatus; the chat indicator shows it in amber — 'Many requests at once — your turn is queued…' / 'High demand — the API is rate-limiting. Retrying in Ns…' — instead of a silent 'Generating…' or an error.
  • Cleared on response / stop / reset / error.

Tests 35/35 ✓, build ✓, lint ✓.

…state

When the shared workshop key is near its limit, turns now degrade
gracefully instead of erroring:
- New requestGate caps concurrent outbound provider calls per browser (4)
  and queues the rest FIFO, so one participant running several
  conversations doesn't burst the key.
- generateResponse reports a WaitStatus (queued / rate-limited+retry) via
  an onWait callback. The engine surfaces it as waitStatus, shown in the
  chat loading indicator ('Many requests at once — your turn is queued…'
  / 'High demand — retrying in Ns…') in amber, so the user sees the app
  is waiting for capacity rather than a frozen spinner or an error.
- Slot is held only during the in-flight request, released during retry
  backoff. Status cleared on response, stop, reset, and error.
@jheller1212
jheller1212 merged commit 056f2f3 into main Jun 24, 2026
@jheller1212
jheller1212 deleted the feat/request-queue-wait-status branch June 24, 2026 18:52
@netlify

netlify Bot commented Jun 24, 2026

Copy link
Copy Markdown

Deploy Preview for ai2aichat ready!

Name Link
🔨 Latest commit 0517540
🔍 Latest deploy log https://app.netlify.com/projects/ai2aichat/deploys/6a3c2777e9f6a20008b2f936
😎 Deploy Preview https://deploy-preview-109--ai2aichat.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95
Accessibility: 97
Best Practices: 100
SEO: 100
PWA: 80
View the detailed breakdown and full score reports

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant