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(ci): seed link-analytics shard data + bump experimental badge to 12px floor (#4763)

LearningCircuitf6537e19de3e
diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index e7d80049f3..45a3275aeb 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -667,6 +667,25 @@ jobs:
python ../scripts/ci/init_test_database.py
echo "::endgroup::"
+ # The link-analytics shard renders /metrics/links, whose domain
+ # cards come entirely from ResearchResource rows. A fresh DB has
+ # none, so seed a small fixture for this shard ONLY — other shards
+ # (and the empty-state screenshot suites) keep an empty DB.
+ if [ "${SHARD}" = "link-analytics" ]; then
+ echo "::group::Seed link analytics data"
+ docker run --rm \
+ -v "${GITHUB_WORKSPACE}":/app \
+ -v "${GITHUB_WORKSPACE}/ci-data":/data \
+ -e TEST_ENV=true \
+ -e LDR_DATA_DIR=/data \
+ -e LDR_DB_CONFIG_KDF_ITERATIONS=1000 \
+ -e LDR_TEST_MODE=1 \
+ -w /app/src \
+ "${TEST_IMAGE}" \
+ python ../scripts/ci/seed_link_analytics.py
+ echo "::endgroup::"
+ fi
+
echo "::group::Start application server"
docker run -d \
--name ldr-server \
diff --git a/scripts/ci/seed_link_analytics.py b/scripts/ci/seed_link_analytics.py
new file mode 100644
index 0000000000..65cc82fe33
--- /dev/null
+++ b/scripts/ci/seed_link_analytics.py
@@ -0,0 +1,175 @@
+#!/usr/bin/env python3
+"""Seed link-analytics test data for the `link-analytics` UI shard.
+
+The /metrics/links page derives its domain cards entirely from
+``ResearchResource`` rows (see ``get_link_analytics`` in
+``web/routes/metrics_routes.py``). A freshly-initialized CI database
+(``scripts/ci/init_test_database.py``) has none, so the page renders the
+"No domain data available" placeholder and ``test_link_analytics_full.js``
+times out waiting for ``#domain-list .ldr-domain-item-expanded``.
+
+This script inserts a small, deterministic fixture (2 researches, 7 resources
+across 4 domains) for the ``test_admin`` user so the page renders real domain
+cards with frequency/diversity badges and a populated "Recent Researches
+(N total)" header.
+
+It is wired into ``.github/workflows/docker-tests.yml`` **only** for the
+``link-analytics`` shard. Other shards (and the responsive / empty-state
+screenshot suites that assert the placeholder on /metrics/links) keep seeing
+an empty database.
+
+Usage:
+ python scripts/ci/seed_link_analytics.py
+
+Environment variables (must match init_test_database.py / the server):
+ LDR_DATA_DIR: Directory for database files.
+ LDR_TEST_MODE / LDR_DB_CONFIG_KDF_ITERATIONS: SQLCipher key-derivation
+ parameters — must match the values used to create the DB or the
+ encryption key will not match.
+"""
+
+import os
+import uuid
+from datetime import UTC, datetime, timedelta
+from pathlib import Path
+
+from sqlalchemy.orm import Session
+
+# Credentials must match CI_TEST_USER in tests/ui_tests/auth_helper.js and the
+# user created by scripts/ci/init_test_database.py.
+TEST_USERNAME = "test_admin"
+TEST_PASSWORD = "testpass123" # pragma: allowlist secret
+
+# A stable namespace UUID so re-running on a fresh DB always produces the same
+# ids (keeps the fixture idempotent and easy to reason about).
+_SEED_NS = uuid.UUID("00000000-0000-0000-0000-00000000a11a")
+
+
+def main():
+ data_dir = Path(
+ os.environ.get(
+ "LDR_DATA_DIR",
+ Path.home() / ".local" / "share" / "local-deep-research",
+ )
+ )
+ print(f"Using data directory: {data_dir}")
+
+ # Imported after the env is set so path/SQLCipher config is picked up.
+ from local_deep_research.database.encrypted_db import db_manager
+ from local_deep_research.database.models.research import (
+ ResearchHistory,
+ ResearchResource,
+ )
+
+ engine = db_manager.open_user_database(TEST_USERNAME, TEST_PASSWORD)
+ if engine is None:
+ raise RuntimeError(
+ f"Could not open encrypted database for user '{TEST_USERNAME}'. "
+ "Was init_test_database.py run first with matching "
+ "LDR_TEST_MODE / LDR_DB_CONFIG_KDF_ITERATIONS?"
+ )
+
+ research_a = str(uuid.uuid5(_SEED_NS, "research-a"))
+ research_b = str(uuid.uuid5(_SEED_NS, "research-b"))
+
+ # created_at lands a day ago so it falls inside the default 30d window the
+ # /metrics/links page queries with. Stored as ISO strings to match the
+ # rest of the codebase (created_at columns are Text/String, not DateTime).
+ created = (datetime.now(UTC) - timedelta(days=1)).isoformat()
+
+ researches = [
+ ResearchHistory(
+ id=research_a,
+ query="Seed: deep learning survey for link analytics",
+ mode="quick_summary",
+ status="completed",
+ created_at=created,
+ completed_at=created,
+ ),
+ ResearchHistory(
+ id=research_b,
+ query="Seed: transformer architectures for link analytics",
+ mode="quick_summary",
+ status="completed",
+ created_at=created,
+ completed_at=created,
+ ),
+ ]
+
+ # (research_id, url, title, source_type). Spread across 4 domains with
+ # uneven counts so frequency_rank / usage_percentage vary, and across both
+ # researches so research_diversity is >1 for the busiest domains.
+ resources = [
+ (
+ research_a,
+ "https://en.wikipedia.org/wiki/Deep_learning",
+ "Deep learning - Wikipedia",
+ "web",
+ ),
+ (
+ research_a,
+ "https://en.wikipedia.org/wiki/Neural_network",
+ "Neural network - Wikipedia",
+ "web",
+ ),
+ (
+ research_a,
+ "https://arxiv.org/abs/1706.03762",
+ "Attention Is All You Need",
+ "academic",
+ ),
+ (
+ research_a,
+ "https://www.nature.com/articles/nature14539",
+ "Deep learning - Nature",
+ "academic",
+ ),
+ (
+ research_b,
+ "https://en.wikipedia.org/wiki/Transformer_(deep_learning_architecture)",
+ "Transformer - Wikipedia",
+ "web",
+ ),
+ (research_b, "https://arxiv.org/abs/1810.04805", "BERT", "academic"),
+ (
+ research_b,
+ "https://github.com/huggingface/transformers",
+ "huggingface/transformers",
+ "code",
+ ),
+ ]
+
+ with Session(engine) as session:
+ # Idempotent: a fresh CI DB is created per attempt, but guard anyway so
+ # a manual re-run does not duplicate the fixture.
+ already = (
+ session.query(ResearchHistory)
+ .filter(ResearchHistory.id == research_a)
+ .first()
+ )
+ if already:
+ print("Link analytics fixture already present — nothing to do.")
+ return
+
+ session.add_all(researches)
+ for research_id, url, title, source_type in resources:
+ session.add(
+ ResearchResource(
+ research_id=research_id,
+ url=url,
+ title=title,
+ source_type=source_type,
+ created_at=created,
+ )
+ )
+ session.commit()
+
+ domains = {url.split("/")[2] for _, url, _, _ in resources}
+ print(
+ f"✅ Seeded {len(researches)} researches and {len(resources)} resources "
+ f"across {len(domains)} domains for '{TEST_USERNAME}'"
+ )
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/local_deep_research/web/templates/pages/research.html b/src/local_deep_research/web/templates/pages/research.html
index ffa457b76e..395042b842 100644
--- a/src/local_deep_research/web/templates/pages/research.html
+++ b/src/local_deep_research/web/templates/pages/research.html
@@ -103,7 +103,7 @@
.ldr-privacy-panel[data-scope="strict"] .ldr-privacy-panel-header { color:#a78bfa; }
/* Local-inference checkboxes adopt the "local = teal" cue when on. */
.ldr-privacy-panel input[type="checkbox"] { accent-color:#14a37f; }
- .ldr-experimental-badge { font-size:0.72rem; font-weight:600; color:#d9a441; border:1px solid rgba(217, 164, 65, 0.4); border-radius:4px; padding:0.05rem 0.35rem; margin-left:0.4rem; vertical-align:middle; text-transform:uppercase; letter-spacing:0.02em; cursor:help; }
+ .ldr-experimental-badge { font-size:0.8rem; font-weight:600; color:#d9a441; border:1px solid rgba(217, 164, 65, 0.4); border-radius:4px; padding:0.05rem 0.35rem; margin-left:0.4rem; vertical-align:middle; text-transform:uppercase; letter-spacing:0.02em; cursor:help; }
/* Whole-workspace scope cue (research card / query textarea /
chat input) lives in styles.css now so chat.html and any
future page that loads the shared stylesheet inherit it. */