Skip to content

Commit 4b4bce4

Browse files
authored
Merge pull request #2203 from cardstack/cs-7966-command-result-dont-show
Fix: command result dont show
2 parents 9a4fc0d + b712449 commit 4b4bce4

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

packages/host/app/resources/room.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ export class RoomResource extends Resource<Args> {
400400
(e: any) =>
401401
e.type === 'm.room.message' &&
402402
e.content.msgtype === APP_BOXEL_COMMAND_MSGTYPE &&
403-
e.content['m.relates_to']?.event_id === effectiveEventId,
403+
(e.event_id === effectiveEventId ||
404+
e.content['m.relates_to']?.event_id === effectiveEventId),
404405
)! as CommandEvent | undefined;
405406
let message = this._messageCache.get(effectiveEventId);
406407
if (!message || !commandEvent) {

packages/host/tests/integration/components/ai-assistant-panel-test.gts

+70
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,76 @@ module('Integration | ai-assistant-panel', function (hooks) {
727727
assert.dom(`${stackCard} [data-test-country="Indonesia"]`).exists();
728728
});
729729

730+
test('it can apply change when the command event is not a replacement event', async function (assert) {
731+
let roomId = await renderAiAssistantPanel(`${testRealmURL}Person/fadhlan`);
732+
733+
await waitFor('[data-test-person="Fadhlan"]');
734+
assert.dom(`[data-test-preferredcarrier="DHL"]`).exists();
735+
736+
let payload = {
737+
name: 'patchCard',
738+
arguments: {
739+
attributes: {
740+
cardId: `${testRealmURL}Person/fadhlan`,
741+
patch: {
742+
attributes: {
743+
firstName: 'Joy',
744+
address: { shippingInfo: { preferredCarrier: 'UPS' } },
745+
},
746+
},
747+
},
748+
},
749+
eventId: 'event1',
750+
};
751+
await simulateRemoteMessage(roomId, '@aibot:localhost', {
752+
body: 'A patch',
753+
msgtype: APP_BOXEL_COMMAND_MSGTYPE,
754+
formatted_body: 'A patch',
755+
format: 'org.matrix.custom.html',
756+
data: JSON.stringify({ toolCall: payload }),
757+
});
758+
759+
await waitFor('[data-test-view-code-button]');
760+
await click('[data-test-view-code-button]');
761+
762+
await waitForCodeEditor();
763+
assert.deepEqual(
764+
JSON.parse(getMonacoContent()),
765+
766+
{
767+
name: 'patchCard',
768+
payload: {
769+
attributes: {
770+
cardId: 'http://test-realm/test/Person/fadhlan',
771+
patch: {
772+
attributes: {
773+
address: {
774+
shippingInfo: {
775+
preferredCarrier: 'UPS',
776+
},
777+
},
778+
firstName: 'Joy',
779+
},
780+
},
781+
},
782+
},
783+
},
784+
'it can preview code when a change is proposed',
785+
);
786+
assert.dom('[data-test-copy-code]').isEnabled('copy button is available');
787+
788+
await click('[data-test-view-code-button]');
789+
assert.dom('[data-test-code-editor]').doesNotExist();
790+
791+
await click('[data-test-command-apply="ready"]');
792+
await waitFor('[data-test-command-card-idle]');
793+
assert.dom('[data-test-apply-state="applied"]').exists();
794+
assert.dom('[data-test-person]').hasText('Joy');
795+
assert.dom(`[data-test-preferredcarrier]`).hasText('UPS');
796+
assert.dom(`[data-test-city="Bandung"]`).exists();
797+
assert.dom(`[data-test-country="Indonesia"]`).exists();
798+
});
799+
730800
test('it does not crash when applying change to a card with preexisting nested linked card', async function (assert) {
731801
let id = `${testRealmURL}Person/mickey`;
732802
let roomId = await renderAiAssistantPanel(id);

0 commit comments

Comments
 (0)