Skip to content

feat: integrate the optional voice plugin - #185

Closed
nozokada wants to merge 6 commits into
adobe:mainfrom
nozokada:feat/voice-plugin-integration
Closed

nozokada wants to merge 6 commits into
adobe:mainfrom
nozokada:feat/voice-plugin-integration

Conversation

@nozokada

@nozokada nozokada commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Stacked on #174. GitHub can't base a PR on a fork branch, so this targets main and also shows #174's commits (feat: add voice session bootstrap request, refactor: keep LiveKit names out of the voice bootstrap API, test: give the voice bootstrap tests more time on slow CI runners). Please review only the last three commits:

  • fix: route each stream's callbacks to its own handlers
  • feat: integrate the optional voice plugin
  • feat: show the voice button in the send slot while the input is empty

Summary

Brand Concierge can now hold a voice conversation through an optional voice plugin. BC only knows the AEPPluginSupport contract (AEPPlugins, VoicePlugin, VoiceSession, VoiceSessionListener). It takes no AEPVoice or LiveKit dependency: the app chooses the implementation by calling AEPPlugins.add(LiveKitVoicePlugin()).

Changes

1. ConciergeChatService: per-request stream handlers (separate commit)

  • The shared URLSession delegate used to call whichever handlers were registered last. A cancelled or superseded request could therefore complete or fail the next one. The voice bootstrap stream can stay open for the whole session, which makes this race likely.
  • Handlers are now kept per task. cancelActiveStream() cancels only the latest request, and every request reports to its own handlers.

2. Voice plugin integration

  • Discovery: ChatController resolves AEPPlugins.get(VoicePlugin.self). The composer's voice button appears only when a plugin is registered.
  • Button placement (separate commit): as in the web client, the voice button takes the send button's place while the text field is empty, and the send button returns once there is text. It stays visible while a session is connecting or running so it can always be ended. Without a plugin the composer is unchanged. The placement rule is a pure function, ComposerEditingView.trailingControl, with unit tests.
  • Start: the voice bootstrap fetches credentials, then BC calls startSession(connection:listener:) with ["url": url, "token": token]. The plugin interprets these fields; BC only maps the backend's names to them.
  • Listener: ChatController is the VoiceSessionListener.
    • Transcripts render as user/assistant bubbles. Text is cumulative per turn, so each bubble is updated in place until isFinal.
    • .failed tracks errorOccurred and shows the theme's network error copy.
    • .ended returns to idle quietly.
  • State: new ChatState.voiceSession. chatState is still written in one place, derived from the active turn and the active voice run.
  • Gating: while voice runs, typed sends, dictation and data handoffs are held off. handleDataHandoff returns false, the same as when a turn is in flight.
  • Teardown: stopping voice, the chat view disappearing, or an identity reset stops the session and cancels a still-open bootstrap. Callbacks from a released session are dropped.
  • Docs: new "Optional: voice conversations" section in Documentation/getting-started.md.

Dependencies

  • AEPPluginSupport is resolved from a local path (../aepsdk-plugin-ios) in Package.swift and the Podfile. The podspec declares AEPPluginSupport >= 1.0.0, < 2.0.0.
  • CI is expected to fail until aepsdk-plugin-ios is public, so this PR stays a draft until then. At that point every consumer switches to a URL/trunk dependency.

API note

ChatState is public. Adding .voiceSession is source-breaking for apps that switch over it exhaustively.

Test plan

  • New ChatControllerVoiceSessionTests (26 tests) drive the integration through a FakeVoicePlugin. They cover:
    • discovery
    • credential mapping
    • bootstrap failure paths
    • transcript rendering
    • ended/failed sessions
    • stop/cancel
    • stale and synchronous plugin callbacks
    • gating
    • identity reset
  • Two ConciergeChatServiceTests cover per-request stream routing. Both fail on the previous service code.
  • Full UnitTests suite: 937 tests. The only failures are 3 ProductCardCarouselSnapshotTests, which also fail on the base branch on the local iOS 26.4 simulator.
  • ConciergeDemoApp builds.
  • The SPM package builds in isolation, and its graph contains no LiveKit.
  • New ComposerEditingViewTests cases (6) cover the voice/send button placement.
  • Manual voice conversation in an SPM-only app that registers LiveKitVoicePlugin, on the simulator and on a physical iPhone: connect, agent audio, transcripts, stop, and the button placement while typing and after clearing.

Adds the client side of the voice bootstrap handshake, without any voice
transport:

- VoicePayload and the optional ConversationResponse.voice field.
- ConciergeChatService.bootstrapVoiceSession, which posts a
  livekit-bootstrap conversation event to /brand-concierge-voice and
  reports the first livekit_session credentials on the stream.
- The voice path has no region segment, matching the Web SDK.
- Chat and bootstrap requests share one event envelope builder, so the
  bootstrap forwards the same identity map and consent state.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- VoicePayload and ConversationResponse.voice are internal. VoicePayload
  mirrors the service's wire format, like the other network models.
- Callers receive a transport-neutral VoiceSessionBootstrap(url:token:)
  instead of LiveKitSessionBootstrap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nozokada
nozokada force-pushed the feat/voice-plugin-integration branch from 5013368 to dd02df7 Compare October 19, 2026 22:18
The bootstrap tests waited at most 3 seconds for the stubbed request to
complete. A stalled shared runner exceeded that, so the network error
test failed although the error was delivered. The wait returns as soon
as its condition holds, so a 10 second default only matters on failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nozokada
nozokada force-pushed the feat/voice-plugin-integration branch from dd02df7 to 9dd6ceb Compare October 19, 2026 23:33
nozokada and others added 3 commits October 19, 2026 16:34
ConciergeChatService has one URLSession delegate and kept a single pair
of chunk/complete handlers. The delegate did not check which task a
callback came from, so a request that was cancelled or superseded could
complete into the next request's handlers, failing it and clearing them.

Handlers are now registered per task under a lock, and a task's data and
completion reach only its own handlers. cancelActiveStream() still
cancels the most recent request, and the cancelled request still reports
its own completion. Tasks without stream handlers, such as feedback
requests, are ignored by the stream delegate.

This keeps a voice bootstrap stream that stays open during a voice
session from interfering with later chat turns.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Brand Concierge discovers a voice plugin through AEPPlugins and drives it
through the AEPPluginSupport contract only, so the SDK takes no AEPVoice or
LiveKit dependency.

- ChatController resolves the registered VoicePlugin, fetches session
  credentials with the voice bootstrap, and hands them to the plugin as the
  "url" and "token" connection fields.
- ChatController is the session listener: transcript updates render as
  user/assistant bubbles updated in place until final; a failure tracks an
  error and shows the network error copy; a normal end returns to idle.
- Add ChatState.voiceSession. Chat state is still derived in one place, from
  the active turn and the active voice run.
- Typed turns, dictation and data handoffs are held off during voice. Stop,
  view disappearance and identity reset end the session and cancel a still
  open bootstrap; callbacks from a released session are dropped.
- The composer shows a voice button only when a plugin is registered.
- Depend on AEPPluginSupport via a local path until it is published.
- Tests drive the integration through FakeVoicePlugin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Match the web client: the voice conversation button takes the send button's
place while the text field is empty and gives it back once there is text. It
stays visible while a session is running or connecting so it can always be
ended. Without a voice plugin the composer is unchanged.
@nozokada

Copy link
Copy Markdown
Member Author

Superseded by #189. Voice no longer goes through an AEPPluginSupport plugin: Brand Concierge now owns the voice session logic, and the app passes its transport with Concierge.show/present(..., voiceTransport:). The stream-handler fix and the voice UI from this PR are carried over there.

@nozokada nozokada closed this Oct 23, 2026
@nozokada
nozokada deleted the feat/voice-plugin-integration branch November 24, 2026 23:29
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.

1 participant