Skip to content

Backup: Open any backup from the Activity Log's backup links - #53929

Merged
dhasilva merged 12 commits into
trunkfrom
add/backup-overview-open-older-backups
Oct 22, 2026
Merged

dhasilva merged 12 commits into
trunkfrom
add/backup-overview-open-older-backups

Conversation

@RafaelFunchal

@RafaelFunchal RafaelFunchal commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Review of #53755 took the Activity Log's backup links out because the Backup dashboard's Overview could only open a backup on a page it had already loaded: a link to an older backup landed on "That item isn't on this page of the activity log…". This makes the Overview open any backup, then brings the links back.

  • Rewindable activity proxy (/jetpack/v4/site/rewindable-activity): accepts optional after and before (ISO 8601 date-times) and forwards them to WordPress.com. Anything rest_parse_date() can't read is refused with a 400 before any request is made.
  • Overview: when ?selected= names a backup that no loaded or cached page holds, it asks for the few seconds of the log around that backup's rewind id (a backup's "Backup complete" row is stamped with it) and opens the row it finds.
    • The spinner shows while that runs, "We couldn't load this item." if it fails.
    • A backup that really doesn't exist now says "That backup couldn't be found. It may no longer be available." Restore rows and other activity keep their existing messages.
    • Only well-formed rewind ids trigger it, only once the page query has answered, and a found backup's row is never refetched.
    • The lookup reads up to three pages of that window before it says a backup can't be found.
    • Backups that finished with warnings ("N Warnings", notice gridicon) are treated as backups, so they open and restore like any other. Entries named as backups that can't be restored, such as storage-limit failures, stay as other activity.
    • If the lookup itself fails, the error offers Retry. Failures of the list's own pages are still reported only by the list.
  • Activity Log: backup links (the "N Warnings" text on backups with warnings, and the date on "Known threats acknowledged") open that backup in the Overview again, through jetpack_activity_log_backup_url_template, when the modernized Backup dashboard is on. Only well-formed rewind ids are linked; anything else stays plain text.

Related product discussion/links

Part of TSCODE-757.

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • Unit tests: pnpm test and composer test-php in projects/packages/backup and projects/packages/activity-log.
  • On a site with the modernized Backup dashboard and more backups than fit on the Overview's first page:
    1. Open the Activity Log and, on a backup with warnings older than the Overview's first page, click its "N Warnings" link (or the date on a "Known threats acknowledged" entry). The Overview opens with that backup selected and its details shown.
    2. Open the Overview with ?selected= set to a made-up rewind id (e.g. 1000000000). It says the backup couldn't be found and offers Clear selection.
    3. Click the "N Warnings" link on a recent backup with warnings. It opens as before, with no extra request.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/backup-overview-open-older-backups branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/backup-overview-open-older-backups

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Backup plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 8 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/activity-log/src/class-initial-state.php 56/57 (98.25%) 0.03% 0 💚
projects/packages/backup/src/class-jetpack-backup.php 462/528 (87.50%) 0.10% 0 💚
projects/packages/backup/src/dashboard/data/normalize/activity-log.ts 12/12 (100.00%) 0.00% 0 💚
projects/packages/backup/src/dashboard/data/query-client.ts 29/29 (100.00%) 0.00% 0 💚
projects/packages/backup/src/dashboard/hooks/use-activity-log.ts 88/88 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

@RafaelFunchal
RafaelFunchal marked this pull request as ready for review October 21, 2026 14:05
@RafaelFunchal RafaelFunchal added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 21, 2026
@dhasilva

Copy link
Copy Markdown
Contributor

@RafaelFunchal I pushed four review fixes to #53755 (067a167), which left this branch behind the PR below it and blocked the stack. I merged #53755 in here (19d8e3a) the way you did in 83e59b8: a merge commit and a normal push, no rebase or force-push.

It merged cleanly, since the two PRs share no files, and the combined tree passes the packages/backup JS tests (1100) and the packages/activity-log JS tests (8).

Generated by Claude.

Base automatically changed from add/known-threats-plugin-restore to trunk October 22, 2026 16:00
@dhasilva
dhasilva requested a review from a team as a code owner October 22, 2026 16:00
RafaelFunchal and others added 6 commits October 22, 2026 13:00
Accept optional `after` and `before` ISO 8601 date-times on the
rewindable-activity route and pass them to WordPress.com, so the Overview
can fetch one backup that isn't on any page it has loaded. Anything else
is refused with a 400 before a request goes out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
The Overview resolved `?selected=` only against the activity pages it had
loaded, so a link to an older backup landed on "That item isn't on this
page". When the loaded pages answer without a backup id, ask the log for
the few seconds around its rewind id, and only report it missing when that
comes back empty too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
Bring back the jetpack_activity_log_backup_url_template filter, its
initial-state field, and the link a backup range renders when it is set.
The Backup dashboard's Overview can now open any backup, not just one on
a page it has loaded. Only well-formed rewind ids are linked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
Answer jetpack_activity_log_backup_url_template with the Overview URL and
the backup selected, when the modernized dashboard is on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5F1MsbPHYHzXLzuK4rCES
@dhasilva
dhasilva force-pushed the add/backup-overview-open-older-backups branch from 19d8e3a to 2882e45 Compare October 22, 2026 16:00
@dhasilva

Copy link
Copy Markdown
Contributor

Review at 2882e45

@RafaelFunchal no blockers. This closes the gap that made #53755 drop the backup links, and the tests cover it well. A few points, two of them worth your call:

Findings

  1. [suggestion] The lookup's page loop has no cap. use-activity-log.ts#L299-L309

    • fetchActivityAroundBackup() keeps fetching until it finds the backup or reaches totalPages. That's safe only while WordPress.com applies the after/before window.
    • It doesn't always. On WordPress.com, the rewindable activity endpoint honours those bounds only for sites with the full activity log. Other sites get the default range back, 20 rows a page, and a made-up ?selected= id would page through all of it, one request at a time.
    • Every Backup plan includes the full activity log, so the Overview's real audience gets the 3-second window, which is why this isn't a blocker. A window that narrow should fit on one page, though, so stopping after two or three pages and treating that as "not found" would be a cheap guard.
  2. [suggestion] There's a one-request alternative. GET /sites/{id}/activity/{rewind_id} returns the single activity for a rewind id, or a 404 when there's none. It also covers backups that exist only in VaultPress. Calypso's restore flow uses it to look up a rewind point.

    • It would replace the window, the ascending sort and the loop.
    • It needs a new proxy route in the Backup package, so it's a bigger change than extending the existing one. An option to weigh, not a requirement.
  3. [question] Can a backup token in the Activity Log name a restore point that isn't a backup row?

    • findById() matches backup rows by rewindId and every other row by activity_id.
    • So if a token carries the rewind id of, say, a post update, the Overview would search, match nothing, and say "That backup couldn't be found" about a point that exists. That could happen on a real-time backup site, or for "Known threats acknowledged" on a restore started elsewhere.
    • I couldn't confirm this either way without live data; your test site would show it. The endpoint in item 2 returns the activity whatever its kind, which would also settle this.
  4. [suggestion] The description still says "Stacked on Backup: warn about known threats before restoring a backup #53755. Merge that one first."

Checked, no issues

  • Security:
    • after/before use format: date-time, so anything rest_parse_date() can't read gets a 400 before WordPress.com is called. Nulls and empty strings are dropped.
    • http_build_query encodes the values, so a +00:00 offset arrives intact; test_forwards_a_time_window proves the round trip.
    • Activity Log links only use ids matching ^\d+(\.\d+)?$, and the URL template is gated on is_modernized(), like the restore template.
  • Error handling: a failed lookup gets its own Retry and is announced, while failures of the list's own pages stay with the list. Both are tested.
  • Cache: the lookup has its own cache key, and a found backup is never refetched.
  • Comments, Phan, ESLint: no over-budget comments, no Phan suppressions or baseline growth, and ESLint is clean on the changed TS files.
  • Hooks: the new jetpack_activity_log_backup_url_template filter is additive and documented.
  • Changelog: the entries for both packages and both plugins are present and read well.

Test results at 2882e45

  • PHP: packages/backup 497 OK, packages/activity-log 32 OK.
  • JS: packages/backup 1100 passed, packages/activity-log 8 passed.
  • Phan and typecheck: clean for both packages.

The tests are good:

  • The hook tests cover found and not-found across several pages, and the exact window sent.
  • The stale-selection suite covers opening a backup without paging, the lookup's retry, and other ids staying hedged.
  • The back-stack test now removes the backup to reach "not found". That's correct, since a backup that merely moved to page 2 is now found.

Verdict

Minor issues, can merge after addressing. Items 1 and 3 are the ones worth a look: a page cap is a small change, and the answer to 3 decides whether 2 is worth a new route.

Generated by Claude.

WordPress.com only honours the lookup's few-second window on sites with the
full activity log. Elsewhere it returns the whole log, and an id that isn't
there would be paged through one request at a time. Treat three pages as
"not found".
@RafaelFunchal

Copy link
Copy Markdown
Contributor Author

@dhasilva Thanks for the review and for merging #53755 in here. On your items:

  1. Page cap: done in 6119411. The lookup stops after three pages and treats that as "not found". A new test covers a window WordPress.com ignores (50 pages), and the page requests stop at 1, 2, 3.

  2. One-request endpoint: not needed, given the answer to 3.

  3. Backup links to a restore point that isn't a backup: yes, it could happen, but only through the new "Known threats acknowledged" entry. Backup links come from <backup rewind_id="…"> tags in the WordPress.com Activity Log text. Only two entries write one:

    • "Backup complete" uses its own rewind id, so it always opens a backup.
    • "Known threats acknowledged" used the restore point, which can be any rewindable event.

    That's fixed on the WordPress.com side. When the entry is recorded, it now looks up the backup the restore point belongs to: the newest backup at or before it, as VaultPress picks it. The link uses that backup's own rewind id, and without one the date is plain text. So every backup link this PR renders opens a backup row. My test site couldn't show the case live: none of its last 998 entries carries a backup tag.

  4. Description: the "Stacked on Backup: warn about known threats before restoring a backup #53755" line is gone.

Checked: packages/backup JS tests pass (1101), typecheck is clean, and ESLint is clean on the changed files.

@dhasilva

Copy link
Copy Markdown
Contributor

Re-review at a35e72a

@RafaelFunchal thanks. Items 1, 2 and 4 are settled. Checking item 3 turned up a blocker, though not where I was looking.

  1. Page cap: confirmed in 6119411, and the new test covers it.
  2. One-request endpoint: agreed, not needed.
  3. [blocker] Backup links: you're right that only two entries write a backup range, and that "Backup complete" uses its own rewind id. But that range only exists on backups with warnings, as the "N Warnings" text. In the same branch, WordPress.com switches the row's gridicon from cloud to notice.
    • The Overview decides what's a backup by gridicon alone (GRIDICON_TO_KIND). A backup with warnings therefore comes through as an other row, and findById() matches it by activity_id, never by the rewind id the link carries.
    • So every link a "Backup complete" entry renders ends at "That backup couldn't be found". That includes the newest backup on page 1, after a lookup whose window also holds the row. A probe against useActivityById finds the same page-1 row with gridicon cloud and returns null with notice.
    • That's also why your site showed no backup ranges: none of its backups had warnings. The fixtures here model every backup as cloud, so the tests can't see it.
    • Fix: also classify backups by name, using the check the Activity Log's badge already uses (/^rewind__backup(_only)?_complete/). That also makes backups with warnings restorable from the Overview, which they aren't today. Storage-limit failures share those names and send notice with is_rewindable: false, so they'd become backup rows that can't be restored. Worth a look.
    • Test: one row with gridicon: 'notice' in the stale-selection suite, as an it.each case.
  4. Description: two lines are now out of date.
    • The lookup no longer goes through every page of the window. It stops after three.
    • Testing steps 1 and 3 say "click the date on a backup". On "Backup complete" entries the link is the "N Warnings" text, and only on backups with warnings. The date is linked only on "Known threats acknowledged".

On the WordPress.com side, the backup lookup ships in the same PR that adds the "Known threats acknowledged" entry (251132-ghe-Automattic/wpcom). No entry can link a bare restore point, whatever order the two land in. I'll leave one note there, about the rewind id the lookup returns for a site's first backup.

Tests at a35e72a: packages/backup 1101 passed, packages/activity-log 8 passed. CI is green.

Verdict: needs changes before merge, for item 3.

Generated by Claude.

Backups with warnings use the notice gridicon, so the Overview classified
them as other and their links failed. Classify by the rewind__backup
complete names as well, keeping entries that cannot be restored as other.
@RafaelFunchal

Copy link
Copy Markdown
Contributor Author

@dhasilva Both items are addressed in 07e4c21.

3. Backups with warnings: the Overview now treats an entry as a backup when its gridicon is cloud or its name matches rewind__backup(_only)?_complete and it isn't marked is_rewindable: false. Backups with warnings (notice) open and restore, and their "N Warnings" links work. Storage-limit failures share the name and gridicon but can't be restored, so they stay other.

  • Tests: two normalizer cases (a warnings backup maps to backup; a non-rewindable backup-named entry stays other), and the stale-selection test now runs it.each( [ 'cloud', 'notice' ] ). The Overview takeover fixture gave every cloud entry a post name, so it now uses rewind__backup_complete_full.
  • Added a fixed changelog entry.

4. Description: it now says the lookup reads up to three pages. Testing steps 1 and 3 use the "N Warnings" link (or the date on "Known threats acknowledged"), and the Activity Log bullet says which links exist.

dhasilva
dhasilva previously approved these changes Oct 22, 2026

@dhasilva dhasilva left a comment

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.

Re-review at 07e4c21

@RafaelFunchal thanks, the blocker is fixed. Treating a backup-named entry as a backup unless it's is_rewindable: false matches WordPress.com. The server gives every non-rewindable backup the "Backup failed - Retention or storage limit reached." summary and the notice gridicon, so a cloud row is always rewindable, and the name check adds only backups with warnings. With the normalizer change reverted, both new tests fail. The description now matches the links that exist.

Two small things, neither blocking:

  1. [suggestion] Changelog wording. The plugins/backup, plugins/jetpack and packages/activity-log entries still say "Link backup dates". On backup entries the link is the "N Warnings" text, so "backup links" would be accurate. The warnings fix also shows up in both plugins, since those backups can now be opened and restored from the dashboard, but only packages/backup has an entry for it. It could fold into the two plugin entries you already have.
  2. [suggestion] Test comments. "WPCOM sends notice instead of cloud…" appears in two test files, and "Storage-limit failures share the backup names…" in a third. The docblock in normalize/activity-log.ts already covers both, and the test names say the rest, so those test comments can go.

Tests at 07e4c21: packages/backup 1104 passed, packages/activity-log 8 passed. CI is green.

Verdict: approving. The changelog wording is worth fixing before merge.

Generated by Claude.

@RafaelFunchal

Copy link
Copy Markdown
Contributor Author

@dhasilva Both suggestions are in:

  • 4a8d37e: the packages/activity-log, plugins/backup and plugins/jetpack entries now say "backup links", and both plugin entries mention that backups with warnings can now be opened and restored.
  • d204e56: dropped the three test comments. The normalizer docblock covers them.

@dhasilva dhasilva left a comment

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.

LGTM

@dhasilva
dhasilva merged commit 86d96d1 into trunk Oct 22, 2026
124 checks passed
@dhasilva
dhasilva deleted the add/backup-overview-open-older-backups branch October 22, 2026 21:21
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Activity Log [Package] Backup [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants