Block conflicting site operations - #4406
Draft
bcotrim wants to merge 10 commits into
Draft
Conversation
Collaborator
📊 Performance Test ResultsComparing a57383e vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
bcotrim
marked this pull request as draft
July 31, 2026 13:22
1 task
…le-stopping # Conflicts: # apps/ui/src/components/site-dropdown/main-view.tsx # apps/ui/src/components/site-list/index.tsx # apps/ui/src/components/site-overview-view/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
studio export --path <site> <out.tar.gz>.kill -9the export mid-run. The site must not stay locked.Verified in light and dark mode.
Pre-merge Checklist
🤖 Generated with Claude Code