fix: PPI warning accept/ignore buttons — v2.0.14
Accept (+) button: - Was reading raw storage (getStorageData) which returns encrypted blobs when encryption is enabled, silently failing to add mappings - Fixed: adds directly to the local mappings array and persists via setStorageData (storage bridge handles encryption transparently) Auto-detect false positives: - Was only checking identity values, not explicit mappings — values already in the mappings table still got flagged as unconfigured PPI - Fixed: now adds all mapping real/substitute values to the skip set Ignore button: - Changed from plain text link to grey pill button for better UX - Still persists permanently via ss_ignored_ppi in storage https://claude.ai/code/session_01SWSwDfMVij53bCTNSCLMwn
This commit is contained in:
+15
-13
@@ -578,7 +578,7 @@
|
||||
if (!text || text.length < 5) return [];
|
||||
const hasContext = CONTEXT_WORDS_RE.test(text);
|
||||
|
||||
// Build skip set from configured values
|
||||
// Build skip set from configured values (identity + explicit mappings)
|
||||
const configured = new Set();
|
||||
if (ident) {
|
||||
const addAll = (arr, key) => (arr || []).forEach(item => {
|
||||
@@ -588,6 +588,11 @@
|
||||
addAll(ident.names); addAll(ident.emails);
|
||||
addAll(ident.usernames); addAll(ident.hostnames); addAll(ident.phones);
|
||||
}
|
||||
// Also skip values that are already in explicit mappings
|
||||
for (const m of mappings) {
|
||||
if (m.real) configured.add(m.real.toLowerCase());
|
||||
if (m.substitute) configured.add(m.substitute.toLowerCase());
|
||||
}
|
||||
|
||||
const findings = [];
|
||||
for (const pat of PPI_PATTERNS) {
|
||||
@@ -1848,13 +1853,12 @@
|
||||
const items = warnings.slice(0, 8).map((w, i) => {
|
||||
const fake = generateFake(w.name, w.value);
|
||||
const displayVal = w.value.length > 25 ? w.value.slice(0, 22) + '...' : w.value;
|
||||
const displayFake = fake.length > 20 ? fake.slice(0, 17) + '...' : fake;
|
||||
return `<div class="ss-ps-item">
|
||||
<span class="ss-ps-type">${w.name}</span>
|
||||
<code class="ss-ps-value">${displayVal}</code>
|
||||
<span class="ss-ps-hint">${w.hint}</span>
|
||||
${settings.autoAddDetected !== false
|
||||
? `<button class="ss-ps-add" data-real="${encodeURIComponent(w.value)}" data-fake="${encodeURIComponent(fake)}" data-cat="${w.category}" title="Add mapping: ${displayVal} → ${fake}">+</button>`
|
||||
: ''}
|
||||
<button class="ss-ps-add" data-real="${encodeURIComponent(w.value)}" data-fake="${encodeURIComponent(fake)}" data-cat="${w.category}" title="Add mapping: ${displayVal} → ${displayFake}">+</button>
|
||||
<button class="ss-ps-ignore" data-value="${encodeURIComponent(w.value)}" title="Never flag this value again">ignore</button>
|
||||
</div>`;
|
||||
}).join('');
|
||||
@@ -1881,28 +1885,26 @@
|
||||
preSendWarningEl.classList.remove('visible');
|
||||
});
|
||||
|
||||
// Auto-add buttons
|
||||
// Auto-add buttons (+)
|
||||
preSendWarningEl.querySelectorAll('.ss-ps-add').forEach(btn => {
|
||||
btn.addEventListener('click', async () => {
|
||||
const real = decodeURIComponent(btn.dataset.real);
|
||||
const fake = decodeURIComponent(btn.dataset.fake);
|
||||
const cat = btn.dataset.cat || 'general';
|
||||
|
||||
// Add to mappings via storage
|
||||
const result = await getStorageData('ss_mappings');
|
||||
const currentMappings = result || [];
|
||||
currentMappings.push({
|
||||
// Add to local mappings array (used by the fetch interceptor)
|
||||
const newMapping = {
|
||||
id: crypto.randomUUID(),
|
||||
real, substitute: fake,
|
||||
category: cat,
|
||||
caseSensitive: false,
|
||||
enabled: true,
|
||||
createdAt: Date.now(),
|
||||
});
|
||||
await setStorageData('ss_mappings', currentMappings);
|
||||
};
|
||||
mappings.push(newMapping);
|
||||
|
||||
// Update local mappings so the fetch interceptor uses them immediately
|
||||
mappings = currentMappings;
|
||||
// Persist via storage bridge (handles encryption transparently)
|
||||
setStorageData('ss_mappings', mappings);
|
||||
|
||||
// Replace the PPI value in the current input right now
|
||||
if (inputEl) {
|
||||
|
||||
Reference in New Issue
Block a user