Skip to content

Fix sensing-server UI path resolution#227

Open
yash27-lab wants to merge 1 commit intoruvnet:mainfrom
yash27-lab:codex/fix-ui-path-autodetect
Open

Fix sensing-server UI path resolution#227
yash27-lab wants to merge 1 commit intoruvnet:mainfrom
yash27-lab:codex/fix-ui-path-autodetect

Conversation

@yash27-lab
Copy link
Copy Markdown

The server defaulted to ../../ui, which only worked from a specific working directory. Resolve the UI directory from common launch locations and warn clearly when assets are missing.

Add focused tests covering current-directory and executable-directory fallback discovery so the browser UI keeps working when the binary is launched outside the repo root.

The server defaulted to ../../ui, which only worked from a specific working directory. Resolve the UI directory from common launch locations and warn clearly when assets are missing.

Add focused tests covering current-directory and executable-directory fallback discovery so the browser UI keeps working when the binary is launched outside the repo root.
Copy link
Copy Markdown
Owner

@ruvnet ruvnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #227

Recommendation: MERGE (with minor suggestion)

Summary

This PR from @yash27-lab fixes issue #188 (visualization page 404) by adding intelligent UI path resolution to the sensing server. The server previously hardcoded ../../ui which only worked when launched from the exact build directory.

Changes

  1. resolve_ui_path() searches multiple candidate locations:
    • The configured path directly
    • Relative to current working directory
    • Ancestor directories of cwd (looking for ui/)
    • Relative to the executable location
    • Ancestor directories of executable
    • Relative to CARGO_MANIFEST_DIR
  2. Validates each candidate by checking for ui/index.html
  3. Canonicalizes the resolved path
  4. Falls back gracefully with a warning if no valid UI dir is found
  5. Includes 3 focused unit tests covering the major resolution strategies

Security Assessment

  • Path traversal: NOT a concern. The resolution only walks up ancestor directories and joins with "ui" — it never takes user-supplied path components from HTTP requests. The --ui-path CLI flag is operator-controlled, not user-facing.
  • std::fs::canonicalize is used on resolved paths, which resolves symlinks and normalizes the path.
  • The env!("CARGO_MANIFEST_DIR") fallback is compile-time only — safe.
  • No XSS, injection, or unsafe code.

Conflict Assessment (ADR-069 through ADR-078)

  • Minor conflicts expected with sensing-server/src/main.rs on main, since our recent work added new CLI arguments and modified the startup sequence. However, the changes are localized to:
    • Import additions (line 20-21)
    • A new function block inserted after Args struct
    • Minor changes in main() for path resolution
  • These should be straightforward to resolve during merge.

Code Quality

  • Good: Clean separation with resolve_ui_path_with_context() for testability (dependency injection of cwd/exe path).
  • Good: Test coverage for the three main resolution strategies.
  • Good: Informative log messages when path is resolved or when assets are missing.
  • Minor: push_ancestor_ui_candidates could potentially generate many candidates for deeply nested paths, but this is a startup-only operation so performance is not a concern.

Suggestion

Consider adding a --no-ui flag or RUVIEW_NO_UI=1 env var for headless deployments that don't need static file serving, to suppress the warning.

Verdict: Clean fix with good test coverage. Safe to merge after resolving minor conflicts with current main.

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.

2 participants