fix(desktop): TODOのStopでclaudeが止まらない問題を修正#195
Conversation
supervisor.abort() は currentChild に SIGINT を送るだけで、 claude -p が spawn する子孫プロセス(MCPサーバ等)には信号が 届いていなかった。結果 Stop を押しても Anthropic API との 通信を続けるケースがあった。 spawn 時に detached: true を指定して子をセッションリーダに し、-pid で process group 丸ごと SIGINT→SIGKILL する killProcessTree ヘルパー経由で終了させるように変更。 Windows は taskkill /T /F にフォールバック。 Closes #191
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 40 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e543ecb2bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (child.pid && !child.killed) { | ||
| killProcessTree(child.pid, "SIGKILL"); |
There was a problem hiding this comment.
Guard delayed SIGKILL against exited child PID reuse
killProcessTree now sends signals via process.kill(...) instead of child.kill(...), so ChildProcess.killed never flips to true. As a result, this timeout guard always passes and sends SIGKILL 1.5s later even if the process already exited after SIGINT; if the PID has been reused in that window (rare but possible on busy systems), the follow-up kill can target an unrelated process group. Please gate on exitCode/signalCode (or clear the timer on close) rather than child.killed.
Useful? React with 👍 / 👎.
| ): void { | ||
| if (process.platform === "win32") { | ||
| try { | ||
| spawnSync("taskkill", ["/pid", String(pid), "/T", "/F"]); |
There was a problem hiding this comment.
Avoid blocking main process with synchronous taskkill
The Windows implementation uses spawnSync("taskkill", ...), which blocks Electron’s main thread until the OS command finishes. In Stop flows, terminating a large or slow process tree can take noticeable time, and this synchronous call can freeze IPC/UI responsiveness during that period. Using an async process API would preserve behavior without stalling the main event loop.
Useful? React with 👍 / 👎.
- killed フラグではなく exitCode/signalCode を見て SIGKILL の 二段目を判断。ついでに 'close' で timer を clear して PID 再利用の誤射を防ぐ - Windows の taskkill を spawnSync から非同期 spawn に変更 (stdio: ignore, detached, unref) して Electron main を ブロックしないようにした Refs: Codex review on PR #195
概要
Issue #191 の対応。AgentManager で Stop を押しても Claude がしばらく動き続けたり、完全に止まらなかったりする症状があった。
根本原因
`supervisor.abort()` は `currentChild.kill("SIGINT")` を呼ぶだけで、`claude -p` が spawn した子孫プロセス(Node-side の agent loop、MCP サーバ、tool helpers など)には一切シグナルが届いていなかった。`claude` の直接の wrapper が終了しても、実際に Anthropic API と話している孫プロセスが残り続けるので UI 的には止まっていない状態に見える。
修正
Test plan
Closes #191