fix(ext): reconcile on setup so existing bookmarks import (#54)#55
Merged
Conversation
…ld-start (#54) Existing browser bookmarks weren't imported after setup: reconcile only ran from top-level `void maybeReconcile()` on SW eval, which on install sees null settings and bails — and saving settings didn't re-trigger it. Nothing tied reconcile to "setup completed", so existing bookmarks never reached GitHub unless the browser happened to restart. Add top-level-registered lifecycle triggers in background.ts: - storage.onChanged on the settings key → clear the staleness stamp and reconcile immediately (setup completed / repo switched) so bookmarks import within seconds. Gated by a pure `isSettingsChange()` predicate to avoid a self-trigger loop (reconcile's own lastReconciledAt/etag writes are other keys). - runtime.onInstalled + runtime.onStartup → maybeReconcile (more reliable than top-level eval alone). Export SETTINGS_KEY from settings.ts for the storage listener. runMaybeReconcile's 1h staleness guard still applies to the eval/startup paths. Tests: +4 isSettingsChange cases (extension-shared 115 → 119; total 306 → 310). Docs: README gets a full categorized Features rundown (extension + web UI + foundation) and an "Importing existing bookmarks" section; CLAUDE.md + both shell READMEs document the new reconcile triggers and an import smoke step. Closes #54 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #54.
Problem
Existing browser bookmarks weren't imported after setup.
reconcile()only ran from top-levelvoid maybeReconcile()on service-worker eval — which on install sees null settings and bails — and saving settings never re-triggered it. Nothing tied reconcile to setup completed, so existing bookmarks only reached GitHub if the browser happened to cold-start later. (Confirmed from a user's popup screenshot: no error banner → reconcile never ran, not an auth failure.)Fix
Top-level-registered lifecycle triggers in
background.ts:storage.onChangedon the settings key → clear the staleness stamp and reconcile immediately (setup completed / repo switched). Registered at top level so the SW wakes for the event even when terminated. Gated by a pureisSettingsChange()predicate so reconcile's ownlastReconciledAt/etag writes don't self-trigger a loop.runtime.onInstalled+runtime.onStartup→maybeReconcile()(more reliable than top-level eval alone).runMaybeReconcile's 1-hour staleness guard still applies to the eval/startup paths.Tests
+4
isSettingsChangecases — extension-shared 115 → 119, monorepo total 306 → 310. Typecheck + both shell builds clean.Docs (per 'document everything / show ALL FEATURES')
🤖 Generated with Claude Code