Skip to content

fix(init): gate MCP setup on unattended mode#1421

Merged
gu-stav merged 1 commit into
mainfrom
fix/init-mcp-json-unattended
Jul 2, 2026
Merged

fix(init): gate MCP setup on unattended mode#1421
gu-stav merged 1 commit into
mainfrom
fix/init-mcp-json-unattended

Conversation

@gu-stav

@gu-stav gu-stav commented Jul 2, 2026

Copy link
Copy Markdown
Member

Description

init's MCP setup switched to non-prompting auto only when --yes was passed. Every other unattended path still fell through to prompt — a non-TTY run, and (once #1420 lands) a --json run — so an init that's meant to be non-interactive could still block on the MCP editor prompt.

Gate the auto branch on isUnattended() instead of flags.yes. The non-interactive terminal case is already handled by the skip branch above, so this is behaviour-neutral for --yes today and closes the gap for --json once it's treated as unattended.

Found while sweeping for other spots that gate prompts on --yes directly rather than isUnattended() — this was the only one; every other command with a --json flag already threads isUnattended() (or its derived unattended boolean) through.

What to review

  • init.ts: the mcpMode derivation now uses this.isUnattended() for the auto branch. resolveIsInteractive() still short-circuits to skip first, so the change only affects interactive, unattended runs.

Testing

Behaviour-neutral on its own (in the auto branch isUnattended() reduces to flags.yes until --json is folded into it by #1420), so existing init unit tests cover it.


Note

Low Risk
Small conditional change in init CLI prompt gating; behavior-neutral for current --yes usage and no auth or data-path changes.

Overview
sanity init MCP setup now picks non-prompting auto mode when the command is unattended (isUnattended()), not only when --yes is set.

That aligns MCP with how other init options treat unattended runs (including future --json flows) so a non-interactive init can apply MCP defaults instead of blocking on the editor prompt. Disabling MCP or non-interactive terminals still use skip first, so behavior for --yes today stays the same until --json is folded into unattended.

Reviewed by Cursor Bugbot for commit f2f3fb0. Bugbot is set up for automated code reviews on this repo. Configure here.

MCP setup switched to non-prompting `auto` only for --yes, so any other
unattended run — a non-TTY, or --json once it implies unattended (#1420) —
still stopped at the MCP prompt. Gate it on isUnattended() so a
non-interactive init never blocks there.
@gu-stav gu-stav requested a review from a team as a code owner July 2, 2026 09:04
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (e56340ae)

@sanity/cli

Metric Value vs main (e56340a)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 915ms -2ms, -0.2%

bin:sanity

Metric Value vs main (e56340a)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.35s -8ms, -0.4%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against main (e56340ae)

Metric Value vs main (e56340a)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 816ms +4ms, +0.4%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against main (e56340ae)

Metric Value vs main (e56340a)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@gu-stav gu-stav changed the title fix(init): gate MCP setup on unattended mode, not --yes alone fix(init): gate MCP setup on unattended mode Jul 2, 2026
@gu-stav gu-stav requested a review from runeb July 2, 2026 09:06
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/commands/init.ts 100.0% (±0%)

Comparing 1 changed file against main @ e56340aea13282b039ed01625801c5268fee9964

Overall Coverage

Metric Coverage
Statements 74.5% (±0%)
Branches 64.3% (±0%)
Functions 68.9% (±0%)
Lines 75.1% (±0%)

@jwoods02 jwoods02 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch, thanks for fixing LGTM

@gu-stav gu-stav merged commit a896651 into main Jul 2, 2026
57 of 58 checks passed
@gu-stav gu-stav deleted the fix/init-mcp-json-unattended branch July 2, 2026 09:16
@cursor cursor Bot mentioned this pull request Jul 2, 2026
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.

2 participants