AI Workspace With Streaming Response

AI workspace

From prompt to production-ready answer

Ask Beste anything about your codebase. Get back a structured response with code, citations, and the ability to apply changes — without leaving the editor.

Beste Copilot

claude-opus-4-7 · streaming

You

How do I rotate refresh tokens on every use without breaking concurrent requests?

Beste

Token rotation needs three pieces working together: a rotating store, a short grace window, and per-user locking on refresh.

1. Generate a fresh token on every use

Issue a new refresh token alongside each access token. Mark the previous one stale but keep it valid for a short overlap.

ts
session.rotate({
  staleAfter: "5s",
  invalidate: "previous",
});

2. Handle concurrent requests

  • Acquire a per-user lock during rotation (Redis SETNX works well)
  • Allow stale tokens for ~5 seconds to bridge in-flight requests
  • Return 409 with retry-after when locks collide
Most rotation bugs come from skipping the grace window. Five seconds is enough to land any concurrent refresh.

From your codebase

src/auth/session.ts · L42

docs/security/tokens.md · §3.2

About this block

AI Workspace With Streaming ResponsePRO

Browser-chrome card rendering an AI prompt and a structured response — markdown blocks (headings, paragraphs, lists, quotes, code), citation list, copy/regenerate/apply footer. Every label is editable; no media props required.

More Showcase blocks

View all Showcase
PRO

showcase28

Markdown Editor With Live Preview

PRO

showcase16

Code Editor With AI Copilot

PRO

showcase17

Code Editor With Test Results

Get Pro access