Skip to content

feat(shadcn): improve chat transcript UX + live agent session on preview#1394

Open
thomasyuill-livekit wants to merge 7 commits into
mainfrom
ty/pr-instructions-v1
Open

feat(shadcn): improve chat transcript UX + live agent session on preview#1394
thomasyuill-livekit wants to merge 7 commits into
mainfrom
ty/pr-instructions-v1

Conversation

@thomasyuill-livekit

@thomasyuill-livekit thomasyuill-livekit commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Issue

Related to livekit-examples/agent-starter-react#347 (comment)

Overview

  • Improves the agent-chat-transcript autoScroll, scroll anchor, and "thinking" UX
  • Updates agent-chat-transcript story with injectable messages for testing
  • Wires AgentSessionView-01's story to a LiveKit agent session for testing
    • both locally and in the Vercel preview

Summary of changes

Note

The /api/agents-ui/token route is intentionally insecure (no auth layer) and refuses to run on a real Vercel Production deployment (VERCEL_ENV === 'production'), but is allowed on Preview

Anyone with the preview link can mint a token against the configured LiveKit project. This was a deliberate, discussed tradeoff for this demo. I don't believe this is a concern as it's just our HP demo

Chat transcript component

File Change
agent-chat-transcript.tsx Adds autoScroll/scrollAnchor props (boolean | 'user' | 'agent' | 'any') and scrollEdgeThreshold for configurable scroll-anchoring; replaces the AnimatePresence thinking indicator with a Marker/MarkerIcon/MarkerContent "Thinking..." row; restyles the scroll-to-bottom button
marker.tsx (new) New Marker/MarkerIcon/MarkerContent UI primitive, registered in registry.json
agent-session-block.tsx Fixes the transcript container to absolute inset-x-0 top-0 bottom-[135px] overflow-hidden so it fills its space correctly instead of relying on padding
bubble.tsx, message.tsx, message-scroller.tsx Formatting only (quote style, semicolons)

Storybook

File Change
AgentChatTranscript.stories.tsx New InjectMessages story — a button that appends a message on each click, alternating agent/user, to visually verify scroll behavior as the transcript grows
AgentSessionProvider.tsx Reverted to the shared LiveKit sandbox token server (works out of the box, no local project needed) — used by every story except AgentSessionView-01
LiveAgentSessionProvider.tsx (new) Connects to a real local/preview LiveKit project and dispatches an agent via AGENT_NAME — used only by AgentSessionView-01, so that story can be exercised against a real agent
.storybook/main.js Local dev-only Vite middleware at /api/agents-ui/token that mints tokens for LiveAgentSessionProvider
api/agents-ui/token.ts (new) Vercel serverless function serving the same /api/agents-ui/token route, so it also works on the deployed preview (the Vite middleware only runs under storybook dev, not the static storybook build Vercel deploys)
.env.example Documents VITE_PUBLIC_LK_SANDBOX_TOKEN_SERVER_ID (sandbox) alongside LIVEKIT_URL/LIVEKIT_API_KEY/LIVEKIT_API_SECRET/AGENT_NAME (live)

Testing

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5b3bbfb

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 22, 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 12:38am

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%)

…ranscript

Adds autoScroll/scrollAnchor props to AgentChatTranscript for configurable
scroll behavior, replaces the AnimatePresence thinking indicator with a
Marker component, and fixes the transcript container layout in
AgentSessionView_01 so it fills the available area with absolute inset-x-0.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds a story with a button that appends a new message on each click,
alternating between agent and user, to make it easy to visually verify
scroll-anchor and auto-scroll behavior with a growing transcript.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
thomasyuill-livekit and others added 3 commits July 22, 2026 17:08
…it agent dispatch

Replaces the sandbox-token-server-based AgentSessionProvider with a
Storybook dev-only Vite middleware (/api/agents-ui/token) that mints tokens
from LIVEKIT_URL/LIVEKIT_API_KEY/LIVEKIT_API_SECRET and optionally dispatches
a named agent via AGENT_NAME, so stories can run against a real local
LiveKit project instead of the shared sandbox. Drops the mocked
WithConversation story in favor of exercising the real session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Splits AgentSessionProvider into two decorators: the default
AgentSessionProvider goes back to the shared sandbox token server (dummy
session, no local setup required) for every story except AgentSessionView-01,
which now uses a new LiveAgentSessionProvider that hits the local
/api/agents-ui/token dev route and dispatches AGENT_NAME against a real
LiveKit project.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…en route

The /api/agents-ui/token route only existed as a Vite dev-server-only
middleware, so it 404'd on the deployed Vercel preview (storybook build
produces a static site with no Node server). Adds a Vercel serverless
function at the same path with its own copy of the token-minting logic,
gated on VERCEL_ENV !== 'production' so it works locally and on Preview but
refuses to run on a real Production deployment. Also cleans up main.js's
response helpers and consolidates AccessToken/RoomAgentDispatch/
RoomConfiguration imports onto livekit-server-sdk to avoid a duplicate
@livekit/protocol version in the dependency tree.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@thomasyuill-livekit thomasyuill-livekit changed the title feat(shadcn): improve chat transcript scroll anchoring and layout feat(shadcn): improve chat transcript UX + live agent session on preview Jul 23, 2026
@thomasyuill-livekit

Copy link
Copy Markdown
Contributor Author

@1egoman Re-requesting your review because there's been some iteration on stroybook preview so we can test /story/agents-ui-agentsessionview-01--default with a real agent (I used the homepage demo agent)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this becomes a Vercel Serverless Function

Comment on lines +28 to +36
if (process.env.VERCEL_ENV === 'production') {
sendResponse(
res,
500,
'THIS API ROUTE IS INSECURE. DO NOT USE THIS ROUTE IN PRODUCTION WITHOUT AN AUTHENTICATION LAYER.',
false,
);
return;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary

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