Resolve the real site running state when resuming code sessions headlessly#4096
Open
shaunandrews wants to merge 1 commit into
Open
Resolve the real site running state when resuming code sessions headlessly#4096shaunandrews wants to merge 1 commit into
shaunandrews wants to merge 1 commit into
Conversation
…essly Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing 9c203e1 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) |
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 investigated the root cause, wrote the fix and tests, and drafted this PR. I reviewed and directed the work.
Proposed Changes
In desktop Studio Code sessions, the agent's per-turn context banner always described the active local site as
(stopped), no matter its actual state. The agent would then defensively callsite_startbefore WP-CLI or other site operations — wasting a tool call every turn and confusing users whose site was clearly already running.The cause: every desktop turn runs
studio code sessions resume --json, which hydrates the active site from the session's event log. That log carries no running state, and the missing flag defaulted to "stopped". Now the headless resume path asks the daemon whether the site is actually up before dispatching the turn, so the agent sees the truth: no more redundantsite_startcalls, and the agent can correctly warn when the site really is stopped.Sites missing from the CLI config are still treated as stopped, and remote (WordPress.com) sites skip the check since running state doesn't apply to them.
Testing Instructions
(stopped)and it would often callsite_startfirst; now the context shows(running)and it goes straight to the WP-CLI call.(stopped).npm test -- apps/cli/commands/ai/sessions/tests/resume.test.tsPre-merge Checklist
🤖 Generated with Claude Code