Skip to content

Conversation

@richardhjtan
Copy link
Contributor

Screenshot 2026-01-12 at 6 20 44 PM

@github-actions
Copy link

Host Test Results

0 files   -     1  0 suites   - 1   0s ⏱️ - 1h 33m 19s
0 tests  - 1 651  0 ✅  - 1 634  0 💤  - 15  0 ❌  - 1 
0 runs   - 1 665  0 ✅  - 1 647  0 💤  - 15  0 ❌  - 2 

Results for commit 979b6af. ± Comparison against base commit c0eb977.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new submission bot for handling pull request submissions and refactors shared bot functionality into a reusable @cardstack/bot-core package. The submission bot can be invited to Matrix rooms to assist with submission workflows, and the refactoring reduces code duplication between bot services.

Changes:

  • Created @cardstack/bot-core package with shared utilities for Matrix bot services (client setup, room locking, shutdown handling, signal handlers, sliding sync, auto-join)
  • Implemented new @cardstack/submission-bot service for handling PR submissions and review workflows
  • Refactored @cardstack/ai-bot to use the new bot-core utilities, eliminating duplicate code
  • Added InviteSubmissionBotCommand in the host app to invite the submission bot to rooms with context
  • Added "Submit for Review" menu item to Listing cards in the catalog realm

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/bot-core/* New shared package with Matrix bot utilities including client setup, room locking, shutdown/signal handlers, sliding sync, and membership management
packages/submission-bot/* New bot service for handling submissions with room state context, greeting messages, and command handling
packages/ai-bot/main.ts Refactored to use bot-core utilities instead of local implementations
packages/ai-bot/lib/signal-handlers.ts Removed - moved to bot-core
packages/ai-bot/lib/shutdown.ts Removed - moved to bot-core
packages/ai-bot/package.json Added bot-core dependency
packages/host/app/commands/invite-submission-bot.ts New command for inviting submission bot with context stored in room state
packages/host/app/commands/index.ts Registered new InviteSubmissionBotCommand
packages/host/app/services/matrix-service.ts Added submissionBotUserId getter and inviteToRoom method
packages/host/app/resources/room.ts Updated to check for both AI bot and submission bot membership
packages/host/app/components/matrix/room.gts Updated generatingResults to only show for AI bot streaming messages
packages/catalog-realm/catalog-app/listing/listing.gts Added "Submit for Review" menu item using InviteSubmissionBotCommand
packages/runtime-common/constants.ts Added submissionBotUsername constant
packages/base/command.gts Added InviteSubmissionBotInput type definition
packages/matrix/package.json Added register-submission-bot script and updated register-all
.github/workflows/ci-lint.yaml Added linting steps for bot-core and submission-bot
pnpm-lock.yaml Updated dependencies and lockfile entries
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

try {
await new InviteSubmissionBotCommand(commandContext).execute({
submissionTarget: cardId,
submissionType: 'listing',
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The submissionType is set to 'listing' here, but the SubmissionContext interface in submission-bot/main.ts only allows 'pull-request', 'card', or 'other'. This will cause the type to fall through to the default case in the switch statement. Either update the SubmissionContext type to include 'listing', or map 'listing' to 'card' since listings are cards.

Suggested change
submissionType: 'listing',
submissionType: 'card',

Copilot uses AI. Check for mistakes.
legacyDecorators: true,
},
},
plugins: ['ember'],
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'ember' plugin is included in the plugins array but this is not an Ember package - it's a pure Node.js/TypeScript utility package. The ember plugin should be removed since it's not needed for bot-core.

Suggested change
plugins: ['ember'],

Copilot uses AI. Check for mistakes.
legacyDecorators: true,
},
},
plugins: ['ember'],
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'ember' plugin is included in the plugins array but this is not an Ember package - it's a pure Node.js/TypeScript bot service. The ember plugin should be removed since it's not needed for submission-bot.

Suggested change
plugins: ['ember'],

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +14
ecmaFeatures: {
legacyDecorators: true,
},
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The legacyDecorators feature is enabled but this package doesn't use decorators. Since this is a utility package for Matrix bot services without class decorators, this setting can be removed.

Suggested change
ecmaFeatures: {
legacyDecorators: true,
},

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +14

// Room state event type for submission context
const SUBMISSION_CONTEXT_EVENT_TYPE = 'com.cardstack.submission_context';

Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant SUBMISSION_CONTEXT_EVENT_TYPE is duplicated between this file and packages/submission-bot/main.ts. Consider defining this constant in a shared location like @cardstack/runtime-common/matrix-constants to ensure consistency and avoid potential mismatches.

Suggested change
// Room state event type for submission context
const SUBMISSION_CONTEXT_EVENT_TYPE = 'com.cardstack.submission_context';
import { SUBMISSION_CONTEXT_EVENT_TYPE } from '@cardstack/runtime-common/matrix-constants';

Copilot uses AI. Check for mistakes.
'', // empty state key
);

// Open the AI assistant panel with the new room
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions "AI assistant panel" but this is the submission bot command which opens a room for submission review, not the AI assistant. The comment should be updated to reflect the actual purpose, for example: "Open the room for submission review" or "Open the chat panel with the new submission room".

Suggested change
// Open the AI assistant panel with the new room
// Open the chat panel with the new submission review room

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +24
"lint:js:fix": "eslint . --report-unused-disable-directives --fix",
"lint:glint": "glint"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint:glint script is included but bot-core is a pure TypeScript package without Glint templates. This script should be removed as it's not applicable to this package.

Suggested change
"lint:js:fix": "eslint . --report-unused-disable-directives --fix",
"lint:glint": "glint"
"lint:js:fix": "eslint . --report-unused-disable-directives --fix"

Copilot uses AI. Check for mistakes.
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\"",
"lint:js": "eslint . --report-unused-disable-directives --cache",
"lint:js:fix": "eslint . --report-unused-disable-directives --fix",
"lint:glint": "glint",
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint:glint script is included but submission-bot is a pure TypeScript package without Glint templates. This script should be removed as it's not applicable to this package.

Suggested change
"lint:glint": "glint",

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +14
ecmaFeatures: {
legacyDecorators: true,
},
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The legacyDecorators feature is enabled but this package doesn't use decorators. Since this is a bot service without class decorators, this setting can be removed.

Suggested change
ecmaFeatures: {
legacyDecorators: true,
},

Copilot uses AI. Check for mistakes.
} from '@cardstack/bot-core';
import { PgAdapter } from '@cardstack/postgres';
import * as Sentry from '@sentry/node';

Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentry is imported and used for error capture but never initialized. The submission bot should either initialize Sentry (similar to how ai-bot has an instrument.ts file that calls Sentry.init) or remove the Sentry import and error capture calls if not needed.

Suggested change
if (process.env.SENTRY_DSN) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
});
}

Copilot uses AI. Check for mistakes.
export class OpenAiAssistantRoomInput extends CardDef {
@field roomId = contains(StringField);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the invite command shud invite any user. This input can be a subclass if neeeded

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submissionTarget and submissionType are obviously part of submission bot only

// Room state event type for submission context
const SUBMISSION_CONTEXT_EVENT_TYPE = 'com.cardstack.submission_context';

export default class InviteSubmissionBotCommand extends HostBaseCommand<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be invite user to room (roomId)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants