From f2fa4befdd8fe784b4bd2d84383e7338d01f7ecc Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Mar 2026 05:19:51 +0000 Subject: [PATCH] fix: sync code import not applying data after authentication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When importing an encrypted sync code, the flow was: 1. Click Apply → importSyncCode returns needsAuth 2. Auth prompt shown → user enters password → authentication succeeds 3. Green checkmark shown... but nobody re-runs the import The user had to manually click Apply a second time. Now the import automatically retries after successful authentication via a __ssPendingSyncImport callback. https://claude.ai/code/session_01SWSwDfMVij53bCTNSCLMwn --- src/options/options.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/options/options.js b/src/options/options.js index 5f6bbbc..33d304c 100644 --- a/src/options/options.js +++ b/src/options/options.js @@ -93,15 +93,20 @@ document.addEventListener('DOMContentLoaded', async () => { setSyncStatus('', 'neutral'); }); - $('#btnApplySyncCode').addEventListener('click', async () => { + $('#btnApplySyncCode').addEventListener('click', applySyncCode); + + async function applySyncCode() { const code = $('#syncImportText').value.trim(); if (!code) return; const force = $('#syncForce').checked; const result = await SilentSendSync.importSyncCode(code, { force }); if (result.needsAuth) { - setSyncStatus('Authentication required to decrypt this sync code.', 'warn'); - showSyncAuthPrompt(); + setSyncStatus('Authentication required — enter your encryption password, then the import will continue.', 'warn'); + showSyncAuthPrompt('decrypt'); + // After auth succeeds, retry the import automatically + window.__ssPendingSyncImport = applySyncCode; } else if (result.success) { + window.__ssPendingSyncImport = null; setSyncStatus(`Imported successfully (data from ${result.importTime}).`, 'ok'); $('#syncImportSection').style.display = 'none'; $('#syncImportText').value = ''; @@ -109,6 +114,7 @@ document.addEventListener('DOMContentLoaded', async () => { settings = await Storage.getSettings(); $('#browserSync').checked = settings.browserSync === true; renderMappings(); + renderPasswords(); renderDomains(); renderLog(); } else if (result.skipped) { @@ -119,7 +125,7 @@ document.addEventListener('DOMContentLoaded', async () => { } else { setSyncStatus(`Failed: ${result.reason}`, 'error'); } - }); + } $('#btnCancelSyncImport').addEventListener('click', () => { $('#syncImportSection').style.display = 'none'; @@ -1026,6 +1032,13 @@ async function initSyncEncryptionUI() { $('#syncAuthPassword').value = ''; $('#syncAuthTOTPForPassword').value = ''; setSyncEncStatus(cached ? 'Re-verified with password.' : 'Authenticated. Sync data unlocked.', 'ok'); + + // If there's a pending sync import, retry it now that auth succeeded + if (window.__ssPendingSyncImport) { + const retry = window.__ssPendingSyncImport; + window.__ssPendingSyncImport = null; + await retry(); + } } else { setSyncAuthStatus(result.reason, 'error'); }