Skip to content

feat: PAC script URL source with per-profile auto-refresh#60

Merged
SYM01 merged 2 commits intodevelopfrom
feat/pac-url-auto-update
Apr 16, 2026
Merged

feat: PAC script URL source with per-profile auto-refresh#60
SYM01 merged 2 commits intodevelopfrom
feat/pac-url-auto-update

Conversation

@SYM01
Copy link
Copy Markdown
Collaborator

@SYM01 SYM01 commented Apr 16, 2026

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.

  • Data model: 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.
  • Fetcher service (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.
  • Adapter layer: new alarms permission, plus createPeriodicAlarm, clearAlarm, getAllAlarmNames, onAlarm across Chrome / Firefox / Web stub.
  • UI: URL input + Fetch Now button, refresh-interval select (defaults to every hour), last-fetched / last-error indicators using Arco's a-typography-text.

Test plan

  • npm run coverage — 93 tests pass, including new pacFetcher tests (fetch success / HTTP error / network failure / timeout / changed / unchanged / error-preserves-data / non-pac skip)
  • npm run build (Chrome) and npm run build:firefox both succeed
  • Load unpacked build in Chrome, create a PAC profile with a test URL, verify Fetch Now populates the script
  • Activate a URL-backed profile, change the remote content, wait for the configured interval, confirm the new script is applied without re-opening the config page
  • Set interval to "Disabled" and verify no alarms fire (chrome://extensions → Service worker console)
  • Export config with a URL-backed profile, re-import, verify sourceURL / refreshIntervalMinutes survive the round-trip
  • Firefox: load dist/ as temporary add-on, repeat fetch + activation

🤖 Generated with Claude Code

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>
gemini-code-assist[bot]

This comment was marked as low quality.

@bytevet bytevet deleted a comment from gemini-code-assist bot Apr 16, 2026
@bytevet bytevet deleted a comment from gemini-code-assist bot Apr 16, 2026
@bytevet bytevet deleted a comment from gemini-code-assist bot Apr 16, 2026
@bytevet bytevet deleted a comment from gemini-code-assist bot Apr 16, 2026
@bytevet bytevet deleted a comment from gemini-code-assist bot Apr 16, 2026
@bytevet bytevet deleted a comment from gemini-code-assist bot Apr 16, 2026
`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>
@SYM01 SYM01 merged commit 2fbfb56 into develop Apr 16, 2026
6 checks passed
@SYM01 SYM01 deleted the feat/pac-url-auto-update branch April 16, 2026 15:06
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