feat(extension): Firefox runtime — recorder window, storage fallbacks, and overlay injection#2001
Conversation
… script for Firefox
…teScript overlay module on Firefox
| chrome.windows.onRemoved.addListener(() => { | ||
| if (capabilities.supportsOffscreen) return; | ||
| void syncRecordingStatus().catch(() => undefined); | ||
| }); |
There was a problem hiding this comment.
When the Firefox recorder popup is closed while it is waiting on the arm button, this removal handler calls syncRecordingStatus(), but that path only resets statuses considered active. creating is not active, so the service worker keeps returning the stale starting state and the recording UI can stay stuck until another action overwrites it.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/chrome-extension/src/background/service-worker.ts
Line: 1925-1928
Comment:
**Creating State Stays Stuck**
When the Firefox recorder popup is closed while it is waiting on the arm button, this removal handler calls `syncRecordingStatus()`, but that path only resets statuses considered active. `creating` is not active, so the service worker keeps returning the stale starting state and the recording UI can stay stuck until another action overwrites it.
How can I resolve this? If you propose a fix, please make it concise.| // script (overlay, countdown, recording bar) stays inert until the user | ||
| // grants access here. The click on the button supplies the required user | ||
| // gesture for permissions.request. | ||
| const HOST_PERMISSION_ORIGINS = ["http://*/*", "https://*/*"]; |
There was a problem hiding this comment.
The Firefox manifest declares file:///* and the injection logic accepts file: tabs, but this permission request only asks for http and https. A Firefox user can complete the new grant flow and still never grant local-file access, so the content script, countdown, and recording toolbar will not run on file:// pages despite the manifest advertising support.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/chrome-extension/src/welcome/main.ts
Line: 53
Comment:
**File Permission Never Granted**
The Firefox manifest declares `file:///*` and the injection logic accepts `file:` tabs, but this permission request only asks for `http` and `https`. A Firefox user can complete the new grant flow and still never grant local-file access, so the content script, countdown, and recording toolbar will not run on `file://` pages despite the manifest advertising support.
How can I resolve this? If you propose a fix, please make it concise.| // setAccessLevel at all — calling it unconditionally throws and kills the | ||
| // whole background script — so content scripts there rely on the runtime | ||
| // message fallbacks instead of the session-storage mirror. | ||
| chrome.storage.session.setAccessLevel?.({ |
There was a problem hiding this comment.
minor hardening: this still throws if chrome.storage.session is undefined (not just setAccessLevel).
| chrome.storage.session.setAccessLevel?.({ | |
| chrome.storage.session?.setAccessLevel?.({ |
| chrome.windows.onRemoved.addListener(() => { | ||
| if (capabilities.supportsOffscreen) return; | ||
| void syncRecordingStatus().catch(() => undefined); | ||
| }); |
There was a problem hiding this comment.
this fires on any window close; quick guard avoids extra getContexts calls when idle.
| chrome.windows.onRemoved.addListener(() => { | |
| if (capabilities.supportsOffscreen) return; | |
| void syncRecordingStatus().catch(() => undefined); | |
| }); | |
| chrome.windows.onRemoved.addListener(() => { | |
| if (capabilities.supportsOffscreen) return; | |
| if (recordingStatus.phase === "idle") return; | |
| void syncRecordingStatus().catch(() => undefined); | |
| }); |
| readFileSync( | ||
| resolve(__dirname, `../../manifests/manifest.${target}.json`), | ||
| "utf8", | ||
| ), |
There was a problem hiding this comment.
__dirname can be undefined under ESM (and this package is type: module). using import.meta.url keeps this stable in vitest.
| readFileSync( | |
| resolve(__dirname, `../../manifests/manifest.${target}.json`), | |
| "utf8", | |
| ), | |
| readFileSync( | |
| new URL(`../../manifests/manifest.${target}.json`, import.meta.url), | |
| "utf8", | |
| ), |
Stacked on #2000 #1998 , only the last commits are new here, the earlier ones will disappear once the base PR merges.
Makes the Firefox build fully functional; every fix here was found and verified in live Firefox QA (recording → instant upload → share-page playback confirmed working on Firefox ESR 140):
Greptile Summary
This PR adds a Firefox-capable build for the browser extension. The main changes are:
Confidence Score: 4/5
The Firefox recorder startup and local-file permission paths need fixes before merging.
creating.file:///*origin.apps/chrome-extension/src/background/service-worker.ts, apps/chrome-extension/src/welcome/main.ts, apps/chrome-extension/src/popup/main.tsx
Important Files Changed
creatingstatus stale.storage.localon Firefox and clears those keys on browser startup.Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(extension): harden Firefox recorder ..." | Re-trigger Greptile
Context used: