feat: cache recent sessions for offline startup - #34
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8dbfa20bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds an encrypted, size-bounded projection snapshot cache that can be loaded via Desktop IPC before the first live host frame arrives, allowing “recent sessions” to render immediately on startup while remaining read-only until live state replaces them.
Changes:
- Introduces new Desktop IPC channels for projection-cache load/save with strict payload validation and size limits.
- Wires a projection cache store through the web runtime into the client
ProjectionStore, and ensures cache saves drain during shutdown. - Implements an Electron-backed encrypted cache store (safeStorage + ElectronStore) and integrates it into the desktop lifecycle + IPC registry, with targeted test coverage.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/protocol/src/desktop-ipc.ts | Adds IPC channel declarations and strict decoders for projection cache load/save payloads and results. |
| packages/protocol/test/desktop-ipc.test.ts | Adds protocol-boundary tests covering versioning, size bounds, and invalid payload rejection for projection cache IPC. |
| packages/client/src/projection.ts | Ensures coalesced cache snapshots continue draining even after dispose begins (shutdown flush behavior). |
| packages/client/test/projection.test.ts | Extends projection store tests to validate async cache-save draining through dispose/shutdown. |
| packages/client/src/projection-cache.ts | Centralizes MAX_PROJECTION_CACHE_BYTES by importing it from protocol and re-exporting it for client usage. |
| packages/client/src/desktop-runtime.ts | Awaits projection hydration (projection.ready()) before bootstrapping the shell to enable offline-first startup. |
| packages/client/src/desktop-runtime-contracts.ts | Extends the shell port contract with projection cache load/save operations. |
| apps/web/src/platform/desktop-runtime.ts | Wires desktop shell cache load/save into a ProjectionCacheStore, and injects a cached ProjectionStore into the runtime controller. |
| apps/web/test/live-composer.test.ts | Adds integration test verifying hydration from shell cache and later persistence of live mutations. |
| apps/desktop/src/ipc.ts | Adds IPC handlers for app:projection-cache:load/save with sender assertion and protocol decoding/encoding. |
| apps/desktop/test/ipc-lifecycle.test.ts | Adds lifecycle proof test that projection cache IPC routes through the trusted shell service and rejects extra fields. |
| apps/desktop/src/stores.ts | Implements ElectronProjectionCacheStore using safeStorage encryption + bounded base64 state validation + serialized writes. |
| apps/desktop/test/stores-lifecycle.test.ts | Adds tests for encrypted-at-rest behavior, degradation when encryption unavailable, corruption clearing, and concurrent save serialization. |
| apps/desktop/src/lifecycle.ts | Creates a single projection cache after app readiness and injects it into IPC runtime bindings across windows. |
| apps/desktop/test/lifecycle-runtime.test.ts | Tests that projection cache is created once post-readiness and reused across subsequent runtime bindings. |
| apps/desktop/src/preload.ts | Adds preload bridge methods for projection cache load/save and decodes results via protocol validators. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f8dbfa2 to
c01d248
Compare
c01d248 to
e43fa3f
Compare
Summary
Verification
pnpm checkpnpm test