Skip to content

fix(extension): persist and serialize per-tab runtime state#8

Open
llmxtfai wants to merge 2 commits intoonllm-dev:mainfrom
llmxtfai:fix/mv3-tab-state-persistence-race
Open

fix(extension): persist and serialize per-tab runtime state#8
llmxtfai wants to merge 2 commits intoonllm-dev:mainfrom
llmxtfai:fix/mv3-tab-state-persistence-race

Conversation

@llmxtfai
Copy link

Problem

This Tab can flip back to Off after hard reload (Ctrl+Shift+R) because MV3 background worker state was in-memory only and gets reset on worker restart.

Fix

  • Persist per-tab runtime state (enabled, annotateMode) to chrome.storage.session
  • Hydrate state manager from session storage on access
  • Convert state manager methods to async and await in background message handlers
  • Serialize session-storage writes with a queue to prevent stale snapshot overwrites during rapid updates

Tests

Added packages/extension/src/background/state.test.ts:

  • restores enabled state after simulated worker restart
  • persists runtime updates to session storage
  • regression for out-of-order write race (ensures latest state survives)

Validation

  • pnpm --filter @onui/extension test (pass: 7 files, 20 tests)
  • pnpm --filter @onui/extension typecheck (pass)

Steve Olson added 2 commits February 28, 2026 12:52
Persist per-tab runtime state in chrome.storage.session so hard reloads and MV3 worker restarts do not reset This Tab toggle. Convert background state accessors to async and await them in message handlers. Serialize storage writes with a queue to prevent stale snapshot overwrites, and add regression tests for restart restore and write-order safety.
Add shared log filter that suppresses [onUI...] console.log output in production builds while keeping warnings/errors. Initialize filter in content, background, and popup entrypoints. Keep logs opt-in via localStorage key onui_debug_logs=1 or true.
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