Add refresh_browser tool so the agent can reload the site preview - #4027
Merged
Conversation
Collaborator
📊 Performance Test ResultsComparing 4b3b907 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) |
|
|
||
| export const refreshBrowserTool = defineTool( | ||
| 'refresh_browser', | ||
| 'Reloads the site preview browser in the Studio app so the user sees your latest changes. Call this after a change that alters what the site renders (content, options/settings, theme, plugins, activation). It reloads in place — never stop/start the site (site_stop/site_start) just to refresh the preview.', |
Contributor
There was a problem hiding this comment.
Nice, this is a much better experience than having to reload things manually which I was doing before
katinthehatsite
approved these changes
Jul 2, 2026
katinthehatsite
left a comment
Contributor
There was a problem hiding this comment.
I think this looks good 👍 I asked to make some visual changes like adjusting colors and I noticed that the preview refreshed by itself once the agent was done without me having to do it manully. I think this is a much better experience.
gcsecsey
added a commit
that referenced
this pull request
Jul 7, 2026
## Related issues - N/A ## How AI was used in this PR Claude cross-checked the auto-generated 1.14.0 changelog against the merged PRs, classifying them as user-facing or internal, and drafting the 1.14.0 wording. I reviewed the changes before raising the PR. ## Proposed Changes - Replace the generated `1.14.0` release-note block with a shorter, user-facing summary. - Grouped the Studio Code changes and folded the shipped dependency bumps into a single "Updated multiple dependencies" line. - Omitted changes not yet visible to users: - the `studio ui` browser surface and `refresh_browser` preview tool - both part of the not-yet-released agentic UI (#3953, #4027) - internal-only PRs (CI/test infra and CI dependency bumps, the Studio apps design doc, release tooling, and internal state/vendor cleanups) - For the Windows E2E PR (#4082), surfaced only the user-facing part: native-PHP sites failing to load on Windows when the profile path uses an 8.3 short name. ## Testing Instructions - Read the `1.14.0` section of `RELEASE-NOTES.txt` - Confirm the groupings and wording read well and are accurate - Cross-check against the merged-PR list for anything important that should be surfaced or reworded ## Pre-merge Checklist - [ ] Have you checked for TypeScript, React or other console errors? --------- Co-authored-by: Fredrik Rombach Ekelund <fredrik@f26d.dev>
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
Built with Claude Code: explored the agent tool + site-preview architecture, implemented the tool and event wiring, and wrote the unit tests. I reviewed every change myself and validated the behavior manually in the app. No CSS/color changes, so there is nothing to review in dark mode.
Proposed Changes
The Studio agent had no way to refresh the in-app site preview after making changes, so it fell back to stopping and starting the whole site just to force a fresh webview mount — slow, disruptive, and impossible when the site was already running (the preview would simply stay stale). This adds a
refresh_browsertool that reloads the preview in place via a dedicatedpreview.reloadevent, and steers the agent through its system prompt to use it after user-visible changes instead of restarting the site. Users now see their agent-made changes reflected immediately, without a server restart.Testing Instructions
Run wp-cli option update blogname "Reloaded-1" on this site. The preview still shows the old title.refresh the browser preview. It should callrefresh_browser(shown as "Refresh preview") and the header should update in place — with no site stop/start.npm test -- apps/cli/ai/tests/tools.test.tsandnpm test -- apps/ui/src/hooks/use-session-commands.test.tsx.Pre-merge Checklist