Skip to content

Preserve offline Reader drafts and speed up repeated highlight anchoring - #359

Merged
callumalpass merged 3 commits into
mainfrom
reader-performance-offline-safety-a11y
Nov 28, 2026
Merged

callumalpass merged 3 commits into
mainfrom
reader-performance-offline-safety-a11y

Conversation

@callumalpass

Copy link
Copy Markdown
Member

Summary

  • Preserve article note and annotation comment text acknowledged on-device. A reload keeps the checkpoint while the native write is pending. If reconnect replaces that text, the existing editor presents both versions and waits for an explicit choice.
  • Show the SDK's preserved conflict values and protected edits in the save menu. Keep mutation submission and settlement in the SDK.
  • Match repeated quotations by searching for the full context first, score fallback candidates in one pass, and use binary search for DOM range boundaries.

Chromium benchmark

Chromium 156.0.8078.4 on the same machine, with nine measured runs after one warm-up for each row. Times are milliseconds. P95 uses nearest rank. Base d1bef69dc99d4ec2b8ff3b002e4c2f44fbd0a59d.

Scenario Base median Base p95 PR median PR p95
Startup to virtualized 10,000-row library 883.2 1269.6 899.7 1361.6
Sort 10,000 sources by title 3.1 5.3 3.1 4.0
Filter 10,000 by metadata and tag 2.1 3.4 2.2 3.3
Tag suggestions from 10,000-source library (2,000-source cap) 0.4 0.5 0.3 0.5
Process 10,000 annotation search hits 4.4 6.6 4.8 7.2
Sanitize and lay out 3,000 HTML paragraphs 81.1 93.8 82.7 101.7
Anchor, register and lay out 600 unique highlights 109.2 114.4 119.9 152.1
Anchor, register and lay out 600 repeated highlights 320.5 329.9 120.9 180.3

Repeated-highlight anchoring improved 62% at the median. The unique-highlight result varied between paired runs. An earlier nine-run pair measured 139.0/147.3 ms before and 122.5/134.9 ms after. Library startup includes the local Vite module graph and fixture request. Search timing covers Reader's processing of simulated SDK query pages.

Offline and accessibility evidence

  • A local Chromium test uses Reader's real editor sessions and SDK client with a persistent in-memory replica fixture. It checks an offline reload with a highlight, an annotation comment, a source note, tags, reading status and position. The fixture then refuses pending same-record writes and applies peer versions. The original code replaced both local note texts with the peer versions. This change presents both texts and confirms explicit resolution, including retirement of the checkpoints. The separately created highlight confirms successfully.
  • The fixture supplies the replay outcomes and cached shell. Hosted conflict arbitration, the production service worker and signed-in two-device sync remain outside this run.
  • Axe-core 4.14.0 found zero WCAG AA violations across 28 checks at 360 and 1280 pixels in light and dark. Coverage includes Library, Article, the sanitized article document at its iframe size, Annotations, Add URL and Settings, and the Import landing route.

Reproduction

From the repository root, install dependencies and run the local fixture server in its own terminal.

pnpm install --frozen-lockfile
pnpm --dir apps/reader exec playwright install chromium
pnpm --dir apps/reader exec vite --host 127.0.0.1 --port 5311 --strictPort
node apps/reader/scripts/benchmark-library-article.mjs
node apps/reader/scripts/audit-offline-conflicts.mjs
rpnpm run check
rpnpm run build:production

For the benchmark baseline, copy apps/reader/scripts/benchmark-library-article.mjs and apps/reader/test-fixtures/library-article-benchmark.tsx into an isolated checkout of the base SHA and run the same benchmark there.

For the axe matrix, generate the loopback LAB manifest in the test checkout and start Vite with the matching environment in its own terminal.

MDBASE_READER_ORIGIN=http://127.0.0.1:5312 VITE_MDBASE_ENV=lab pnpm --dir apps/reader manifest
VITE_MDBASE_ENV=lab pnpm --dir apps/reader exec vite --host 127.0.0.1 --port 5312 --strictPort
READER_AUDIT_ORIGIN=http://127.0.0.1:5312 node apps/reader/scripts/audit-reader-accessibility.mjs

@callumalpass
callumalpass enabled auto-merge (squash) November 28, 2026 12:30
@callumalpass
callumalpass merged commit cb7ff1e into main Nov 28, 2026
3 checks passed
@callumalpass
callumalpass deleted the reader-performance-offline-safety-a11y branch November 28, 2026 12:51
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.

1 participant