diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 198d5ba4..7d14055d 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -31,7 +31,7 @@ Counts include settings exposure as separate rows; they are not feature quality |---|---|---|---|---| | Catalog lists, search and detail through the BookOrbit integration | ✅ (v0.11.3-rc.17) Cached catalog adapter. [android/koreader/orbit.koplugin/ko/cache.lua:24](../android/koreader/orbit.koplugin/ko/cache.lua#L24) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Catalog cache and facet queries. [xteink/orbify/CatalogRefresh.inc:31](../xteink/orbify/CatalogRefresh.inc#L31) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Catalog cache and facet queries. [xteink/orbify/CatalogRefresh.inc:31](../xteink/orbify/CatalogRefresh.inc#L31) | 🟡 Online catalog; no BookSync offline cache; **hardware: cache uses PSRAM; X3 flash cuts**. [xteink/tailnet/tailnet_build.py:292](../xteink/tailnet/tailnet_build.py#L292) | | Group every catalog list by series or author | ✅ (v0.11.3-rc.17) Series/author chips and grouped rows. [android/koreader/orbit.koplugin/ko/grouping.lua:40](../android/koreader/orbit.koplugin/ko/grouping.lua#L40) | ❌ Facet lists exist; no group-every-list control; **deliberately deferred: ROADMAP Next 6a**. [xteink/overlay/patches/v2.0/0054-orbify-bulk-catalog.patch:6](../xteink/overlay/patches/v2.0/0054-orbify-bulk-catalog.patch#L6) | ❌ Facet lists exist; no group-every-list control; **deliberately deferred: ROADMAP Next 6a**. [xteink/overlay/patches/v2.0/0054-orbify-bulk-catalog.patch:6](../xteink/overlay/patches/v2.0/0054-orbify-bulk-catalog.patch#L6) | ❌ No grouping control; **hardware: current cached implementation excluded on X3; ROADMAP Next 6a**. [xteink/tailnet/tailnet_build.py:292](../xteink/tailnet/tailnet_build.py#L292) | -| Offline catalog pages and retained book details | ✅ (v0.11.3-rc.17) SQLite cache via companion; local window queries. [android/companion/app/src/main/java/net/fledgewing/orbitcompanion/CacheStore.kt:15](../android/companion/app/src/main/java/net/fledgewing/orbitcompanion/CacheStore.kt#L15) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Ranked SD rows serve every refreshed list window without Wi-Fi, independent of source page size. [xteink/orbify/CacheStore.cpp:396](../xteink/orbify/CacheStore.cpp#L396) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Ranked SD rows serve every refreshed list window without Wi-Fi, independent of source page size. [xteink/orbify/CacheStore.cpp:396](../xteink/orbify/CacheStore.cpp#L396) | ❌ Online catalog; no refreshed SD windows; **hardware: X3 flash gate; no PSRAM**. [xteink/tailnet/tailnet_build.py:292](../xteink/tailnet/tailnet_build.py#L292) | +| Offline catalog pages and retained book details | ✅ (v0.11.3-rc.17) SQLite cache via companion; local window queries serve cached pages immediately. [android/companion/app/src/main/java/net/fledgewing/orbitcompanion/CacheStore.kt:15](../android/companion/app/src/main/java/net/fledgewing/orbitcompanion/CacheStore.kt#L15) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Ranked SD rows serve every refreshed list window without Wi-Fi or Loading screens, independent of source page size. [xteink/orbify/CacheStore.cpp:396](../xteink/orbify/CacheStore.cpp#L396), [xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch:7](../xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch#L7) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Ranked SD rows serve every refreshed list window without Wi-Fi or Loading screens, independent of source page size. [xteink/orbify/CacheStore.cpp:396](../xteink/orbify/CacheStore.cpp#L396), [xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch:7](../xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch#L7) | ❌ Online catalog; no refreshed SD windows or BookSync offline paging; **hardware: X3 flash gate; no PSRAM**. [xteink/tailnet/tailnet_build.py:292](../xteink/tailnet/tailnet_build.py#L292) | | Explicit resumable Full refresh; monotone percentage | ✅ (v0.11.3-rc.17) Refresh tap always refreshes normally; hold offers Full refresh; companion owns queued/active progress and completion stamps without timer-only failure; explicit resumes show immediate startup feedback, missing acknowledgements warn once, and liveness queries back off; Full refresh joins an active incremental bulk run and displays its progress. [android/companion/app/src/main/java/net/fledgewing/orbitcompanion/Worker.kt:60](../android/companion/app/src/main/java/net/fledgewing/orbitcompanion/Worker.kt#L60) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Refreshed SD lists serve browser windows offline; live list, book and cover counts; finish-time BookSync stamp; runs in firmware without an Android companion or companion acknowledgement path. [xteink/orbify/RefreshRunner.cpp:32](../xteink/orbify/RefreshRunner.cpp#L32) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Refreshed SD lists serve browser windows offline; live list, book and cover counts; finish-time BookSync stamp; runs in firmware without an Android companion or companion acknowledgement path. [xteink/orbify/RefreshRunner.cpp:32](../xteink/orbify/RefreshRunner.cpp#L32) | ❌ X3 flash gate; no PSRAM; **hardware: X3 flash gate and no PSRAM exclude the bulk catalog worker and its progress counts; Home sync keeps its finish-time stamp; Android companion acknowledgement and startup-repair recovery do not apply to firmware**. [xteink/tailnet/tailnet_build.py:295](../xteink/tailnet/tailnet_build.py#L295) | | Bulk manifest, derived lists and batched state reconciliation | ✅ (v0.11.3-rc.17) Bulk catalog plan. [android/companion/app/src/main/java/net/fledgewing/orbitcompanion/BulkWork.kt:10](../android/companion/app/src/main/java/net/fledgewing/orbitcompanion/BulkWork.kt#L10) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Bulk catalog derived author/series lists. [xteink/orbify/BulkCatalog.cpp:22](../xteink/orbify/BulkCatalog.cpp#L22) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Bulk catalog derived author/series lists. [xteink/orbify/BulkCatalog.cpp:22](../xteink/orbify/BulkCatalog.cpp#L22) | ❌ X3 flash gate; no PSRAM; **hardware: X3 flash gate; no PSRAM**. [xteink/tailnet/tailnet_build.py:295](../xteink/tailnet/tailnet_build.py#L295) | | Refresh continues away from the catalog; foreground remains usable | ✅ (v0.11.3-rc.17) Companion worker. [android/companion/app/src/main/java/net/fledgewing/orbitcompanion/Worker.kt:17](../android/companion/app/src/main/java/net/fledgewing/orbitcompanion/Worker.kt#L17) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Separate refresh task. [xteink/orbify/RefreshRunner.cpp:38](../xteink/orbify/RefreshRunner.cpp#L38) | ✅ (xteink-v2.0.0.373+bookorbit.1-rc3) Separate refresh task. [xteink/orbify/RefreshRunner.cpp:38](../xteink/orbify/RefreshRunner.cpp#L38) | ❌ X3 flash gate; no PSRAM; **hardware: X3 flash gate; no PSRAM**. [xteink/tailnet/tailnet_build.py:295](../xteink/tailnet/tailnet_build.py#L295) | diff --git a/docs/design/emulated-release-tests.md b/docs/design/emulated-release-tests.md index 018ff644..059df920 100644 --- a/docs/design/emulated-release-tests.md +++ b/docs/design/emulated-release-tests.md @@ -491,3 +491,25 @@ series-card cover fetch and no lent connection, so it runs the three that apply | `catalog_refresh_stamp` | catalog refresh stamp (screenshot) | X4 Pro | | `catalog_cache_first` | cache-first catalog | X4 Pro | | `menu_home_swipe` | menu Home swipe | X4 Pro | + +### Offline catalog paging regression + +`offline_cached_list_no_loading` (X4 Pro) saves 245 synthetic books through an ordinary +Home refresh, using its real 100-row write-through replies, with no bulk generation. +It removes saved Wi-Fi credentials and makes 64 forward/backward swipes through the +saved list with compact rows; `home_refresh_completion_stamp` also checks the default +sectioned layout. Every swipe must complete, including the actual simulator list paint, in +less than 250 ms; no blocking catalog paint, HTTP request or Wi-Fi join is allowed +once the listing opens. The simulator logs blocking paints directly from `render()`, +so a transient Loading screen cannot hide between screenshots. + +The session-list cache previously missed these refreshed sources and caused the +browser to paint Loading before the catalog client consulted the write-through cache. +At CrossInk `87e2e1984481e8a3d996f12b34b50a383f9013b8`, the session-only probe is +[`src/activities/browser/BookOrbitCatalogListCache.cpp:223`](https://github.com/agosez/CrossInk-Bookorbit/blob/87e2e1984481e8a3d996f12b34b50a383f9013b8/src/activities/browser/BookOrbitCatalogListCache.cpp#L223) +and the premature Loading call is +[`src/activities/browser/BookOrbitCatalogBrowserActivity.cpp:931`](https://github.com/agosez/CrossInk-Bookorbit/blob/87e2e1984481e8a3d996f12b34b50a383f9013b8/src/activities/browser/BookOrbitCatalogBrowserActivity.cpp#L931). +Patch 0059 makes the list-cache probe use that client's SD adapters with network access +explicitly disabled. The existing two-page row window stays bounded. X4 Classic uses +the same cache path; X3 has no BookSync offline mirror. Hardware SD latency and e-ink +refresh duration still need a real-reader check. diff --git a/shared/features.json b/shared/features.json index 55712d7e..882d073b 100644 --- a/shared/features.json +++ b/shared/features.json @@ -142,7 +142,7 @@ "platforms": { "android": { "status": "supported", - "note": "SQLite cache via companion; local window queries", + "note": "SQLite cache via companion; local window queries serve cached pages immediately", "reason": null, "evidence": [ { @@ -154,31 +154,39 @@ }, "x4_pro": { "status": "supported", - "note": "Ranked SD rows serve every refreshed list window without Wi-Fi, independent of source page size", + "note": "Ranked SD rows serve every refreshed list window without Wi-Fi or Loading screens, independent of source page size", "reason": null, "evidence": [ { "path": "xteink/orbify/CacheStore.cpp", "line": 396 + }, + { + "path": "xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch", + "line": 7 } ], "version": "xteink-v2.0.0.373+bookorbit.1-rc3" }, "x4": { "status": "supported", - "note": "Ranked SD rows serve every refreshed list window without Wi-Fi, independent of source page size", + "note": "Ranked SD rows serve every refreshed list window without Wi-Fi or Loading screens, independent of source page size", "reason": null, "evidence": [ { "path": "xteink/orbify/CacheStore.cpp", "line": 396 + }, + { + "path": "xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch", + "line": 7 } ], "version": "xteink-v2.0.0.373+bookorbit.1-rc3" }, "x3": { "status": "missing", - "note": "Online catalog; no refreshed SD windows", + "note": "Online catalog; no refreshed SD windows or BookSync offline paging", "reason": "hardware: X3 flash gate; no PSRAM", "evidence": [ { diff --git a/xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch b/xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch new file mode 100644 index 00000000..8e47e468 --- /dev/null +++ b/xteink/overlay/patches/v2.0/0059-offline-catalog-paging.patch @@ -0,0 +1,181 @@ +Subject: [PATCH] BookSync: consult every SD cache before a blocking catalog fetch + +Ordinary refresh saves 100-row replies, not session-list pages. Resolve those +locally before the browser decides it needs a Loading screen. Cache probes +never enter HTTP, including when the radio is already connected. + +diff --git a/src/activities/browser/BookOrbitCatalogBrowserActivity.cpp b/src/activities/browser/BookOrbitCatalogBrowserActivity.cpp +--- a/src/activities/browser/BookOrbitCatalogBrowserActivity.cpp ++++ b/src/activities/browser/BookOrbitCatalogBrowserActivity.cpp +@@ -2332,6 +2332,9 @@ + // so a finger can walk a long listing the way the buttons already do. + const auto swipe = mappedInput.wasSwipe(); + if (swipe == MappedInputManager::SwipeDir::Up || swipe == MappedInputManager::SwipeDir::Down) { ++#ifdef SIMULATOR ++ const unsigned long pageTurnBegan = millis(); ++#endif + if (swipe == MappedInputManager::SwipeDir::Up) { + const int wantedCount = topIndex + 2 * visibleRows; + while (loadedEnd() < wantedCount && hasMorePages()) { +@@ -2345,6 +2348,12 @@ + topIndex = scrollListBy(topIndex, delta, visibleRows, loadedEnd()); + if (!revealRow(topIndex)) topIndex = windowStart; + if (topIndex != previousTop) requestUpdate(); ++#ifdef SIMULATOR ++ // Wait for the actual list paint, so the budget includes rendering as well as SD reads. ++ requestUpdateAndWait(); ++ LOG_INF("BookOrbit", "Catalog page turn: from=%d to=%d elapsedMs=%lu", previousTop, topIndex, ++ millis() - pageTurnBegan); ++#endif + return; + } + // Prefetch at the page turn: after a forward move onto the last loaded +@@ -2623,6 +2632,9 @@ + // WIFI_SELECTION: the Wi-Fi screen is only pushed on the next loop, and a network + // boot paints the catalog before that, with no listing loaded yet. + if (state == BrowserState::CHECK_WIFI || state == BrowserState::LOADING || state == BrowserState::WIFI_SELECTION) { ++#ifdef SIMULATOR ++ LOG_INF("BookOrbit", "Catalog blocking paint: %s", statusMessage.c_str()); ++#endif + renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2, statusMessage.c_str()); + const auto labels = mappedInput.mapLabels(tr(STR_BACK), "", "", ""); + GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4); +diff --git a/src/activities/browser/BookOrbitCatalogListCache.cpp b/src/activities/browser/BookOrbitCatalogListCache.cpp +--- a/src/activities/browser/BookOrbitCatalogListCache.cpp ++++ b/src/activities/browser/BookOrbitCatalogListCache.cpp +@@ -197,10 +197,16 @@ + + bool loadFacetPage(const std::string& sectionId, const int page, BookOrbitFacetPage& outPage) { + #if CROSSINK_TAILNET_ORBIFY_MIRROR +- if(OrbifyBulk::active()) return BookOrbitCatalogClient::fetchSectionEntries(sectionId,page,outPage); ++ if(OrbifyBulk::active()) return BookOrbitCatalogClient::fetchSectionEntries(sectionId,page,outPage, /*allowNetwork=*/false); + #endif + std::string text; +- if (!readJsonStringFile(cachePathForKey(facetCacheKey(sectionId, page)), text)) return false; ++ if (!readJsonStringFile(cachePathForKey(facetCacheKey(sectionId, page)), text)) { ++#if CROSSINK_TAILNET_ORBIFY_CACHE ++ return BookOrbitCatalogClient::fetchSectionEntries(sectionId, page, outPage, /*allowNetwork=*/false); ++#else ++ return false; ++#endif ++ } + + JsonDocument doc; + if (deserializeJson(doc, text) != DeserializationError::Ok || !doc["items"].is()) return false; +@@ -243,10 +249,16 @@ + + bool loadBooksPage(const BookOrbitBookQuery& query, const int page, BookOrbitBookPage& outPage) { + #if CROSSINK_TAILNET_ORBIFY_MIRROR +- if(OrbifyBulk::active() && query.query.empty()) return BookOrbitCatalogClient::fetchBooks(query,page,outPage); ++ if(OrbifyBulk::active() && query.query.empty()) return BookOrbitCatalogClient::fetchBooks(query,page,outPage, /*allowNetwork=*/false); + #endif + std::string text; +- if (!readJsonStringFile(cachePathForKey(booksCacheKey(query, page)), text)) return false; ++ if (!readJsonStringFile(cachePathForKey(booksCacheKey(query, page)), text)) { ++#if CROSSINK_TAILNET_ORBIFY_CACHE ++ return BookOrbitCatalogClient::fetchBooks(query, page, outPage, /*allowNetwork=*/false); ++#else ++ return false; ++#endif ++ } + + JsonDocument doc; + if (deserializeJson(doc, text) != DeserializationError::Ok || !doc["items"].is()) return false; +diff --git a/src/network/BookOrbitCatalogClient.cpp b/src/network/BookOrbitCatalogClient.cpp +--- a/src/network/BookOrbitCatalogClient.cpp ++++ b/src/network/BookOrbitCatalogClient.cpp +@@ -175,7 +175,7 @@ + // tens of KB. Buffering them in a std::string aborts on OOM (throwing operator new with + // -fno-exceptions), so stream the body to a temp file on SD instead and parse it from + // there with a filter that keeps only the handful of fields we actually read. +-bool fetchJson(const std::string& url, const FilterBuilder& buildFilter, JsonDocument& outDoc) { ++bool fetchJson(const std::string& url, const FilterBuilder& buildFilter, JsonDocument& outDoc, const bool allowNetwork = true) { + constexpr char TMP_PATH[] = "/.crosspoint/bookorbit_catalog.json"; + CatalogRequestLock networkLock(catalogNetworkMutex, std::defer_lock); + BookOrbitCatalogClient::lastFetchBadResponse = false; +@@ -196,6 +196,10 @@ + JsonDocument filter(ORBIFY_CATALOG_JSON_ALLOCATOR);buildFilter(filter); + if(OrbifyCache::readWindow(url,filter.as(),outDoc))return true; + } ++ // A browser cache probe includes every saved representation (bulk, refreshed ++ // 100-row windows, and exact replies). A miss must not acquire a radio hold, ++ // connect, or enter HTTP, even if Wi-Fi is currently connected. ++ if (!allowNetwork && (!cached.serve || cached.fetch)) return false; + OrbifyWifi::Hold miss(OrbifyWifi::Owner::OfflineMiss, !cached.hasEntry); + if (!cached.hasEntry) OrbifyWifi::simulatorIdleOffProbe(); + // Patch 0040: offline with nothing saved, no request (orbify::cache::readStep). The cache-first +@@ -208,6 +212,8 @@ + } + OrbifyWifi::Hold requestRadio(OrbifyWifi::Owner::Catalog, step == orbify::cache::ReadStep::Request); + if (step == orbify::cache::ReadStep::Saved) parsePath = cached.path.c_str(); ++#else ++ if (!allowNetwork) return false; + #endif + + // Two attempts: TLS on the C3 runs with a few KB of headroom, so a fetch can fail +@@ -805,7 +811,7 @@ + return result; + } + +-bool BookOrbitCatalogClient::fetchBooks(const BookOrbitBookQuery& query, const int page, BookOrbitBookPage& outPage) { ++bool BookOrbitCatalogClient::fetchBooks(const BookOrbitBookQuery& query, const int page, BookOrbitBookPage& outPage, const bool allowNetwork) { + outPage = BookOrbitBookPage{}; + if (!BOOKORBIT_STORE.hasCredentials()) return false; + +@@ -815,7 +821,7 @@ + bookOrbitSetFilter(filter, R"({"section":{"books":[{"id":true,"title":true,"authors":true,"formats":true}]}})"); + }; + JsonDocument doc(ORBIFY_CATALOG_JSON_ALLOCATOR); +- if (!fetchJson(booksUrl(query, page, PAGE_SIZE), buildFilter, doc)) return false; ++ if (!fetchJson(booksUrl(query, page, PAGE_SIZE), buildFilter, doc, allowNetwork)) return false; + JsonArrayConst books = doc["section"]["books"].as(); + outPage.books.reserve(books.size()); + for (JsonObjectConst item : books) { +@@ -844,7 +850,7 @@ + } + }; + JsonDocument doc(ORBIFY_CATALOG_JSON_ALLOCATOR); +- if (!fetchJson(url, buildFilter, doc)) return false; ++ if (!fetchJson(url, buildFilter, doc, allowNetwork)) return false; + + outPage.page = doc["page"] | page; + outPage.total = doc["total"] | 0; +@@ -867,7 +873,7 @@ + } + + bool BookOrbitCatalogClient::fetchSectionEntries(const std::string& sectionId, const int page, +- BookOrbitFacetPage& outPage) { ++ BookOrbitFacetPage& outPage, const bool allowNetwork) { + outPage = BookOrbitFacetPage{}; + if (!BOOKORBIT_STORE.hasCredentials()) return false; + +@@ -887,7 +893,7 @@ + R"({"page":true,"total":true,"size":true,"hasNext":true,"items":[{"id":true,"title":true,"count":true,"seriesId":true}]})"); + }; + JsonDocument doc(ORBIFY_CATALOG_JSON_ALLOCATOR); +- if (!fetchJson(url, buildFilter, doc)) return false; ++ if (!fetchJson(url, buildFilter, doc, allowNetwork)) return false; + + outPage.page = doc["page"] | page; + outPage.hasNext = doc["hasNext"] | false; +diff --git a/src/network/BookOrbitCatalogClient.h b/src/network/BookOrbitCatalogClient.h +--- a/src/network/BookOrbitCatalogClient.h ++++ b/src/network/BookOrbitCatalogClient.h +@@ -229,7 +229,7 @@ + * @param query Sort and filter fields; empty fields are omitted + * @param page 1-based page number + */ +- static bool fetchBooks(const BookOrbitBookQuery& query, int page, BookOrbitBookPage& outPage); ++ static bool fetchBooks(const BookOrbitBookQuery& query, int page, BookOrbitBookPage& outPage, bool allowNetwork = true); + + /** The total of a books listing, read from a single-item page. -1 on failure. */ + static int fetchBookTotal(const BookOrbitBookQuery& query); +@@ -239,7 +239,7 @@ + * @param sectionId The facet section id from the catalog root + * @param page 1-based page number + */ +- static bool fetchSectionEntries(const std::string& sectionId, int page, BookOrbitFacetPage& outPage); ++ static bool fetchSectionEntries(const std::string& sectionId, int page, BookOrbitFacetPage& outPage, bool allowNetwork = true); + + /** Fetch full detail (including downloadable files) for one book. */ + static bool fetchBookDetail(int64_t bookId, BookOrbitBookDetail& outDetail); diff --git a/xteink/test/e2e/run.py b/xteink/test/e2e/run.py index 4d38ec3e..ab75a774 100644 --- a/xteink/test/e2e/run.py +++ b/xteink/test/e2e/run.py @@ -543,11 +543,69 @@ def home_refresh_completion_stamp(ctx: Context, tmp: Path) -> None: offline = ctx.sim.run(card,"ordinary-refresh-offline-pages", script=f"3000:SWIPE:0.8,0.5,0.2,0.5,250;4500:TAP:{cx},{cy};6000:DOWN:100;6500:CONFIRM:100;"+downs+";24000:QUIT", timeout_s=30) after(offline.output,"Listing page 3") + assert "Catalog blocking paint:" not in after(offline.output, "Listing page 1"), "saved sectioned list painted Loading" assert "Joining saved network" not in offline.output and not ctx.requests()[before:], "refreshed 100-row data woke the network" samples=[int(n) for n in re.findall(r"Heap after saved catalog window: internal free=(\d+)",offline.output)] assert len(samples)>=3 and min(samples)>=60*1024, f"ordinary refresh paging heap: {samples}" +@scenario("x4-pro") +def offline_cached_list_no_loading(ctx: Context, tmp: Path) -> None: + """Ordinary refresh's 100-row SD sources, never-visited pages, both swipe directions. + + Full refresh uses a separate bulk adapter; this must also work without a bulk generation + or session-list files. Cross 12 browser-page boundaries in a 245-book saved listing. + """ + card = ctx.card(tmp) + card.theme(UI_THEME_BOOKORBIT) + # Compact rows keep screen boundaries fixed while walking the whole list both ways. + # The ordinary-refresh scenario below also checks the default sectioned layout. + card.settings["libraryListExpanded"] = 0 + card.save() + sleep_pick(card, **{"from": "library", "hours": 0}) + sx, sy = home_tile(ctx.sim.run(card, "home", script="3000:QUIT", timeout_s=10).output, "sync") + template = kit.Device().call("GET", "/plugin/catalog/books?format=epub&size=1")["items"][0] + rows = [{**template, "id": 700000 + n, "title": f"Offline cached book {n:03}", + "formats": ["epub"], "addedAt": "2026-11-01T00:00:00Z"} for n in range(245)] + rules = [] + for page in range(1, 4): + rules.append({"match": {"path": "/plugin/catalog/books$", "query": {"size": "^100$", "page": f"^{page}$"}}, + "action": "status", "status": 200, "body": json.dumps({"items": rows[(page-1)*100:page*100], + "page": page, "size": 100, "total": len(rows), "hasNext": page < 3})}) + ctx.faults(rules) + seeded = ctx.sim.run(card, "ordinary-refresh", script=f"3000:TAP:{sx},{sy},120", after_reboot="", + timeout_s=100, env={"ORBIFY_SIM_QUIT_HOME_DONE": "1"}) + after(seeded.output, "Home refresh over (ok=1") + assert not (card.crosspoint / "orbify-catalog" / "bulk" / "active").exists() + # Each process starts with Wi-Fi off. No saved network permits a genuine miss to hide + # behind a successful reconnect. The proxy also rejects any accidental HTTP request. + (card.crosspoint / "wifi.json").unlink() + ctx.faults("offline") + library = ctx.sim.run(card, "library", script="3000:SWIPE:0.8,0.5,0.2,0.5,250;5000:QUIT", timeout_s=10) + cx, cy = home_tile(library.output, "catalog") + before = len(ctx.requests()) + turns = [] + for n in range(32): + turns.append(f"{8000+n*650}:SWIPE:0.5,0.8,0.5,0.2,150") + for n in range(32): + turns.append(f"{30000+n*650}:SWIPE:0.5,0.2,0.5,0.8,150") + run = ctx.sim.run(card, "offline-cached-swipes", timeout_s=65, quit_after_sync=False, + script=f"3000:SWIPE:0.8,0.5,0.2,0.5,250;4500:TAP:{cx},{cy};6000:DOWN:100;6500:CONFIRM:100;" + + ";".join(turns) + ";53000:QUIT") + listing = after(run.output, "Listing page 1") + assert "Catalog blocking paint:" not in listing, "cached paging painted a blocking Loading screen" + assert not ctx.requests()[before:], "cached paging attempted HTTP" + assert "Joining saved network" not in listing and "[WIFI] Joined" not in listing + pages = [int(p) for p in re.findall(r"Listing page (\d+) from cache", listing)] + assert max(pages, default=0) >= 13, f"did not traverse the saved list: {pages}" + samples = [(int(a), int(b), int(ms)) for a, b, ms in + re.findall(r"Catalog page turn: from=(\d+) to=(\d+) elapsedMs=(\d+)", listing)] + assert len(samples) == 64, f"lost swipe inputs: {samples}" + assert any(b > a for a, b, _ in samples) and any(b < a for a, b, _ in samples) + assert samples[-1][1] == 0, f"reverse paging did not return to the beginning: {samples[-1]}" + assert max(ms for _, _, ms in samples) < 250, f"cached page exceeded 250 ms (including paint): {samples}" + + @scenario("x4-pro") def home_tile_touch(ctx: Context, tmp: Path) -> None: """X8 by touch (X4 Pro, .167: a hold did nothing, a tap failed, a slow tap started a Full