Add tests for UI proxy and service lifecycle; enable static /ui/root serving#15
Add tests for UI proxy and service lifecycle; enable static /ui/root serving#15Psyborgs-git wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1451a5016d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not dist_dir.exists(): | ||
| raise HTTPException(status_code=503, detail=f"React dist directory not found: {dist_dir}") | ||
|
|
||
| rel = path or "index.html" |
There was a problem hiding this comment.
Stop hard-coding
dist/index.html as static entry
When harness_debug is false and no subpath is requested, this branch always resolves index.html. In this repo, the React production build is configured with JS/TS Rollup inputs (react/vite.config.ts build.rollupOptions.input), which produces hashed bundles in dist/assets but no dist/index.html; as a result, /ui/root returns 404 in static mode even after a successful vite build. This makes the new static serving path non-functional in the default production build.
Useful? React with 👍 / 👎.
| raise HTTPException(status_code=404, detail="Asset not found") | ||
| content = candidate.read_text(encoding="utf-8") if candidate.suffix == ".html" else candidate.read_bytes() | ||
| if candidate.suffix != ".html": | ||
| return Response(content=content) |
There was a problem hiding this comment.
Preserve MIME type for static UI assets
For non-HTML files in static mode, the response is returned without forwarding or setting Content-Type. Browsers enforce strict MIME checks for module scripts and styles, so /ui/root/{path} JS/CSS assets can be refused even when they exist, breaking static dashboard loads. Set media_type (or headers) based on the asset extension when returning these files.
Useful? React with 👍 / 👎.
Motivation
Description
/ui/rootinharness/server/routes/proxy.pywith a_react_dist_dirhelper, safe path resolution, injected harness vars into HTML, and explicit errors for missing dist or assets whenharness_debugis false.tests/test_proxy_routes.pywith isolated tests that mockhttpx.AsyncClientand usetmp_pathto verify/ui/rootin debug (Vite proxy) and static (react/dist) modes, plus failure modes for missing Vite and missing dist.tests/test_service_manager.pyexercisingProcessManagerstart/stop/restart, cleanup semantics, background-task cancellation, and watchdog crash logging using aDummyComponentand short-lived async tasks.tests/test_agent_routes.pyasserting workspace URLs open as/ui/{first_react_view}derived fromAppManifest.react_viewsto match the ReactAppManifestPanelbehavior, and keep tests fast and isolated via tmp dirs and mocks.Testing
python -m compileall harness/server/routes/proxy.py tests/test_proxy_routes.py tests/test_service_manager.py tests/test_agent_routes.pywhich completed successfully.pytest -q tests/test_proxy_routes.py tests/test_service_manager.py tests/test_agent_routes.py, but the run was blocked in this environment due to a missing dependency (ModuleNotFoundError: No module named 'pytest_asyncio').Codex Task