Skip to content

Download history again when a device loses it but keeps its cursor (6.9.1) - #18

Merged
jitdor merged 1 commit into
mainfrom
ccr-c9f4e623-e1og9s
Sep 28, 2026
Merged

jitdor merged 1 commit into
mainfrom
ccr-c9f4e623-e1og9s

Conversation

@jitdor

@jitdor jitdor commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Problem

The visited history and the sync bookmark (cursor, in javstore_sync_config_v1) are stored under separate keys. When a userscript manager lost only the history, the device kept asking the worker for rows after its cursor, so the history it lost was never sent back. Seen in practice: 5 visits on the device and 435 on the worker, with the panel showing "synced just now".

Fix

  • The stored history now carries a historyId. The sync config records the ID its cursor belongs to.
  • A sync that finds no matching ID pulls from cursor 0. That covers a wiped or unreadable history, a history saved by an older version, and a history that has recorded new visits since the loss. It shows "Restored N visited URLs from the worker."
  • A new ID is persisted to storage before the config records it, the same ordering already used for the cursor.
  • The ID is only adopted from local storage, never from the worker. Storage wins over a tab's memory, so a stale tab cannot write the history back without it.
  • Devices updating from 6.9.0 download everything once.

The worker code is unchanged; WORKER_VERSION moves with the script because a test requires them to match.

Tests

Three new sync tests, all failing on the old script and passing now: a lost history with its cursor kept, a visit recorded after the loss, and a device synced by an older version (full download once, then deltas). Full suite: 75/75 passing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BGAYvSDCqQt1R7AerUwSeT


Generated by Claude Code

….9.1)

The sync cursor and the visited history live under separate storage keys.
When a userscript manager lost only the history, the device kept asking the
worker for rows after its cursor and never got the lost ones back. The
history now carries an id that the sync config records alongside the
cursor; a history without the matching id pulls from cursor 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BGAYvSDCqQt1R7AerUwSeT
@jitdor
jitdor merged commit 44e502f into main Sep 28, 2026
2 of 3 checks passed
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