Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions packages/bot-runner/lib/create-listing-pr-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,18 @@ export class CreateListingPRHandler {
eventContent.input && typeof eventContent.input === 'object'
? (eventContent.input as Record<string, unknown>)
: {};
let listingDescription =
typeof input.listingDescription === 'string'
? input.listingDescription.trim()
: typeof input.description === 'string'
? input.description.trim()
: '';
let listingSummary =
typeof input.listingSummary === 'string'
? input.listingSummary.trim()
: '';
let files = await getContentsFromRealm(runCommandResult?.cardResultString);
let descriptionValue = listingDescription || '_No description provided_';

return [
'## Summary',
'',
...(listingSummary
? [listingSummary, '', '---']
: []),
`- Listing Name: ${context.listingDisplayName}`,
`- Listing Description: ${descriptionValue}`,
`- Room ID: \`${context.roomId}\``,
`- User ID: \`${runAs}\``,
`- Number of Files: ${files.files.length}`,
Expand Down
6 changes: 3 additions & 3 deletions packages/bot-runner/tests/command-runner-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ module('command runner', () => {
userId: '@alice:localhost',
input: {
roomId: '!abc123:localhost',
listingName: 'My Listing',
listingDescription: 'Example listing',
},
listingName: 'My Listing Name',
listingSummary: 'My listing Summary'
},
},
'bot-registration-2',
);
Expand Down
8 changes: 6 additions & 2 deletions packages/bot-runner/tests/create-listing-pr-handler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module('create-listing-pr handler', () => {
input: {
roomId: '!abc123:localhost',
listingName: 'My Listing',
listingDescription: 'Example listing',
listingSummary: 'My listing Summary',
},
};

Expand Down Expand Up @@ -75,6 +75,10 @@ module('create-listing-pr handler', () => {
openedCall.params.body?.toString().includes('Submission Card'),
'summary body omits submission card URL when not provided',
);
assert.true(
openedCall.params.body?.toString().includes('My listing Summary\n\n---'),
'summary body includes listing summary followed by divider',
);
});

test('includes submission card URL as a markdown link when provided', async (assert) => {
Expand All @@ -96,7 +100,7 @@ module('create-listing-pr handler', () => {
input: {
roomId: '!abc123:localhost',
listingName: 'My Listing',
listingDescription: 'Example listing',
listingSummary: 'My listing Summary',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ export default class CreateListingPRRequestCommand extends HostBaseCommand<

let { realm, listingId } = input;
let listingName: string | undefined;
let listingSummary: string | undefined;
let listing = await this.store.get<Listing>(listingId);
if (listing && isCardInstance(listing)) {
listingName = listing.name ?? listing.id;
listingSummary = listing.summary ?? undefined;
}

let useAiAssistantCommand = new UseAiAssistantCommand(this.commandContext);
Expand All @@ -65,6 +67,7 @@ export default class CreateListingPRRequestCommand extends HostBaseCommand<
realm,
listingId,
...(listingName ? { listingName } : {}),
...(listingSummary ? { listingSummary } : {}),
},
});
}
Expand Down
Loading