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 research_id type issues and clean up codebase

LearningCircuit172711aa7873
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 004a8d7a57..f397b15ca6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -53,3 +53,9 @@ repos:
language: script
files: \.py$
description: "Prevent usage of shared ldr.db database - all data must use per-user encrypted databases"
+ - id: check-research-id-type
+ name: Check for incorrect research_id type hints
+ entry: .pre-commit-hooks/check-research-id-type.py
+ language: script
+ files: \.py$
+ description: "Ensure research_id is always treated as string/UUID, never as int"
diff --git a/.pre-commit-hooks/check-research-id-type.py b/.pre-commit-hooks/check-research-id-type.py
new file mode 100755
index 0000000000..19a75b8faf
--- /dev/null
+++ b/.pre-commit-hooks/check-research-id-type.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+"""
+Pre-commit hook to check for incorrect research_id type hints.
+Research IDs are UUIDs and should always be treated as strings, never as integers.
+"""
+
+import sys
+import re
+
+
+def check_file(filepath):
+ """Check a single file for incorrect research_id patterns."""
+ errors = []
+
+ with open(filepath, "r", encoding="utf-8") as f:
+ lines = f.readlines()
+
+ # Patterns to check for
+ patterns = [
+ # Flask route with int type
+ (
+ r"<int:research_id>",
+ "Flask route uses <int:research_id> - should be <string:research_id>",
+ ),
+ # Type hints with int
+ (
+ r"research_id:\s*int",
+ "Type hint uses research_id: int - should be research_id: str",
+ ),
+ # Function parameters with int conversion
+ (
+ r"int\(research_id\)",
+ "Converting research_id to int - research IDs are UUIDs/strings",
+ ),
+ # Integer comparison patterns
+ (
+ r"research_id\s*==\s*\d+",
+ "Comparing research_id to integer - research IDs are UUIDs/strings",
+ ),
+ ]
+
+ for line_num, line in enumerate(lines, 1):
+ for pattern, message in patterns:
+ if re.search(pattern, line):
+ errors.append(f"{filepath}:{line_num}: {message}")
+ errors.append(f" {line.strip()}")
+
+ return errors
+
+
+def main():
+ """Main entry point."""
+ # Get files to check from command line arguments
+ files_to_check = sys.argv[1:]
+
+ if not files_to_check:
+ print("No files to check")
+ return 0
+
+ all_errors = []
+
+ for filepath in files_to_check:
+ # Skip non-Python files
+ if not filepath.endswith(".py"):
+ continue
+
+ # Skip test files, migration files, and pre-commit hooks (they might have legitimate int usage)
+ if (
+ "test_" in filepath
+ or "migration" in filepath.lower()
+ or ".pre-commit-hooks" in filepath
+ ):
+ continue
+
+ errors = check_file(filepath)
+ all_errors.extend(errors)
+
+ if all_errors:
+ print("Research ID type errors found:")
+ print("-" * 80)
+ for error in all_errors:
+ print(error)
+ print("-" * 80)
+ print(
+ f"Total errors: {len([e for e in all_errors if not e.startswith(' ')])}"
+ )
+ return 1
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/examples/news_example.py b/examples/news_example.py
deleted file mode 100644
index 5e715b56ce..0000000000
--- a/examples/news_example.py
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/usr/bin/env python
-"""
-Example usage of the LDR News module.
-
-This script demonstrates how to use the news aggregation features
-both programmatically and through the CLI.
-"""
-
-import asyncio
-from local_deep_research.news import (
- get_news_feed,
- research_news_item,
- submit_news_feedback,
- save_news_preferences,
- get_news_categories,
-)
-
-
-async def basic_news_example():
- """Basic example of getting news feed."""
- print("=== Basic News Feed Example ===\n")
-
- # Get latest news using default settings
- result = await get_news_feed(limit=5)
-
- print(f"Found {len(result['news_items'])} news items:")
- print(f"Generated at: {result['generated_at']}")
- print(f"Search strategy: {result.get('search_strategy', 'default')}\n")
-
- # Display news items
- for i, item in enumerate(result["news_items"], 1):
- print(f"{i}. {item.get('headline', 'No headline')}")
- print(f" Category: {item.get('category', 'Unknown')}")
- print(f" Impact: {item.get('impact_score', 0)}/10")
- print(f" Summary: {item.get('summary', 'No summary')[:100]}...")
- print()
-
-
-async def focused_news_example():
- """Example of getting focused news."""
- print("\n=== Focused News Example ===\n")
-
- # Get technology-focused news
- result = await get_news_feed(
- focus="artificial intelligence technology",
- limit=5,
- search_strategy="source-based", # Use a different strategy
- )
-
- print(f"Found {len(result['news_items'])} tech news items:")
-
- for item in result["news_items"]:
- print(f"- {item.get('headline', 'No headline')}")
- if item.get("surprising_element"):
- print(f" Surprising: {item['surprising_element']}")
-
-
-async def news_research_example():
- """Example of researching a specific news item."""
- print("\n=== News Research Example ===\n")
-
- # First get some news
- news_result = await get_news_feed(limit=3)
-
- if news_result["news_items"]:
- # Research the first news item
- first_item = news_result["news_items"][0]
- news_id = first_item.get("id")
-
- print(f"Researching: {first_item.get('headline', 'Unknown')}")
- print("Running quick research...\n")
-
- research = await research_news_item(news_id, depth="quick")
-
- print("Research Summary:")
- print(research.get("summary", "No summary available"))
-
- if research.get("sources"):
- print("\nTop Sources:")
- for source in research["sources"][:3]:
- print(f"- {source}")
-
-
-async def user_preferences_example():
- """Example of setting user preferences."""
- print("\n=== User Preferences Example ===\n")
-
- # Define preferences
- preferences = {
- "categories": ["tech", "science", "economy"],
- "impact_threshold": 7, # Only show high-impact news
- "focus_preferences": {
- "surprising": True,
- "breaking": True,
- "positive": False,
- },
- "custom_search_terms": "AI quantum computing",
- "search_strategy": "focused-iteration",
- }
-
- # Save preferences
- result = await save_news_preferences("example_user", preferences)
- print("Saved preferences:", result["preferences_saved"])
-
- # Get personalized news
- personalized = await get_news_feed(user_id="example_user", limit=5)
-
- print("\nPersonalized news (impact >= 7):")
- for item in personalized["news_items"]:
- print(
- f"- [{item.get('impact_score', 0)}/10] {item.get('headline', 'Unknown')}"
- )
-
-
-async def news_categories_example():
- """Example of getting news categories."""
- print("\n=== News Categories Example ===\n")
-
- result = await get_news_categories()
-
- print(f"Categories from last {result['time_range']}:")
- print(f"Total items: {result['total_items']}\n")
-
- for cat_info in result["categories"]:
- name = cat_info["name"]
- count = cat_info["count"]
- percentage = (
- (count / result["total_items"] * 100)
- if result["total_items"] > 0
- else 0
- )
- print(f"{name:15} {count:3} items ({percentage:5.1f}%)")
-
-
-async def feedback_example():
- """Example of submitting feedback on news."""
- print("\n=== Feedback Example ===\n")
-
- # Get some news
- news = await get_news_feed(limit=3)
-
- if news["news_items"]:
- item = news["news_items"][0]
- news_id = item.get("id")
-
- print(f"Upvoting: {item.get('headline', 'Unknown')}")
-
- # Submit feedback
- result = await submit_news_feedback(news_id, "up", "example_user")
-
- print(
- f"New vote counts - Up: {result['upvotes']}, Down: {result['downvotes']}"
- )
-
-
-async def main():
- """Run all examples."""
-
- # Basic examples
- await basic_news_example()
- await focused_news_example()
-
- # Advanced examples
- await news_research_example()
- await user_preferences_example()
- await news_categories_example()
- await feedback_example()
-
- print("\n=== CLI Usage Examples ===\n")
- print("You can also use the news feature from the command line:")
- print()
- print("# Get latest news feed")
- print("python -m local_deep_research.news.cli news feed")
- print()
- print("# Get tech-focused news")
- print(
- "python -m local_deep_research.news.cli news feed --focus technology --limit 10"
- )
- print()
- print("# Research a specific news item")
- print("python -m local_deep_research.news.cli news research <news_id>")
- print()
- print("# Start background scheduler")
- print("python -m local_deep_research.news.cli news scheduler --interval 30")
- print()
- print("# Show news categories")
- print("python -m local_deep_research.news.cli news categories")
-
-
-if __name__ == "__main__":
- # Run the examples
- asyncio.run(main())
diff --git a/scripts/migrations/add_model_config_to_subscriptions.py b/scripts/migrations/add_model_config_to_subscriptions.py
deleted file mode 100755
index 325da47962..0000000000
--- a/scripts/migrations/add_model_config_to_subscriptions.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python3
-"""
-DEPRECATED: This migration script is for the old shared database.
-News subscriptions are now stored in per-user encrypted databases.
-Do not use this script - migrations should be handled per-user.
-"""
-
-import sys
-import os
-from pathlib import Path
-from sqlalchemy import create_engine, text
-from loguru import logger
-
-# Add project root to path
-project_root = Path(__file__).parent.parent.parent
-sys.path.insert(0, str(project_root))
-
-
-def migrate():
- """DEPRECATED: This migration is for the old shared database."""
-
- logger.error("This migration script is deprecated!")
- logger.error("News data is now stored in per-user encrypted databases.")
- logger.error("Do not use the shared database.")
- return False
-
- # Original code kept for reference but should not be executed
- # Get database path
- db_path = os.path.join(project_root, "data", "deprecated_shared.db")
- if not os.path.exists(db_path):
- logger.error(f"Database not found at {db_path}")
- return False
-
- # Create engine
- engine = create_engine(f"sqlite:///{db_path}")
-
- try:
- with engine.begin() as conn:
- # Check if columns already exist
- result = conn.execute(text("PRAGMA table_info(news_subscriptions)"))
- existing_columns = {row[1] for row in result}
-
- columns_to_add = [
- ("model_provider", "VARCHAR(50)"),
- ("model", "VARCHAR(100)"),
- ("search_strategy", "VARCHAR(50) DEFAULT 'news_aggregation'"),
- ("custom_endpoint", "VARCHAR(500)"),
- ]
-
- # Add columns if they don't exist
- for column_name, column_type in columns_to_add:
- if column_name not in existing_columns:
- logger.info(
- f"Adding column {column_name} to news_subscriptions"
- )
- conn.execute(
- text(
- f"ALTER TABLE news_subscriptions ADD COLUMN {column_name} {column_type}"
- )
- )
- else:
- logger.info(f"Column {column_name} already exists")
-
- logger.success("Migration completed successfully")
- return True
-
- except Exception as e:
- logger.exception(f"Migration failed: {e}")
- return False
-
-
-if __name__ == "__main__":
- success = migrate()
- sys.exit(0 if success else 1)
diff --git a/src/local_deep_research/metrics/search_tracker.py b/src/local_deep_research/metrics/search_tracker.py
index 9a266b982f..06c5bdb98b 100644
--- a/src/local_deep_research/metrics/search_tracker.py
+++ b/src/local_deep_research/metrics/search_tracker.py
@@ -244,7 +244,7 @@ class SearchTracker:
logger.exception(f"Error getting search metrics: {e}")
return {"search_engine_stats": [], "recent_calls": []}
- def get_research_search_metrics(self, research_id: int) -> Dict[str, Any]:
+ def get_research_search_metrics(self, research_id: str) -> Dict[str, Any]:
"""Get search metrics for a specific research session."""
with self.db.get_session() as session:
try:
diff --git a/src/local_deep_research/news/cli.py b/src/local_deep_research/news/cli.py
deleted file mode 100644
index 13025ec38e..0000000000
--- a/src/local_deep_research/news/cli.py
+++ /dev/null
@@ -1,267 +0,0 @@
-#!/usr/bin/env python3
-"""
-CLI for LDR News System - Standalone for testing
-"""
-
-import click
-from loguru import logger
-
-# Import our modules
-from .core.storage_manager import StorageManager
-from .recommender.topic_based import TopicBasedRecommender
-from .subscription_manager import SearchSubscription, TopicSubscription
-from .subscription_manager.scheduler import SubscriptionScheduler
-
-
-def cli():
- """LDR News System CLI"""
- pass
-
-
[email protected]("--user-id", default="test-user", help="User ID")
[email protected]("--limit", default=10, help="Number of news items")
-def feed(user_id, limit):
- """Show news feed for user"""
- try:
- StorageManager()
- recommender = TopicBasedRecommender()
-
- click.echo(f"📰 News Feed for {user_id}")
- click.echo("=" * 50)
-
- # Get recommendations
- cards = recommender.generate_recommendations(user_id, context={})
-
- if not cards:
- click.echo("No news items found. Try subscribing to some topics!")
- return
-
- # Display cards
- for i, card in enumerate(cards[:limit], 1):
- click.echo(f"\n{i}. {card.topic}")
- click.echo(f" ID: {card.id}")
- click.echo(
- f" Source: {card.source.type} - {card.source.created_from}"
- )
- click.echo(f" Created: {card.created_at}")
- if card.versions:
- click.echo(f" Versions: {len(card.versions)}")
-
- except Exception as e:
- logger.error(f"Error showing feed: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
[email protected]("--user-id", default="test-user", help="User ID")
[email protected]("--interval", default=4, help="Refresh interval in hours")
-def subscribe_search(query, user_id, interval):
- """Subscribe to a search query"""
- try:
- storage = StorageManager()
-
- # Create subscription
- sub = SearchSubscription(
- user_id=user_id, query=query, refresh_interval_hours=interval
- )
-
- # Store it using subscriptions storage
- subscription_data = {
- "id": sub.id,
- "user_id": sub.user_id,
- "subscription_type": "search",
- "query_or_topic": sub.query_or_topic,
- "refresh_interval_hours": sub.refresh_interval_hours,
- "source_type": sub.source.type if sub.source else "cli",
- "created_from": "CLI command",
- }
- storage.subscriptions.create(subscription_data)
-
- click.echo(f"✅ Subscribed to search: '{query}'")
- click.echo(f" User: {user_id}")
- click.echo(f" Refresh: Every {interval} hours")
- click.echo(f" ID: {sub.id}")
-
- except Exception as e:
- logger.error(f"Error creating subscription: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
[email protected]("--user-id", default="test-user", help="User ID")
[email protected]("--interval", default=6, help="Refresh interval in hours")
-def subscribe_topic(topic, user_id, interval):
- """Subscribe to a news topic"""
- try:
- storage = StorageManager()
-
- # Create subscription
- sub = TopicSubscription(
- user_id=user_id, topic=topic, refresh_interval_hours=interval
- )
-
- # Store it using subscriptions storage
- subscription_data = {
- "id": sub.id,
- "user_id": sub.user_id,
- "subscription_type": "topic",
- "query_or_topic": sub.query_or_topic,
- "refresh_interval_hours": sub.refresh_interval_hours,
- "source_type": sub.source.type if sub.source else "cli",
- "created_from": "CLI command",
- }
- storage.subscriptions.create(subscription_data)
-
- click.echo(f"✅ Subscribed to topic: '{topic}'")
- click.echo(f" User: {user_id}")
- click.echo(f" Refresh: Every {interval} hours")
- click.echo(f" ID: {sub.id}")
-
- except Exception as e:
- logger.error(f"Error creating subscription: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
[email protected]("--user-id", default="test-user", help="User ID")
-def subscriptions(user_id):
- """List user's subscriptions"""
- try:
- storage = StorageManager()
- # Get subscriptions from storage
- sub_data = storage.subscriptions.list({"user_id": user_id})
-
- click.echo(f"📋 Subscriptions for {user_id}")
- click.echo("=" * 50)
-
- if not sub_data:
- click.echo("No subscriptions found.")
- return
-
- for i, sub in enumerate(sub_data, 1):
- click.echo(
- f"\n{i}. {sub.get('subscription_type', 'Unknown')} subscription"
- )
- click.echo(f" ID: {sub.get('id', 'N/A')}")
- click.echo(f" Query/Topic: {sub.get('query_or_topic', 'N/A')}")
- click.echo(
- f" Interval: {sub.get('refresh_interval_hours', 'N/A')}h"
- )
- next_refresh = sub.get("next_refresh")
- if next_refresh:
- click.echo(f" Next refresh: {next_refresh}")
- click.echo(f" Status: {sub.get('status', 'active')}")
-
- except Exception as e:
- logger.error(f"Error listing subscriptions: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
-def scheduler_status():
- """Check scheduler status"""
- try:
- scheduler = SubscriptionScheduler.get_instance()
-
- click.echo("📅 Scheduler Status")
- click.echo("=" * 50)
- click.echo(f"Running: {scheduler.is_running}")
-
- if scheduler.is_running:
- jobs = scheduler.scheduler.get_jobs()
- click.echo(f"Active jobs: {len(jobs)}")
- for job in jobs:
- click.echo(f" - {job.id}: Next run at {job.next_run_time}")
-
- except Exception as e:
- logger.error(f"Error checking scheduler: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
-def start_scheduler():
- """Start the background scheduler"""
- try:
- scheduler = SubscriptionScheduler.get_instance()
- scheduler.start()
-
- click.echo("✅ Scheduler started!")
- click.echo("Press Ctrl+C to stop...")
-
- # Keep running
- import time
-
- while True:
- time.sleep(1)
-
- except KeyboardInterrupt:
- click.echo("\n⏹️ Stopping scheduler...")
- scheduler.stop()
- except Exception as e:
- logger.error(f"Error starting scheduler: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
-def test_priority():
- """Test priority system (user search interrupts news)"""
- try:
- from .core.priority_manager import get_priority_manager
-
- pm = get_priority_manager()
-
- click.echo("🧪 Testing Priority System")
- click.echo("=" * 50)
-
- # Simulate news search
- click.echo("1. Starting news search...")
- news_id = "test-news-123"
- can_proceed = pm.register_news_search(news_id)
- click.echo(f" News search registered: {can_proceed}")
- click.echo(f" User search active: {pm.user_search_active}")
-
- # Simulate user search
- click.echo("\n2. User starts search...")
- user_search_id = "test-user-456"
- pm.on_user_search_start(user_search_id)
- click.echo(f" User search active: {pm.user_search_active}")
- click.echo(
- f" Can register news search: {pm.register_news_search('test-news-789')}"
- )
-
- # Complete user search
- click.echo("\n3. User search completes...")
- pm.on_user_search_complete(user_search_id)
- click.echo(f" User search active: {pm.user_search_active}")
- click.echo(
- f" Can register news search: {pm.register_news_search('test-news-999')}"
- )
-
- click.echo("\n✅ Priority system working correctly!")
-
- except Exception as e:
- logger.error(f"Error testing priority: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
-def init_db():
- """Initialize database tables"""
- try:
- from .database import init_news_database
-
- click.echo("🗄️ Initializing database...")
- init_news_database()
- click.echo("✅ Database initialized!")
-
- except Exception as e:
- logger.error(f"Error initializing database: {e}")
- click.echo(f"❌ Error: {str(e)}", err=True)
-
-
-if __name__ == "__main__":
- cli()
diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.py
index d5bad3ae3c..120faa0bdb 100644
--- a/src/local_deep_research/search_system.py
+++ b/src/local_deep_research/search_system.py
@@ -75,7 +75,7 @@ class AdvancedSearchSystem:
use_atomic_facts: bool = False,
username: str | None = None,
settings_snapshot: dict | None = None,
- research_id: int | None = None,
+ research_id: str | None = None,
research_context: dict | None = None,
):
"""Initialize the advanced search system.
diff --git a/src/local_deep_research/web/routes/metrics_routes.py b/src/local_deep_research/web/routes/metrics_routes.py
index 6a356d8f51..a40d9325bf 100644
--- a/src/local_deep_research/web/routes/metrics_routes.py
+++ b/src/local_deep_research/web/routes/metrics_routes.py
@@ -877,7 +877,7 @@ def api_enhanced_metrics():
)
-@metrics_bp.route("/api/ratings/<int:research_id>", methods=["GET"])
+@metrics_bp.route("/api/ratings/<string:research_id>", methods=["GET"])
@login_required
def api_get_research_rating(research_id):
"""Get rating for a specific research session."""
@@ -920,7 +920,7 @@ def api_get_research_rating(research_id):
)
-@metrics_bp.route("/api/ratings/<int:research_id>", methods=["POST"])
+@metrics_bp.route("/api/ratings/<string:research_id>", methods=["POST"])
@login_required
def api_save_research_rating(research_id):
"""Save or update rating for a specific research session."""
diff --git a/src/local_deep_research/web/routes/route_registry.py b/src/local_deep_research/web/routes/route_registry.py
index 40ad665185..ee48f85b56 100644
--- a/src/local_deep_research/web/routes/route_registry.py
+++ b/src/local_deep_research/web/routes/route_registry.py
@@ -25,13 +25,13 @@ ROUTE_REGISTRY = {
),
(
"GET",
- "/api/research/<int:research_id>",
+ "/api/research/<string:research_id>",
"get_research_details",
"Get research details",
),
(
"GET",
- "/api/research/<int:research_id>/logs",
+ "/api/research/<string:research_id>/logs",
"get_research_logs",
"Get research logs",
),
@@ -43,19 +43,19 @@ ROUTE_REGISTRY = {
),
(
"GET",
- "/api/report/<int:research_id>",
+ "/api/report/<string:research_id>",
"get_research_report",
"Get research report",
),
(
"POST",
- "/api/terminate/<int:research_id>",
+ "/api/terminate/<string:research_id>",
"terminate_research",
"Stop research",
),
(
"DELETE",
- "/api/delete/<int:research_id>",
+ "/api/delete/<string:research_id>",
"delete_research",
"Delete research",
),
@@ -68,19 +68,19 @@ ROUTE_REGISTRY = {
),
(
"GET",
- "/progress/<int:research_id>",
+ "/progress/<string:research_id>",
"progress_page",
"Research progress page",
),
(
"GET",
- "/results/<int:research_id>",
+ "/results/<string:research_id>",
"results_page",
"Research results page",
),
(
"GET",
- "/details/<int:research_id>",
+ "/details/<string:research_id>",
"research_details_page",
"Research details page",
),
@@ -126,37 +126,37 @@ ROUTE_REGISTRY = {
("GET", "/api", "get_history", "Get history data"),
(
"GET",
- "/status/<int:research_id>",
+ "/status/<string:research_id>",
"get_research_status",
"Get research status",
),
(
"GET",
- "/details/<int:research_id>",
+ "/details/<string:research_id>",
"get_research_details",
"Get research details",
),
(
"GET",
- "/logs/<int:research_id>",
+ "/logs/<string:research_id>",
"get_research_logs",
"Get research logs",
),
(
"GET",
- "/log_count/<int:research_id>",
+ "/log_count/<string:research_id>",
"get_log_count",
"Get log count",
),
(
"GET",
- "/history/report/<int:research_id>",
+ "/history/report/<string:research_id>",
"get_report",
"Get research report",
),
(
"GET",
- "/markdown/<int:research_id>",
+ "/markdown/<string:research_id>",
"get_markdown",
"Get markdown report",
),
@@ -250,37 +250,37 @@ ROUTE_REGISTRY = {
("GET", "/api/pricing", "api_pricing", "Get pricing data"),
(
"GET",
- "/api/metrics/research/<int:research_id>",
+ "/api/metrics/research/<string:research_id>",
"api_research_metrics",
"Research metrics",
),
(
"GET",
- "/api/metrics/research/<int:research_id>/timeline",
+ "/api/metrics/research/<string:research_id>/timeline",
"api_research_timeline_metrics",
"Timeline metrics",
),
(
"GET",
- "/api/metrics/research/<int:research_id>/search",
+ "/api/metrics/research/<string:research_id>/search",
"api_research_search_metrics",
"Search metrics",
),
(
"GET",
- "/api/ratings/<int:research_id>",
+ "/api/ratings/<string:research_id>",
"api_get_research_rating",
"Get research rating",
),
(
"POST",
- "/api/ratings/<int:research_id>",
+ "/api/ratings/<string:research_id>",
"api_save_research_rating",
"Save research rating",
),
(
"GET",
- "/api/research-costs/<int:research_id>",
+ "/api/research-costs/<string:research_id>",
"api_research_costs",
"Get research costs",
),
diff --git a/src/local_deep_research/web/static/css/news.css b/src/local_deep_research/web/static/css/news.css
index 14af1ca111..c0026c0489 100644
--- a/src/local_deep_research/web/static/css/news.css
+++ b/src/local_deep_research/web/static/css/news.css
@@ -769,8 +769,7 @@
color: var(--text-primary);
line-height: 1.8;
margin: 1.5rem 0;
- max-height: 600px;
- overflow: hidden;
+ /* Removed max-height and overflow as items are always expanded */
position: relative;
font-size: 1.1rem;
transition: max-height 0.5s ease;
@@ -818,7 +817,8 @@
color: inherit;
}
-/* Expand/Collapse button */
+/* Expand/Collapse button - Commented out as news items are now always expanded */
+/*
.expand-toggle-btn {
position: absolute;
bottom: 1.5rem;
@@ -852,6 +852,7 @@
.news-card.is-expanded .expand-toggle-btn i {
transform: rotate(180deg);
}
+*/
/* Expanded state styles */
.news-item.is-expanded,
@@ -966,6 +967,8 @@
padding: 0.125rem 0.375rem;
}
+/* Fade-out effect - commented out as items are always expanded */
+/*
.news-findings::after {
content: '';
position: absolute;
@@ -977,6 +980,7 @@
pointer-events: none;
transition: opacity 0.3s;
}
+*/
/* Expanded state */
.news-item.is-expanded .news-findings {
@@ -1006,11 +1010,12 @@
line-height: 1.8;
margin: 1.25rem 0;
font-size: 1.05rem;
- max-height: 180px;
- overflow: hidden;
+ /* Removed max-height and overflow as items are always expanded */
position: relative;
}
+/* Fade-out effect - commented out as items are always expanded */
+/*
.news-summary::after {
content: '';
position: absolute;
@@ -1021,6 +1026,7 @@
background: linear-gradient(to bottom, transparent, var(--bg-tertiary));
pointer-events: none;
}
+*/
.news-category {
padding: 0.25rem 0.5rem;
diff --git a/src/local_deep_research/web/static/js/pages/news.js b/src/local_deep_research/web/static/js/pages/news.js
index a77c28f866..f6e4cbdfcc 100644
--- a/src/local_deep_research/web/static/js/pages/news.js
+++ b/src/local_deep_research/web/static/js/pages/news.js
@@ -832,7 +832,7 @@ function renderNewsItems(searchQuery = null) {
const isExpanded = expandedNewsIds.has(item.id);
return `
- <div class="news-item priority-${priorityClass} ${newClasses} ${readClasses} ${isExpanded ? 'is-expanded' : ''}" data-news-id="${item.id}">
+ <div class="news-item priority-${priorityClass} ${newClasses} ${readClasses} is-expanded" data-news-id="${item.id}">
${isNew ? '<span class="new-indicator">New</span>' : ''}
<div class="news-item-header">
<div class="news-headline">${item.headline}</div>
@@ -900,10 +900,6 @@ function renderNewsItems(searchQuery = null) {
</button>` : ''}
</div>
</div>
- <button class="expand-toggle-btn" onclick="toggleExpanded('${item.id}')" title="${isExpanded ? 'Show less' : 'Show more'}">
- <i class="bi bi-chevron-${isExpanded ? 'up' : 'down'}"></i>
- ${isExpanded ? 'Show less' : 'Show more'}
- </button>
</div>
`;
}).join('');
diff --git a/tests/infrastructure_tests/test_route_registry.py b/tests/infrastructure_tests/test_route_registry.py
index b8f6907967..4b0562192c 100644
--- a/tests/infrastructure_tests/test_route_registry.py
+++ b/tests/infrastructure_tests/test_route_registry.py
@@ -167,7 +167,8 @@ class TestRouteRegistry:
research_id_routes = [
r
for r in all_routes
- if "<int:research_id>" in r["path"] or "<research_id>" in r["path"]
+ if "<string:research_id>" in r["path"]
+ or "<research_id>" in r["path"]
]
assert len(research_id_routes) > 0, (
@@ -247,13 +248,11 @@ class TestRouteRegistry:
for route in param_routes:
# Check common parameters
if "research_id" in route["path"]:
- # Should be typed as int in most cases
- if (
- "api/research/<research_id>/status" not in route["path"]
- ): # Exception
- assert "<int:research_id>" in route["path"], (
- f"research_id should be typed as int in {route['path']}"
- )
+ # Should be typed as string (research IDs are UUIDs)
+ assert (
+ "<string:research_id>" in route["path"]
+ or "<research_id>" in route["path"]
+ ), f"research_id should be typed as string in {route['path']}"
if "resource_id" in route["path"]:
assert "<int:resource_id>" in route["path"], (
diff --git a/tests/infrastructure_tests/test_urls_js.py b/tests/infrastructure_tests/test_urls_js.py
index 3a7089c6e2..6ecf3cadfb 100644
--- a/tests/infrastructure_tests/test_urls_js.py
+++ b/tests/infrastructure_tests/test_urls_js.py
@@ -70,7 +70,7 @@ class TestJavaScriptURLConfiguration:
def normalize_url_pattern(self, url):
"""Normalize URL patterns for comparison"""
# Replace {id} with Flask-style <int:id> or <id>
- url = re.sub(r"\{id\}", "<int:research_id>", url)
+ url = re.sub(r"\{id\}", "<string:research_id>", url)
url = re.sub(r"\{key\}", "<path:key>", url)
url = re.sub(r"\{(\w+)\}", r"<\1>", url)
return url
@@ -97,11 +97,11 @@ class TestJavaScriptURLConfiguration:
critical_mappings = [
("API.START_RESEARCH", "/api/start_research"),
("API.RESEARCH_STATUS", "/api/research/<research_id>/status"),
- ("API.RESEARCH_DETAILS", "/api/research/<int:research_id>"),
- ("API.RESEARCH_LOGS", "/api/research/<int:research_id>/logs"),
- ("API.RESEARCH_REPORT", "/api/report/<int:research_id>"),
- ("API.TERMINATE_RESEARCH", "/api/terminate/<int:research_id>"),
- ("API.DELETE_RESEARCH", "/api/delete/<int:research_id>"),
+ ("API.RESEARCH_DETAILS", "/api/research/<string:research_id>"),
+ ("API.RESEARCH_LOGS", "/api/research/<string:research_id>/logs"),
+ ("API.RESEARCH_REPORT", "/api/report/<string:research_id>"),
+ ("API.TERMINATE_RESEARCH", "/api/terminate/<string:research_id>"),
+ ("API.DELETE_RESEARCH", "/api/delete/<string:research_id>"),
("API.HISTORY", "/history/api"),
("PAGES.HOME", "/"),
("PAGES.HISTORY", "/history/"),