Skip to content

fix(mcp): open plans created with items at Review in Studio - #3501

Merged
integry merged 2 commits into
mainfrom
fix/mcp-plan-drafts-open-in-review
Nov 12, 2026
Merged

integry merged 2 commits into
mainfrom
fix/mcp-plan-drafts-open-in-review

Conversation

@integry

@integry integry commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Problem

A plan created through the MCP create_plan tool with plan items was stored with status draft. Studio maps draft to 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_plan stores review when it is given plan items; a prompt-only draft stays draft. The returned status matches.
  • update_plan moves a draft to review when it supplies a non-empty plan. Other statuses are not changed.
  • A data migration moves existing draft rows whose plan_json is a non-empty JSON array to review. It has no down step: the moved rows are not recorded, and review is the right status for them on any version.
  • docs/mcp.md and the changelog describe the behaviour.

Tests

  • packages/api/test/mcpIntegration.test.ts: a plan created with items is review on create and on read; a prompt-only draft stays draft after a rename and becomes review when update_plan gives it a plan.
  • test/reviewDraftsWithPlanMigration.test.ts: only drafts with plan items move; null, empty, non-array and invalid plan_json and other statuses are untouched; the migration is a no-op without the table and when run twice.

Run locally: typecheck, lint for packages/api and packages/core at zero warnings, and mcpIntegration, mcpWorkflows, mcpPublishPlan, mcpToolInputBudget, mcpDocs, mcpObservableSurface plus the migration test, all passing.

🤖 Generated with Claude Code

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]>
@integry integry added the AI label Nov 12, 2026
@integry

integry commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

/review

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

Ready to merge. The PR directly fixes Studio visibility for populated MCP plans while preserving prompt-only drafts and other lifecycle states.

✅ Consistent status transitions — create_plan persists and returns review for populated plans. update_plan promotes only draft, within the existing revision-guarded update.

✅ 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 blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Cover preserved update statuses

Consider adding cases that supply plan items to review, approved, and failed plans and assert their statuses remain unchanged. The conditional SQL in packages/api/mcp/toolsPlanning.ts:156 correctly preserves these states, but the added integration coverage exercises only promotion from draft. This is optional regression coverage.

Score

The 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

  • Model: GPT-6 Astra
  • Time: 25s
  • Tokens: 42,980 (42,641 in / 339 out)
  • Cost: $0.33

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S1

🤖 Review by ProPR

@integry

integry commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

/fix all

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Applied the requested follow-up changes in commit 2038663

Addressed 1 AI review comment (IDs: 6832208066)

Addressed suggestion S1

Summary of Changes

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.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 5m 1s
  • Tokens: 640,713 (636,464 in / 4,249 out)
  • Cost: $0.44
  • Subscription usage: Weekly +1%

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 6832476201✓

…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
@integry
integry merged commit 1d11edb into main Nov 12, 2026
42 checks passed
@integry
integry deleted the fix/mcp-plan-drafts-open-in-review branch November 12, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants