Skip to content

Block conflicting site operations - #4406

Draft
bcotrim wants to merge 10 commits into
trunkfrom
guard-site-start-while-stopping
Draft

Block conflicting site operations#4406
bcotrim wants to merge 10 commits into
trunkfrom
guard-site-start-while-stopping

Conversation

@bcotrim

@bcotrim bcotrim commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude Code handled the implementation. I designed the solution, reviewed and iterated over the code, and manually tested.

Proposed Changes

Two Studio operations on the same site could run at once and corrupt each other. Starting a site while it was stopping left it down while the UI claimed it started, then looped retrying. Because the agent calls the CLI directly, guarding this in the UI alone wouldn't hold.

The CLI now claims a per-site lease for each operation and refuses a conflicting one with a readable error — so the guard applies no matter who started the work: you, the agent, a terminal, or a second window. Operations that restart the site or rewrite its files (start, stop, delete, import, pull, settings) run alone; read-only ones (export, push) run alongside each other.

The lease reaches the UI, which disables the actions it blocks and names what's running ("Exporting…") rather than leaving controls that look live but swallow the click. Progress survives navigating away and back, and a lease whose owning process dies is reclaimed automatically, so a crash can't wedge a site.

Testing Instructions

  1. Start a long export: studio export --path <site> <out.tar.gz>.
  2. While it runs, try to start / delete / change settings on that site — from the sidebar, the site dropdown and the overview screen, and by asking the agent. Controls are disabled and read "Exporting…"; the agent gets a readable refusal.
  3. Navigate away from the site and back — it still shows as exporting.
  4. Let it finish — everything re-enables.
  5. Repeat, but kill -9 the export mid-run. The site must not stay locked.

Verified in light and dark mode.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

🤖 Generated with Claude Code

@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing a57383e vs trunk

app-size

Metric trunk a57383e Diff Change
App Size (Mac) 1372.96 MB 1372.96 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk a57383e Diff Change
load 1064 ms 1038 ms 26 ms ⚪ 0.0%

site-startup

Metric trunk a57383e Diff Change
siteCreation 6527 ms 6507 ms 20 ms ⚪ 0.0%
siteStartup 2381 ms 2358 ms 23 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim
bcotrim marked this pull request as draft July 31, 2026 13:22
@bcotrim bcotrim changed the title Don't start a site while a stop for it is still in flight Agentic UI: Don't start a site while a stop for it is still in flight Jul 31, 2026
@bcotrim bcotrim changed the title Agentic UI: Don't start a site while a stop for it is still in flight Block conflicting site operations with a per-site lease Aug 7, 2026
@bcotrim bcotrim changed the title Block conflicting site operations with a per-site lease Block conflicting site operations Aug 7, 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