Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ui): bind listeners before async init awaits in pdf-upload + help (#4421)

LearningCircuitef77e37ad581
diff --git a/src/local_deep_research/web/static/js/pdf_upload_handler.js b/src/local_deep_research/web/static/js/pdf_upload_handler.js
index 36f1774733..446d058e09 100644
--- a/src/local_deep_research/web/static/js/pdf_upload_handler.js
+++ b/src/local_deep_research/web/static/js/pdf_upload_handler.js
@@ -51,9 +51,6 @@ class PDFUploadHandler {
return;
}
- // Fetch upload limits from backend (non-blocking, uses defaults as fallback)
- await this.fetchUploadLimits();
-
this.queryTextarea = document.getElementById('query');
if (!this.queryTextarea) {
SafeLogger.error('PDF Upload Handler: Query textarea not found!');
@@ -61,8 +58,19 @@ class PDFUploadHandler {
}
SafeLogger.log('PDF Upload Handler: Found query textarea, setting up drag-and-drop...');
+ // Bind drag/drop/paste listeners SYNCHRONOUSLY, before the awaited
+ // limits fetch below. The #query textarea exists in static HTML, so
+ // wiring after the await left a window where a PDF dropped/pasted
+ // onto it was silently ignored (no handler attached). Validation
+ // uses the default limits until fetchUploadLimits() resolves.
this.setupDragAndDrop();
this.setupFileInput();
+
+ // Fetch upload limits from backend (non-blocking, uses defaults as
+ // fallback). Only affects validation thresholds, not event wiring.
+ await this.fetchUploadLimits();
+
+ // Refresh the placeholder now that real limits are known.
this.updatePlaceholder();
SafeLogger.log('PDF Upload Handler: Initialization complete!');
}
diff --git a/src/local_deep_research/web/static/js/services/help.js b/src/local_deep_research/web/static/js/services/help.js
index 1a5007a05a..72d9183d9a 100644
--- a/src/local_deep_research/web/static/js/services/help.js
+++ b/src/local_deep_research/web/static/js/services/help.js
@@ -268,10 +268,10 @@ const HelpService = (function() {
// returns at the guard above instead of double-running everything.
initialized = true;
- // Initialize panel states (async to load from backend)
- await initPanelStates();
-
- // Add keyboard navigation for tooltips
+ // Add keyboard navigation for tooltips SYNCHRONOUSLY, before the
+ // awaited panel-state load below. The tooltips exist in static
+ // HTML, so binding after the await left a window where Enter/Space
+ // on a tooltip was lost (no handler attached yet).
document.querySelectorAll('.ldr-help-tooltip').forEach(tooltip => {
tooltip.addEventListener('keydown', function(e) {
// Show tooltip on Enter or Space
@@ -283,6 +283,9 @@ const HelpService = (function() {
}
});
});
+
+ // Initialize panel states (async to load from backend)
+ await initPanelStates();
}
// Auto-initialize when DOM is ready