Skip to content

Commit

Permalink
Merge pull request #2169 from cardstack/matrix-service-adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemelia authored Feb 19, 2025
2 parents 2774829 + ebda5c7 commit 3b2b6f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/host/app/commands/create-ai-assistant-room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { service } from '@ember/service';

import format from 'date-fns/format';

import { aiBotUsername } from '@cardstack/runtime-common';

import {
APP_BOXEL_ACTIVE_LLM,
DEFAULT_LLM,
Expand Down Expand Up @@ -31,14 +29,8 @@ export default class CreateAiAssistantRoomCommand extends HostBaseCommand<
input: BaseCommandModule.CreateAIAssistantRoomInput,
): Promise<BaseCommandModule.CreateAIAssistantRoomResult> {
let { matrixService } = this;
let { userId } = matrixService;
if (!userId) {
throw new Error(
`bug: there is no userId associated with the matrix client`,
);
}
let server = userId!.split(':')[1];
let aiBotFullId = `@${aiBotUsername}:${server}`;
let userId = matrixService.userId;
let aiBotFullId = matrixService.aiBotUserId;
let { room_id: roomId } = await matrixService.createRoom({
preset: matrixService.privateChatPreset,
invite: [aiBotFullId],
Expand Down
7 changes: 7 additions & 0 deletions packages/host/app/services/matrix-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import {
baseRealm,
LooseCardResource,
ResolvedCodeRef,
aiBotUsername,
} from '@cardstack/runtime-common';

import {
basicMappings,
generateJsonSchemaForCardType,
Expand Down Expand Up @@ -233,6 +235,11 @@ export default class MatrixService extends Service {
return this.client.getUserId();
}

get aiBotUserId() {
let server = this.userId!.split(':')[1];
return `@${aiBotUsername}:${server}`;
}

get userName() {
return this.userId ? getMatrixUsername(this.userId) : null;
}
Expand Down

0 comments on commit 3b2b6f8

Please sign in to comment.