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: Fix 'Create and Run Now' button to properly start immediate research

LearningCircuite246feea13e4
diff --git a/src/local_deep_research/web/static/js/pages/subscriptions.js b/src/local_deep_research/web/static/js/pages/subscriptions.js
index 12a81bfb8e..5a853edec5 100644
--- a/src/local_deep_research/web/static/js/pages/subscriptions.js
+++ b/src/local_deep_research/web/static/js/pages/subscriptions.js
@@ -359,7 +359,7 @@ async function toggleSubscription(subscriptionId) {
if (!subscription) return;
try {
- const response = await fetch(`/news/api/subscription/subscriptions/${subscriptionId}`, {
+ const response = await fetch(`/news/api/subscriptions/${subscriptionId}`, {
...fetchOptions,
method: 'PUT',
headers: {
diff --git a/src/local_deep_research/web/templates/pages/news-subscription-form.html b/src/local_deep_research/web/templates/pages/news-subscription-form.html
index dbd7006bf9..42719a632a 100644
--- a/src/local_deep_research/web/templates/pages/news-subscription-form.html
+++ b/src/local_deep_research/web/templates/pages/news-subscription-form.html
@@ -116,7 +116,7 @@
<div class="col-md-6 mb-3">
<label for="subscription-interval" class="form-label">Update Frequency (minutes)</label>
<input type="number" class="form-control" id="subscription-interval"
- min="1" step="1" value="{% if subscription %}{{ (subscription.refresh_interval_hours * 60)|int if subscription.refresh_interval_hours else 1440 }}{% else %}60{% endif %}" required>
+ min="1" step="1" value="{% if subscription %}{{ (subscription.refresh_interval_hours * 60)|int if subscription.refresh_interval_hours else 1440 }}{% else %}1440{% endif %}" required>
<div class="form-text">
Common values: 1 (every minute), 60 (hourly), 1440 (daily), 10080 (weekly)
<br>
@@ -219,15 +219,6 @@
Active (subscription will run automatically)
</label>
</div>
-
- {% if not subscription %}
- <div class="form-check">
- <input class="form-check-input" type="checkbox" id="subscription-run-now">
- <label class="form-check-label" for="subscription-run-now">
- Run search immediately after creating
- </label>
- </div>
- {% endif %}
</div>
<!-- Action Buttons -->
@@ -238,6 +229,11 @@
<button type="button" class="btn btn-info" id="test-subscription-btn">
<i class="bi bi-play-circle"></i> Test Run
</button>
+ {% if not subscription %}
+ <button type="button" class="btn btn-success" id="create-and-run-btn">
+ <i class="bi bi-rocket-takeoff"></i> Create & Run Now
+ </button>
+ {% endif %}
<button type="submit" class="btn btn-primary">
<i class="bi bi-save"></i> {{ 'Update' if subscription else 'Create' }} Subscription
</button>
@@ -563,6 +559,13 @@ document.addEventListener('DOMContentLoaded', async function() {
console.error('Test button not found!');
}
+ // Handle create and run button
+ const createAndRunBtn = document.getElementById('create-and-run-btn');
+ if (createAndRunBtn) {
+ console.log('Adding click handler to create and run button');
+ createAndRunBtn.addEventListener('click', handleCreateAndRun);
+ }
+
// Handle model refresh button
const modelRefreshBtn = document.querySelector('.custom-dropdown-container .refresh-btn');
if (modelRefreshBtn) {
@@ -657,7 +660,6 @@ async function handleSubscriptionSubmit(e) {
const intervalMinutes = parseInt(document.getElementById('subscription-interval').value);
const folder = document.getElementById('subscription-folder').value;
const isActive = document.getElementById('subscription-active').checked;
- const runNow = document.getElementById('subscription-run-now')?.checked || false;
// Model configuration
const modelHidden = document.getElementById('subscription-model_hidden');
@@ -709,21 +711,16 @@ async function handleSubscriptionSubmit(e) {
const data = await response.json();
showAlert('Subscription {{ "updated" if subscription else "created" }} successfully!', 'success');
- // If run now is checked, trigger the subscription
- if (runNow && data.subscription_id) {
- await runSubscription(data.subscription_id);
- } else {
- // Redirect to appropriate page after a short delay
- setTimeout(() => {
- {% if subscription %}
- // Editing - go back to subscriptions page
- window.location.href = '/news/subscriptions';
- {% else %}
- // Creating - go to news feed
- window.location.href = '/news';
- {% endif %}
- }, 1500);
- }
+ // Redirect to appropriate page after a short delay
+ setTimeout(() => {
+ {% if subscription %}
+ // Editing - go back to subscriptions page
+ window.location.href = '/news/subscriptions';
+ {% else %}
+ // Creating - go to news feed
+ window.location.href = '/news';
+ {% endif %}
+ }, 1500);
} else {
const error = await response.json();
showAlert('Error: ' + (error.error || 'Failed to save subscription'), 'error');
@@ -851,25 +848,83 @@ async function handleTestRun(event) {
}
}
-// Run subscription
-async function runSubscription(subscriptionId) {
+
+// Handle create and run button click
+async function handleCreateAndRun(event) {
+ if (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+
+ console.log('Create and Run button clicked');
+
try {
- const response = await fetch(`/news/api/subscriptions/${subscriptionId}/run`, {
+ // First create the subscription
+ const query = document.getElementById('subscription-query').value;
+ const name = document.getElementById('subscription-name').value || query.substring(0, 50);
+ const intervalMinutes = parseInt(document.getElementById('subscription-interval').value);
+ const folder = document.getElementById('subscription-folder').value;
+ const isActive = document.getElementById('subscription-active').checked;
+
+ // Model configuration
+ const modelHidden = document.getElementById('subscription-model_hidden');
+ const model = modelHidden ? modelHidden.value : '';
+ const provider = document.getElementById('subscription-provider').value;
+ const customEndpoint = document.getElementById('subscription-custom-endpoint').value;
+
+ // Search configuration
+ const searchEngineHidden = document.getElementById('subscription-search-engine_hidden');
+ const searchEngine = searchEngineHidden ? searchEngineHidden.value : 'auto';
+ const iterations = document.getElementById('subscription-iterations').value;
+ const questionsPerIteration = document.getElementById('subscription-questions').value;
+ const strategy = document.getElementById('subscription-strategy').value;
+
+ // Show loading state
+ showAlert('Creating subscription and starting research...', 'info');
+
+ // Create subscription
+ const createResponse = await fetch('/news/api/subscribe', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': getCSRFToken()
- }
+ },
+ body: JSON.stringify({
+ user_id: 'default_user',
+ query: query,
+ name: name,
+ subscription_type: 'search',
+ refresh_hours: intervalMinutes / 60,
+ folder_id: folder || null,
+ is_active: isActive,
+ model_provider: provider,
+ model: model,
+ custom_endpoint: customEndpoint || null,
+ search_engine: searchEngine,
+ search_iterations: parseInt(iterations),
+ questions_per_iteration: parseInt(questionsPerIteration),
+ search_strategy: strategy,
+ source_id: window.sourceResearchId || null
+ })
});
- if (response.ok) {
- showAlert('Subscription started successfully! Redirecting...', 'success');
- setTimeout(() => {
- window.location.href = '/news';
- }, 1500);
+ if (!createResponse.ok) {
+ const error = await createResponse.json();
+ showAlert('Error: ' + (error.error || 'Failed to create subscription'), 'error');
+ return;
}
+
+ const createData = await createResponse.json();
+ console.log('Subscription created:', createData);
+ console.log('Full response data:', JSON.stringify(createData, null, 2));
+
+ // Now run the subscription using the test run functionality
+ console.log('Subscription created, now starting immediate research run');
+ await handleTestRun();
+
} catch (error) {
- console.error('Error running subscription:', error);
+ console.error('Error in create and run:', error);
+ showAlert('Error: ' + error.message, 'error');
}
}