Skip to content

refactor(shadcn): share agent token logic between Vercel route and dev server#1395

Merged
thomasyuill-livekit merged 1 commit into
mainfrom
ty/address-pr-1394-comment
Jul 23, 2026
Merged

refactor(shadcn): share agent token logic between Vercel route and dev server#1395
thomasyuill-livekit merged 1 commit into
mainfrom
ty/address-pr-1394-comment

Conversation

@thomasyuill-livekit

Copy link
Copy Markdown
Contributor

Issue

Addresses reviewer feedback on merged PR #1394 — no Linear ticket for this follow-up.

Overview

  • The AgentSessionView-01 story needs a LiveKit token from two places: a Vercel Preview API route and a local Storybook dev-server middleware.
  • Both had duplicated token-minting logic, risking future updates being applied to only one copy.
  • Extracted the shared "core" into one TypeScript module, used by both.

Summary of changes

File Change
docs/storybook/api/agents-ui/tokenCore.ts New. Shared createAgentToken(env) — env validation, AccessToken + RoomConfiguration construction.
docs/storybook/api/agents-ui/token.ts Vercel route now just calls createAgentToken and sends the response.
docs/storybook/.storybook/main.js Dev middleware loads tokenCore.ts via Vite's server.ssrLoadModule (needed since this file is CommonJS and can't natively import TS), then calls createAgentToken.

Testing

  • pnpm --filter @livekit/component-docs-storybook tsx:check passes on all touched/new files.
  • Ran pnpm dev:storybook locally and confirmed the token route still executes end-to-end through the new shared module (returns the expected validation error without LIVEKIT_URL set).
  • Once this PR's Vercel Preview deploys, verify the AgentSessionView-01 story still connects to a live room at <preview-url>/?path=/story/agents-ui-agentsessionview-01--default.

🤖 Generated with Claude Code

…e and dev server

Extracts the AccessToken-building logic duplicated across the Vercel
Preview API route and the local Storybook dev middleware into a single
tokenCore.ts, addressing review feedback on #1394.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ca4023c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
components-js-storybook-5kld Ready Ready Preview, Comment Jul 23, 2026 3:20pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
LiveKitRoom only 7.89 KB (0%)
LiveKitRoom with VideoConference 32.52 KB (0%)
All exports 44.13 KB (0%)

@thomasyuill-livekit
thomasyuill-livekit merged commit 428c30e into main Jul 23, 2026
5 checks passed
@thomasyuill-livekit
thomasyuill-livekit deleted the ty/address-pr-1394-comment branch July 23, 2026 15:33
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.

2 participants