Skip to content

Studio Code: State saved Site Editor copies in tool results, when a call touches the theme file they replace - #5343

Merged
chubes4 merged 7 commits into
trunkfrom
studio-code/saved-copy-notes
Oct 23, 2026
Merged

chubes4 merged 7 commits into
trunkfrom
studio-code/saved-copy-notes

Conversation

@chubes4

@chubes4 chubes4 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude (via the Pi coding agent in a Roadie session) wrote the change and the test and ran the evals below. I reviewed the diff and the results.

Proposed Changes

When someone saves a template, template part or Global Styles in the Site Editor, WordPress renders that saved copy instead of the theme file. An agent that edits parts/header.html then changes nothing the visitor sees. #5092 told the agent this in edit-manage-site; #5301 moved it into Active site facts, which listed every saved copy in every prompt.

  • The notice moves into tool results, stated when a call or its result names a theme file a saved copy replaces, for example:

    WordPress renders the template part header from its copy saved in the Site Editor (post 12), not from wp-content/themes/twentytwentyfive/parts/header.html.

  • cli/ai/saved-copies.ts reads the copies from the site's SQLite database when a theme file is named, so copies saved earlier in the turn count. Each copy is stated once per tracker.
  • It is registered in cli/ai/result-notes.ts (Studio MCP: Add the declared settings of core blocks to tool results #5333). The notes now see the call's arguments with its result (a Write names the file in its arguments), on both surfaces.
  • Active site facts keep the WordPress version; saved copies leave them.

Limits:

  • MCP clients read and write theme files with their own tools, which never pass through Studio, so for them the notice fires only when a Studio tool names the file.
  • Like every result note, a notice stated early in a turn can be lost if the context is compacted later in that turn.

Testing Instructions

Pre-merge Checklist

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

@chubes4
chubes4 marked this pull request as draft October 23, 2026 17:33
@chubes4
chubes4 marked this pull request as ready for review October 23, 2026 18:02
@chubes4
chubes4 merged commit e62d922 into trunk Oct 23, 2026
12 checks passed
@chubes4
chubes4 deleted the studio-code/saved-copy-notes branch October 23, 2026 19:10
@youknowriad

Copy link
Copy Markdown
Contributor

Thanks, this answers my concern about the prompt, but to be honest, I don't see how this is worth it. your numbers show the old sentence cost nothing measurable (14.3 vs 14.1 calls, same tokens and time) and passed the same evals, so I’d rather keep that one line in edit-manage-site than maintain a SQLite reader and path matching that covers files named exactly. It feels over engineered and too specific.

@chubes4

chubes4 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

For me it's about the philosophy behind the changes. The opportunity to remove a line from the prompt and replace it with code is always worth it, because it is now impossible to have the kind of error that caused the line to be added to the prompt in the first place.

The line in the skill was also extremely specific and didn't need to be there. It also could be ignored by the agent. Some of my earlier evals did show the agent ignoring it.

Also, pushing on this revealed multiple bugs like the ones with --post_content that came up during evals.

By removing prose from our skills and prompts, we can reserve real estate for custom workflows and other things that can't be handled structurally.

@youknowriad

Copy link
Copy Markdown
Contributor

The opportunity to remove a line from the prompt and replace it with code is always worth it, because it is now impossible to have the kind of error that caused the line to be added to the prompt in the first place.

I'm not sure I'm on board with this policy personally. I think it's always a balance and if removing a code means shipping some code that is too specific to address one edge case, I don't think it's worth it at the moment.

It's possible that I'm wrong but I don't want us in a month to end up with a harness with hundreds of specific fixes like this.

@chubes4

chubes4 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

I'm taking small bites towards an architecture like #5146. These low-risk changes make it easier to ship bigger things later, such as removing validate_blocks in favor of automated validation owned by Studio.

I don't see these as one-off changes, I am creating primitives that share WordPress state with the agent. Over time, this will lead to Studio Code being more efficient, faster, and more reliable. I'm confident that this direction is worth it.

@youknowriad

Copy link
Copy Markdown
Contributor

In that case, I think it's better to build the whole architecture change in a dedicated branch to be able to compare it without ur current architecture, unless you think that PR is already better than trunk in which case I will have to test it properly.

I need to be convinced that the new architecture is better, I'm not at the moment. We have a lot of generic tools like rest api, wp cli, ... and automating validation in the tools is not something that I think can work reliably for instance, especially with third party blocks (woo, jetpack...). I want to be convinced otherwise though so that's why I think it's better to build the whole vision separately instead of building it bit by bit so we have two mixed visions that fight each other.

@chubes4

chubes4 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

I don't think #5146 is better than trunk in its current state. Fair enough, I'll build out everything I think needs to be done on that branch and let you know when it's ready.

I expected it would take some convincing, which is part of why I started small.

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