Skip to content

fix(ait): persist sandbox storage across reloads#108

Merged
imjlk merged 2 commits into
mainfrom
codex/ait-sandbox-persistent-storage
Jul 20, 2026
Merged

fix(ait): persist sandbox storage across reloads#108
imjlk merged 2 commits into
mainfrom
codex/ait-sandbox-persistent-storage

Conversation

@imjlk

@imjlk imjlk commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • persist AIT sandbox storage through browser reloads with a configurable namespace
  • retain isolated in-memory fallback behavior when browser storage is unavailable or becomes unusable
  • recover from corrupt persisted values without repeated parse failures
  • expose persistence degradation through focused diagnostics

Verification

  • adapter-ait: 52 tests passed
  • adapter-ait typecheck passed
  • workspace pnpm check passed
  • global Open Code Review: 0 comments

Summary by CodeRabbit

  • New Features

    • AIT sandbox data now persists across browser reloads when browser storage is available.
    • Storage keys are isolated using a configurable namespace.
    • Custom storage backends can be provided when needed.
  • Bug Fixes

    • Automatically falls back to in-memory storage when browser storage is unavailable or fails.
    • Handles corrupted saved data safely and prevents repeated storage failures.
    • Preserves the latest sandbox values during temporary persistence issues.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@imjlk, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 84c65efb-64d0-4c1c-98c1-5188e6a2b230

📥 Commits

Reviewing files that changed from the base of the PR and between c64f042 and c7574e9.

📒 Files selected for processing (1)
  • .sampo/changesets/ait-sandbox-persistent-storage.md
📝 Walkthrough

Walkthrough

AIT sandbox storage now supports configurable, namespaced browser persistence, with JSON serialization, corruption handling, and automatic fallback to in-memory storage. Tests cover persistence across gateway recreation and storage failure scenarios.

Changes

AIT sandbox storage

Layer / File(s) Summary
Storage contract and bridge wiring
adapters/ait/src/index.ts
Adds exported storage interfaces, configurable storage injection, namespaced keys, and an in-memory cache.
Persistent load and save behavior
adapters/ait/src/index.ts
Loads and saves JSON values through persistent storage, handles corrupt data, and disables persistence after failures while retaining memory behavior.
Persistence behavior validation
adapters/ait/src/index.test.ts, .sampo/changesets/ait-sandbox-persistent-storage.md
Tests gateway recreation, save/read failures, corrupt values, cleanup failures, and records the patch changeset.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Sandbox
  participant MemoryCache
  participant PersistentStorage
  Sandbox->>MemoryCache: Check cached key
  MemoryCache-->>Sandbox: Return cached value when present
  Sandbox->>PersistentStorage: Read or write namespaced JSON value
  PersistentStorage-->>Sandbox: Return value or throw failure
  Sandbox->>MemoryCache: Hydrate or retain in-memory value
Loading

Possibly related PRs

  • imjlk/mpgd-kit#90: Both changes modify AIT sandbox storage load/save semantics and JSON cloning.

Poem

I’m a bunny with storage tucked under my ear,
Persistent through reloads, yet memory stays near.
When local shelves crumble, I hop back in-flight,
Corrupt crumbs are cleared, fresh values turn right.
Namespaced keys keep each burrow just so—
A happy sandbox wherever I go!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: persistent AIT sandbox storage across reloads.
Description check ✅ Passed Covers the required Summary and Verification sections; only the Notes section is missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/ait-sandbox-persistent-storage

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@imjlk

imjlk commented Jul 20, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.sampo/changesets/ait-sandbox-persistent-storage.md:
- Line 2: Update the `@mpgd/adapter-ait` changeset release level from patch to
minor to reflect the newly exported AitSandboxStorage and
CreateAitSandboxBridgeOptions interfaces and the optional options parameter
added to createAitSandboxBridge.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d3990996-e885-4956-9a69-9cc530ca44fc

📥 Commits

Reviewing files that changed from the base of the PR and between 5f4e714 and c64f042.

📒 Files selected for processing (3)
  • .sampo/changesets/ait-sandbox-persistent-storage.md
  • adapters/ait/src/index.test.ts
  • adapters/ait/src/index.ts

Comment thread .sampo/changesets/ait-sandbox-persistent-storage.md Outdated
@imjlk
imjlk merged commit 5304da9 into main Jul 20, 2026
6 checks passed
@imjlk
imjlk deleted the codex/ait-sandbox-persistent-storage branch July 20, 2026 06:15
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