@@ -6,7 +6,6 @@ import 'package:livekit_client/livekit_client.dart' as sdk;
66import 'package:provider/provider.dart' ;
77
88import '../../../context/track_reference_context.dart' ;
9- import '../../../types/agent_state.dart' ;
109
1110enum VisualizerState { thinking, listening, active }
1211
@@ -123,7 +122,7 @@ class _SoundWaveformWidgetState extends State<SoundWaveformWidget> with SingleTi
123122 sdk.EventsListener <sdk.ParticipantEvent >? _participantListener;
124123
125124 // Agent support
126- AgentState _agentState = AgentState .initializing ;
125+ sdk. AgentState _agentState = sdk. AgentState .INITIALIZING ;
127126
128127 @override
129128 void didUpdateWidget (SoundWaveformWidget oldWidget) {
@@ -153,9 +152,9 @@ class _SoundWaveformWidgetState extends State<SoundWaveformWidget> with SingleTi
153152 if (widget.participant? .kind == sdk.ParticipantKind .AGENT ) {
154153 _participantListener? .on < sdk.ParticipantAttributesChanged > ((e) {
155154 if (! mounted) return ;
156- final agentStateString = e.attributes[agentStateAttributeKey] ;
155+ final agentAttributes = sdk. AgentAttributes . fromJson ( e.attributes) ;
157156 setState (() {
158- _agentState = agentStateString != null ? AgentState . fromString (agentStateString) : AgentState .initializing ;
157+ _agentState = agentAttributes.lkAgentState ?? sdk. AgentState .INITIALIZING ;
159158 });
160159 });
161160 }
@@ -259,13 +258,13 @@ class _SoundWaveformWidgetState extends State<SoundWaveformWidget> with SingleTi
259258 }
260259
261260 VisualizerState _determineState () {
262- if (widget.participant? .kind == sdk.ParticipantKind .AGENT && _agentState == AgentState .thinking ) {
261+ if (widget.participant? .kind == sdk.ParticipantKind .AGENT && _agentState == sdk. AgentState .THINKING ) {
263262 return VisualizerState .thinking;
264263 }
265264
266265 if (widget.participant == null ||
267266 widget.participant? .kind == sdk.ParticipantKind .AGENT &&
268- (_agentState == AgentState .initializing || _agentState == AgentState .listening )) {
267+ (_agentState == sdk. AgentState .INITIALIZING || _agentState == sdk. AgentState .LISTENING )) {
269268 return VisualizerState .listening;
270269 }
271270
0 commit comments