Skip to content

Revert #4421 and narrow the cache restore fix - #4436

Merged
boudra merged 4 commits into
mainfrom
revert-4421-narrow-cache-restore
Sep 7, 2026
Merged

Revert #4421 and narrow the cache restore fix#4436
boudra merged 4 commits into
mainfrom
revert-4421-narrow-cache-restore

Conversation

@boudra

@boudra boudra commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

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

  • Bug fix
  • Docs

Goals

  • Paint cached conversations and the complete cached workspace directory despite live updates during disk reads.
  • Preserve the established timeline reconciliation and persisted format.
  • Keep native model loading, appearance changes, and cold-start navigation working.

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.

Commit Change Production additions/deletions Ignoring whitespace
5d1dd0580142a80968df5adc40b5d8d172078c0c Plain squash revert +2508 / −2840 = 5348 +2420 / −2752 = 5172
f5fdf0254bc2ad1a1856cd09448472af4dcd621e Native AbortSignal.aborted + CancelledError +3 / −3 = 6 6
b19628245beee0f55a65b09fb59b8889e00e1b22 Appearance boundaries below navigators, array transform origin, ready navigation intent +139 / −64 = 203 +106 / −31 = 137
1e378c94c4114cd8ab89730ed4b76419fb6dcc96 Concurrent baseline reads; retain cached rows beneath live updates +20 / −18 = 38 +13 / −11 = 24

Counts exclude tests/docs; E/commit-lines.json records 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.

  1. Revert base was corrected to 8c89e72a0; 1c51b52d0 was verified as an ancestor. No revert conflicts; Restore body dragging for model and plugin sheets #4431's bottom-sheet gesture changes remain intact.
  2. Provider test reproduced the missing native throwIfAborted; all 13 provider tests pass.
  3. Back → launcher → agent deep link reproduced the Root Layout error on the reverted APK: E/baseline-deeplink-error.png, baseline-logcat.txt. Ready-intent test fails before and all 8 pass after (navigation-red.log and focused logs). Final journey passes: final-back-launcher.png, final-deeplink.png. Appearance placement 3, menu 18, explorer host 4 tests pass.
  4. Real SQLite row adapter/cache tests reproduce display-only restoration and timeline/directory read ordering races: 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:check pass: E/final-typecheck.log, final-lint.log, final-format-check.log. npm run format ran before every commit/amend.
  • Review follow-up: real SQLite diagnostic deletes an agent and workspace during the directory read and asserts a second storage read plus absence of both deleted rows. It passes on this head: 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.
  • Focused Vitest files ran individually with --bail=1, including reverted reducer/store/cache/host/submission owners. Logs are retained under E; no full workspace suite ran.
  • 102 unchanged Playwright cases pass, one worker: agent stream, viewed timelines, submission, pagination, resume, all New Workspace specs, and published 0.2.5 daemon pagination. E/playwright.log = 75; submission-passed.txt/playwright-quota-failure.log = 25; playwright-submission-remaining.log = 2.
  • Release x86_64 APK built with APP_VARIANT=production EXPO_PUBLIC_LOCAL_DAEMON=localhost:6768, assembleRelease; installed on existing paseo-api35 emulator against the dev daemon on 6768 through a local response-delay proxy. E/android-final-build.log, final-apk.sha256, final.apk.
APK check Result and observation Evidence under E
Delayed reply PASS: cached paint at 3.62s; reply at 13.02s, 9.40s later check1-delayed.log, delayed-cached.png, qa-events.jsonl, proxy.jsonl
Offline paint and directory PASS: history painted with both endpoint ports REJECTed; all 46 cached workspaces visible after Show more; none missing check2-offline.log, offline-history.png, offline-sidebar-comparison.json, offline-sidebar-expanded-*.txt
Live event during read PASS: five real live events during a 12s native SQLite pause; cached history and live content visible before delayed reply check3-race.json, read-race-attached.log, race-after-read.png, race-after-read.db
Reopen order PASS: app process stopped while this task streamed; all 40 persisted rows match their order in the daemon's 292-entry projected reply, including non-monotonic ending cursors check4-order.json, daemon-projection.json, reopen-before.db, reopen-after.db, check4-reopened.png
Model selectors PASS: existing agent list and New Workspace provider/model lists populate check5-existing-models.png, check5-new-workspace-codex.png, new-model-list.txt
Appearance and five cold starts PASS: interface size 15→16 committed, syntax menu opened; five distinct app PIDs painted history; zero native crash/Root Layout matches font-committed.txt, check6-syntax-menu.png, check6-cold-starts.json, check6-cold-*.png, check6-logcat.txt, check6-crash-matches.txt

Codec behavior: rows written by #4421 containing source are 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.log and E/cache-diagnostic.test.ts retain the failing-test evidence. No cache queue or codec changes are included.

Verification deviations and limits

  • Approved line-count exception and conditional ready-intent inclusion are described above; exactly four commits remain.
  • Revert used --no-commit so the required formatter could run before committing; its patch is the plain reverse of the squash commit.
  • Shared /tmp quota 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.
  • Early Frida spawn instrumentation failed in the Android linker before SQLite. The successful race check attached after normal startup and paused the real SQLite read when opening an uncached-in-memory agent. The six normal native cold starts/deep-link checks ran without instrumentation. Instrumentation logs remain under E.
  • The baseline repro APK packaging reused its already-built baseline bundle after an interrupted build; the final APK was rebuilt with all four commits.
  • Android emulator and browser were exercised. iOS, physical devices, and Electron were not manually tested. Configured Copilot and slow-test providers returned their own errors; working providers populated successfully.
  • Neither daemon on 6768/6767 was restarted; /tmp/replica-4160 was not modified. No other model was started or delegated work.

Checklist

  • One focused change
  • npm run typecheck passes
  • npm run lint passes
  • npm run format passes
  • QA evidence
  • Tests added or updated where it made sense

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.
@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reverts the broad timeline/cache architecture from #4421 while retaining narrower native provider, appearance, navigation-readiness, and concurrent cache-baseline fixes.

  • Restores the established timeline reducer, session projection, and persisted cache format.
  • Moves cache preparation back to existing directory and viewed-timeline owners.
  • Preserves native provider cancellation compatibility and navigator identity across appearance changes.
  • Adds route-level cached workspace/agent preparation and ready-time navigation intent handling.
  • Contains a directory-cache race that can resurrect rows deleted while the baseline read is pending.
  • Weakens two asynchronous browser assertions by replacing polling with immediate samples.

Confidence Score: 4/5

The PR is not safe to merge until deleted rows cannot be resurrected by a late bulk cache read and the explicit deterministic-E2E requirement is restored.

A live deletion during the directory SQLite read can be undone by the subsequent cached-map merge, leaving the removed entity visible until a later demanded refresh; two browser tests also lost required retry behavior around asynchronous UI state.

Files Needing Attention: packages/app/src/runtime/directory-sync/index.ts, packages/app/src/runtime/directory-sync/agent-replica.ts, packages/app/src/runtime/directory-sync/workspace-replica.ts, packages/app/e2e/browser/sidebar-model-b.spec.ts, packages/app/e2e/browser/composer-autocomplete.spec.ts

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix(app): retain cached baselines during..." | Re-trigger Greptile

Comment thread packages/app/src/runtime/directory-sync/index.ts
Comment thread packages/app/e2e/browser/sidebar-model-b.spec.ts
@boudra
boudra merged commit c46aee4 into main Sep 7, 2026
24 checks passed
@boudra
boudra deleted the revert-4421-narrow-cache-restore branch September 7, 2026 17:18
iammvaibhav added a commit to iammvaibhav/paseo that referenced this pull request Sep 7, 2026
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.
omorsi45 pushed a commit to omorsi45/paseo that referenced this pull request Sep 8, 2026
* 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.
Githab-capibara added a commit to Githab-capibara/paseo-reloaded that referenced this pull request Sep 9, 2026
* 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.
Legoless added a commit to Legoless/paseo that referenced this pull request Sep 9, 2026
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.
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