Revert #4421 and narrow the cache restore fix - #4436
Conversation
This reverts commit 1c51b52.
Reapply the isolated appearance boundaries and native menu transform origin from #4421 so appearance hydration preserves native navigator and gesture host lifetimes.
Read the timeline concurrently with agent preparation and reconcile display-only cache rows beneath the live head using the existing reducer. Merge cached directory entries beneath live state while preserving the existing checkpoint race guard.
|
| Filename | Overview |
|---|---|
| packages/app/src/runtime/directory-sync/index.ts | Restores demand-driven directory ownership and concurrent baseline reads, but commits stale cached rows after live deletions. |
| packages/app/src/runtime/directory-sync/agent-replica.ts | Reverts agent directory lifetime integration and adds targeted cache-read tokens; bulk cached merges cannot retain deletion knowledge. |
| packages/app/src/runtime/directory-sync/workspace-replica.ts | Adds targeted workspace cache admission while bulk merges preserve live values but can reinsert deleted cached keys. |
| packages/app/src/timeline/viewed-timeline-sync.ts | Restores the established timeline owner and merges cached baselines beneath live observations. |
| packages/app/src/contexts/session-context.tsx | Rewires timeline response handling and transport ownership into the session bridge. |
| packages/app/src/navigation/themed-stack.tsx | Places appearance remount boundaries below native navigators to preserve navigator identity. |
| packages/app/src/navigation/workspace-route-navigation.ts | Retains the latest workspace navigation intent until the root navigation container is ready. |
| packages/app/src/data/providers-snapshot.ts | Uses React Query cancellation errors with native-compatible AbortSignal.aborted checks. |
| packages/app/e2e/browser/sidebar-model-b.spec.ts | Replaces an eventual tab assertion with an immediate snapshot, introducing hydration-timing sensitivity. |
| packages/app/e2e/browser/composer-autocomplete.spec.ts | Replaces polling of animation-dependent stacking state with a single immediate sample. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Disk[Cached directory read] --> Merge[Commit cached baseline]
Live[Live directory update] --> Current[Current session directory]
Delete[Live deletion] --> Current
Current --> Merge
Merge -->|Present keys override cache| Updated[Updated live rows retained]
Merge -->|Deleted key absent from current map| Resurrected[Cached deleted row reinserted]
Resurrected --> UI[Directory/sidebar state]
Refresh[Later demanded network refresh] -->|Eventually removes row| UI
Reviews (1): Last reviewed commit: "fix(app): retain cached baselines during..." | Re-trigger Greptile
Upstream reverted the timeline rewrite (getpaseo#4436), so the fork rebaseline path stays. Plugin lifecycle hooks land alongside the fork's launch labels: buildLaunchContext now takes both.
* Revert "Restore cached conversations before reconnecting (getpaseo#4421)" This reverts commit 1c51b52. * fix(app): restore provider loading on native * fix(app): preserve native navigators across appearance changes Reapply the isolated appearance boundaries and native menu transform origin from getpaseo#4421 so appearance hydration preserves native navigator and gesture host lifetimes. * fix(app): retain cached baselines during live updates Read the timeline concurrently with agent preparation and reconcile display-only cache rows beneath the live head using the existing reducer. Merge cached directory entries beneath live state while preserving the existing checkpoint race guard.
* Revert "Restore cached conversations before reconnecting (getpaseo#4421)" This reverts commit 77851af. * fix(app): restore provider loading on native * fix(app): preserve native navigators across appearance changes Reapply the isolated appearance boundaries and native menu transform origin from getpaseo#4421 so appearance hydration preserves native navigator and gesture host lifetimes. * fix(app): retain cached baselines during live updates Read the timeline concurrently with agent preparation and reconcile display-only cache rows beneath the live head using the existing reducer. Merge cached directory entries beneath live state while preserving the existing checkpoint race guard.
Port of getpaseo#4436. Cached agents and workspaces paint even when live updates arrived during the cache read. Live state still wins, and a stale checkpoint is ignored if the revision moved.
Reasoning
Revert #4421 because phone dogfooding produced a reordered conversation after its timeline reducer and persisted-cache rewrite. Restore the established reducer, retain the provider/native crash fixes, and fix cached baseline restoration at the existing restore owners.
Linked issue
Refs #4421, #4401, #4431. Related open work #4256 and #4153 addresses separate timeline problems and is not superseded.
Type of change
Goals
Non-goals
No replacement reducer, provenance fields, second timeline lane, new production module, queue, revision counter, or state machine. No changes after the revert to
session-stream-reducers.ts,types/stream.ts,session-store.ts, or the cache codec/row format.Four commits and evidence
Evidence root E =
/tmp/revert-4421-evidence/, a symlink to this worktree's.dev/revert-4421-evidence/. Paths below are local artifacts retained for maintainer review.5d1dd0580142a80968df5adc40b5d8d172078c0cf5fdf0254bc2ad1a1856cd09448472af4dcd621eAbortSignal.aborted+CancelledErrorb19628245beee0f55a65b09fb59b8889e00e1b221e378c94c4114cd8ab89730ed4b76419fb6dcc96Counts exclude tests/docs;
E/commit-lines.jsonrecords them. Commits 2–4 total 247 raw changed lines / 167 ignoring whitespace. The maintainer explicitly approved exceeding the initial 150-line guard to retain the reproduced navigation crash fix.8c89e72a0;1c51b52d0was verified as an ancestor. No revert conflicts; Restore body dragging for model and plugin sheets #4431's bottom-sheet gesture changes remain intact.throwIfAborted; all 13 provider tests pass.E/baseline-deeplink-error.png,baseline-logcat.txt. Ready-intent test fails before and all 8 pass after (navigation-red.logand focused logs). Final journey passes:final-back-launcher.png,final-deeplink.png. Appearance placement 3, menu 18, explorer host 4 tests pass.timeline-red.log,timeline-ordering-red.log,directory-red.log. Final viewed timeline 31, replica 14, directory 18 tests pass. The existing directory test proved that the checkpoint must still be withheld after a live revision; only checkpoint assignment retains that existing guard. Cache rows now merge beneath live state.QA
CI green on
1e378c94c4114cd8ab89730ed4b76419fb6dcc96: all applicable checks, including all four Playwright shards, passed; review threads resolved. Final status evidence:E/ci-review.json.npm run typecheck,npm run lint,npm run format:checkpass:E/final-typecheck.log,final-lint.log,final-format-check.log.npm run formatran before every commit/amend.E/directory-deletion-green.log,directory-deletion-diagnostic.test.ts. The existing cache host-revision check flushes mutations and rereads before returning; no new deletion tracking is needed.--bail=1, including reverted reducer/store/cache/host/submission owners. Logs are retained under E; no full workspace suite ran.E/playwright.log= 75;submission-passed.txt/playwright-quota-failure.log= 25;playwright-submission-remaining.log= 2.APP_VARIANT=production EXPO_PUBLIC_LOCAL_DAEMON=localhost:6768,assembleRelease; installed on existingpaseo-api35emulator against the dev daemon on 6768 through a local response-delay proxy.E/android-final-build.log,final-apk.sha256,final.apk.check1-delayed.log,delayed-cached.png,qa-events.jsonl,proxy.jsonlcheck2-offline.log,offline-history.png,offline-sidebar-comparison.json,offline-sidebar-expanded-*.txtcheck3-race.json,read-race-attached.log,race-after-read.png,race-after-read.dbcheck4-order.json,daemon-projection.json,reopen-before.db,reopen-after.db,check4-reopened.pngcheck5-existing-models.png,check5-new-workspace-codex.png,new-model-list.txtfont-committed.txt,check6-syntax-menu.png,check6-cold-starts.json,check6-cold-*.png,check6-logcat.txt,check6-crash-matches.txtCodec behavior: rows written by #4421 containing
sourceare rejected as cache misses and fall through to a normal fetch; older-format rows decode. SQLite diagnostic covered all ten original rows (five source-bearing, five older format):E/cache-diagnostics.log,cache-diagnostic.test.ts,original-4421-cache.db. Direct APK proof: one remaining 40-item source-bearing row fetched successfully and was replaced by 40 decodable items, with visible history and no permanent spinner:codec-native-result.json,codec-native-before.db,codec-native-after.db,codec-native-after.png.Not fixed
The shared cache write queue can delay a host A read behind a host B write. Reproduced using the real SQLite adapter, left unfixed as explicitly requested:
E/cache-diagnostics.logandE/cache-diagnostic.test.tsretain the failing-test evidence. No cache queue or codec changes are included.Verification deviations and limits
--no-commitso the required formatter could run before committing; its patch is the plain reverse of the squash commit./tmpquota exhaustion and browser process crashes interrupted one run. Evidence and temporary files moved onto the workspace disk; all incomplete/failed requested cases subsequently passed unchanged. No assertions, retries, or timeouts were weakened./tmp/replica-4160was not modified. No other model was started or delegated work.Checklist
npm run typecheckpassesnpm run lintpassesnpm run formatpasses