feat(discord): add /status command for thread inspection#28
feat(discord): add /status command for thread inspection#28jettcc wants to merge 2 commits intoDoctor-wu:mainfrom
Conversation
Shows backend, model, effort, working directory, session state, and last task summary for the current thread. Useful when switching between multiple threads or checking whether a session is still resumable.
📝 WalkthroughWalkthroughA new Discord "status" slash command and handler were added, registered in the bot index, and a test mock for the status module was included to simulate command behavior in tests. Changes
Sequence DiagramsequenceDiagram
actor User
participant Discord as Discord Interaction
participant Handler as handleStatusCommand
participant Maps as In-Memory Maps
participant Formatter as Format Helpers
participant Bot as Bot Reply
User->>Discord: /status (in thread)
Discord->>Handler: ChatInputCommandInteraction
Handler->>Handler: Validate thread context
alt Not in thread
Handler->>Bot: Reply with error (ephemeral)
Bot->>User: Error message
else In thread
Handler->>Maps: Query session/backend/model/working-dir/status
Maps-->>Handler: Thread-specific data
Handler->>Formatter: formatSessionStatus()
Formatter-->>Handler: Status with emoji
Handler->>Formatter: formatLastTask()
Formatter-->>Handler: Task summary or null
Handler->>Handler: Aggregate report
Handler->>Bot: Reply with formatted report (ephemeral)
Bot->>User: Status report
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Doctor-wu
left a comment
There was a problem hiding this comment.
Code Review
PR #28: feat(discord): add /status command for thread inspection
Author: jettcc | Branch: feat/status → main | +95 -0 | 3 files
新增 /status slash command,在 thread 内显示当前 backend、model、effort、cwd、session 状态和上次任务摘要。ephemeral reply,只有调用者可见。
⚠️ WARNING
1. conversationEffort 导入需确认 core 已导出
status.ts 从 @agent-im-relay/core 导入了 conversationEffort,需要确认该 Map 已在 core 包中导出,否则运行时 import 报错。
2. threadContinuationSnapshots 的字段类型保障
snapshot.taskSummary 和 snapshot.whyStopped 没有在这个 PR 里定义类型,假设 core 包已有。建议确认字段名和类型一致。
💬 NIT
3. 缺少 /status 命令自身的单元测试
测试文件只加了 mock,没有测试 handleStatusCommand 本身。建议至少覆盖:
- 非 thread 中调用 → ephemeral 提示
- thread 中调用 → 正确拼装状态信息
- 有 lastTask vs 无 lastTask
4. stopReasonEmoji 可以提取为模块级常量
每次调用 formatLastTask 都重新创建对象,提到模块顶层更干净。
5. backend 默认值硬编码 claude (default) 可能不准确
const backend = conversationBackend.get(id) ?? 'claude (default)';如果系统默认 backend 不是 claude,这里会误导用户。建议改为 'not set' 或从配置读取实际默认值。
✅ 亮点
- 功能实用,多 thread 工作时快速了解当前状态
- ephemeral reply 不污染 thread 对话
- session 状态用 emoji 区分,一目了然
- taskSummary 截断到 120 字符,防止消息过长
✅ Review 通过,建议补上单元测试和修正 backend 默认值显示。不阻塞合并。
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/discord/src/__tests__/index.test.ts (1)
152-155: Consider adding a direct/statusrouting assertion test.Right now this mock is added, but there’s no explicit test that a
statuschat-input interaction invokeshandleStatusCommand. Adding one would prevent silent handler-map regressions.Suggested test addition
import { handleDiscordMessageCreate } from '../index'; import { handleSkillAutocomplete } from '../commands/skill'; +import { handleStatusCommand } from '../commands/status'; import { config as discordConfig } from '../config'; +it('routes /status chat-input interactions to the status handler', async () => { + const interaction = { + isChatInputCommand: () => true, + isAutocomplete: () => false, + commandName: 'status', + } as any; + + await interactionCreateHandler?.(interaction); + + expect(handleStatusCommand).toHaveBeenCalledWith(interaction); +});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/discord/src/__tests__/index.test.ts` around lines 152 - 155, Add a unit test that verifies a chat-input interaction with commandName "status" routes to the mocked handler: create a fake interaction object representing a chat-input `/status` (matching whatever router entry point you already call in index.test.ts), invoke the message/interaction dispatcher used in the tests (the same function that currently processes other interactions in the file), and assert that the mocked handleStatusCommand was called; reference the mocked symbols statusCommand and handleStatusCommand so the test explicitly protects against handler-map regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/discord/src/__tests__/index.test.ts`:
- Around line 152-155: Add a unit test that verifies a chat-input interaction
with commandName "status" routes to the mocked handler: create a fake
interaction object representing a chat-input `/status` (matching whatever router
entry point you already call in index.test.ts), invoke the message/interaction
dispatcher used in the tests (the same function that currently processes other
interactions in the file), and assert that the mocked handleStatusCommand was
called; reference the mocked symbols statusCommand and handleStatusCommand so
the test explicitly protects against handler-map regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 923dc5f6-62a6-45db-8f63-efd87cbf5c7e
📒 Files selected for processing (2)
packages/discord/src/__tests__/index.test.tspackages/discord/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/discord/src/index.ts
Summary
/statusslash command to the Discord adapterMotivation
When working across multiple threads, it's hard to know:
/statussurfaces all of this in a single ephemeral reply.Output
Thread Status
Session states:
Summary by CodeRabbit
New Features
Tests