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.

refactor: Move follow-up modal HTML to separate template file

LearningCircuiteb17baad2a37
diff --git a/src/local_deep_research/web/static/js/followup.js b/src/local_deep_research/web/static/js/followup.js
index 2b7b496843..a134e6acee 100644
--- a/src/local_deep_research/web/static/js/followup.js
+++ b/src/local_deep_research/web/static/js/followup.js
@@ -77,76 +77,23 @@ class FollowUpResearch {
return;
}
- // Try to load modal template from server
+ // Load modal template from server
try {
const response = await fetch('/static/templates/followup_modal.html');
- if (response.ok) {
- const modalHtml = await response.text();
- document.body.insertAdjacentHTML('beforeend', modalHtml);
- this.modalElement = document.getElementById('followUpModal');
- this.attachModalEventHandlers();
- return;
+ if (!response.ok) {
+ throw new Error(`Failed to load modal template: ${response.status}`);
}
+
+ const modalHtml = await response.text();
+ document.body.insertAdjacentHTML('beforeend', modalHtml);
+ this.modalElement = document.getElementById('followUpModal');
+ this.attachModalEventHandlers();
+ this.addModalStyles();
} catch (e) {
- console.debug('Could not load modal template, using inline HTML');
+ console.error('Error loading follow-up modal template:', e);
+ // Show error message to user
+ this.showModalLoadError();
}
-
- // Fallback to inline HTML if template not available
- const modalHtml = `
- <div class="modal fade" id="followUpModal" tabindex="-1" aria-labelledby="followUpModalLabel" aria-hidden="true" style="z-index: 10000;">
- <div class="modal-dialog modal-lg modal-dialog-centered">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">Ask a Follow-up Question</h5>
- <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
- </div>
- <div class="modal-body">
- <div class="alert alert-info">
- <i class="fas fa-info-circle"></i>
- <strong>What you can do with follow-up:</strong>
- <ul class="mb-0 mt-2">
- <li>Ask deeper questions about the research findings</li>
- <li>Request different formatting (e.g., "provide this data in a table")</li>
- <li>Explore specific aspects in more detail</li>
- <li>Get clarification on complex topics</li>
- </ul>
- <small class="d-block mt-2">Your follow-up will build on the previous research context and sources.</small>
- </div>
-
- <div id="parentContext" class="mb-3 p-3 bg-light rounded" style="display: none;">
- <h6>Previous Research:</h6>
- <p id="parentSummary" class="text-muted"></p>
- <small><span id="parentSources"></span> sources available for reuse</small>
- </div>
-
- <div class="mb-3">
- <label for="followUpQuestion" class="form-label">Your Follow-up Question:</label>
- <textarea
- id="followUpQuestion"
- class="form-control"
- rows="3"
- placeholder="Examples: 'Can you explain the timeline in more detail?' or 'Format the key findings as a comparison table' or 'What are the long-term implications?'"
- required
- ></textarea>
- </div>
-
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
- <button type="button" class="btn btn-primary" onclick="followUpResearch.submitFollowUp()">
- <i class="fas fa-search"></i> Start Follow-up Research
- </button>
- </div>
- </div>
- </div>
- </div>
- `;
-
- // Add modal to page
- document.body.insertAdjacentHTML('beforeend', modalHtml);
- this.modalElement = document.getElementById('followUpModal');
- this.attachModalEventHandlers();
- this.addModalStyles();
}
/**
@@ -250,7 +197,12 @@ class FollowUpResearch {
*/
async showFollowUpModal() {
if (!this.modalElement) {
- this.createModal();
+ await this.createModal();
+ }
+
+ // Only proceed if modal was successfully created
+ if (!this.modalElement) {
+ return;
}
// Load parent context
@@ -261,6 +213,20 @@ class FollowUpResearch {
modal.show();
}
+ /**
+ * Show error message when modal template fails to load
+ */
+ showModalLoadError() {
+ const followUpBtn = document.getElementById('ask-followup-btn');
+ if (followUpBtn) {
+ followUpBtn.disabled = true;
+ followUpBtn.title = 'Failed to load follow-up modal template';
+ }
+
+ // Show user-friendly error
+ alert('Unable to load follow-up interface. Please refresh the page and try again.');
+ }
+
/**
* Load parent research context
*/
diff --git a/src/local_deep_research/web/static/templates/followup_modal.html b/src/local_deep_research/web/static/templates/followup_modal.html
new file mode 100644
index 0000000000..f6f7942a64
--- /dev/null
+++ b/src/local_deep_research/web/static/templates/followup_modal.html
@@ -0,0 +1,47 @@
+<div class="modal fade" id="followUpModal" tabindex="-1" aria-labelledby="followUpModalLabel" aria-hidden="true" style="z-index: 10000;">
+ <div class="modal-dialog modal-lg modal-dialog-centered">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title">Ask a Follow-up Question</h5>
+ <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
+ </div>
+ <div class="modal-body">
+ <div class="alert alert-info">
+ <i class="fas fa-info-circle"></i>
+ <strong>What you can do with follow-up:</strong>
+ <ul class="mb-0 mt-2">
+ <li>Ask deeper questions about the research findings</li>
+ <li>Request different formatting (e.g., "provide this data in a table")</li>
+ <li>Explore specific aspects in more detail</li>
+ <li>Get clarification on complex topics</li>
+ </ul>
+ <small class="d-block mt-2">Your follow-up will build on the previous research context and sources.</small>
+ </div>
+
+ <div id="parentContext" class="mb-3 p-3 bg-light rounded" style="display: none;">
+ <h6>Previous Research:</h6>
+ <p id="parentSummary" class="text-muted"></p>
+ <small><span id="parentSources"></span> sources available for reuse</small>
+ </div>
+
+ <div class="mb-3">
+ <label for="followUpQuestion" class="form-label">Your Follow-up Question:</label>
+ <textarea
+ id="followUpQuestion"
+ class="form-control"
+ rows="3"
+ placeholder="Examples: 'Can you explain the timeline in more detail?' or 'Format the key findings as a comparison table' or 'What are the long-term implications?'"
+ required
+ ></textarea>
+ </div>
+
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
+ <button type="button" class="btn btn-primary" onclick="followUpResearch.submitFollowUp()">
+ <i class="fas fa-search"></i> Start Follow-up Research
+ </button>
+ </div>
+ </div>
+ </div>
+</div>