feat: PAC script URL source with per-profile auto-refresh#60
Merged
Conversation
Closes #41. PAC profiles can now be populated from a remote URL instead of pasting the script inline. Each URL-backed profile has its own refresh interval (5m to 24h, or disabled) and its own alarm; the active profile is also refreshed on service-worker wake if it's been stale for more than 5 minutes. - `PacScriptConfig` carries `data`, `sourceURL`, `refreshIntervalMinutes`, `lastFetched`, `lastError`; the chrome-native PacScript type only crosses the adapter boundary, so the new fields never leak into `chrome.proxy.settings`. - `pacFetcher.ts` handles one-shot fetches (with 15s timeout + 1MB cap), change-detection, per-profile alarm reconciliation, and wake-time refresh of the active profile. - Added `alarms` permission + `createPeriodicAlarm` / `clearAlarm` / `getAllAlarmNames` / `onAlarm` to the adapter layer. - `ProfileConfig.vue` adds a URL input, Fetch Now button, interval select (defaults to every hour), and last-fetched / last-error indicators using `a-typography-text`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
`onProfileUpdate` was an in-memory callback list, so saves made from the popup/config page never reached the background. Alarm reconciliation therefore missed interval changes until the next service-worker wake. Route `onProfileUpdate` through `chrome.storage.local.onChanged` instead — the browser dispatches storage events in every extension context, so subscribers fire regardless of which context wrote. `overwriteProfiles` no longer fans out in-memory; the storage event does it. Added `onLocalStorageChanged` to the adapter layer (Chrome/Firefox wrap the native event; the WebBrowser dev adapter simulates it so local dev reactivity still works). Co-Authored-By: Claude Opus 4.6 (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.
Summary
Closes #41. PAC profiles can now be populated from a remote URL instead of pasting the script inline. Each URL-backed profile gets its own refresh interval (5m to 24h, or disabled) and its own alarm. The active profile is also refreshed on service-worker wake if it's been stale for more than 5 minutes.
PacScriptConfigcarriesdata,sourceURL,refreshIntervalMinutes,lastFetched,lastError. The chrome-nativePacScripttype only crosses the adapter boundary, so the new fields never leak intochrome.proxy.settings.src/services/proxy/pacFetcher.ts): one-shot fetches with 15s timeout + 1MB body cap, change-detection (no-op saves are suppressed), per-profile alarm reconciliation, and wake-time refresh of the active profile.alarmspermission, pluscreatePeriodicAlarm,clearAlarm,getAllAlarmNames,onAlarmacross Chrome / Firefox / Web stub.a-typography-text.Test plan
npm run coverage— 93 tests pass, including newpacFetchertests (fetch success / HTTP error / network failure / timeout / changed / unchanged / error-preserves-data / non-pac skip)npm run build(Chrome) andnpm run build:firefoxboth succeedchrome://extensions→ Service worker console)sourceURL/refreshIntervalMinutessurvive the round-tripdist/as temporary add-on, repeat fetch + activation🤖 Generated with Claude Code