Skip to content
This repository was archived by the owner on Oct 15, 2026. It is now read-only.

refactor: introduce browser.* adapter for chrome.* - #9

Merged
kevinraymond merged 1 commit into
mainfrom
claude/create-browser-adapter-tmpXw
Apr 27, 2026
Merged

kevinraymond merged 1 commit into
mainfrom
claude/create-browser-adapter-tmpXw

Conversation

@kevinraymond

Copy link
Copy Markdown
Member

Summary

Preparation for the Firefox/Edge port (Phase 2 #1) — no functional change.

  • Add src/shared/browser.ts, a thin adapter that re-exports the WebExtensions namespaces Raft uses (tabs, tabGroups, windows, storage, alarms, runtime, commands, contextMenus, action, identity). On Chromium it's a pure pass-through; live property getters back each namespace so lookups always reflect the current chrome.* binding (important so existing test mocks keep working without touching tests/mocks/chrome.ts).
  • Replace every chrome.X runtime call and chrome.X.Y type reference in src/ with browser.X / browser.X.Y, plus a single import { browser } per file.
  • Comment-only mentions were also rewritten so git grep 'chrome\.' src/ returns only the adapter file itself.

The diff is almost entirely s/chrome\./browser\./g plus the new adapter file and import additions across ~26 files. Once Phase 2 swaps the adapter implementation, no call site needs to change.

Non-goals (deliberately out of scope, deferred to Phase 2):

  • No Firefox build target.
  • No API shims (e.g. no browser.tabs.discard fallback).
  • tests/mocks/chrome.ts is untouched.

Test plan

  • pnpm typecheck — clean
  • pnpm lint — 0 problems
  • pnpm test:coverage — 745/745 passing (including the 9 oauth tests that mutate chrome.identity after module load — handled by the live-getter design)
  • pnpm test:safety — 55/55 passing
  • pnpm build — clean
  • git grep 'chrome\.' src/ — returns only src/shared/browser.ts

https://claude.ai/code/session_012JBpkTyfaoEBvDdixKFX7W


Generated by Claude Code

Add src/shared/browser.ts as a thin alias over the WebExtensions API
namespaces Raft uses (tabs, tabGroups, windows, storage, alarms, runtime,
commands, contextMenus, action, identity), and replace every chrome.* call
in src/ with browser.*. This is preparation for the Firefox/Edge port:
once a Phase 2 polyfill replaces this single seam, no call site needs to
change.

On Chromium the adapter is a pure pass-through. Live property getters are
used so that namespace lookups always reflect the current chrome.* binding
(e.g. test mocks installed after module load).

No behavior change. Pure mechanical rewrite.
@codecov-commenter

codecov-commenter commented Apr 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/background/deduplication.ts 87.50% 1 Missing ⚠️
src/background/sessions.ts 93.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@kevinraymond
kevinraymond merged commit 6e45fc0 into main Apr 27, 2026
7 checks passed
@kevinraymond
kevinraymond deleted the claude/create-browser-adapter-tmpXw branch April 27, 2026 06:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants