Repository navigation
fix(browser): keep a reset from another tab from being undone - #44
Merged
Merged
Conversation
A tab whose IndexedDB model cache had not opened yet never heard about another tab's reset: its reset count is local and no version change reaches a cache without a connection. Its first write then recreated the deleted database and stored the model again. Each reset now also writes a new value to a shared localStorage key, and a cache created before that value changed stays empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Another tab can reset between a cache's reset check and its open request, so the open lands after the delete and no version change arrives. The cache now checks the mark again once the open succeeds, and closes the connection if a reset happened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Comments Outside DiffThese findings could not be posted inline.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #43, fixing the gap Devin and Greptile both reported there. A tab whose IndexedDB model cache had not opened yet never learned about another tab's reset. Its reset count is local to the page, and a
versionchangeonly reaches open connections. Its first write then recreated the deleted database and stored the model again.Each reset now also writes a new random value to a
localStoragekey that every tab shares. A cache created before that value changed stays empty, as it already did after a reset in its own page. The key holds no image or model data. The value is written only where IndexedDB exists. WithoutlocalStorage, such as in some privacy modes, only resets in the same page are seen, as before.Another tab can also reset between a cache's check and its open request. The open then lands after the delete, and no version change arrives. So the cache checks the mark again once the open succeeds, and closes the connection if a reset happened.
Two new cache tests load a second copy of the module to stand in for another tab. One resets before the cache opens and fails on main. The other resets between the check and the open request, and it fails without the second check.
I checked it in headless Chrome with two real tabs sharing an origin, over plain http on this machine's Tailscale address. Tab A stored a model and created a second cache without opening it. Tab B reset. Tab A then wrote through the unopened cache. With main's module, a new cache in tab A read the model back. With this change, it did not.
I also ran the remover on WASM from this branch's build over the same origin, so it used IndexedDB after that reset marker was set. The first image processed in 61 s, and the PNG has alpha from 0 to 255 with 245,444 fully transparent pixels. After a reload the model sat in IndexedDB (34 entries), and a second image processed in 51 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 (202 browser, 98 web) and build pass.
Created with Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code