fix(rkd): run the bot only in the session started as a channel #2
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/channel-only-in-channel-sessions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Once installed, the plugin's MCP server starts in every Claude Code session, and each one took the single-session lock and connected as the bot. Opening any ordinary session would kill the real channel session's server, connect as the bot where channel messages never reach the model (so triggers vanished), and rotate the refresh token underneath the channel session. Found while setting up the local walkthrough: an unrelated session on this Mac was already holding
bot.pid. The Telegram channel plugin behaves the same way, which likely explains its disconnect earlier today.Part of nanoya-biz/rkd#917.
Type of change
Test plan
Automated:
pnpm test: 95 passed. Newchannel-mode.test.tscovers the flag forms (--channels,=, comma lists,@inline,server:plugin:rkd:, the versioned binary path), non-matches (other plugins,rkd-extra,--plugin-diralone, a shell-cscript that mentions the flag, a non-claude process), the ancestor walk through a wrapper, maxDepth and theRKD_CHANNELoverridepnpm typecheck,pnpm check:dist,claude plugin validate --strict rkd, handshake smokerkd-server: 8/8 (it now setsRKD_CHANNEL=1, since its parent is vitest)Manual, with a configured bot (
claude_code_boton a local server):statussaysconnected: no/idle: this Claude Code session was not started with the rkd channel…, and nobot.pidis writtenclaude -p --plugin-dir rkd --dangerously-load-development-channels plugin:rkd@inline:statussaysconnected: yes, as claude_code_bot-cscript contained the flag text. Now only theclaudebinary's own arguments countReview checklist
console.log/dbg!/ commented-out code left behindNotes for the reviewer
Claude Code sends the same
initialize(same capabilities and env) whether or not the server was loaded as a channel. I checked both with a probe plugin under 2.1.278, so the launching command line is the only signal. It walks up to 4 ancestors withps, which is fine on macOS and Linux. The Claude desktop app, or a future settings-based way to enable channels, wouldn't show the flag:RKD_CHANNEL=1covers that. Version bumped to 0.1.1 so installed copies pick it up.https://claude.ai/code/session_01GdkP2Y3vcxcGz5XCFFWW16