Skip to content

fix: capture OnTrack data on first install without a manual reload - #21

Merged
Aarav261 merged 1 commit into
mainfrom
claude/first-install-capture-fix
Jul 15, 2026
Merged

fix: capture OnTrack data on first install without a manual reload#21
Aarav261 merged 1 commit into
mainfrom
claude/first-install-capture-fix

Conversation

@Aarav261

Copy link
Copy Markdown
Owner

Summary

  • Backfill content.js/injected.js into any already-open OnTrack tab on install/update via chrome.scripting.executeScript (new scripting permission) — Chrome never retroactively injects content_scripts into tabs opened before the extension was installed, so a student who already had OnTrack open got no capture until they manually reloaded.
  • Harden the extension's ingest dedup cache to only mark a payload as sent on genuine success (2xx + ok: true + no skipped) instead of on any resolved JSON body — a 404 "not subscribed" (ingest fires the moment the content script loads, before the popup's /link-ontrack has created the backend user row) was being cached as if it had landed, so the same task data never retried until it changed or the service worker restarted.
  • Bump extension to 1.13.0 — the new scripting permission changes what's shown on install/update.

Test plan

  • ruff check . passes
  • pytest passes (12 passed) — unaffected backend suite, run as a baseline check
  • npm run lint passes in extension/
  • npm run build succeeds; verified the built dist/manifest.json carries the new permission and dist/background.js matches the source unmodified
  • Manual: load unpacked in Chrome with an OnTrack tab already open, confirm task capture starts without reloading that tab

Generated by Claude Code

Two gaps left a brand-new install silently empty:

- Chrome never runs content_scripts in a tab that was already open before
  install/update, so a student who had OnTrack open (likely, since that's
  why they installed the extension) got no capture until they reloaded.
  Backfill content.js/injected.js into any already-open matching tab from
  onInstalled via chrome.scripting.executeScript.
- The ingest dedup cache marked a payload as "sent" on any resolved JSON
  response, including a 404 "not subscribed" (ingest fires the moment the
  content script loads, before the popup's /link-ontrack has created the
  backend user row) or a `skipped` rejection. Once cached, the identical
  task data never retried until it changed or the ephemeral service worker
  restarted. Only cache on genuine success now (2xx + ok:true + no skipped).

Bump to 1.13.0 — the scripting permission addition changes what's shown on
install/update.
Copilot AI review requested due to automatic review settings July 15, 2026 00:59
@Aarav261
Aarav261 merged commit 702eb00 into main Jul 15, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Chrome extension so it can start capturing OnTrack data immediately after installation (without requiring the user to manually reload an already-open OnTrack tab) and improves reliability of the background ingest dedup cache by only deduping after confirmed successful storage.

Changes:

  • Add scripting permission and backfill-inject the content script into any already-open OnTrack tabs on install.
  • Harden /ingest dedup caching to only mark a payload as sent on confirmed success (HTTP 2xx + ok: true + not skipped).
  • Bump extension version to 1.13.0.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
extension/public/manifest.json Bumps version and adds scripting permission needed for runtime injection.
extension/public/background.js Injects content script into already-open OnTrack tabs on install and tightens ingest dedup success criteria.
extension/package.json Bumps extension package version to 1.13.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +12 to 25
chrome.runtime.onInstalled.addListener(async () => {
let tabs;
try {
tabs = await chrome.tabs.query({ url: "https://ontrack.deakin.edu.au/*" });
} catch {
return; // host permission not yet granted or tabs API unavailable
}
for (const tab of tabs) {
if (!tab.id) continue;
chrome.scripting
.executeScript({ target: { tabId: tab.id }, files: ["config.js", "content.js"] })
.catch(() => {}); // e.g. a chrome:// or restricted tab matched unexpectedly
}
});
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.

3 participants