Repository navigation
fix(mobile): count opening a cached page generation as use; cache six hosts - #23780
Conversation
… hosts Eviction order was written only when a download committed, so a host opened daily but downloaded long ago was evicted first and each revisit cost a full redownload. An open now refreshes that host's recency inside the store queue. The ceiling rises to six hosts and the update-failure cap to six hosts' worth. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…n open An open stamped wall time, so a backward clock jump made the host in use the oldest entry and the next download evicted it. Recency now stamps past the newest entry. An unreadable or torn index read as empty, so every open rewrote it with one host and demoted the rest; opens now leave it for a commit. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Recency on open —
readActiveGenerationnow routes throughopenActive, which stamps the host's recency in the store's serialised queue after a generation is found, with no eviction pass. It skips the write when no generation is found and when the index is unreadable/torn. - Order-based recency — new
stampRecencysets the host tomax(now(), ...values + 1), so a backward clock jump cannot mark the just-used host oldest; applied to both commit paths as well. - Ceilings —
MAX_CACHED_HOSTS4 → 6 andMAX_UPDATE_FAILURES20 → 30, preserving the 5-per-host ratio (guarded by a test rather than an import that would cycle). - Index read contract —
readHostIndexnow returnsnullfor unreadable/torn (was an emptyMap);commitstill rewrites it whole (?? new Map()) whileopenActiveleaves it alone, anddeleteHosttolerates null. - Tests — new cases for open-counts-as-use, null reads writing nothing, an unwritable index still returning the generation, backward-clock ordering, and a torn index left untouched; eviction tests derive host counts from
MAX_CACHED_HOSTS; the offline-staleness assertion permits the one newhosts.jsontouch.
The behavior is coherent with the module's "recency, not truth" contract. I ran the full mobile-web-shell suite (91 files / 1343 tests) and tsc --noEmit against mobile — both green.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe generation store now supports six cached hosts and stores host recency as an ordered list in Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The cache and failure-log capacity changes have no identified issue requiring resolution before merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The cache can retain six hosts instead of four, and opening a cached page now updates its eviction order. The review found no demonstrated new security access path, but the format change and incomplete security coverage warrant a cautious assessment. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives a detailed explanation of the behavior change and lists test coverage, but it omits most required template sections, including ELI5, Linked Issue, Visual Proof or an explicit N/A, Testing checkboxes and platform details, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Complete the required template sections. Add a plain-language ELI5 summary, a separate Why section, the linked issue under Linked Issue, Visual Proof or an explicit N/A with a reason, testing steps and platform coverage, AI Disclosure when applicable, Review, the Agent skill upstream boundary checkbox, Notes, and the Checklist. Mark completed checklist items accurately. ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… write Every open rewrote hosts.json even when the host was already the newest, so a single-host user paid a native write per open. Opens now write only when the order changes. The index is written to a sibling and renamed over the old one, so an interrupted write leaves the previous index or none, never a torn file. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: cb8ea292-ca3c-485e-bb34-ceeee1396dc5
📒 Files selected for processing (2)
mobile/src/mobile-web-shell/generation-store.test.tsmobile/src/mobile-web-shell/generation-store.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (53f08c82f7), a single commit (4b786e7533) landed:
- Skip no-op recency writes on open —
openActivenow writes the host index only when the host is absent from it or not already the newest entry, so the common single-host open does no native I/O. A new test pins that opening the newest host leaves the file bytes and write count unchanged while opening an older host writes. - Stage the index write —
writeHostIndexwriteshosts.json.tmpand renames it overhosts.json, so a kill mid-write leaves the previous index or none rather than a torn one. The write-failure tests now target the staging path and assert the previous index survives intact. - Reverted the offline-staleness relaxation — because the skip-write path means the single cached host is already newest, an open writes nothing, so
mobile-web-shell-offline-grant-staleness.test.tsreturns to its original "no writes" assertion and drops out of the diff.
I ran the full mobile-web-shell suite (91 files / 1344 tests) and tsc --noEmit against mobile — both green. The behavior remains coherent with the module's "recency, not truth" contract.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Eviction needs order only, so hosts.json is now the cache keys least recently used first. That drops the clock, the monotonic stamp, the unreadable-versus- absent split and the staged write: a torn or old-format file reads as empty, the same state a missing one gives. Opens and same-build commits share one touch that writes only when the host is not already last. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
| const order = await readHostOrder() | ||
| if (order.at(-1) !== hostKey) { | ||
| await writeHostOrder(withHostLast(order, hostKey)) |
There was a problem hiding this comment.
Failed read erases cache order If reading
hosts.json fails while a cached generation is opened, readHostOrder returns an empty list. touchHost can then overwrite a valid list with only the opened host. When a later activation exceeds the six-host limit, the other hosts have no recorded order, so a recently used bundle may be evicted and downloaded again. Keep a failed read distinct from an empty index on this path.
Knowledge Base Used: Mobile web delivery
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (4b786e7533), one commit landed (2368d3a7e6) — a refactor of the cache recency index:
- Order, not time —
hosts.jsonis now astring[]of host cache keys, least recently used first (HostOrderSchema = z.array(z.string())). This drops thenowoption,stampRecency/Math.max, and the unreadable-vs-absentnullcontract;readHostOrderreturns[]for anything it cannot parse. - Staged write dropped —
writeHostOrderwriteshosts.jsondirectly again. A torn or old-format file reads as an empty order, which is now the same state a missing one gives, so the staging added in the previous commit is no longer load-bearing. - Activated host stays protected —
withHostLastis shared bytouchHostand the commit path, so the just-activated/opened host is always last in the order;enforceHostLimitsorts activated hosts byorder.indexOf(missing →-1, evicted first). I traced the ceiling-crossing and torn-index cases: the in-use host is never among the evicted and no generation is ever deleted from a lost order. - Tests — cases updated to the array shape; the clock-jump tests are gone and replaced with a legacy-timestamp-reads-as-empty case; the
MAX_UPDATE_FAILURESratio is pinned toMAX_UPDATE_FAILURES_PER_HOST * MAX_CACHED_HOSTS.
I ran the five changed-adjacent suites (72 tests) and tsc --noEmit -p mobile/tsconfig.json — all green, and oxfmt --check passes on the changed files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…3789, #23812, #23852) into brennanb2025/codex-home-single-writer #23744 moves every agent's folder pre-trust into the PTY spawn hook (and the structured Codex chat create), removing Codex's launch-prep and resume-prep trust writes. markCodexProjectTrusted now takes the config files to write. Conflicts: - agent-trust-presets.ts: #23744's configFiles signature and nested lane acquisition, with this branch's lane rationale (hook installs read and rewrite across awaits); main's "capture->restore window" wording described the grant snapshot this branch removed. - agent-trust-write-deadline.ts: the Codex writer waits only on managed-home installs' inline grant; the real-home background approval holds no lane. #23744's SSH/SFTP writer is gone, so it is no longer named; its 1.5 s short deadline is kept. - codex-trust-config-concurrent-launch.test.ts: this branch's tests (a launch's write lands while a grant session runs; the renamed sibling-failure case) with #23744's new call signature. Outside the conflicts: codex-launch-during-real-home-grant.test.ts passed launchAgent/workspacePath into launch prep, which #23744 removed; its launch helper now runs launch prep and then applyAgentWorkspaceTrust, as the spawn builder does, so it still proves a launch and its project trust land while the real-home approval hangs.

What
The phone caches one OTA page-bundle generation per paired desktop and evicts the least recently used host past a ceiling. Recency was written only when a download committed, never when a cached bundle was opened. So a user with more desktops than the ceiling would see their daily host evicted first, because it was downloaded longest ago, and every return to it cost a fresh ~4 MB download that evicted another.
readActiveGenerationmoves the host to the end of the recency order inside the store's serialised queue, only when a generation is found and only when the host is not already last (the single-host case never writes), with no eviction pass because the host count did not change. The same-build recommit shares that onetouchHost.hosts.jsonis now a list of host cache keys, least recently used first. Eviction needs nothing more, so there is no clock, no timestamp arithmetic, and a clock set back cannot demote the host in use. A host missing from the list sorts first; the host just activated is last, so it is never evicted. The timestamp record earlier builds wrote fails the parse and reads as empty once, which costs eviction order only, as the index already documents: recency, not truth.persistActiveManifeststill does not touch recency; its contract is "rewrites the manifest, and nothing else", and it always follows an open that already did.Tests
expected undefined to be '75cb0005…'); opening the host already last writes nothing; an index write that fails during an open still returns the generation; a host missing from the order is evicted first; the old timestamp-shaped file reads as empty.MAX_CACHED_HOSTSinstead of a hardcoded four. The failure-log test pins the ratio to the host ceiling (a derived constant would import-cycle).