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.

feat: share file upload limits between frontend and backend via API (#1398)

LearningCircuit50cd129125e0
diff --git a/src/local_deep_research/__version__.py b/src/local_deep_research/__version__.py
index 51cd752de5..56241c5d78 100644
--- a/src/local_deep_research/__version__.py
+++ b/src/local_deep_research/__version__.py
@@ -1 +1 @@
-__version__ = "1.3.17"
+__version__ = "1.3.18"
diff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.py
index 5d7f95ecd3..85c07ef9d8 100644
--- a/src/local_deep_research/web/routes/research_routes.py
+++ b/src/local_deep_research/web/routes/research_routes.py
@@ -1499,6 +1499,23 @@ def get_queue_position(research_id):
), 500
+@research_bp.route("/api/config/limits", methods=["GET"])
+def get_upload_limits():
+ """
+ Get file upload configuration limits.
+
+ Returns the backend's authoritative limits for file uploads,
+ allowing the frontend to stay in sync without hardcoding values.
+ """
+ return jsonify(
+ {
+ "max_file_size": FileUploadValidator.MAX_FILE_SIZE,
+ "max_files": FileUploadValidator.MAX_FILES_PER_REQUEST,
+ "allowed_mime_types": list(FileUploadValidator.ALLOWED_MIME_TYPES),
+ }
+ )
+
+
@research_bp.route("/api/upload/pdf", methods=["POST"])
@login_required
@upload_rate_limit
diff --git a/src/local_deep_research/web/static/js/config/urls.js b/src/local_deep_research/web/static/js/config/urls.js
index 1d42ce02b4..537915b5f1 100644
--- a/src/local_deep_research/web/static/js/config/urls.js
+++ b/src/local_deep_research/web/static/js/config/urls.js
@@ -27,7 +27,8 @@ if (typeof URLS !== 'undefined') {
MARKDOWN_EXPORT: '/api/markdown/{id}',
HISTORY: '/history/api', // Changed to match backend route
HEALTH: '/api/v1/health', // Added health check endpoint
- UPLOAD_PDF: '/api/upload/pdf' // PDF upload endpoint
+ UPLOAD_PDF: '/api/upload/pdf', // PDF upload endpoint
+ CONFIG_LIMITS: '/api/config/limits' // Upload limits configuration
},
// Page routes
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 fa16426eea..20c70736a7 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
@@ -9,16 +9,40 @@ class PDFUploadHandler {
this.queryTextarea = null;
this.isDragOver = false;
this.uploadedPDFs = [];
+ // Default fallback values (used if API is unavailable)
this.maxFileSize = 50 * 1024 * 1024; // 50MB limit
- this.maxFiles = 100; // Maximum 100 PDFs at once
+ this.maxFiles = 200; // Maximum PDFs at once
this.statusTimers = []; // Track setTimeout IDs to prevent timer leaks
+ this.limitsLoaded = false;
this.init();
}
+ /**
+ * Fetch upload limits from the backend API
+ * This ensures frontend and backend stay in sync
+ */
+ async fetchUploadLimits() {
+ try {
+ const limitsUrl = URLS?.API?.CONFIG_LIMITS || '/api/config/limits';
+ const response = await fetch(limitsUrl);
+ if (response.ok) {
+ const limits = await response.json();
+ this.maxFileSize = limits.max_file_size;
+ this.maxFiles = limits.max_files;
+ this.limitsLoaded = true;
+ console.log(`PDF Upload Handler: Loaded limits from API - maxFileSize: ${this.formatFileSize(this.maxFileSize)}, maxFiles: ${this.maxFiles}`);
+ } else {
+ console.warn('PDF Upload Handler: Could not fetch limits from API, using defaults');
+ }
+ } catch (error) {
+ console.warn('PDF Upload Handler: Error fetching limits, using defaults:', error.message);
+ }
+ }
+
/**
* Initialize the PDF upload handler
*/
- init() {
+ async init() {
console.log('PDF Upload Handler: Starting initialization...');
// Wait a bit longer for DOM to be ready
@@ -27,6 +51,9 @@ 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) {
console.error('PDF Upload Handler: Query textarea not found!');