Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .omni/e42f8a19-untitled/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

- Selection capture is coordinated in `src/background/service-worker.ts`: popup sends `CAPTURE_SCREENSHOT`, service worker injects the selection overlay, then receives `SELECTION_COMPLETE` and crops via the offscreen document.
- Popup runtime message listeners must ignore unrelated messages synchronously; an async listener can interfere with offscreen `ADD_WATERMARK` responses while the popup is open.
- Extension badge count is maintained by background `updateExtensionBadge()` from IndexedDB asset count; popup-side deletes should send `REFRESH_BADGE`.

---
_Last system refresh: 2026-05-06 07:09 UTC_
_Last system refresh: 2026-05-06 07:28 UTC_
11 changes: 11 additions & 0 deletions src/background/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ chrome.runtime.onMessage.addListener((message: ExtensionMessage, sender, sendRes
});
return true;

case 'REFRESH_BADGE':
// Only allow from extension pages, not content scripts
if (sender.tab) {
sendResponse({ success: false, error: 'Unauthorized sender' });
return false;
}
updateExtensionBadge()
.then(() => sendResponse({ success: true }))
.catch((error) => sendResponse({ success: false, error: error.message }));
return true;

default:
logger.warn('Unknown message type:', message.type);
sendResponse({ success: false, error: 'Unknown message type' });
Expand Down
13 changes: 13 additions & 0 deletions src/popup/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* Main Popup Component
*/
function PopupApp() {

Check warning on line 28 in src/popup/popup.tsx

View workflow job for this annotation

GitHub Actions / ci

Fast refresh only works when a file has exports. Move your component(s) to a separate file
const [isAuthenticated, setIsAuthenticated] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [assets, setAssets] = useState<Asset[]>([]);
Expand All @@ -40,7 +40,7 @@

useEffect(() => {
loadInitialData();
}, []);

Check warning on line 43 in src/popup/popup.tsx

View workflow job for this annotation

GitHub Actions / ci

React Hook useEffect has a missing dependency: 'loadInitialData'. Either include it or remove the dependency array

async function loadInitialData() {
setIsLoading(true);
Expand Down Expand Up @@ -195,6 +195,17 @@
}
}

async function refreshExtensionBadge() {
try {
const response = await chrome.runtime.sendMessage({ type: 'REFRESH_BADGE' });
if (!response?.success) {
logger.warn('Failed to refresh badge:', response?.error || 'Unknown error');
}
} catch (error) {
logger.warn('Failed to refresh badge:', error);
}
}

async function handleDeleteAsset(assetId: string) {
if (!confirm('Are you sure you want to delete this screenshot?')) {
return;
Expand All @@ -204,6 +215,7 @@
const updatedAssets = await indexedDBService.getAllAssets();
setAssets(updatedAssets);
setEditingAsset(null);
await refreshExtensionBadge();
} catch (error) {
logger.error('Failed to delete asset:', error);
alert('Failed to delete screenshot');
Expand Down Expand Up @@ -257,6 +269,7 @@
try {
const allAssets = await indexedDBService.getAllAssets();
await Promise.all(allAssets.map((asset) => indexedDBService.deleteAsset(asset.id)));
await refreshExtensionBadge();
} catch (error) {
logger.error('Failed to clear IndexedDB assets on logout:', error);
}
Expand Down Expand Up @@ -302,7 +315,7 @@

chrome.runtime.onMessage.addListener(handleMessage);
return () => chrome.runtime.onMessage.removeListener(handleMessage);
}, [showInsufficientCreditsNotification, huntMode.enabled]); // Add huntMode dependency

Check warning on line 318 in src/popup/popup.tsx

View workflow job for this annotation

GitHub Actions / ci

React Hook useEffect has a missing dependency: 'checkCreditStatus'. Either include it or remove the dependency array

if (isLoading) {
return (
Expand Down
3 changes: 2 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export type MessageType =
| 'ADD_WATERMARK'
| 'START_GOOGLE_AUTH'
| 'SELECTION_COMPLETE'
| 'CROP_IMAGE';
| 'CROP_IMAGE'
| 'REFRESH_BADGE';

export interface ExtensionMessage<T = any> {
type: MessageType;
Expand Down
Loading