refactor: extract ama fundamentals into a framework - #224
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChangesThe PR extracts reusable Discord bot infrastructure into Bot Core Framework
Formatting Updates
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AmaBotBin
participant BotCore
participant AmaBotHandlers
participant Discord
AmaBotBin->>BotCore: create REST, gateway, and client
AmaBotBin->>AmaBotHandlers: register commands and components
AmaBotBin->>Discord: connect gateway
Discord->>BotCore: deliver interaction
BotCore->>AmaBotHandlers: dispatch registered handler
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
packages/private/bot-core/src/lib/components.ts (1)
30-41: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the directory-registration path.
The supplied tests exercise
registerComponentHandler()directly, notregisterComponentHandlers(). A broken glob, dynamic import, or invalid-default-export check would ship undetected. Add a fixture-based test covering valid and invalid handler modules.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/private/bot-core/src/lib/components.ts` around lines 30 - 41, Extend test coverage for registerComponentHandlers by creating fixture modules in a temporary components directory, including valid and invalid default exports. Exercise directory discovery, dynamic importing, validation, and registration, and assert valid handlers are registered while invalid modules are skipped.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/private/bot-core/src/lib/__tests__/commands.test.ts`:
- Around line 94-99: Update the fallback reply assertion in the relevant command
test to verify that the response includes the ephemeral MessageFlags value,
while preserving the existing content assertion and logger warning check.
In `@packages/private/bot-core/src/lib/__tests__/deploy.test.ts`:
- Around line 67-71: Update the fakeReply assertion in the authorization-denial
test to also verify the response is marked ephemeral, while retaining the
existing checks for interaction-1, tok, and the “not authorized” content.
In `@packages/private/bot-core/src/lib/client.ts`:
- Around line 97-99: Update the interval callback around GuildList.set to handle
rejected synchronization promises instead of discarding them: catch failures
from GuildList.set and log them using the client’s existing logging mechanism,
while preserving the existing periodic update behavior.
In `@packages/private/bot-core/src/lib/gateway.ts`:
- Line 26: Update the WebSocketShardEvents.Error callback in the gateway event
handler to accept parameters in WebSocketManager’s emitted order, `(error,
shardId)`, and keep the logger fields mapped to the corresponding values.
---
Nitpick comments:
In `@packages/private/bot-core/src/lib/components.ts`:
- Around line 30-41: Extend test coverage for registerComponentHandlers by
creating fixture modules in a temporary components directory, including valid
and invalid default exports. Exercise directory discovery, dynamic importing,
validation, and registration, and assert valid handlers are registered while
invalid modules are skipped.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 09f9ce22-d696-4b06-a861-8642ad42a88a
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (44)
apps/website/src/api/routes/modmail.tsapps/website/src/app/dashboard/[id]/modmail/blocks/_components/BlockCard.tsxapps/website/src/app/dashboard/[id]/modmail/categories/_components/AddCategoryCard.tsxapps/website/src/app/dashboard/[id]/modmail/categories/_components/CategoryCard.tsxapps/website/src/app/dashboard/[id]/modmail/panels/[panelId]/_components/EditPanelForm.tsxapps/website/src/app/dashboard/[id]/modmail/panels/new/_components/CreatePanelForm.tsxapps/website/src/app/dashboard/[id]/modmail/panels/new/_components/PanelPreview.tsxapps/website/src/app/dashboard/[id]/modmail/snippets/_components/AddSnippetCard.tsxapps/website/src/components/common/EmojiInput.tsxapps/website/src/components/common/ForumTagSelect.tsxdocs/roadmap/01-architecture.mdeslint.config.jspackages/private/bot-core/package.jsonpackages/private/bot-core/src/index.tspackages/private/bot-core/src/lib/__tests__/collector.test.tspackages/private/bot-core/src/lib/__tests__/commands.test.tspackages/private/bot-core/src/lib/__tests__/components.test.tspackages/private/bot-core/src/lib/__tests__/deploy.test.tspackages/private/bot-core/src/lib/__tests__/testEnv.tspackages/private/bot-core/src/lib/client.tspackages/private/bot-core/src/lib/collector.tspackages/private/bot-core/src/lib/commands.tspackages/private/bot-core/src/lib/components.tspackages/private/bot-core/src/lib/deploy.tspackages/private/bot-core/src/lib/gateway.tspackages/private/bot-core/src/lib/rest.tspackages/private/bot-core/tsconfig.eslint.jsonpackages/private/bot-core/tsconfig.jsonpackages/private/bot-core/vitest.config.tsservices/ama-bot/package.jsonservices/ama-bot/src/bin.tsservices/ama-bot/src/commands/ama.tsservices/ama-bot/src/components/amaEndSelect.tsservices/ama-bot/src/components/amaRepostSelect.tsservices/ama-bot/src/components/guestApprove.tsservices/ama-bot/src/components/guestSkip.tsservices/ama-bot/src/components/modApprove.tsservices/ama-bot/src/components/modDeny.tsservices/ama-bot/src/components/modFlag.tsservices/ama-bot/src/components/submitQuestion.tsservices/ama-bot/src/index.tsservices/ama-bot/src/lib/gateway.tsservices/ama-bot/src/lib/rest.tsservices/api/src/index.ts
💤 Files with no reviewable changes (2)
- services/ama-bot/src/lib/gateway.ts
- services/ama-bot/src/lib/rest.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/private/bot-core/src/lib/__tests__/components.test.ts`:
- Around line 96-102: Reset the imported fixture’s calls array before invoking
handleComponentInteraction by setting calls.length to zero after importing
validComponent.js. Keep the existing assertion that the handler records exactly
one call with the expected interaction, logger, and state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 14dead25-96a0-43dc-ab01-6d8f0c1cdb27
📒 Files selected for processing (8)
packages/private/bot-core/src/lib/__tests__/commands.test.tspackages/private/bot-core/src/lib/__tests__/components.test.tspackages/private/bot-core/src/lib/__tests__/deploy.test.tspackages/private/bot-core/src/lib/__tests__/fixtures/invalidComponent.jspackages/private/bot-core/src/lib/__tests__/fixtures/validComponent.d.tspackages/private/bot-core/src/lib/__tests__/fixtures/validComponent.jspackages/private/bot-core/src/lib/client.tspackages/private/bot-core/src/lib/gateway.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- packages/private/bot-core/src/lib/gateway.ts
- packages/private/bot-core/src/lib/tests/deploy.test.ts
- packages/private/bot-core/src/lib/tests/commands.test.ts
- packages/private/bot-core/src/lib/client.ts
Closes #217