Skip to content

pull-reprint: stop touching internal Reprint state directly - #4491

Merged
fredrikekelund merged 10 commits into
trunkfrom
f26d/pull-reprint-jetpack-remote-file-index-phar
Aug 13, 2026
Merged

pull-reprint: stop touching internal Reprint state directly#4491
fredrikekelund merged 10 commits into
trunkfrom
f26d/pull-reprint-jetpack-remote-file-index-phar

Conversation

@fredrikekelund

@fredrikekelund fredrikekelund commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Codex wrote the whole thing based on a detailed upfront plan that I drafted with Claude. The process was highly iterative.

Proposed Changes

The pull-reprint command in Studio currently both reads and writes private Reprint state. This was implemented as a temporary measure to make selective sync work, and I'm now working on making the necessary upstream changes and then adapting Studio accordingly.

Here are the specific changes in this PR:

This PR depends on WordPress/reprint#436 and WordPress/reprint#540 being included in the bundled PHAR. To make things easier for testers, I've simply committed the patched PHAR.

Testing Instructions

  1. npm run cli:build
  2. Create a new site for testing and cd into it
  3. STUDIO_ENABLE_PULL_REPRINT=1 studiodev pull-reprint
  4. Ensure that the file picker displays successfully
  5. Deselect the database and ensure that the sync finishes successfully (and that the site works)
  6. Ensure that a second partial file sync also finishes successfully

Pre-merge Checklist

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

@fredrikekelund
fredrikekelund requested review from a team, gavande1 and gcsecsey August 10, 2026 14:11
@fredrikekelund fredrikekelund self-assigned this Aug 10, 2026
@fredrikekelund fredrikekelund changed the title Reprint: first part of cleanup related to reading Reprint private state pull-reprint: stop touching internal Reprint state directly Aug 10, 2026
Comment thread wp-files/reprint/reprint.phar Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reiterate: I will remove this file before merging. It's here to make testing easier.

@wpmobilebot

wpmobilebot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing b8ef175 vs trunk

app-size

Metric trunk b8ef175 Diff Change
App Size (Mac) 1406.71 MB 1406.77 MB +0.06 MB ⚪ 0.0%

site-editor

Metric trunk b8ef175 Diff Change
load 1054 ms 1029 ms 25 ms ⚪ 0.0%

site-startup

Metric trunk b8ef175 Diff Change
siteCreation 7514 ms 7557 ms +43 ms ⚪ 0.0%
siteStartup 2877 ms 2858 ms 19 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Comment thread apps/cli/lib/pull/reprint-selector.ts
Comment thread apps/cli/commands/pull-reprint.ts Outdated
Comment thread apps/cli/commands/pull-reprint.ts
savePullSelection( session, selection );
return selection;
}
const tree = await fetchJetpackPullTree( wpComAccessToken, wpComSiteId );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the raw-scratch reset removed, how does a pull recover when raw/ is non-empty and no cursor exists? Studio does not pass --on-fs-root-nonempty, so Reprint falls back to error and throws "Filesystem root is not empty and no cursor found". Does the move to state/remotes/<md5(url)>/pull/state.json put existing scratches from older builds into exactly that state?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍

The situation was a little different when this logic was implemented in #3976, but the only realistic situation where we'd get a non-empty fs-root and no cursor today is if the Reprint API URL changes, because that's what generates the state/remotes/<md5(url)> path.

After shipping this project, that won't happen, but it will definitely happen for us engineers working on this before then, because the code flips between the "v1" and "v2" API endpoints based on availability (and we just had to revert the v2 API endpoints in Automattic/jetpack#51179).

In any case: there's no legitimate case to keep this when viewing it from the end user's perspective now. We engineers might have to do some cleanup when the Jetpack API endpoint is reinstated, but that's it.

As for --on-fs-root-nonempty – that's going away when WordPress/reprint#529 lands, so there's no point in starting to pass that.

@fredrikekelund

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @gavande1! Several good feedback items 👍 My work is a bit spread out atm. I'll try to consolidate it, but it may be best to inherit one or two of these issues into another PR.

I've pushed fixes related to the buildTreeFromRemote and downloadSkippedFiles issues. For the former, I refined how we generate the --only paths from the selection, and for the latter, I've actually dropped --filter=essential-files altogether for now. We can revisit this later.

No need to review again just yet. I'll revisit all of this tomorrow

@fredrikekelund

Copy link
Copy Markdown
Contributor Author

@gavande1, I'll go ahead and merge this as I've worked through your initial review and to keep a handle on the number of open work threads around Reprint. Feel free to call out anything that doesn't work as expected, and I'll fold that into #4531

Thanks for staying alert in the review 👍

@fredrikekelund
fredrikekelund merged commit 0b89e74 into trunk Aug 13, 2026
10 of 13 checks passed
@fredrikekelund
fredrikekelund deleted the f26d/pull-reprint-jetpack-remote-file-index-phar branch August 13, 2026 13:34
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.

3 participants