Skip to content

feat: always serve UI dist and fail fast when missing#38

Merged
lan17 merged 2 commits intomainfrom
codex/always-serve-ui-fastapi
Feb 27, 2026
Merged

feat: always serve UI dist and fail fast when missing#38
lan17 merged 2 commits intomainfrom
codex/always-serve-ui-fastapi

Conversation

@lan17
Copy link
Owner

@lan17 lan17 commented Feb 27, 2026

Summary

This PR makes FastAPI always serve the built UI and fail fast at startup when UI artifacts are missing.

Why

We want a single predictable runtime mode:

  • Python server always serves UI
  • no runtime toggle drift
  • immediate startup failure if UI build artifacts are not present

What changed

  • Removed server.serve_ui from config model and env parsing.
  • Kept server.ui_dist_dir with env override via HOMESEC_SERVER_UI_DIST_DIR.
  • Enforced strict config keys for FastAPIServerConfig (extra = "forbid") so legacy serve_ui now fails validation.
  • Updated UI serving behavior in FastAPI:
    • Always configures SPA routes.
    • Raises startup error if index.html is missing.
    • Raises startup error if assets/ directory is missing.
    • Adds non-GET catch-all (POST/PUT/PATCH/DELETE/OPTIONS) to return 404 for unknown SPA paths.
  • Docker:
    • Removed HOMESEC_SERVER_SERVE_UI env from Dockerfile.
    • Kept HOMESEC_SERVER_UI_DIST_DIR=/app/ui/dist default.
  • Tests:
    • Updated API/config tests for fail-fast semantics and removed toggle assumptions.
    • Added tests/homesec/ui_dist_stub.py helper to keep unrelated route tests deterministic when using default ui/dist in stubs.
  • Regenerated UI API artifacts:
    • ui/src/api/generated/openapi.json
    • ui/src/api/generated/schema.ts

Breaking change

server.serve_ui is removed. Any config still including it will now fail validation.

Validation

  • make check
  • docker build --target runtime -t homesec:ui-dist-check .

Related

@lan17 lan17 marked this pull request as ready for review February 27, 2026 20:14
@lan17 lan17 merged commit c1ae42c into main Feb 27, 2026
2 checks passed
@lan17 lan17 deleted the codex/always-serve-ui-fastapi branch February 27, 2026 20:29
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.73%. Comparing base (daf65c3) to head (7ecaa24).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
- Coverage   82.73%   82.73%   -0.01%     
==========================================
  Files         107      107              
  Lines        9685     9673      -12     
==========================================
- Hits         8013     8003      -10     
+ Misses       1672     1670       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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