From c2971edd988d374b9efb00e4541ce602a9bb9b31 Mon Sep 17 00:00:00 2001
From: AmirNCI
Date: Tue, 27 Oct 2026 20:40:15 +0000
Subject: [PATCH] SECFOO-22 Clear empty states for new users
Checked every dashboard page with an empty store (a brand-new user's
first view):
- Assessments list said "No assessments match these filters" when there
were no assessments at all, with no next step. It now says "No
assessments yet" with a New Assessment button; the filters message is
kept for when filters really match nothing, plus a "Clear filters" link.
- Activity pages (Security Architecture, Threat Modeling, SAST, SCA,
Secret Scanning and the simpler skill pages) showed all-zero cards and
charts with no explanation. They now open with "No runs
yet" and how to start (Run Assessment page or `secfoo run --skill`).
- Third-party page showed a full list of "not assessed" bars with no
message. It now explains how to create a third-party assessment.
New shared empty_state() macro in _macros.html (alert box + optional
action button, role="status"); spacing comes from an .empty-state class
in alerts.css rather than new inline styles. Tests cover both sides of
each case (message shown with no data, gone once there is data).
Co-Authored-By: Claude Opus 5.5
---
design-system/components/alerts.css | 9 +++++++++
.../static/design-system/components/alerts.css | 9 +++++++++
src/secfoo/web/templates/_macros.html | 15 +++++++++++++++
src/secfoo/web/templates/activities/detail.html | 10 +++++++++-
src/secfoo/web/templates/assessments/list.html | 9 +++++++--
src/secfoo/web/templates/third_party.html | 9 ++++++++-
tests/test_web/test_activity_routes.py | 17 +++++++++++++++++
tests/test_web/test_assessment_routes.py | 15 ++++++++++++++-
tests/test_web/test_routes.py | 16 ++++++++++++++++
9 files changed, 104 insertions(+), 5 deletions(-)
diff --git a/design-system/components/alerts.css b/design-system/components/alerts.css
index 5ce223a..6b105c9 100644
--- a/design-system/components/alerts.css
+++ b/design-system/components/alerts.css
@@ -47,3 +47,12 @@
border-color: #f0b3af;
color: var(--color-error);
}
+
+/* "Nothing here yet" / "nothing matches" message at the top of a page or
+ list (the empty_state() macro in the dashboard's _macros.html). */
+.empty-state {
+ margin-top: var(--space-6);
+}
+.empty-state__action {
+ margin: var(--space-3) 0 0;
+}
diff --git a/src/secfoo/web/static/design-system/components/alerts.css b/src/secfoo/web/static/design-system/components/alerts.css
index 5ce223a..6b105c9 100644
--- a/src/secfoo/web/static/design-system/components/alerts.css
+++ b/src/secfoo/web/static/design-system/components/alerts.css
@@ -47,3 +47,12 @@
border-color: #f0b3af;
color: var(--color-error);
}
+
+/* "Nothing here yet" / "nothing matches" message at the top of a page or
+ list (the empty_state() macro in the dashboard's _macros.html). */
+.empty-state {
+ margin-top: var(--space-6);
+}
+.empty-state__action {
+ margin: var(--space-3) 0 0;
+}
diff --git a/src/secfoo/web/templates/_macros.html b/src/secfoo/web/templates/_macros.html
index 46688d9..e316a5b 100644
--- a/src/secfoo/web/templates/_macros.html
+++ b/src/secfoo/web/templates/_macros.html
@@ -13,3 +13,18 @@
{{ a.responsible_ai_status }}
{%- else %}—{% endif -%}
{% endmacro %}
+
+{#- Shared "nothing here yet" box: says what's missing and how to start.
+ Use for a page or list that has no data at all (not for "your filters
+ matched nothing" -- that should offer to clear the filters instead). -#}
+{% macro empty_state(title, action_href=None, action_label=None) %}
+
+
+
{{ title }}
+
{{ caller() }}
+ {%- if action_href %}
+
{{ action_label }}
+ {%- endif %}
+
+
+{% endmacro %}
diff --git a/src/secfoo/web/templates/activities/detail.html b/src/secfoo/web/templates/activities/detail.html
index fc0b5e9..a6a03fd 100644
--- a/src/secfoo/web/templates/activities/detail.html
+++ b/src/secfoo/web/templates/activities/detail.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-{% from "_macros.html" import findings_badges %}
+{% from "_macros.html" import findings_badges, empty_state %}
{% set verdict_projects = projects | selectattr("design_verdict") | list %}
{% block title %}{{ skill.nav_label }} — secfoo{% endblock %}
{% block content %}
@@ -7,6 +7,14 @@
{{ skill.name }}
{{ skill.description }}
+{% if run_count == 0 %}
+{% call empty_state("No " ~ skill.name ~ " runs yet", "/assessments", "Go to assessments") %}
+ The figures below fill in after the first run. Start one from an
+ assessment's Run Assessment page, or run
+ secfoo run --skill {{ skill.id }}.
+{% endcall %}
+{% endif %}
+
{% if dash %}
{% include "activities/architecture_dashboard.html" %}
{% endif %}
diff --git a/src/secfoo/web/templates/assessments/list.html b/src/secfoo/web/templates/assessments/list.html
index fc313ac..8e7db8f 100644
--- a/src/secfoo/web/templates/assessments/list.html
+++ b/src/secfoo/web/templates/assessments/list.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-{% from "_macros.html" import findings_badges, responsible_ai_badges %}
+{% from "_macros.html" import findings_badges, responsible_ai_badges, empty_state %}
{% block title %}secfoo — Assessments{% endblock %}
{% block content %}
@@ -62,7 +62,12 @@
Assessment register
+{% elif counts.all == 0 %}
+{% call empty_state("No assessments yet", "/assessments/new", "New Assessment") %}
+ An assessment groups the security checks for one application. Create one,
+ then choose which checks to run on it.
+{% endcall %}
{% else %}
-No assessments match these filters.
+
{% endif %}
{% endblock %}
diff --git a/src/secfoo/web/templates/third_party.html b/src/secfoo/web/templates/third_party.html
index c04ca87..89d9f6f 100644
--- a/src/secfoo/web/templates/third_party.html
+++ b/src/secfoo/web/templates/third_party.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-{% from "_macros.html" import findings_badges %}
+{% from "_macros.html" import findings_badges, empty_state %}
{% block title %}secfoo — Third-Party{% endblock %}
{% block content %}
Third-Party
@@ -8,6 +8,13 @@ Third-party assessments
{{ counts.total }} third-party assessment(s) · AI-BOM: {{ models_count }} model(s), {{ tools_count }} tool(s) tracked.
+{% if counts.total == 0 %}
+{% call empty_state("No third-party assessments yet", "/assessments/new", "New Assessment") %}
+ Create an assessment with type Third-Party and upload the
+ vendor's documents (SOC 2 report, ISO certificate, pen test report or
+ questionnaire). The conformance view below fills in from that evidence.
+{% endcall %}
+{% endif %}
Vendor CCM v4 conformance
diff --git a/tests/test_web/test_activity_routes.py b/tests/test_web/test_activity_routes.py
index 6c03fa4..4ef4010 100644
--- a/tests/test_web/test_activity_routes.py
+++ b/tests/test_web/test_activity_routes.py
@@ -51,6 +51,23 @@ def test_activity_page_empty_state(client):
assert "No project has been scanned with this activity yet" in resp.text
+@pytest.mark.parametrize("skill_id", ["sast", "security-architecture-review", "threat-modeling", "prompt-review"])
+def test_activity_page_explains_why_it_is_empty_before_the_first_run(client, skill_id):
+ # The dashboards render all-zero charts with no data, so the top of the
+ # page has to say nothing has run yet, and how to start.
+ resp = client.get(f"/activities/{skill_id}")
+ assert resp.status_code == 200
+ assert "runs yet" in resp.text
+ assert f"secfoo run --skill {skill_id}" in resp.text
+
+
+def test_activity_page_hides_the_no_runs_message_once_it_has_run(client):
+ _seed_run(skill_id="sast", high=1)
+ resp = client.get("/activities/sast")
+ assert resp.status_code == 200
+ assert "runs yet" not in resp.text
+
+
def test_activity_page_shows_per_project_rollup(client):
_seed_run(skill_id="sast", project_name="acme/app", high=2, medium=1)
_seed_run(skill_id="sast", project_name="acme/other", high=1)
diff --git a/tests/test_web/test_assessment_routes.py b/tests/test_web/test_assessment_routes.py
index 55af9d7..dce43ff 100644
--- a/tests/test_web/test_assessment_routes.py
+++ b/tests/test_web/test_assessment_routes.py
@@ -29,9 +29,22 @@ def _create_assessment(*, assessment_type: str = "internal", status: str = "read
def test_assessments_list_empty_state(client):
+ # No assessments at all: say so and offer to create one -- not
+ # "no assessments match these filters", which reads as a filter problem.
resp = client.get("/assessments")
assert resp.status_code == 200
- assert "No assessments match" in resp.text
+ assert "No assessments yet" in resp.text
+ assert "No assessments match" not in resp.text
+ assert 'href="/assessments/new"' in resp.text
+
+
+def test_assessments_list_filters_matching_nothing_offers_to_clear_them(client):
+ _create_assessment(status="ready")
+ resp = client.get("/assessments?status=completed")
+ assert resp.status_code == 200
+ assert "No assessments match these filters" in resp.text
+ assert "Clear filters" in resp.text
+ assert "No assessments yet" not in resp.text
def test_assessments_list_shows_created_assessment(client):
diff --git a/tests/test_web/test_routes.py b/tests/test_web/test_routes.py
index 27c7b0e..f1e5745 100644
--- a/tests/test_web/test_routes.py
+++ b/tests/test_web/test_routes.py
@@ -145,3 +145,19 @@ def test_mermaid_init_js_sanitizes_agent_generated_content():
content = (STATIC_DIR / "js" / "mermaid-init.js").read_text()
assert 'securityLevel: "strict"' in content
+
+
+def test_third_party_page_explains_it_is_empty(client):
+ resp = client.get("/third-party")
+ assert resp.status_code == 200
+ assert "No third-party assessments yet" in resp.text
+
+
+def test_third_party_page_hides_the_empty_message_once_one_exists(client, tmp_path):
+ project_id, _run_uuid = _seed_run(tmp_path)
+ repo = RunRepository()
+ repo.create_assessment(project_id=project_id, assessment_type="third_party", status="ready")
+ repo.close()
+ resp = client.get("/third-party")
+ assert resp.status_code == 200
+ assert "No third-party assessments yet" not in resp.text