Skip to content

feat: add knowledge stats, discourse sync, and tools to dashboard#240

Merged
neuromechanist merged 3 commits into
developfrom
feature/issue-239-dashboard-knowledge-stats
Feb 26, 2026
Merged

feat: add knowledge stats, discourse sync, and tools to dashboard#240
neuromechanist merged 3 commits into
developfrom
feature/issue-239-dashboard-knowledge-stats

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

  • Add discourse to sync types so Discourse sync status appears on dashboard
  • Add KnowledgeStats model to /sync/status response with item counts per category (GitHub, papers, docstrings, discourse, FAQ, mailing list)
  • Add available_tools_list to community public metrics endpoint
  • Update dashboard frontend with knowledge base stats grid and available tools badges

Test plan

  • uv run pytest tests/test_api/test_sync.py -v -- 18/18 passed
  • uv run pytest tests/test_api/test_community.py -v -- passed
  • uv run ruff check -- clean
  • Verify on dev: curl "https://api.osc.earth/osa-dev/sync/status?community_id=mne" shows discourse in syncs and knowledge counts
  • Verify on dev: curl "https://api.osc.earth/osa-dev/mne/metrics/public" shows available_tools_list
  • Visit develop-demo.osc.earth and check knowledge stats and tools sections

Closes #239

- Add "discourse" to sync types so Discourse sync status appears
- Add KnowledgeStats model with item counts to sync status response
- Add available_tools_list to community public metrics
- Update dashboard with knowledge base grid and tool badges

Closes #239
@github-actions

github-actions Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Dashboard Preview

Name Link
Preview URL https://feature-issue-239-dashboard-.osa-dash.pages.dev
Branch feature/issue-239-dashboard-knowledge-stats
Commit 56d496b

This preview will be updated automatically when you push new commits.

- Add "discourse" to trigger_sync validation whitelist
- Add else branch for available_tools_list (always present in response)
- Wrap tool derivation in try/except matching config_health pattern
- Simplify FAQ condition (remove redundant bool() wrapper)
- Replace inline styles with CSS classes for dark mode support
- Add dark mode rules for tool badges, section headings, config banners
@neuromechanist

Copy link
Copy Markdown
Member Author

PR Review Summary

Reviewed by: code-reviewer, silent-failure-hunter, code-simplifier (run in parallel)

Critical Issues (2 found) -- FIXED

  1. [silent-failure-hunter] "discourse" missing from trigger_sync() validation whitelist (sync.py:365). Status endpoint lists it as valid but trigger would reject it with 400.

    • Fix: Added "discourse" to valid_types tuple and docstring.
  2. [code-reviewer + silent-failure-hunter] available_tools_list key absent from response when community_config is None (community.py:1378). Unlike config_health which always has a fallback, this key would silently disappear.

    • Fix: Added else branch with empty list fallback.

Important Issues (2 found) -- FIXED

  1. [silent-failure-hunter] Tool derivation has no error handling (community.py:1378-1395). An AttributeError from a partially constructed config would crash the entire /metrics/public endpoint, losing all other data already computed.

    • Fix: Wrapped in try/except (AttributeError, TypeError) matching the adjacent config_health pattern.
  2. [code-simplifier] Inline styles on tool badges and section headings bypass dark mode CSS (index.html). New elements had hardcoded light-mode colors.

    • Fix: Replaced with .section-heading and .tool-badge CSS classes; added dark mode rules for those plus .config-banner-warning and .config-banner-error.

Suggestions (2 found) -- FIXED

  1. [code-simplifier] renderKnowledgeStats used repetitive push pattern for 6 categories.

    • Fix: Refactored to data-driven KNOWLEDGE_FIELDS array with .filter().map().
  2. [code-simplifier] FAQ condition used inconsistent bool(config.mailman) wrapper.

    • Fix: Simplified to config.faq_generation and config.mailman.

Not addressed (out of scope, pre-existing)

  • Broad except Exception in scheduler job retrieval (sync.py:307) -- pre-existing
  • Path traversal hardening in find_logo_file -- pre-existing, IDs come from trusted registry
  • X-Content-Type-Options: nosniff header for SVG responses -- pre-existing

Strengths

  • escapeHtml() used consistently for all user-facing data (XSS prevention)
  • Frontend gracefully handles missing/null data with guard clauses
  • Exception handling uses specific types, not bare except
  • KnowledgeStats model cleanly maps to existing get_stats() output
  • Dark mode now fully supported for all new elements

@neuromechanist neuromechanist merged commit d3be988 into develop Feb 26, 2026
8 checks passed
@neuromechanist neuromechanist deleted the feature/issue-239-dashboard-knowledge-stats branch February 26, 2026 19:00
neuromechanist added a commit that referenced this pull request Feb 26, 2026
…) (#241)

* feat: add knowledge stats, discourse sync, and tools to dashboard

- Add "discourse" to sync types so Discourse sync status appears
- Add KnowledgeStats model with item counts to sync status response
- Add available_tools_list to community public metrics
- Update dashboard with knowledge base grid and tool badges

Closes #239

* fix: address PR review findings

- Add "discourse" to trigger_sync validation whitelist
- Add else branch for available_tools_list (always present in response)
- Wrap tool derivation in try/except matching config_health pattern
- Simplify FAQ condition (remove redundant bool() wrapper)
- Replace inline styles with CSS classes for dark mode support
- Add dark mode rules for tool badges, section headings, config banners

* refactor: use data-driven approach for knowledge stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant