Skip to content

feat: cache recent sessions for offline startup - #34

Merged
wolfiesch merged 1 commit into
LycaonLLC:feat/v0.1.23-polishfrom
wolfiesch:feat/offline-session-cache
Jul 18, 2026
Merged

feat: cache recent sessions for offline startup#34
wolfiesch merged 1 commit into
LycaonLLC:feat/v0.1.23-polishfrom
wolfiesch:feat/offline-session-cache

Conversation

@wolfiesch

Copy link
Copy Markdown
Collaborator

Summary

  • persist a bounded, versioned projection snapshot so recent sessions stay visible before the first live host frame arrives
  • keep cached sessions authenticated but read-only until live state replaces them, with explicit offline and starting indicators
  • make persistence best-effort and drain queued cache writes during shutdown without blocking live projection updates

Verification

  • pnpm check
  • pnpm test

Copilot AI review requested due to automatic review settings July 18, 2026 05:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/web/src/platform/desktop-runtime.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@wolfiesch
wolfiesch force-pushed the feat/offline-session-cache branch from f8dbfa2 to c01d248 Compare July 18, 2026 06:38
@wolfiesch
wolfiesch deleted the branch LycaonLLC:feat/v0.1.23-polish July 18, 2026 07:00
@wolfiesch wolfiesch closed this Jul 18, 2026
@wolfiesch wolfiesch reopened this Jul 18, 2026
@wolfiesch
wolfiesch force-pushed the feat/offline-session-cache branch from c01d248 to e43fa3f Compare July 18, 2026 07:12
@wolfiesch
wolfiesch requested a review from Copilot July 18, 2026 07:17
@wolfiesch
wolfiesch merged commit c7f4a7a into LycaonLLC:feat/v0.1.23-polish Jul 18, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Comment thread apps/web/src/platform/desktop-runtime.ts
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.

2 participants