Skip to content

Add manual compile mode to pause Turbopack scheduling during batched edits#92410

Open
gaojude wants to merge 1 commit intocanaryfrom
mcp-manual-compile-mode
Open

Add manual compile mode to pause Turbopack scheduling during batched edits#92410
gaojude wants to merge 1 commit intocanaryfrom
mcp-manual-compile-mode

Conversation

@gaojude
Copy link
Copy Markdown
Contributor

@gaojude gaojude commented Apr 6, 2026

When an AI agent edits multiple files in sequence, Turbopack eagerly recompiles after each save. This produces ephemeral compilation errors (e.g. importing a module that hasn't been created yet) and wastes CPU on intermediate states that are immediately invalidated.

This adds two new MCP tools: pause_compilation and compile_and_resume. Calling pause_compilation pauses the turbo-tasks scheduler — file changes still mark tasks dirty via the file watcher, but schedule() buffers task IDs instead of dispatching them to the priority runner. No compilation happens, no errors are produced, and no HMR messages reach the browser.

Calling compile_and_resume clears the pause flag, drains all buffered tasks into the scheduler, and waits for event_foreground_done before returning. This produces exactly one compilation cycle from the final file-system state. The existing HMR pipeline then sends one clean update to the browser with the correct issues and module state. Zero JS-side guards are needed because no intermediate compilation ever occurs.

The pause is implemented as an AtomicBool and a Mutex<Vec<(TaskId, TaskPriority)>> on the TurboTasks struct. The gate in schedule() is the only code path that changes behavior — everything else (subscriptions, handleProjectUpdates, sendEnqueuedMessages, sendToClient) runs unmodified.

@nextjs-bot nextjs-bot added created-by: Next.js team PRs by the Next.js team. tests Turbopack Related to Turbopack with Next.js. type: next labels Apr 6, 2026
@gaojude gaojude changed the title [MCP] Add manual compile mode to pause Turbopack scheduling during batched edits [Agent] Add manual compile mode to pause Turbopack scheduling during batched edits Apr 6, 2026
@gaojude gaojude changed the title [Agent] Add manual compile mode to pause Turbopack scheduling during batched edits [AI] Add manual compile mode to pause Turbopack scheduling during batched edits Apr 6, 2026
@gaojude gaojude changed the title [AI] Add manual compile mode to pause Turbopack scheduling during batched edits Add manual compile mode to pause Turbopack scheduling during batched edits Apr 6, 2026
@gaojude gaojude force-pushed the mcp-manual-compile-mode branch from 4aef97c to b6698bb Compare April 6, 2026 17:02
@nextjs-bot
Copy link
Copy Markdown
Collaborator

nextjs-bot commented Apr 6, 2026

Failing test suites

Commit: b9a132e | About building and testing Next.js

pnpm test-dev test/development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts (job)

  • instant-nav-panel > should show loading skeleton during SPA navigation after clicking Start (DD)
Expand output

● instant-nav-panel › should show loading skeleton during SPA navigation after clicking Start

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false

  164 |           '[data-testid="dynamic-skeleton"]'
  165 |         )
> 166 |         expect(skeleton).toBe(true)
      |                          ^
  167 |       },
  168 |       30000,
  169 |       500

  at toBe (development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts:166:26)
  at retry (lib/next-test-utils.ts:861:14)
  at Object.<anonymous> (development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts:161:5)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 6, 2026

Merging this PR will not alter performance

✅ 17 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing mcp-manual-compile-mode (b9a132e) with canary (d3cbd5b)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gaojude gaojude force-pushed the mcp-manual-compile-mode branch from b6698bb to 98d73ac Compare April 6, 2026 17:19
@nextjs-bot
Copy link
Copy Markdown
Collaborator

nextjs-bot commented Apr 6, 2026

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 456ms 456ms ▅▅▅▅▁
Cold (Ready in log) 441ms 439ms ▅▇█▂▁
Cold (First Request) 1.091s 1.091s ▁▆██▆
Warm (Listen) 457ms 456ms ▁▁▁██
Warm (Ready in log) 439ms 439ms ▇▇█▁▂
Warm (First Request) 336ms 335ms ▇▅▇▁▃
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▃▆▃▆▃
Cold (Ready in log) 437ms 437ms ▅▆▃▂▁
Cold (First Request) 1.948s 1.941s ▇█▄▆▇
Warm (Listen) 456ms 456ms █████
Warm (Ready in log) 437ms 437ms ▅▆▃▃▁
Warm (First Request) 1.956s 1.962s ▇▇▃▆▆

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 3.876s 3.844s █▅█▅▇
Cached Build 3.830s 3.891s █▄▅█▅
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 14.501s 14.488s █▇▁▁▁
Cached Build 14.601s 14.594s ██▃▂▁
node_modules Size 488 MB 488 MB ▄▅███
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
02fkg8wfh0iju.js gzip 9.19 kB N/A -
050zwt5xh_0tx.js gzip 10.4 kB N/A -
06rvbj82bhyo0.js gzip 13 kB N/A -
087fzjd-gvlzv.js gzip 450 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0j9nyyebpzuve.js gzip 65.7 kB N/A -
0liwiknewtyj-.js gzip 155 B N/A -
0lz6rvqk4dq28.js gzip 157 B N/A -
0ppxcl_z43mad.js gzip 8.52 kB N/A -
0t-vypuopaopr.js gzip 156 B N/A -
0taq90fnaps1c.js gzip 154 B N/A -
0w-q2j65cf4d_.js gzip 70.8 kB N/A -
177wlvvlyngbh.js gzip 162 B N/A -
19oha6-znmkcv.js gzip 8.55 kB N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1jiaxunj6aqjm.js gzip 154 B N/A -
1lwlgx9s5r-bl.js gzip 155 B N/A -
2_5rjb7lqxntf.js gzip 221 B 221 B
219prxwxgaalc.js gzip 7.61 kB N/A -
26elcgxnn9zjd.js gzip 8.52 kB N/A -
2900hudr6gvm0.js gzip 2.28 kB N/A -
2lv2js3kmdeho.js gzip 8.48 kB N/A -
2pcakafkxmy0y.js gzip 159 B N/A -
2rehygrd36hqv.js gzip 8.58 kB N/A -
2srwswih0m9_h.js gzip 13.3 kB N/A -
3-p9p9mheqhzx.js gzip 8.55 kB N/A -
31030bryqpolg.js gzip 8.53 kB N/A -
31dx5nmrzzuy7.js gzip 225 B N/A -
35jcqqltah41n.js gzip 161 B N/A -
3925v09gtu-5k.js gzip 49 kB N/A -
39x4zj5mjb4d_.js gzip 9.77 kB N/A -
3em05vpajqpwz.js gzip 169 B N/A -
3k-48b78ys_vy.js gzip 10.1 kB N/A -
3m7-5rfj0avoz.js gzip 12.9 kB N/A -
3s-7xts2e4w68.js gzip 158 B N/A -
3uqce_6sa526g.js gzip 8.47 kB N/A -
3yurjqk-sjs3y.js gzip 1.46 kB N/A -
40ybjx9c192n0.js gzip 13.8 kB N/A -
421vzwdt9j1b_.js gzip 5.62 kB N/A -
450cprx9a1he-.js gzip 157 B N/A -
458kx8xybb_ty.js gzip 157 B N/A -
turbopack-0g..vaan.js gzip 4.18 kB N/A -
turbopack-0x..zr41.js gzip 4.18 kB N/A -
turbopack-1d..d4y6.js gzip 4.18 kB N/A -
turbopack-1j..5f0x.js gzip 4.18 kB N/A -
turbopack-1q..mobr.js gzip 4.18 kB N/A -
turbopack-1x..zepa.js gzip 4.18 kB N/A -
turbopack-20..hso6.js gzip 4.17 kB N/A -
turbopack-24..svkv.js gzip 4.17 kB N/A -
turbopack-2i..2mpu.js gzip 4.18 kB N/A -
turbopack-2m..v5gs.js gzip 4.18 kB N/A -
turbopack-2t..mebg.js gzip 4.16 kB N/A -
turbopack-39..hd24.js gzip 4.19 kB N/A -
turbopack-3m..e-_l.js gzip 4.17 kB N/A -
turbopack-42..g8c-.js gzip 4.17 kB N/A -
03dgzoo-qf3sm.js gzip N/A 9.19 kB -
05tx5f25dlivn.js gzip N/A 8.53 kB -
085gix7vncldb.js gzip N/A 154 B -
08qxf1bxk2sy0.js gzip N/A 153 B -
0c7ez6p2qc57f.js gzip N/A 5.62 kB -
0duvj3qk5pvgn.js gzip N/A 13.8 kB -
0hvsdb3udqtqq.js gzip N/A 156 B -
0k12a08xkwlz-.js gzip N/A 157 B -
0m-34rm9w_wpm.js gzip N/A 7.6 kB -
0nlykkpfyyg2w.js gzip N/A 155 B -
0qnwuk92m8i7o.js gzip N/A 10.4 kB -
0r4wrn6n0ue2m.js gzip N/A 8.55 kB -
0rp0fodtbt_6m.js gzip N/A 8.52 kB -
0sfck-km4dl1k.js gzip N/A 8.47 kB -
0x0xuhmxzwkp8.js gzip N/A 8.47 kB -
1_t7k492adi7n.js gzip N/A 155 B -
1_xgyhyp7ql91.js gzip N/A 157 B -
1-wdvgxnzicj7.js gzip N/A 1.46 kB -
11u6nxujb2eg4.js gzip N/A 450 B -
15w1ub8e8wqfw.js gzip N/A 159 B -
1aeiaf859ymle.js gzip N/A 154 B -
1jv-o1_s-zmua.js gzip N/A 49 kB -
2in9gz64_b29q.js gzip N/A 168 B -
2k9ax08cjl2id.js gzip N/A 12.9 kB -
2lms6k76q5-6m.js gzip N/A 13.3 kB -
2qx4twi9i3xus.js gzip N/A 2.28 kB -
2srnqic6tvxxd.js gzip N/A 8.52 kB -
30beetijii86g.js gzip N/A 65.7 kB -
30l7m4nayp73a.js gzip N/A 8.55 kB -
33hhl7rvbciep.js gzip N/A 159 B -
38rr7d3kfutni.js gzip N/A 13 kB -
3b-ri3-nxw0g7.js gzip N/A 70.8 kB -
3c73-g0fvlevb.js gzip N/A 154 B -
3h_ecpiaatwgc.js gzip N/A 10.1 kB -
3ity0aahajapd.js gzip N/A 225 B -
3tn3pab2yum0u.js gzip N/A 155 B -
3wrhpuc-j1aw9.js gzip N/A 9.77 kB -
43mlw9dy_8f02.js gzip N/A 8.58 kB -
turbopack-08..n7x8.js gzip N/A 4.18 kB -
turbopack-0a..t8jc.js gzip N/A 4.18 kB -
turbopack-0a..nf4n.js gzip N/A 4.17 kB -
turbopack-0r..v9zz.js gzip N/A 4.18 kB -
turbopack-0z..a5r2.js gzip N/A 4.16 kB -
turbopack-1-..bedd.js gzip N/A 4.17 kB -
turbopack-1c..qjua.js gzip N/A 4.17 kB -
turbopack-1p..1_tg.js gzip N/A 4.17 kB -
turbopack-1q..-f4x.js gzip N/A 4.17 kB -
turbopack-2u..6dws.js gzip N/A 4.17 kB -
turbopack-2u..dzlg.js gzip N/A 4.18 kB -
turbopack-2y..u7ck.js gzip N/A 4.17 kB -
turbopack-30..s215.js gzip N/A 4.18 kB -
turbopack-44..868h.js gzip N/A 4.19 kB -
Total 464 kB 464 kB ✅ -60 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 719 B 714 B
Total 719 B 714 B ✅ -5 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 432 B 427 B 🟢 5 B (-1%)
Total 432 B 427 B ✅ -5 B

📦 Webpack

Client

Main Bundles
Canary PR Change
5528-HASH.js gzip 5.54 kB N/A -
6280-HASH.js gzip 60.7 kB N/A -
6335.HASH.js gzip 169 B N/A -
912-HASH.js gzip 4.59 kB N/A -
e8aec2e4-HASH.js gzip 62.8 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 256 B 254 B
main-HASH.js gzip 39.3 kB 39.2 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
262-HASH.js gzip N/A 4.59 kB -
2889.HASH.js gzip N/A 169 B -
5602-HASH.js gzip N/A 5.55 kB -
6948ada0-HASH.js gzip N/A 62.8 kB -
9544-HASH.js gzip N/A 61.4 kB -
Total 235 kB 235 kB ⚠️ +649 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 194 B 194 B
_error-HASH.js gzip 183 B 180 B 🟢 3 B (-2%)
css-HASH.js gzip 331 B 330 B
dynamic-HASH.js gzip 1.81 kB 1.81 kB
edge-ssr-HASH.js gzip 256 B 256 B
head-HASH.js gzip 351 B 352 B
hooks-HASH.js gzip 384 B 383 B
image-HASH.js gzip 580 B 581 B
index-HASH.js gzip 260 B 260 B
link-HASH.js gzip 2.51 kB 2.51 kB
routerDirect..HASH.js gzip 320 B 319 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 315 B 315 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.98 kB 7.98 kB ✅ -1 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 126 kB 126 kB
page.js gzip 273 kB 273 kB
Total 399 kB 398 kB ✅ -173 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 617 B 616 B
middleware-r..fest.js gzip 156 B 155 B
middleware.js gzip 44.2 kB 44.3 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 45.8 kB 45.9 kB ⚠️ +53 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 715 B 718 B
Total 715 B 718 B ⚠️ +3 B
Build Cache
Canary PR Change
0.pack gzip 4.38 MB 4.37 MB
index.pack gzip 116 kB 114 kB 🟢 1.94 kB (-2%)
index.pack.old gzip 116 kB 115 kB
Total 4.61 MB 4.6 MB ✅ -6.88 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 342 kB 342 kB
app-page-exp..prod.js gzip 189 kB 189 kB
app-page-tur...dev.js gzip 341 kB 341 kB
app-page-tur..prod.js gzip 189 kB 189 kB
app-page-tur...dev.js gzip 338 kB 338 kB
app-page-tur..prod.js gzip 187 kB 187 kB
app-page.run...dev.js gzip 338 kB 338 kB
app-page.run..prod.js gzip 187 kB 187 kB
app-route-ex...dev.js gzip 76.6 kB 76.6 kB
app-route-ex..prod.js gzip 52.2 kB 52.2 kB
app-route-tu...dev.js gzip 76.6 kB 76.6 kB
app-route-tu..prod.js gzip 52.2 kB 52.2 kB
app-route-tu...dev.js gzip 76.2 kB 76.2 kB
app-route-tu..prod.js gzip 52 kB 52 kB
app-route.ru...dev.js gzip 76.2 kB 76.2 kB
app-route.ru..prod.js gzip 52 kB 52 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.8 kB 43.8 kB
pages-api-tu..prod.js gzip 33.4 kB 33.4 kB
pages-api.ru...dev.js gzip 43.8 kB 43.8 kB
pages-api.ru..prod.js gzip 33.4 kB 33.4 kB
pages-turbo....dev.js gzip 53.2 kB 53.2 kB
pages-turbo...prod.js gzip 39 kB 39 kB
pages.runtim...dev.js gzip 53.2 kB 53.2 kB
pages.runtim..prod.js gzip 39 kB 39 kB
server.runti..prod.js gzip 62.8 kB 62.8 kB
Total 3.03 MB 3.03 MB ⚠️ +1 B
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/b9a132eaa979a748d7b5541820d5898ab9d936d4/next

@gaojude gaojude force-pushed the mcp-manual-compile-mode branch from 98d73ac to 5efe904 Compare April 6, 2026 18:06
@gaojude gaojude force-pushed the mcp-manual-compile-mode branch from 5efe904 to b9a132e Compare April 6, 2026 18:33
@gaojude gaojude requested a review from sokra April 6, 2026 20:55
gaojude added a commit that referenced this pull request Apr 6, 2026
Adds a new `next-dev` plugin to the Next.js Claude Code marketplace
that wires the dev server's MCP endpoint into Claude Code via two
skill-scoped hooks:

- UserPromptSubmit: pings the dev server and calls `pause_compilation`
  so intermediate edits don't trigger HMR.
- Stop: calls `compile_and_resume` (one batch compile) followed by
  `get_compilation_issues`, blocking the agent from finishing if
  compilation errors exist.

State files (`.claude/port`, `.claude/dismissed-issues.json`) are
project-local; hook scripts live under `${CLAUDE_PLUGIN_ROOT}`.

Marked experimental in the manifest, marketplace, and README — depends
on `pause_compilation`/`compile_and_resume` MCP tools that are still
landing in #92410. The activation script verifies the tools are
present and refuses to enable hooks otherwise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Next.js team PRs by the Next.js team. tests Turbopack Related to Turbopack with Next.js. type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants