Skip to content

Commit 7be953a

Browse files
committed
Merge branch 'reuse-room-resource' into return-of-the-skill-commands
2 parents ba864b2 + 304b9ff commit 7be953a

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

packages/host/app/components/ai-assistant/panel.gts

+8-5
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,14 @@ export default class AiAssistantPanel extends Component<Signature> {
188188
</div>
189189
{{else if this.isReady}}
190190
{{! below if statement is covered in 'isReady' check above but added due to glint not realizing it }}
191-
{{#if this.matrixService.currentRoomId}}
192-
<Room
193-
@roomId={{this.matrixService.currentRoomId}}
194-
@monacoSDK={{this.monacoSDK}}
195-
/>
191+
{{#if this.roomResource}}
192+
{{#if this.matrixService.currentRoomId}}
193+
<Room
194+
@roomId={{this.matrixService.currentRoomId}}
195+
@roomResource={{this.roomResource}}
196+
@monacoSDK={{this.monacoSDK}}
197+
/>
198+
{{/if}}
196199
{{/if}}
197200
{{else}}
198201
<LoadingIndicator

packages/host/app/components/matrix/room.gts

+16-21
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import UpdateSkillActivationCommand from '@cardstack/host/commands/update-skill-
3939
import { Message } from '@cardstack/host/lib/matrix-classes/message';
4040
import type { StackItem } from '@cardstack/host/lib/stack-item';
4141
import { getAutoAttachment } from '@cardstack/host/resources/auto-attached-card';
42+
import { RoomResource } from '@cardstack/host/resources/room';
4243

4344
import type CardService from '@cardstack/host/services/card-service';
4445
import type CommandService from '@cardstack/host/services/command-service';
@@ -66,6 +67,7 @@ import type { Skill } from '../ai-assistant/skill-menu';
6667
interface Signature {
6768
Args: {
6869
roomId: string;
70+
roomResource: RoomResource;
6971
monacoSDK: MonacoSDK;
7072
};
7173
}
@@ -77,7 +79,7 @@ export default class Room extends Component<Signature> {
7779
class='room'
7880
data-room-settled={{this.doWhenRoomChanges.isIdle}}
7981
data-test-room-settled={{this.doWhenRoomChanges.isIdle}}
80-
data-test-room-name={{this.roomResource.name}}
82+
data-test-room-name={{@roomResource.name}}
8183
data-test-room={{@roomId}}
8284
>
8385
<AiAssistantConversation
@@ -147,15 +149,12 @@ export default class Room extends Component<Signature> {
147149
@autoAttachedFile={{this.autoAttachedFile}}
148150
@filesToAttach={{this.filesToAttach}}
149151
/>
150-
151-
{{#if this.roomResource}}
152-
<LLMSelect
153-
@selected={{this.roomResource.activeLLM}}
154-
@onChange={{this.roomResource.activateLLM}}
155-
@options={{this.supportedLLMs}}
156-
@disabled={{this.roomResource.isActivatingLLM}}
157-
/>
158-
{{/if}}
152+
<LLMSelect
153+
@selected={{@roomResource.activeLLM}}
154+
@onChange={{@roomResource.activateLLM}}
155+
@options={{this.supportedLLMs}}
156+
@disabled={{@roomResource.isActivatingLLM}}
157+
/>
159158
</div>
160159
</div>
161160
</footer>
@@ -217,10 +216,6 @@ export default class Room extends Component<Signature> {
217216
@service private declare operatorModeStateService: OperatorModeStateService;
218217
@service private declare loaderService: LoaderService;
219218

220-
private get roomResource() {
221-
return this.matrixService.roomResources.get(this.args.roomId);
222-
}
223-
224219
private autoAttachmentResource = getAutoAttachment(
225220
this,
226221
() => this.topMostStackItems,
@@ -519,25 +514,25 @@ export default class Room extends Component<Signature> {
519514
};
520515

521516
private isDisplayingCode = (message: Message) => {
522-
return !!this.roomResource?.isDisplayingCode(message);
517+
return this.args.roomResource.isDisplayingCode(message);
523518
};
524519

525520
private toggleViewCode = (message: Message) => {
526-
this.roomResource?.toggleViewCode(message);
521+
this.args.roomResource.toggleViewCode(message);
527522
};
528523

529524
private doMatrixEventFlush = restartableTask(async () => {
530525
await this.matrixService.flushMembership;
531526
await this.matrixService.flushTimeline;
532-
await this.roomResource?.loading;
527+
await this.args.roomResource.loading;
533528
});
534529

535530
private get messages() {
536-
return this.roomResource?.messages ?? [];
531+
return this.args.roomResource.messages;
537532
}
538533

539-
private get skills() {
540-
return this.roomResource?.skills ?? [];
534+
private get skills(): Skill[] {
535+
return this.args.roomResource.skills;
541536
}
542537

543538
private get supportedLLMs(): string[] {
@@ -555,7 +550,7 @@ export default class Room extends Component<Signature> {
555550
}
556551

557552
private get room() {
558-
let room = this.roomResource?.matrixRoom;
553+
let room = this.args.roomResource.matrixRoom;
559554
return room;
560555
}
561556

0 commit comments

Comments
 (0)