Skip to content

Commit f555864

Browse files
committed
Share cloud sync across browsing tabs and batch visit uploads
1 parent 3c6d7d7 commit f555864

6 files changed

Lines changed: 392 additions & 25 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 6.11.0
4+
5+
- Share initial cloud sync across a browsing session: page navigation and new tabs reuse locally stored history instead of starting another download. Sessions expire after 30 minutes without startup/sync activity; a new session resumes from the durable cursor.
6+
- Batch uploads from rapid context-menu browsing, including bursts of 50 tabs. Keep recording every item-page visit while suppressing redundant upload, focus, and periodic requests.
7+
- Read current shared sync progress before each exchange, coordinate tabs with Web Locks (or an expiring storage lease), and serialize sync settings changes with progress writes.
8+
- Verify saved sync progress and history identity before marking recovery complete. Failed/incomplete downloads and actual history loss remain recoverable.
9+
- Add regression coverage for network request counts, downloaded rows, concurrent tabs, session expiry, and failed storage writes. Document session and batching behavior.
10+
- The worker version moves to 6.11.0 with the userscript; the worker protocol is unchanged.
11+
312
## 6.10.2
413

514
- Performance: paint visited markers and keyword tinting as soon as the local working copy is read, without waiting for sync configuration, recovery journals, or DOMContentLoaded. Observe newly inserted tiles during page loading too.

‎README.md‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@ Userscript-manager storage is local to one device and AdGuard has been known to
3232

3333
Once it is deployed, open the `JVS` panel → **Cloud sync**, enter the worker URL and the access token you generated, tick the box, and save. Repeat on every device with the same URL and token.
3434

35-
- Each device syncs on page load, when its tab regains focus, a few seconds after a visit, on the interval you choose, and whenever you press **Sync now**. The panel's status line reports the last sync or the reason the last one failed.
36-
- Devices exchange only what changed: each remembers the sequence number it last saw and the moment it last pushed, so an idle page load costs about 150 bytes each way rather than the whole history. The first sync on a device transfers everything, and so does the next sync on a device whose userscript manager lost its history but kept the sync settings: the history carries an id that the saved position is tied to, so a history without it is downloaded again rather than left behind.
37-
- Tabs on one device share a history but not a sync. Before deciding what to send, a sync merges what the device has on disk, so a visit recorded in one tab is not passed over by another tab's sync; and an entry that turns up stamped before the last push—a click replayed from the previous page, a restored backup—pulls the mark back to itself rather than being left behind it.
35+
- The first page in a browsing session checks the worker; later pages and new tabs immediately use the shared local history. A session is shared across tabs and expires after 30 minutes without startup/sync activity. Starting another session checks for new changes using the saved cursor; it does not download the entire history again.
36+
- Opening 30–50 item tabs from the context menu still records every visit when its item page loads. Uploads wait a few seconds and collect visits from all tabs; tabs whose changes were already uploaded skip their redundant requests. Advancing the listing to page 2 does not restart restoration.
37+
- **Sync now** always checks the worker. Focus refreshes and the configured periodic refresh use shared progress, so tabs do not independently download the same changes. Hidden tabs skip periodic refreshes, but their new visits can still upload. The panel's status line reports the last sync or the reason the last one failed.
38+
- Devices exchange only what changed: each remembers the sequence number it last saw and the moment it last pushed, so incremental checks exchange only new rows, and an ordinary page load during an active session needs no cloud request. The first sync on a device transfers everything, and so does the next sync on a device whose userscript manager lost its history but kept the sync settings: the history carries an id that the saved position is tied to, so a history without it is downloaded again rather than left behind.
39+
- Tabs on one device share history, a sync cursor, and session progress. Before deciding what to send, a sync merges what the device has on disk, so a visit recorded in one tab is not passed over by another tab's sync; and an entry that turns up stamped before the last push—a click replayed from the previous page, a restored backup—pulls the mark back to itself rather than being left behind it.
3840
- The worker applies the same rules as the local merge—newest timestamp wins per URL—so a device that has been offline for a week cannot overwrite what the others recorded. A device that pushes a stale entry is handed the winning one back.
3941
- No device can delete visited history from the worker. **Clear visited history**, retention pruning, unmarking a card and a backup import that leaves entries out all apply to the device they happen on; the worker and the other devices keep their copies. The worker drops only its oldest visits beyond 50,000, to bound its storage. Per-card overrides are choices rather than history, so removing one still reaches every device.
4042
- Because a Durable Object is single-threaded, each sync's read-merge-write is serialized and strongly consistent: two devices syncing in the same second queue behind one another rather than racing.
4143
- Settings sync too, including the match and excluded terms, and they merge setting by setting: each one goes to the device that changed it last. A setting a device has never changed carries no timestamp and cannot win, so a new install picks up your keywords from the worker instead of pushing its defaults over them, even if you changed something else on it first. **Restore defaults** and a backup import set every setting on purpose, so they win everywhere.
4244
- The Cloud sync panel shows the worker version from the worker's last answer. When the worker is behind the userscript, a **⚠ Redeploy worker** button appears on screen next to the JavStore controls; tap it for the versions. The worker redeploys through Cloudflare whenever `main` changes, so a lasting warning means its Cloudflare build did not go through. When the worker is ahead instead, an **⚠ Update script** button appears on screen and links to the latest release, because the userscript manager has not installed it yet.
4345
- AdGuard for Android clears a userscript's storage whenever it installs an update. After setting sync up, press **Copy sync link** and keep the link somewhere private, such as a password manager. After a wipe, open it on JavStore, or paste it into the endpoint box and save, to set everything up again. The link carries your token, so treat it like a password.
4446
- The endpoint and token live only on the device they were entered on. They are never written into the synced document, never appear in an exported backup, and are not left in the page: the token box stays empty once a token is stored and only reports that one exists.
45-
- A worker that is unreachable does not affect anything locally: history is still saved to the userscript manager, and the next sync picks it up.
47+
- A worker that is unreachable does not affect anything locally: history is still saved to the userscript manager, and the next sync picks it up. Failed or incomplete restoration is not marked complete. If local history is actually lost, recovery bypasses the session marker and downloads it again; **Restored … visited URLs** reports that recovery, not ordinary page navigation.
48+
- Current browsers coordinate cloud work with Web Locks. Browsers without that API use a userscript-storage lease with expiry and ownership checks, so a tab that disappears cannot hold sync indefinitely. Session/progress metadata stays in userscript-manager storage; credentials and history are not placed in page `localStorage`.
4649
- **Sync now** reports both directions—what went up and what came down—so a device that is failing to push is not mistaken for one with nothing to push.
4750
- Restoring a backup keeps the backup's own timestamps, so the restored entries reach the worker and the other devices instead of being discarded by them. Entries the backup leaves out are dropped on the importing device only. Entries a history clear on this device already covers cannot be restored, and the panel says how many were skipped.
4851

@@ -72,4 +75,6 @@ The distributable is [`javstore-full-layout-cleanup.user.js`](./javstore-full-la
7275

7376
Releases publish themselves: a push to `main` whose `@version` header names a version with no release yet runs the tests and publishes that release, which is what `@updateURL`/`@downloadURL` point at. A push that does not bump the header is a no-op, so releasing a change means bumping `@version` and `SCRIPT_VERSION` and adding the matching `## <version>` section to `CHANGELOG.md` in the same pull request. The workflow can still be run manually to release from a branch.
7477

75-
`npm install && npm test` runs the storage-persistence and cloud-sync suites. Both load the userscript into jsdom windows that share one asynchronous value store with no change notifications—an AdGuard-shaped engine—and assert that history survives reloads, concurrent tabs, interrupted saves, and explicit removals. The store can be given random per-call latency, which is how the suite reproduces several tabs' saves overlapping on a slow engine. The sync suite additionally runs the real worker from [`worker/src/worker.mjs`](./worker/src/worker.mjs): its Durable Object class executes against a `node:sqlite` database standing in for `ctx.storage.sql`, with each jsdom window acting as a separate device, so both halves of a sync are covered against real SQL.
78+
`npm install && npm test` runs the link, startup, storage-persistence, and cloud-sync suites (a current Node.js 22 or newer with `node:sqlite`; CI uses Node.js 22). The suites load the userscript into jsdom windows that share one asynchronous value store with no change notifications—an AdGuard-shaped engine—and assert that history survives reloads, concurrent tabs, interrupted saves, and explicit removals. The store can be given random per-call latency, which is how the suite reproduces several tabs' saves overlapping on a slow engine. The sync suite additionally runs the real worker from [`worker/src/worker.mjs`](./worker/src/worker.mjs): its Durable Object class executes against a `node:sqlite` database standing in for `ctx.storage.sql`, with each jsdom window acting as a separate device, so both halves of a sync are covered against real SQL.
79+
80+
Session regression tests assert request counts and downloaded rows across navigation, concurrent first tabs, a 50-tab context-menu burst, session expiry, stale tab cursors, failed progress writes, and actual history loss.

0 commit comments

Comments
 (0)