Skip to content

fix(desktop): TODO の maxConcurrentTasks を尊重しキュー消化する (#220)#224

Merged
MocA-Love merged 1 commit intomainfrom
fix/todo-max-concurrent-tasks
Apr 16, 2026
Merged

fix(desktop): TODO の maxConcurrentTasks を尊重しキュー消化する (#220)#224
MocA-Love merged 1 commit intomainfrom
fix/todo-max-concurrent-tasks

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

Summary

Issue #220 の修正。TODO 機能の最大同時実行数設定が実質未実装で、常に 1 セッションずつ順次実行されていた。また設定変更時に supervisor に通知が届かないため、1→2 への引き上げ後も pending タスクが動き出さなかった。

原因

  • TodoSupervisor.activeActiveRun | undefined で、シングルスロット実装だった
  • start()if (this.active) { queue.push(); return; } とするだけで、maxConcurrentTasks をどこからも参照していなかった
  • updateTodoSettings() は JSON を書き換えるだけで、supervisor へ通知する経路がなかった

修正内容

  • apps/desktop/src/main/todo-agent/supervisor.ts
    • activeMap<string, ActiveRun> に変更(keyed storage)
    • start() を「キューへ追加して drain() を呼ぶ」形に変更
    • drain() メソッドを追加。毎回 getTodoSettings().maxConcurrentTasks を読み直し、容量が空いていて終端状態でないセッションを順次起動する
    • runSession を fire-and-forget にし、finally でスロット解放 + drain() 再実行
    • handleSettingsChanged() を追加。設定変更直後に drain して詰まっていたタスクを即起動する
    • abort() を Map ベースに書き換え、対象セッションだけ停止
  • apps/desktop/src/main/todo-agent/trpc-router.ts
    • todoAgent.settings.update ミューテーション内で updateTodoSettings 後に getTodoSupervisor().handleSettingsChanged() を呼ぶ

動作

  • maxConcurrentTasks=1 の状態で 2 タスク作成 → 従来通り 1 つずつ順次
  • maxConcurrentTasks=2 に上げた瞬間 → 残りの pending タスクが即 running に
  • 実行中に減らした場合 → 走っているセッションはそのまま継続、以後の新規 start は容量空きまで待機
  • start() 重複呼び出しは active.has() || queue.includes() でガード

Test plan

  • bun run lint 通過
  • bun run typecheck 通過
  • 手動: maxConcurrentTasks=1 で 2 タスク作成 → 1 つだけ running、もう 1 つは queued
  • 手動: 上記の状態で maxConcurrentTasks を 2 に変更 → 2 つ目も running に切り替わる
  • 手動: maxConcurrentTasks=3 で 3 タスク同時起動 → 3 つとも running

Closes #220

supervisor がシングルスロット (`active: ActiveRun | undefined`) だったため、
設定の `maxConcurrentTasks` が完全に無視され、常に 1 セッションしか走らず
残りは永久キュー待ちになっていた。加えて設定変更時に supervisor へ通知が
飛ばないので、ユーザーが 1→2 に上げても pending のまま動き出さなかった。

- `active` を `Map<string, ActiveRun>` に変更し、複数同時実行を可能に
- `start()` をキュー登録 + `drain()` 呼び出しに変更
- 各 runSession の `finally` で slot を解放し `drain()` を再実行
- `handleSettingsChanged()` を追加し、settings.update のミューテーションから呼ぶ
- abort() も Map ベースに書き換え、対象セッションだけを停止
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

Warning

Rate limit exceeded

@MocA-Love has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 38 seconds before requesting another review.

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 35 minutes and 38 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6b904159-2c92-4a37-bce8-6ea935fdcdce

📥 Commits

Reviewing files that changed from the base of the PR and between 8c082df and 1ece3dd.

📒 Files selected for processing (2)
  • apps/desktop/src/main/todo-agent/supervisor.ts
  • apps/desktop/src/main/todo-agent/trpc-router.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/todo-max-concurrent-tasks

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MocA-Love MocA-Love self-assigned this Apr 16, 2026
@MocA-Love MocA-Love merged commit f338bec into main Apr 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] TODO機能の設定に関して

1 participant