feat(remote-control): add /agent command for all channels#1696
Conversation
📝 WalkthroughWalkthroughThis PR implements a complete ChangesRemote /agent command feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/presenter/remoteControlPresenter/services/discordCommandRouter.ts (1)
314-351: 🏗️ Heavy liftConsolidate duplicated
/agenthandler/formatter across routers.
handleAgentCommand+formatAgentOvervieware now copy-pasted across four platform routers. Extracting a shared helper (or base utility) would reduce drift risk for future behavior/text changes.Also applies to: 472-484
🤖 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 `@src/main/presenter/remoteControlPresenter/services/discordCommandRouter.ts` around lines 314 - 351, The handleAgentCommand logic and formatAgentOverview text are duplicated across multiple platform routers; extract a shared helper module (e.g., remoteControlAgentHelper) that exposes a single function (handleAgentCommand or handleAgentCommandShared) and a formatter (formatAgentOverview) and have each router import and call those instead of duplicate code; update the current handleAgentCommand in discordCommandRouter to delegate to the new shared function (passing deps, message, endpointKey, and session retrieval as needed) and remove the copied formatter implementations from the other routers so all four routers call the common helpers.
🤖 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
`@src/main/presenter/remoteControlPresenter/services/remoteConversationRunner.ts`:
- Around line 633-635: The code sets the channel default agent via
bindingStore.setChannelDefaultAgentId(endpointKey, matched.id) before creating a
session with createNewSession(endpointKey), so if session creation fails the
default remains changed; change the flow to either (A) delay calling
bindingStore.setChannelDefaultAgentId until after createNewSession(endpointKey)
succeeds, or (B) keep the current order but catch errors from createNewSession
and rollback by calling bindingStore.setChannelDefaultAgentId(endpointKey,
previousAgentId) (ensure you read and store the previous agent id beforehand).
Use the existing symbols bindingStore.setChannelDefaultAgentId,
createNewSession, endpointKey, and matched.id to implement the chosen fix.
---
Nitpick comments:
In `@src/main/presenter/remoteControlPresenter/services/discordCommandRouter.ts`:
- Around line 314-351: The handleAgentCommand logic and formatAgentOverview text
are duplicated across multiple platform routers; extract a shared helper module
(e.g., remoteControlAgentHelper) that exposes a single function
(handleAgentCommand or handleAgentCommandShared) and a formatter
(formatAgentOverview) and have each router import and call those instead of
duplicate code; update the current handleAgentCommand in discordCommandRouter to
delegate to the new shared function (passing deps, message, endpointKey, and
session retrieval as needed) and remove the copied formatter implementations
from the other routers so all four routers call the common helpers.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: b3a19ab0-f1b8-4a80-a6a7-3110784c9f63
📒 Files selected for processing (15)
docs/features/remote-agent-switch/plan.mddocs/features/remote-agent-switch/spec.mddocs/features/remote-agent-switch/tasks.mdsrc/main/presenter/remoteControlPresenter/services/discordCommandRouter.tssrc/main/presenter/remoteControlPresenter/services/feishuCommandRouter.tssrc/main/presenter/remoteControlPresenter/services/qqbotCommandRouter.tssrc/main/presenter/remoteControlPresenter/services/remoteBindingStore.tssrc/main/presenter/remoteControlPresenter/services/remoteCommandRouter.tssrc/main/presenter/remoteControlPresenter/services/remoteConversationRunner.tssrc/main/presenter/remoteControlPresenter/services/weixinIlinkCommandRouter.tssrc/main/presenter/remoteControlPresenter/types.tstest/main/presenter/remoteControlPresenter/feishuCommandRouter.test.tstest/main/presenter/remoteControlPresenter/remoteBindingStore.test.tstest/main/presenter/remoteControlPresenter/remoteCommandRouter.test.tstest/main/presenter/remoteControlPresenter/remoteConversationRunner.test.ts
close #1692
Summary by CodeRabbit
Release Notes
New Features
/agentcommand to list available agents and switch the active agent across Discord, Feishu, QQBot, Weixin iLink, and Telegram platforms.Documentation
/agentremote command, including specifications and implementation details.Tests