fix(desktop): AgentManager の preparing 状態でも description/goal を編集可能に#233
fix(desktop): AgentManager の preparing 状態でも description/goal を編集可能に#233
Conversation
`preparing` は supervisor が Claude プロセスを spawn する前の 準備状態で、この時点での編集は `prepareArtifacts` が goal.md を 書き直すため安全に反映される。キュー待ちで `preparing` 停滞中の セッションも編集できるようにする。 キュー待ちセッションの番が回ってきて編集中に `running` / `verifying` に遷移した場合は、フロント側の useEffect で編集モードを自動解除し toast で通知する。バックエンドも `queued` / `preparing` / `failed` / `aborted` / `escalated` のみ許可する二重ガードを維持。 Closes #232
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx (1)
1043-1051: 実行開始時の自動キャンセル実装は妥当ですが、doneへの遷移時にも編集状態が残る点だけ留意してください。
running/verifyingへの遷移検知は要件通りで実装は適切です。一方、編集中(例:preparing状態で編集を開いたまま放置)にセッションが直接doneなどに遷移するパスではcanEditFieldsがfalseになっても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
📒 Files selected for processing (2)
apps/desktop/src/main/todo-agent/trpc-router.tsapps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsx
概要
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.tsupdateFieldsの許可ステータスにpreparingを追加。apps/desktop/src/renderer/features/todo-agent/TodoManager/TodoManager.tsxcanEditFieldsにsession.status === \"preparing\"を追加。running/verifyingに遷移した場合、useEffectで編集モードを自動キャンセルし、toast.warning で通知する。これにより、ユーザーが保存ボタンを押してから backend のPRECONDITION_FAILEDを踏む体験を避ける。編集中に running に遷移するケースの扱い
キュー待ちの別セッションが終わって自分の番が回ってくるタイミングで編集していると、
preparing → runningへ遷移し得る。その際の挙動:statusを監視し、running/verifyingに遷移したら編集を自動キャンセル + 下書きを破棄 + toast 警告。updateFieldsがrunning/verifyingを拒否するガードを維持しているため安全。preparing中の保存はprepareArtifactsによる goal.md 書き直しを通じて Claude 起動前に反映される。動作確認
bun run lint✅bun run typecheck✅Test plan
preparing状態のセッション詳細を開き、「やって欲しいこと」「ゴール」の「編集」ボタンが表示されることpreparing中に編集 → 保存で goal.md が書き換わり、次の iteration に反映されることpreparingセッションで編集中にrunningに遷移すると、編集モードが自動解除され toast 警告が出ることrunning/verifying/done/pausedのセッションは編集ボタンが出ないこと(回帰なし)Summary by CodeRabbit
改善