Skip to content

fix(desktop): AgentManager の preparing 状態でも description/goal を編集可能に#233

Merged
MocA-Love merged 1 commit intomainfrom
fix/todo-preparing-editable
Apr 16, 2026
Merged

fix(desktop): AgentManager の preparing 状態でも description/goal を編集可能に#233
MocA-Love merged 1 commit intomainfrom
fix/todo-preparing-editable

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

@MocA-Love MocA-Love commented Apr 16, 2026

概要

AgentManager(TODO Agent Manager)でタスクの「やって欲しいこと」「ゴール」を編集できる状態を拡張し、preparing ステータスでも編集可能にした。併せて、編集中に他セッションの終了を受けて running に遷移した場合のレースに対処した。

Closes #232

背景

  • これまで preparing ステータス(start 後〜Claude プロセス起動前)ではフロント側・バック側ともに編集が不可だった。
  • 実際には preparing はキュー待ちの間も留まり得るステータスで、Claude はまだ goal.md を読んでいないため、編集を許容しても安全。
  • preparing 中の updateFields は既存の prepareArtifacts によって goal.md を書き直すため、その後に Claude が読み込む段階で最新内容が反映される。

変更点

apps/desktop/src/main/todo-agent/trpc-router.ts

  • updateFields の許可ステータスに preparing を追加。
  • エラーメッセージとドキュメントコメントを実態に合わせて更新。

apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx

  • canEditFieldssession.status === \"preparing\" を追加。
  • 編集中にセッションが running / verifying に遷移した場合、useEffect で編集モードを自動キャンセルし、toast.warning で通知する。これにより、ユーザーが保存ボタンを押してから backend の PRECONDITION_FAILED を踏む体験を避ける。

編集中に running に遷移するケースの扱い

キュー待ちの別セッションが終わって自分の番が回ってくるタイミングで編集していると、preparing → running へ遷移し得る。その際の挙動:

  1. フロント側で status を監視し、running / verifying に遷移したら編集を自動キャンセル + 下書きを破棄 + toast 警告。
  2. 万一 1 をすり抜けて保存ミューテーションが走っても、バックエンドの updateFieldsrunning / verifying を拒否するガードを維持しているため安全。
  3. preparing 中の保存は prepareArtifacts による goal.md 書き直しを通じて Claude 起動前に反映される。

動作確認

  • bun run lint
  • bun run typecheck

Test plan

  • AgentManager で preparing 状態のセッション詳細を開き、「やって欲しいこと」「ゴール」の「編集」ボタンが表示されること
  • preparing 中に編集 → 保存で goal.md が書き換わり、次の iteration に反映されること
  • キュー待ちの preparing セッションで編集中に running に遷移すると、編集モードが自動解除され toast 警告が出ること
  • running / verifying / done / paused のセッションは編集ボタンが出ないこと(回帰なし)

Summary by CodeRabbit

改善

  • セッション準備中でもフィールドの編集が可能になり、より長い時間編集できるようになりました
  • セッション実行中に編集中の操作が自動的にキャンセルされ、その旨が警告通知として表示されるようになりました

`preparing` は supervisor が Claude プロセスを spawn する前の
準備状態で、この時点での編集は `prepareArtifacts` が goal.md を
書き直すため安全に反映される。キュー待ちで `preparing` 停滞中の
セッションも編集できるようにする。

キュー待ちセッションの番が回ってきて編集中に `running` / `verifying`
に遷移した場合は、フロント側の useEffect で編集モードを自動解除し
toast で通知する。バックエンドも `queued` / `preparing` / `failed` /
`aborted` / `escalated` のみ許可する二重ガードを維持。

Closes #232
@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

📝 Walkthrough

Walkthrough

preparing ステータス中のタスク詳細編集を許可するよう変更。フロントエンドの編集可能判定ロジックを更新し、バックエンドのサーバー側チェックを拡張。編集中に running/verifying に遷移した際は自動でキャンセルする監視機構を追加。

Changes

Cohort / File(s) Summary
バックエンド トランザクション検証
apps/desktop/src/main/todo-agent/trpc-router.ts
updateFields の許可ステータスに preparing を追加。エラーメッセージを「実行中またはキュー済みでない…」から「実行中のセッションは編集できません…」に変更。関連コメントを preparing での編集サポートを反映するよう更新。
フロントエンド 編集状態管理
apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx
canEditFields の条件を canStart && !isRunning から canStart || session.status === "preparing" に変更。編集中に running/verifying へ遷移した場合、自動的に編集モードをキャンセルし警告 toast を表示する useEffect を追加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨
preparing の間も編集できるように、
ウサギが駆け抜ける新しい道!
走り始めたら、さっと手放す、
優しき通知で、ユーザーもご満悦。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは「preparing 状態でも description/goal を編集可能に」という主な変更を明確に述べており、変更内容と一致している。
Description check ✅ Passed PR 説明は必要なセクション(概要、背景、変更点、動作確認、テストプラン)をすべて含み、充実している。
Linked Issues check ✅ Passed PR はリンク済み issue #232 の全要件を実装している:preparing 状態での編集を許可、running/verifying 遷移時の自動キャンセル、バックエンド安全性を確保している。
Out of Scope Changes check ✅ Passed すべての変更は #232 のスコープ内であり、タスク編集機能の拡張とレース条件対策に限定されている。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/todo-preparing-editable

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
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx (1)

1043-1051: 実行開始時の自動キャンセル実装は妥当ですが、done への遷移時にも編集状態が残る点だけ留意してください。

running / verifying への遷移検知は要件通りで実装は適切です。一方、編集中(例: preparing 状態で編集を開いたまま放置)にセッションが直接 done などに遷移するパスでは canEditFieldsfalse になっても editingField がリセットされないため、編集 UI が表示され続け「保存」を押すと backend で PRECONDITION_FAILED を踏みます(toast.error で「更新に失敗しました」と出るのみ)。

仕様通り running / verifying のみを対象にするのが本 PR の方針なので必須ではありませんが、ガードを !canEditFields ベースに広げておくと UX が一段安定します。

♻️ 任意のリファクタ案
 useEffect(() => {
   if (!editingField) return;
-  if (session.status !== "running" && session.status !== "verifying") return;
+  if (canEditFields) return;
   setEditingField(null);
   setEditDraft("");
   toast.warning(
-    "タスクの実行が開始されたため編集を中止しました。中断してから再度編集してください。",
+    "セッションの状態が変わったため編集を中止しました。",
   );
-}, [editingField, session.status]);
+}, [editingField, canEditFields]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx`
around lines 1043 - 1051, The effect currently clears editingField only when
session.status becomes "running" or "verifying"; expand the guard to use the
canEditFields boolean instead so any transition that disables editing (e.g., to
done) also resets UI state. In the useEffect that references editingField and
session.status, replace the session.status checks with a check for
!canEditFields and, when true, call setEditingField(null) and setEditDraft("")
and show the existing toast warning; keep the early return when !editingField
and retain the dependency array to include canEditFields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx`:
- Around line 1043-1051: The effect currently clears editingField only when
session.status becomes "running" or "verifying"; expand the guard to use the
canEditFields boolean instead so any transition that disables editing (e.g., to
done) also resets UI state. In the useEffect that references editingField and
session.status, replace the session.status checks with a check for
!canEditFields and, when true, call setEditingField(null) and setEditDraft("")
and show the existing toast warning; keep the early return when !editingField
and retain the dependency array to include canEditFields.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4930ef4b-255c-43d3-86ad-b151c3476de1

📥 Commits

Reviewing files that changed from the base of the PR and between 8c082df and 10167b8.

📒 Files selected for processing (2)
  • apps/desktop/src/main/todo-agent/trpc-router.ts
  • apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx

@MocA-Love MocA-Love merged commit 742a986 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.

AgentManager: preparing ステータスでもタスク詳細を編集できるようにする

1 participant