This repository was archived by the owner on Oct 15, 2026. It is now read-only.
Repository navigation
refactor(background): split index.ts into domain modules - #10
Merged
kevinraymond merged 2 commits intoApr 27, 2026
Merged
Conversation
Trim src/background/index.ts from 1756 to 142 lines by moving
message handlers, lifecycle logic, and listener bodies into
domain modules. The MV3 service worker still registers all
listeners synchronously at module top level so wake-up events
aren't missed.
- messages/{suspension,sessions,cloud,pro,recovery,exportReminder,
dedup,backupHealth,devtools}.ts: one handler per slice of the
MessageType union; messages/index.ts is the central dispatcher
- lifecycle/{hibernation,onInstalled,onStartup}.ts: install/startup
handlers and the post-startup re-discard guard
- state.ts, badge.ts, alarms.ts, contextMenus.ts: shared helpers
- listeners.ts: listener bodies (registrations stay in index.ts)
No behavior change. The MessageType union is unchanged.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Mirror the pre-PR coverage semantics. The old src/background/index.ts
was excluded by the src/**/index.ts entry-point rule, so the handler
code inside it was never measured. Now that the same code lives in
src/background/{listeners,lifecycle/*,messages/*}.ts, codecov sees
643 "newly uncovered" lines on what is in fact unchanged code.
Add the moved files to the exclude list so the coverage signal
reflects what's actually been tested.
https://claude.ai/code/session_012cj1ZbkZ5aJop1tCDtJ9QQ
kevinraymond
deleted the
claude/modularize-background-service-worker-qChjG
branch
April 27, 2026 07:49
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Trims
src/background/index.tsfrom 1756 → 142 lines by moving message handlers, lifecycle logic, and listener bodies into domain modules. Future PRs can touch one concern at a time without re-reading the entire service worker.The MV3 service worker still registers all listeners synchronously at module top level so wake-up events aren't dropped during cold start.
Layout
messages/{suspension,sessions,cloud,pro,recovery,exportReminder,dedup,backupHealth,devtools}.ts— one handler per slice of theMessageTypeunionmessages/index.ts— centralhandleMessagedispatcher (with exhaustiveness check)messages/types.ts— the unchangedMessageTypeunionlifecycle/{hibernation,onInstalled,onStartup}.ts— install/startup handlers and the post-startup re-discard guard (its comment block moved with it)state.ts,badge.ts,alarms.ts,contextMenus.ts— shared helperslisteners.ts— listener bodies (registrations stay inindex.ts)No behavior change. The
MessageTypeunion is unchanged.Test plan
pnpm typecheckpnpm lintpnpm test --run(745/745 passing)Alt+Shift+Sand confirm the active tab discards (validates synchronous listener registration on wake)https://claude.ai/code/session_012cj1ZbkZ5aJop1tCDtJ9QQ
Generated by Claude Code