affectUI › Components › Agents

Voice Session

A live voice call with an agent – both voices as audio waves with the pause between them measured, the words as they are spoken, voice-to-voice latency split up against a budget.

Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/voice-session.json · Import from @/components/ui/voice-session

When to use

  • A live voice call with an agent – support lines, phone agents, voice assistants in your app
  • Showing who speaks, how long the agent takes to answer and what it says, word by word
  • Watching voice-to-voice latency per turn against a budget – where the time goes and the P50 of the call

When not to use

  • A text chat – use Response Stream for the answer, Chat Composer for the input
  • Monitoring many calls at once – this is one call

Usage

import { VoiceSession } from "@/components/ui/voice-session";

export function Call({ turns, status, levels }) {
  return (
    <VoiceSession
      agent={{ id: "atlas", name: "Atlas" }}
      subtitle="Billing support"
      personName="Maya"
      status={status} // "connecting" | "listening" | "thinking" | "speaking" | "ended"
      turns={turns}
      levels={levels} // { person: 0.4, agent: 0 } – from your audio analyser
      startedAt={callStart}
      onBargeIn={() => call.interrupt()}
    />
  );
}

Props

NameTypeDefaultDescription
agent{ id, name, color? }Who is on the call – its pixel mark is drawn from the id, its voice in color (blue by default)
titlestringagent.nameHeading of the card
subtitlestringWhat the call is about, next to the heading
personNamestring"You"The person's name on their lane and in the transcript
personAvatarstringThe person's photo before their name – their initial in a circle without one; the agent always shows its pixel mark
status"connecting" | "listening" | "thinking" | "speaking" | "ended"Where the call is – the badge, the mark, the lanes and the big number follow it
turnsVoiceTurn[]{ id, speaker, text, spoken?, interrupted?, responseMs?, latency? } – oldest first; the last exchange is the transcript, every agent turn counts toward the P50
levels{ person?, agent? }How loud each side is right now, 0 to 1 – sampled every 90ms into the lanes
initialLevels{ person?, agent? }[]The last seconds before the card opened, one entry per 90ms – the lanes start filled, e.g. when a call is reopened
startedAtnumberDate.now() when the call started – the footer counts from here
budgetMsnumber800Voice to voice above this is over budget: a red badge and a red pause
pausedbooleanfalseThe lanes stand still and the call time stops
onPauseChange(paused: boolean) => voidPause / Resume
onBargeIn() => voidBarge in – take over from the agent
settingsVoiceSettingsSection[]{ title?, items: { id, label, icon?, checked?, onSelect? }[] }[] – what the settings icon opens; items with checked show a check and keep the menu open
showTranscriptbooleantrueThe words of the turn above the lanes
classNamestringExtra class on the card

Keyboard

  • Tab: Move through the settings icon, the pause labels, the latency parts (each highlights its slice), Pause and Barge in
  • Enter / Space: Press a button, open the settings or pick an item
  • ↑ / ↓ / Home / End: Move through the settings menu
  • Esc: Close the settings menu – focus goes back to its icon

Accessibility

  • Each turn is read out once it is over, never word by word; status changes are announced by the badge
  • Every pause label is a button whose name says how long the agent took and where the time went
  • Pause is a toggle button (aria-pressed); the lanes are decoration and hidden, the latency bar carries its numbers as a label

Responsive

  • The card keeps its height – each transcript line keeps its newest two rows, the legend reserves its row while measuring
  • Below 380px the names move above their lines, the subtitle steps aside and the legend wraps
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Response Stream – One agent answer through every state it goes through – words streaming in, stopped and continued from the exact word, failed and retried from there, done – with steer and queued messages above it
  • Thinking State – AI working panel with a live timer, searched sources and thinking steps that appear one by one
  • Chat Composer – Prompt composer with model picker, voice input, app connections and approval request
  • Metering Chart – Usage per day as soft gradient bars drifting from blue to lilac, with a live bar for today that keeps growing, a Real-time badge and rolling totals