Fix PII mapping add (plus button) not persisting and not dismissing notification
The plus button handler in the pre-send PII warning had two bugs: 1. It read/wrote mappings directly via the storage bridge (api.storage.local), bypassing the Storage module's encryption layer. When at-rest encryption was enabled, getStorageData returned an encrypted blob instead of an array, causing .push() to throw a TypeError that silently aborted the handler — the mapping was never saved and replaceInInput never ran. 2. Unlike the ignore button which immediately removes the DOM item, the plus button relied on a re-scan at 150ms to dismiss the notification. If replaceInInput didn't stick (e.g. React-controlled inputs), the re-scan found PII again and the notification persisted. Fix: Route mapping creation through the background service worker via a new 'add:mapping' message handler (which uses Storage.addMapping with proper encryption support), and immediately dismiss the notification item from the DOM like the ignore button does. https://claude.ai/code/session_01RfzvB5sHah326acr8Xa7Jn
This commit is contained in:
@@ -193,6 +193,26 @@
|
||||
if (event.data?.type === 'ss:storage-set') {
|
||||
await api.storage.local.set({ [event.data.key]: event.data.value });
|
||||
}
|
||||
|
||||
if (event.data?.type === 'ss:add-mapping') {
|
||||
try {
|
||||
const response = await api.runtime.sendMessage({
|
||||
type: 'add:mapping',
|
||||
mapping: event.data.mapping,
|
||||
});
|
||||
window.postMessage({
|
||||
type: 'ss:add-mapping-result',
|
||||
id: event.data.id,
|
||||
mappings: response?.mappings || [],
|
||||
}, '*');
|
||||
} catch {
|
||||
window.postMessage({
|
||||
type: 'ss:add-mapping-result',
|
||||
id: event.data.id,
|
||||
mappings: [],
|
||||
}, '*');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user