Skip to content

Commit 83cd2aa

Browse files
committedMar 25, 2024
Do not show bot streaming message indicator when it sends an error or a patch option
1 parent 4a7bec2 commit 83cd2aa

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
 

‎packages/ai-bot/main.ts

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ async function sendOption(
104104
msgtype: 'org.boxel.command',
105105
formatted_body: body,
106106
format: 'org.matrix.custom.html',
107+
isStreamingFinished: true,
107108
data: {
108109
command: {
109110
type: 'patch',
@@ -159,6 +160,9 @@ async function sendError(
159160
room,
160161
'There was an error processing your request, please try again later',
161162
eventToUpdate,
163+
{
164+
isStreamingFinished: true,
165+
},
162166
);
163167
} catch (e) {
164168
// We've had a problem sending the error message back to the user

‎packages/base/room.gts

+1
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ export class RoomField extends FieldDef {
520520
commandType: command.type,
521521
payload: command,
522522
}),
523+
isStreamingFinished: true,
523524
});
524525
} else {
525526
// Text from the AI bot

‎packages/host/tests/integration/components/operator-mode-test.gts

+45
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,51 @@ module('Integration | operator-mode', function (hooks) {
11571157
'Answer to my last question is not in progress',
11581158
);
11591159
});
1160+
1161+
test('it does not display the streaming indicator when ai bot sends an option', async function (assert) {
1162+
await setCardInOperatorModeState();
1163+
await renderComponent(
1164+
class TestDriver extends GlimmerComponent {
1165+
<template>
1166+
<OperatorMode @onClose={{noop}} />
1167+
<CardPrerender />
1168+
</template>
1169+
},
1170+
);
1171+
let roomId = await openAiAssistant();
1172+
1173+
addRoomEvent(matrixService, {
1174+
event_id: 'event1',
1175+
room_id: roomId,
1176+
state_key: 'state',
1177+
type: 'm.room.message',
1178+
origin_server_ts: new Date(2024, 0, 3, 12, 30).getTime(),
1179+
sender: '@aibot:localhost',
1180+
content: {
1181+
body: 'i am the body',
1182+
msgtype: 'org.boxel.command',
1183+
formatted_body: 'A patch',
1184+
format: 'org.matrix.custom.html',
1185+
data: JSON.stringify({
1186+
command: {
1187+
type: 'patch',
1188+
id: `${testRealmURL}Person/fadhlan`,
1189+
patch: {
1190+
attributes: { firstName: 'Dave' },
1191+
},
1192+
},
1193+
}),
1194+
},
1195+
});
1196+
1197+
await waitFor('[data-test-message-idx="0"]');
1198+
assert
1199+
.dom('[data-test-message-idx="0"] [data-test-ai-avatar]')
1200+
.doesNotHaveClass(
1201+
'ai-avatar-animated',
1202+
'ai bot patch message does not have a spinner',
1203+
);
1204+
});
11601205
});
11611206

11621207
test('it loads a card and renders its isolated view', async function (assert) {

0 commit comments

Comments
 (0)
Failed to load comments.