-
Notifications
You must be signed in to change notification settings - Fork 59
Disconnect the client when the bot disconnects, with option to disable #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9e43a28
ca48670
63888dc
015de48
ad1c19a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,7 +70,7 @@ export type RTVIEventCallbacks = Partial<{ | |||||||||||||||||
| onBotStarted: (botResponse: unknown) => void; | ||||||||||||||||||
| onBotConnected: (participant: Participant) => void; | ||||||||||||||||||
| onBotReady: (botReadyData: BotReadyData) => void; | ||||||||||||||||||
| onBotDisconnected: (participant: Participant) => void; | ||||||||||||||||||
| onBotDisconnected: (participant?: Participant) => void; | ||||||||||||||||||
| onMetrics: (data: PipecatMetricsData) => void; | ||||||||||||||||||
|
|
||||||||||||||||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||||||||||||||
|
|
@@ -158,6 +158,13 @@ export interface PipecatClientOptions { | |||||||||||||||||
| * Default to false | ||||||||||||||||||
| */ | ||||||||||||||||||
| enableScreenShare?: boolean; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Disconnect when the bot disconnects. | ||||||||||||||||||
| * | ||||||||||||||||||
| * Default to true | ||||||||||||||||||
|
||||||||||||||||||
| * Default to true | |
| * Default to true. | |
| * | |
| * NOTE: This default of `true` is a breaking change compared to earlier | |
| * versions, where the client would remain connected when the bot | |
| * disconnected unless this behavior was explicitly requested. | |
| * If you rely on the previous behavior, explicitly set | |
| * `disconnectOnBotDisconnect: false` when creating the client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another good point by copilot except... that technically the current behavior is breaking. we used to disconnect the client when the bot disconnected but somewhere along the way that stopped and it's pretty annoying.
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New behavior (auto-disconnect when the bot disconnects, and the disconnectOnBotDisconnect opt-out) isn’t covered by existing Jest tests in client-js/tests/client.spec.ts. Please add tests that simulate a bot-disconnect callback from the transport and assert (1) disconnect is triggered by default, and (2) disconnect is not triggered when disconnectOnBotDisconnect: false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -110,7 +110,7 @@ export type RTVIEvents = Partial<{ | |||||
| botStarted: (botResponse: unknown) => void; | ||||||
| botConnected: (participant: Participant) => void; | ||||||
| botReady: (botData: BotReadyData) => void; | ||||||
| botDisconnected: (participant: Participant) => void; | ||||||
| botDisconnected: (participant?: Participant) => void; | ||||||
|
||||||
| botDisconnected: (participant?: Participant) => void; | |
| botDisconnected: (participant: Participant) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copilot has a valid point here, but i don't know how to NOT break this. There IS no participant when it comes to the smallWebRTC Transport.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onBotDisconnectednow takes an optionalParticipant, which is a breaking change for TS consumers using(participant: Participant) => voidhandlers (not assignable to an optional-param callback understrict). Prefer keeping the callback signature stable and ensuring aParticipantis always provided, or add a new separate callback/event for the no-participant case instead of changing this one.