chore: clean up legacy tool/UI code paths and remove unused events
This commit is contained in:
@@ -57,8 +57,6 @@ extension _ChatBlocEvents on ChatBloc {
|
||||
_handleToolCallEnd(event as ToolCallEndEvent);
|
||||
case AgUiEventType.toolCallResult:
|
||||
_handleToolCallResult(event as ToolCallResultEvent);
|
||||
case AgUiEventType.toolCallError:
|
||||
_handleToolCallError(event as ToolCallErrorEvent);
|
||||
case AgUiEventType.unknown:
|
||||
break;
|
||||
}
|
||||
@@ -89,11 +87,6 @@ extension _ChatBlocEvents on ChatBloc {
|
||||
timestamp,
|
||||
);
|
||||
|
||||
final uiSchema = event.uiSchema;
|
||||
if (uiSchema != null) {
|
||||
_upsertUiSchema(items, event.messageId, uiSchema, timestamp);
|
||||
}
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
items: _removeToolCallItems(items),
|
||||
@@ -133,28 +126,6 @@ extension _ChatBlocEvents on ChatBloc {
|
||||
return result;
|
||||
}
|
||||
|
||||
void _upsertUiSchema(
|
||||
List<ChatListItem> items,
|
||||
String messageId,
|
||||
Map<String, dynamic> uiSchema,
|
||||
DateTime timestamp,
|
||||
) {
|
||||
final uiItemId = '$messageId-ui';
|
||||
final uiItem = ToolResultItem(
|
||||
id: uiItemId,
|
||||
callId: messageId,
|
||||
uiSchema: uiSchema,
|
||||
timestamp: timestamp,
|
||||
sender: MessageSender.ai,
|
||||
);
|
||||
final existingIndex = items.indexWhere((item) => item.id == uiItemId);
|
||||
if (existingIndex >= 0) {
|
||||
items[existingIndex] = uiItem;
|
||||
return;
|
||||
}
|
||||
items.add(uiItem);
|
||||
}
|
||||
|
||||
void _handleToolCallStart(ToolCallStartEvent event) {
|
||||
final exists = state.items.any(
|
||||
(item) => item is ToolCallItem && item.id == event.toolCallId,
|
||||
@@ -248,22 +219,6 @@ extension _ChatBlocEvents on ChatBloc {
|
||||
items.add(uiItem);
|
||||
}
|
||||
|
||||
void _handleToolCallError(ToolCallErrorEvent event) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
items: state.items.map((item) {
|
||||
if (item is ToolCallItem && item.id == event.toolCallId) {
|
||||
return item.copyWith(
|
||||
status: ToolCallStatus.error,
|
||||
errorMessage: event.error,
|
||||
);
|
||||
}
|
||||
return item;
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<ChatListItem> _removeToolCallItems(List<ChatListItem> items) {
|
||||
return items.where((item) => item is! ToolCallItem).toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user