Skip to content

fix(browser): keep the IndexedDB model cache cleared after a reset - #43

Merged
leoisadev1 merged 1 commit into
mainfrom
bg0/review-followups-9
Sep 29, 2026
Merged

leoisadev1 merged 1 commit into
mainfrom
bg0/review-followups-9

Conversation

@leoisadev1

@leoisadev1 leoisadev1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #42, fixing Greptile's P1 there. clearModelCache() deletes the IndexedDB model cache, but a load that started before the reset still held the old cache. After #42 closed its connection on versionchange, the old cache reopened on its next write. That recreated the deleted database and wrote the model back, where a new cache read it, even after a reload.

An IndexedDB cache now stays empty once its database is deleted, or once a reset has run since it was created. Its reads miss and its writes are dropped. Only caches created after the reset open the database again. Another tab's reset retires this tab's cache the same way, so that tab stops caching the model until it reloads.

The IndexedDB tests now use fake-indexeddb (Apache-2.0, dev only) instead of a hand-rolled mock. They cover Greptile's P2 as well: a reset must delete stored models, and a clear that targets the wrong database now fails. The three write-back tests fail on main.

I checked the same scenarios in headless Chrome's real IndexedDB, loading the built cache.js over plain http on this machine's Tailscale address. On main, a write after a reset was readable from a new cache in all three cases: a cache that had opened before the reset, one first used after it, and a delete from another tab. With this change, none were readable. Stored models are gone after a reset, and a cache created afterward reads and writes normally.

I also ran the remover on WASM from this branch's build over the same plain-http origin, so it used IndexedDB:

  • The first image processed in 57 s. The PNG has alpha from 0 to 255, with 245,444 fully transparent pixels.
  • After a reload the model sat in IndexedDB: 3 files in 34 entries. A second image processed in 40 s with no model fetch.
  • Esc returned to the picker, and an unreadable file showed "This image could not be opened. Try exporting it as PNG or JPG."

Not tested: WebGPU, iOS, and the Cache API path, which this change does not touch. Root lint, typecheck, test and build pass.

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code


Devin Review

A load that started before clearModelCache() could reopen the deleted
database through its old cache and write the model back, where a new
cache read it. A cache now stays empty once its database is deleted or
a reset has run since it was created, and only caches created after the
reset open the database again.

The IndexedDB tests now run against fake-indexeddb, so they check that
a reset really deletes stored models.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bg0-docs Ready Ready Preview Sep 29, 2026 6:39pm UTC
bg0-web Ready Ready Preview Sep 29, 2026 6:39pm UTC

Request Review

@leoisadev1
leoisadev1 merged commit 5265268 into main Sep 29, 2026
5 of 6 checks passed
@leoisadev1
leoisadev1 deleted the bg0/review-followups-9 branch September 29, 2026 18:40

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

Devin Review

Comment thread packages/browser/src/cache.ts
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Fixes IndexedDB cache clearing after database reset.

Do not merge until an unopened cache can no longer restore a model after another tab clears the database.

Fix All in Claude CodeFindings

  1. P1 Unopened cache restores deleted models ▶

Summary

The PR retires IndexedDB cache instances after a local reset or an open connection’s cross-tab version change, and adds fake-indexeddb tests. If a user clears the model cache in one tab while another tab holds an unopened cache instance, that instance can recreate the database and store a pre-reset model on its first write.

Reviews (1) · Last reviewed commit: "fix(browser): keep the IndexedDB model c..."

Comment thread packages/browser/src/cache.ts
@greptile-apps

greptile-apps Bot commented Sep 29, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 An unopened cache can restore a model after another tab resets IndexedDB ▶

    • Bug
      • A cache created in tab A before tab B’s reset can make its first write afterward, recreating bg0-model-cache and making the stale model readable in B. This contradicts the intended cross-tab reset protection.
    • Cause
      • At packages/browser/src/cache.ts:104-110, createdAt !== resets checks only tab A’s module-local counter. Because A had never opened IndexedDB, it had no connection to receive versionchange and set deleted when B deleted the database.
    • Fix
      • Coordinate reset state across tabs or otherwise verify that an unopened cache is still valid before its first write; a connection’s versionchange handler alone cannot cover this path.

This branch was successfully deployed

2 active deployments
Preview – bg0-docs — 0035b541 Deployed Sep 29, 2026 by vercel[bot]
Preview – bg0-web — 0035b541 Deployed Sep 29, 2026 by vercel[bot]
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