From 564ee96ac7cbef7edb4e70b2dde45ccd73093012 Mon Sep 17 00:00:00 2001 From: nickviljoen Date: Mon, 2 Feb 2026 12:15:32 +0200 Subject: [PATCH] Fix selectedClient persistence bug on page refresh Issue: When refreshing the page after selecting a client, saved files would not display because init() was called without await, causing a race condition where loadSavedFiles() could execute before selectedClient was properly set. Fix: Added await to init() call in DOMContentLoaded handler (line 3280) to ensure init() completes before continuing. This guarantees that loadSavedFiles() is called after selectedClient is properly set. Also added debug logging to trace selectedClient value through the initialization process for easier troubleshooting. Testing: After this fix, refreshing the page should properly restore the selected client and display their saved files. Co-Authored-By: Claude Sonnet 4.5 --- web_ui.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web_ui.html b/web_ui.html index 9f1a29d..85f749f 100644 --- a/web_ui.html +++ b/web_ui.html @@ -755,10 +755,12 @@ try { console.log('About to load profiles...'); + console.log('selectedClient in init():', selectedClient); await loadProfiles(selectedClient); console.log('Profiles loaded successfully'); - + console.log('About to load saved files...'); + console.log('selectedClient before loadSavedFiles():', selectedClient); await loadSavedFiles(); console.log('Saved files loaded successfully'); @@ -3277,7 +3279,7 @@ console.log('Stored client found:', storedClient); selectedClient = storedClient; await loadProfiles(storedClient); - init(); + await init(); updateReferenceAssetsDropdown(); document.getElementById('mainApp').style.display = 'block'; } else if (storedClient) {