Repository navigation
Preview a Live chat's remote site, and let the agent reload the preview with refresh_browser - #5336
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Button, IconButton, Tooltip and Spinner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l dialog overrides Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ild's popup surface Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ntrols with the agentic UI's own Field, Input, Select, Switch and Checkbox Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… @wordpress/theme from the agentic UI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d stop as in progress
…ew mid-run with refresh_browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mattic/studio into claude/eloquent-sammet-4454d7
…the end of every run Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ude/eloquent-sammet-4454d7 # Conflicts: # apps/cli/ai/tools/index.ts # apps/ui/src/components/add-site-dialog/connect-panel.tsx # apps/ui/src/components/open-in-menu/use-open-in-destinations.test.tsx # apps/ui/src/components/open-in-menu/use-open-in-destinations.tsx # apps/ui/src/components/publish-panel/index.test.tsx # apps/ui/src/components/session-view/index.tsx # apps/ui/src/components/site-preview/address-bar.tsx # apps/ui/src/components/site-preview/index.test.tsx # apps/ui/src/components/site-preview/index.tsx # apps/ui/src/components/stopped-site-preview/index.tsx # apps/ui/src/data/core/connectors/ipc/index.ts
|
I had removed the |
📊 Performance Test ResultsComparing 15d58ee 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) |
…ude/eloquent-sammet-4454d7
|
Yes, and for me that was a regression. the preview was reloading constantly as I was chatting with the agent and it was disorienting. |
|
Could we fine-tune the timing of the refresh rather than handing it back to the agent?
I'm hoping to move this directive into code. It also reduces branching between the app and the CLI, since it is only needed when the app is open. |
|
I don't know how to do that without too much complexity. I'd rather keep things simple for now. I understand the need to be more and more deterministic but I think we should balance that with the complexity of our tools and their interdependencies. The tools become way too specific if we go in this direction. |
|
One potential thing we could that (and that we had at some point in the past) is make the agent create "artifacts" which are like generic checkpoints, and the app/mcp... whatever consumer of the agent can decide what to do for these artifacts. For me that keeps a clean separation between agent knowledge and app feedback |
|
Yeah, I went overboard with the reloads, sorry about that. I agree the complexity can balloon. I tried a few approaches and went with something minimal instead. If you want to punt removing Using artifacts could be interesting, but it shouldn't be the agent's responsibility to set them, or we will have the same problem as One idea that I considered was using metadata provided by the tools so the app would know when it needs to refresh based on which tools were used. This seems like the most promising direction for a long term solution to me. |
I like that, the problem I see though is that some of our tools are too broad (like wp cli), which wp CLI tool is going to need a refresh is very hard to define. Same for any broad tool like wpcom_request ... |
|
I'm merging this PR for now and we can see how we can improve that over time. |
Related issues
How AI was used in this PR
Claude Code implemented the change against the rebuild reference (
workspace.tsx,use-preview-navigation.ts,refresh-browser.ts), wrote the tests, ran a targeted eval, and checked the Live preview instudio uiin light and dark with an isolated config and a fake Live connection. Riad reviewed the behavior and asked for the end-of-run reload to be dropped.Proposed Changes
refresh_browsertool lets the agent reload the in-app preview mid-run, after a change that alters what the site renders. The preview no longer reloads on its own at the end of every run, whatever you were doing, so this is now the only agent-driven reload, as in the rebuild. The tool exists only when a Studio UI is attached: terminalstudio codesessions andstudio mcpnever see it.Testing Instructions
Run
npm run cli:build:ui && node apps/cli/dist/cli/main.mjs ui --no-open(or the Desktop app) with a local site connected to a WordPress.com site.refresh_browser, not when the turn ends.Evals:
npm run eval -- --filter-pattern "asking for a site leaves a working new site"passes. The eval runner attaches no UI, sorefresh_browserisn't registered there and its prompt is unchanged; the tool is covered by unit tests on both ends.Pre-merge Checklist
🤖 Generated with Claude Code