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

Browser-chrome card rendering a markdown source editor on the left and the rendered HTML on the right — minimal monochrome syntax markers, structured preview blocks (headings, paragraphs, lists, fenced code). Every label is editable; no media props required.

PRO

showcase18

Code Editor With Live Logs

Browser-chrome card pairing a syntax-highlighted code editor with a live log stream — filter pills, color-coded levels, and a tail-mode footer. Every label is editable; no media props required.

PRO

showcase17

Code Editor With Test Results

Browser-chrome card pairing a syntax-highlighted code editor with a live test-results panel — pass/fail rows, expandable failures, and a coverage footer. Every label is editable; no media props required.

PRO

showcase16

Code Editor With AI Copilot

Browser-chrome card pairing a syntax-highlighted code editor with an AI chat panel — assistant suggestions arrive as inline snippets you can apply with one click. Every label is editable; no media props required.

PRO

showcase21

API Inspector With Code Editor

Browser-chrome card pairing a DevTools-style API inspector on the left with a syntax-highlighted code editor on the right — method badge, response body, timing footer. Every label is editable; no media props required.

PRO

showcase15

Code Editor With Live Activity Feed

Browser-chrome card pairing a syntax-highlighted code editor with a live activity feed — pulsing status dot, color-coded events, and an open-log footer. Every label is editable; no media props required.