Skip to content

feat: add voice to the demo app through a LiveKit transport - #191

Merged
nozokada merged 74 commits into
adobe:feature/voicefrom
nozokada:feat/demo-app-voice
Nov 24, 2026
Merged

nozokada merged 74 commits into
adobe:feature/voicefrom
nozokada:feat/demo-app-voice

Conversation

@nozokada

@nozokada nozokada commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Stacked on #189 (which is stacked on #174). Merge order: #174 → #189 → #191. GitHub can't base a PR on a fork branch, so this targets feature/voice and also shows the changes of #174 and #189 until they merge.
Base: feature/voice, cut from main at 5.10.3. Voice lands there, not in dev, so releases during the restricted change period don't pick it up. The pilot will use a prerelease tag on that branch, and the branch goes to dev once a public release is approved.
This PR's own changes only: feat/voice-transport...feat/demo-app-voice

Its commits (the merge commits bring in #189):

  • feat: add voice to the demo app through a LiveKit transport
  • docs: walk through adding voice with the LiveKit transport
  • feat: report LiveKit reconnects to Brand Concierge in the demo transport
  • fix: restore LiveKit's speaker preference when the demo transport disconnects
  • feat: pass the voice transport to the floating-button wrap in the demo app
  • docs: describe how voice handles interruptions that can't resume
  • feat: keep demo app voice conversations running in the background
  • feat: send voice text prompts from the LiveKit transport
  • docs: say voice conversations send the XDM context captured at the start
  • Register the demo's voice transport at launch
  • Fix the step 4 link in the background conversations section

The follow-up #189 mentions: the reference LiveKitTransport, now in ConciergeDemoApp so the demo app can hold voice conversations.

Summary

ConciergeDemoApp gets voice through an app-side transport, the way a customer app would. LiveKit is added to the demo app target only. Package.swift, the podspec and the AEPBrandConcierge target are unchanged, so the SDK still ships no third-party dependency.

Changes

  • ConciergeDemoApp/LiveKitTransport.swift (new, ~160 lines): implements VoiceTransport on the LiveKit Swift SDK, for apps to copy.
    • Uses preconnect audio, so speech before the agent joins still reaches it. Falls back to a plain connect if the preconnect path fails.
    • Reports LiveKit's reconnects as .reconnecting, then .connected once the room is back.
    • Prefers the built-in speaker (AudioManager.shared.isSpeakerOutputPreferred) while connected. That setting is LiveKit-wide, so the transport saves the app's value and restores it once it is idle again.
    • Keeps its state on the main thread. LiveKit callbacks hop to main and are dropped unless they come from the current room, so nothing is reported after disconnect().
    • Leaving, the room being deleted or the user being removed reports .disconnected; any other disconnect reports .failed, the same set as the Android test app's transport.
    • Implements send(_:topic:) (added in feat: hold voice conversations through an app-provided transport #189) with publish(data:options:) and reliable: true, since LiveKit's default is lossy. It throws when there is no room, so Brand Concierge shows its send-failed message.
    • Returns continuesInBackground true, so a conversation keeps running with the screen locked or in another app (see feat: hold voice conversations through an app-provided transport #189). It already starts the microphone in connect(_:) with the preconnect recording, as iOS requires for background audio.
  • One app-wide transport (DemoVoice.transport), registered once with Concierge.setVoiceTransport in ConciergeDemoApp.init() (feat: hold voice conversations through an app-provided transport #189 section 7). Every Concierge.show / Concierge.present call (SwiftUI, UIKit and Testing tabs) and the Magic tab's Concierge.wrap, whose floating button opens the chat, get voice without passing it.
  • Info.plist: declares the audio background mode (UIBackgroundModes).
  • Project: the LiveKit package (https://github.com/livekit/client-sdk-swift, exact 2.17.0) is linked to ConciergeDemoApp. Package.resolved gains LiveKit and its WebRTC and uniffi binaries.
  • Docs: the voice section of getting-started.md becomes a walkthrough:
    1. Add LiveKit with Swift Package Manager, linked to the app target. This also works from CocoaPods projects: current LiveKit releases are not on CocoaPods trunk, and the demo app mixes both. The doc names the version tested on devices (2.17.0).
    2. Add NSMicrophoneUsageDescription and the audio background mode.
    3. Copy LiveKitTransport.swift.
    4. Register one instance with Concierge.setVoiceTransport(_:) at launch.

The same transport is in the standalone reference app (Adobe-AI-Core-Services/voice_demo-app-ios#2); the demo app here becomes the primary reference.

Test plan

  • ConciergeDemoApp builds; SwiftLint is clean on the changed files.
  • End to end against the demo app's existing Edge config, with a local-only UI test (open chat → start voice → stay connected 10 s → stop):
    • iPhone 17 Pro, iOS 27.0.1: 23/23 runs passed. In every run the device log shows the bootstrap, the room connect, the microphone published, about 2.6 s of preconnect audio sent to the agent, and the agent's audio subscribed. No fallbacks or failures.
    • Simulator (iOS 26.4): a fresh session passes. Back-to-back runs that rejoin the same session's room can fail with Audio Engine Error -4010 after the preconnect path times out. The standalone reference app shows the same today, so this is Simulator audio, not this change.
  • Background on device (iPhone 17 Pro, iOS 27.0.1, Stage config and a 3-minute cap in a local build only): screen locked, another app in front, locking while connecting, an incoming call, Wi-Fi ↔ cellular, AirPods, force-quit, the cap, and 60 s of silence in the background.
  • On device with feat: hold voice conversations through an app-provided transport #189's voice turns (Stage config in a local build only): a product card arriving while the screen is locked renders with the reply after unlocking, and a suggestion tapped during voice reaches the agent through send(_:topic:) and gets a voice reply.
  • On device with feat: hold voice conversations through an app-provided transport #189's thinking indicator (iPhone 16e, iOS 27.2.1, Stage config in a local build only): the thinking indicator shows after speaking and after a suggestion tap, turns into the reply when its text starts, and is removed when voice stops or fails.
  • Manual on device (iPhone 17 Pro, iOS 27.0.1, Stage config in a local build only):
    • Conversation audio and transcript.
    • Opening and closing the chat several times in a row.
    • Switching the audio route to AirPods mid-conversation: audio continues on AirPods.
    • Siri: it doesn't respond while a voice conversation is active, so there was no interruption to handle.
    • Denied microphone permission: the dialog offers only Cancel or Open Settings, and nothing connects until the user allows the microphone in Settings.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

nozokada and others added 8 commits October 28, 2026 15:38
Adds the public VoiceTransport protocol, through which an app supplies the
real-time audio and data connection for voice conversations, and brings the
voice session logic into Brand Concierge as internal types: the session
controller, the data-channel message parser and the session state.

The session claims the app's single transport only while connected, and
releases it (clearing the delegate, then disconnecting) before reporting its
end, so the transport can be reused by the next conversation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Concierge.show(...) and Concierge.present(...) take an optional voiceTransport,
kept across re-shows like textSpeaker. When one is passed, the composer shows a
voice button in the send slot; tapping it fetches session credentials from the
Concierge service and runs the conversation over the app's transport. The
transcript renders in the chat, and typed turns, dictation and data handoffs
are held off until the conversation ends.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	AEPBrandConcierge/Sources/Controllers/ChatController.swift
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	AEPBrandConcierge/Tests/UnitTests/ConciergeChatServiceTests.swift
The demo app adds the LiveKit Swift SDK to its own target and implements
Brand Concierge's VoiceTransport in LiveKitTransport.swift, a reference for
apps to copy. One transport instance is passed to every Concierge.show and
Concierge.present call, since a reopened chat keeps the transport it was
first shown with. The SDK itself still has no third-party dependency.

The getting-started guide now links to the reference transport.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The voice section of the getting-started guide now covers adding LiveKit
with Swift Package Manager (also from CocoaPods projects), the microphone
usage description, copying the reference transport, passing one instance
to every show and present call, and audio quality: voice processing,
speaker output, interruptions and the device checks to repeat.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nozokada
nozokada force-pushed the feat/demo-app-voice branch from 1af3aab to f1fb0bf Compare October 28, 2026 22:42
nozokada and others added 4 commits October 29, 2026 15:50
…stops

LiveKit's preconnect capture starts the shared audio stack's microphone
input but never stops it when the room fails to connect, which left the
system microphone indicator on after a failed voice start. Disconnecting
now stops the microphone input right away, and again once a cancelled join
settles. A new connection waits for that teardown. The plain-connect
fallback now runs only when preconnect capture could not start, so a
failed connection is no longer retried with a second timeout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…talled one

LiveKit keeps a cancelled connection attempt going until it times out, and
the next connection used to wait for it, so restarting voice right after
stopping could take up to 15 seconds. Teardown now only releases the
microphone and disconnects the room. The cancelled join gives up as soon as
its capture starts, and when a superseded join does end, it releases the
microphone only if no newer connection is using it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…redentials

Only the voice session itself watched for the app entering the background,
and it exists only once the credentials arrive. Going to the background
while they were still being fetched left the request running, and the
session then connected and opened the microphone. The chat controller now
stops voice on background in every phase, cancelling a pending credentials
request, so the session no longer watches for it separately.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nozokada
nozokada force-pushed the feat/demo-app-voice branch from e66439b to 0d9ab4f Compare October 30, 2026 00:12
nozokada and others added 5 commits October 29, 2026 17:43
…re a voice session

Track a running voice conversation with ChatController.isVoiceSessionActive instead of a new public ChatState case, so exhaustive switches in host apps keep compiling.

Ask for microphone permission before requesting voice credentials. A denial starts nothing and shows the Settings dialog worded for voice conversations, matching Android.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	Documentation/getting-started.md
Name the reasons the reference transport treats as a normal end, the same set as the Android reference transport.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread ConciergeDemoApp/LiveKitTransport.swift Resolved
nozokada and others added 22 commits November 17, 2026 14:55
Track the current voice turn the way web's handleTurnDone does. The
user's transcript decides the turn; a new user turn closes the open
reply, and messages for any other or already finished turn are dropped.
The latest ui_payload snapshot is held for the turn.

When the turn ends, the reply bubble gets the authoritative text and the
sources, followed by the cards, CTAs and suggestions, through the same
code typed chat uses. An error or an empty reply replaces the bubble
with the new voice.turn.failed copy, still renders the payload and
keeps the conversation open. An interrupted turn counts as completed.

Add the voice.turn.failed and voice.turn.messageSendFailed copy with
web's defaults.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add VoiceTransport.send(_:topic:), which the app implements with
reliable delivery. During a voice conversation, a tapped prompt
suggestion (including a welcome one) goes to the worker as a
text_prompt on the bc-text-input topic, like on web, and is tracked as
a submitted query. The user's bubble shows at once and the worker's
echo of it is dropped. After the conversation ends, taps stream over
SSE as before; the composer stays read-only during voice, as on web.

Taps are dropped while connecting or reconnecting, and from the start
of the user's speech until the reply starts. A rejected prompt
(text_input_error) fails the turn with voice.turn.failed, and a send
that throws fails it with voice.turn.messageSendFailed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement VoiceTransport.send in the demo app's LiveKitTransport with
reliable delivery, so suggestion taps during voice reach the agent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A voice session failure now carries a typed reason with a fixed message.
Errors from the app's transport and the bootstrap call can include URLs,
tokens or server responses, so their text only goes to the debug log and
never to Edge or the warning and error logs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When the final transcript for a turn has no text, the open bubble is
removed instead of being left empty, and the next bubble becomes the
scroll anchor.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
setMicrophoneEnabled returns immediately and can't throw, so a transport
whose mute or unmute fails is the only one that knows. Brand Concierge
can't tell whether the microphone is live then, so the transport now
reports .failed and the conversation ends.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
LiveKitTransport changed the microphone in a task and only logged a
failure, so Brand Concierge kept the conversation going while the
microphone could be live during an interruption or muted while the chat
shows Listening. A mute or unmute that throws now leaves the room and
reports .failed, as VoiceTransport asks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The voice bootstrap now carries the held XDM context, resolved for the
same session as the bootstrap request. The service replays it on every
voice turn, so a tapped prompt suggestion's Query Submitted event uses
that snapshot rather than the store's current context. Updates made
during a voice conversation apply from the next conversation or typed
message; the implementation guide says so.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	Documentation/Implementation/implementation-guide.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The session reports when the current turn starts and stops waiting for
its reply: from the user's final transcript, spoken or sent as text,
until the reply's first text, the turn's end, a newer turn or the end of
the session. The chat shows the wait the way a typed turn does, as an
empty reply bubble with the theme's loading message, and the reply fills
that bubble. An empty bubble left behind is removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	Documentation/getting-started.md
show, present and wrap no longer take a voiceTransport. The app
registers one transport with Concierge.setVoiceTransport(_:), from any
thread, and every chat reads it, so a new value reaches chats that are
already open as well as later ones. A running conversation keeps the
transport it started with. After nil, the voice button stays while a
conversation runs, so the user can stop it, and disappears once it
ends. Resetting identities keeps the registered transport.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	Documentation/getting-started.md
The demo app registers its LiveKit transport once with
Concierge.setVoiceTransport when it starts, instead of passing it to
every show, present and wrap call. The style guide says the voice
button appears while a transport is registered.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Say a transport is registered rather than provided in the composer
comments, and note in the getting-started guide that taps are ignored
while connecting and that setVoiceTransport can be called from any
thread.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	Documentation/getting-started.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resetting identities ends a running voice conversation and keeps the
transport registered with Concierge.setVoiceTransport.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nozokada and others added 4 commits November 24, 2026 13:53
The voice bootstrap now takes the app's auth token, as a chat turn does.
Resolve it after the microphone check and before the bootstrap request.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nozokada
nozokada merged commit 9fdd79f into adobe:feature/voice Nov 24, 2026
11 checks passed
@nozokada
nozokada deleted the feat/demo-app-voice branch November 24, 2026 23:28
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.

3 participants