Repository navigation
fix(mcp): open plans created with items at Review in Studio - #3501
Conversation
create_plan stored every draft as 'draft', which Studio shows at Define with no plan, so a plan created through MCP with items could not be read before publishing. A draft created or updated with plan items is now stored as 'review'; prompt-only drafts stay 'draft'. A migration moves existing drafts that already hold plan items to 'review'. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
/review |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationReady to merge. The PR directly fixes Studio visibility for populated MCP plans while preserving prompt-only drafts and other lifecycle states. ✅ Consistent status transitions — ✅ Targeted migration — The migration selects drafts with valid, non-empty JSON arrays. Tests cover malformed data, excluded states, missing tables, and repeated execution. ✅ Protocol coverage — Integration tests verify the new create/read behavior and prompt-only draft transition through both supported SDK protocol eras. This assessment uses the supplied code and context; no commands were run. Current-head checks report 21 passed and no failures or pending checks. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Cover preserved update statusesConsider adding cases that supply plan items to ScoreThe implementation meets the stated objective with focused changes, relevant regression coverage, and passing current-head checks. No merge-blocking defects were identified in the supplied code. Score: 9/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
/fix all |
|
✅ Applied the requested follow-up changes in commit 2038663
Summary of ChangesI added the S1 coverage. Change ( One thing that tripped the first version: changing Verification:
Sibling check: the only path in this PR that promotes a status is the There's nothing visible to the user here, so I didn't make previews. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…on test showing that giving a plan to a `review`, `approved` or `failed` plan leaves its status as it was. I added the S1 coverage. `update_plan` now has an integration test showing that giving a plan to a `review`, `approved` or `failed` plan leaves its status as it was. **Change** (`packages/api/test/mcpIntegration.test.ts`, after the existing draft→review promotion): the same plan is set to each of the three statuses in turn. Each time, `update_plan` sends it a plan with a new item title. The test checks that the update went through (the revision goes up by one), the status is unchanged, and the new plan was saved. It runs under both the modern and legacy SDK clients. **One thing that tripped the first version:** changing `status` directly in the database also bumps `mcp_revision`. A fixed revision number therefore got `STALE_REVISION`, so the test now reads the current revision from the row before each update. **Verification:** - `mcpIntegration.test.ts` passes (3/3). - As a check that the test can fail, I temporarily replaced the conditional SQL at `packages/api/mcp/toolsPlanning.ts:156` with an unconditional `status: 'review'`. The new test failed, and I restored the file afterwards. - `eslint --max-warnings 0` on the test file and `tsc --noEmit` for `packages/api` both pass. **Sibling check:** the only path in this PR that promotes a status is the `update_plan` CASE expression. `create_plan` only ever inserts new rows, so there's no existing status to preserve. The migration's limits on which statuses it moves are already tested in `test/reviewDraftsWithPlanMigration.test.ts`. I found no other place with the same problem and changed no production code. There's nothing visible to the user here, so I didn't make previews. PR: #3501 Comment by: @integry (ID: 6832476201) Model: Claude Opus 5.5
Problem
A plan created through the MCP
create_plantool with plan items was stored with statusdraft. Studio mapsdraftto the Define stage and shows only the prompt, so the plan's issues could not be read in the UI until the plan was published.Change
create_planstoresreviewwhen it is given plan items; a prompt-only draft staysdraft. The returnedstatusmatches.update_planmoves adrafttoreviewwhen it supplies a non-empty plan. Other statuses are not changed.draftrows whoseplan_jsonis a non-empty JSON array toreview. It has no down step: the moved rows are not recorded, andreviewis the right status for them on any version.docs/mcp.mdand the changelog describe the behaviour.Tests
packages/api/test/mcpIntegration.test.ts: a plan created with items isreviewon create and on read; a prompt-only draft staysdraftafter a rename and becomesreviewwhenupdate_plangives it a plan.test/reviewDraftsWithPlanMigration.test.ts: only drafts with plan items move; null, empty, non-array and invalidplan_jsonand other statuses are untouched; the migration is a no-op without the table and when run twice.Run locally: typecheck, lint for
packages/apiandpackages/coreat zero warnings, andmcpIntegration,mcpWorkflows,mcpPublishPlan,mcpToolInputBudget,mcpDocs,mcpObservableSurfaceplus the migration test, all passing.🤖 Generated with Claude Code