fix(osis_app): correct RPC URL pattern and context header #39

Merged
rawan merged 3 commits from development_fix_osis_island_rpc_url into development 2026-04-29 11:16:38 +00:00
Member

Summary

Fixes the OSIS Dioxus island so it can talk to hero_osis_base from inside hero_os (built with FEATURES=web-native). The island previously POSTed to /hero_osis/ui/rpc/{context}, which has no handler on hero_router and failed with "Service unavailable — unexpected response".

The new code builds the URL as {api_host}/hero_osis_<domain>/rpc (domain derived from the JSON-RPC method's first dotted segment) and sends the context via the X-Hero-Context HTTP header — matching the documented Hero RPC pattern.

Closes #37

Changes

  • crates/hero_osis_app/src/rpc.rs

    • Renamed module-level state and helpers: RPC_BASEAPI_HOST, set_rpc_baseset_api_host, rpc_baseapi_host.
    • Replaced URL builder. Old: {base}/rpc/{context}. New: {api_host}/hero_osis_<domain>/rpc.
    • Special-cased domain == "rpc" to fall back to "base" so rpc.discover reaches hero_osis_base/rpc rather than the non-existent hero_osis_rpc.
    • Added X-Hero-Context: <context> header to every request; the context is no longer placed in the URL path.
    • Empty api_host() yields a same-origin relative URL (e.g. /hero_osis_base/rpc) — correct behind hero_router.
    • Preserved auth_header() Bearer-token injection from localStorage, the JSON-RPC body shape, and response/error parsing.
    • Updated the file-level //! doc comment to describe the new URL pattern, domain derivation rule, and header semantics.
  • crates/hero_osis_app/src/app.rs

    • Replaced crate::rpc::set_rpc_base("/hero_osis/ui") with crate::rpc::set_api_host(&props.context.api_host). All three existing rpc::rpc(...) callsites are unchanged — they already pass the context as the first argument, which the new rpc() puts in the header.

Test Results

  • cargo check --target wasm32-unknown-unknown on crates/hero_osis_app passes clean.
  • make test (the CI-style invocation: cargo test --lib --no-default-features --features all-domains) passes: 113/113 in hero_osis_server, 0 tests in hero_osis_sdk and hero_osis_ui.
  • grep -rn "set_rpc_base\|RPC_BASE\|rpc_base" --include="*.rs" returns no matches — no orphan callers of the renamed symbols.
  • End-to-end browser verification: built hero_os locally with FEATURES=web-native against this branch via a local Cargo [patch]. Opening the OSIS island in hero_os now successfully reaches hero_osis_base and lists contexts. Requests in DevTools → Network show POST /hero_osis_base/rpc with X-Hero-Context: root, never /hero_osis/ui/rpc/....

Notes

  • Native admin (make dev-minimalhttp://127.0.0.1:9988/hero_osis/ui/) is unaffected. It uses Askama templates + js/dashboard.js and does not import hero_osis_app.
  • rpc.discover now hits hero_osis_base only (instead of all installed domains via the previous — broken — service hub call). The "Domains in context" panel will list only base.* methods after a context is selected. Functionally this is a strict improvement over the prior "Service unavailable" failure; restoring full domain aggregation by fanning out to every installed OSIS domain can be tracked as a follow-up.
## Summary Fixes the OSIS Dioxus island so it can talk to `hero_osis_base` from inside hero_os (built with `FEATURES=web-native`). The island previously POSTed to `/hero_osis/ui/rpc/{context}`, which has no handler on hero_router and failed with `"Service unavailable — unexpected response"`. The new code builds the URL as `{api_host}/hero_osis_<domain>/rpc` (domain derived from the JSON-RPC method's first dotted segment) and sends the context via the `X-Hero-Context` HTTP header — matching the documented Hero RPC pattern. ## Related Issue Closes https://forge.ourworld.tf/lhumina_code/hero_osis/issues/37 ## Changes - `crates/hero_osis_app/src/rpc.rs` - Renamed module-level state and helpers: `RPC_BASE` → `API_HOST`, `set_rpc_base` → `set_api_host`, `rpc_base` → `api_host`. - Replaced URL builder. Old: `{base}/rpc/{context}`. New: `{api_host}/hero_osis_<domain>/rpc`. - Special-cased `domain == "rpc"` to fall back to `"base"` so `rpc.discover` reaches `hero_osis_base/rpc` rather than the non-existent `hero_osis_rpc`. - Added `X-Hero-Context: <context>` header to every request; the context is no longer placed in the URL path. - Empty `api_host()` yields a same-origin relative URL (e.g. `/hero_osis_base/rpc`) — correct behind hero_router. - Preserved `auth_header()` Bearer-token injection from `localStorage`, the JSON-RPC body shape, and response/error parsing. - Updated the file-level `//!` doc comment to describe the new URL pattern, domain derivation rule, and header semantics. - `crates/hero_osis_app/src/app.rs` - Replaced `crate::rpc::set_rpc_base("/hero_osis/ui")` with `crate::rpc::set_api_host(&props.context.api_host)`. All three existing `rpc::rpc(...)` callsites are unchanged — they already pass the context as the first argument, which the new `rpc()` puts in the header. ## Test Results - `cargo check --target wasm32-unknown-unknown` on `crates/hero_osis_app` passes clean. - `make test` (the CI-style invocation: `cargo test --lib --no-default-features --features all-domains`) passes: 113/113 in `hero_osis_server`, 0 tests in `hero_osis_sdk` and `hero_osis_ui`. - `grep -rn "set_rpc_base\|RPC_BASE\|rpc_base" --include="*.rs"` returns no matches — no orphan callers of the renamed symbols. - End-to-end browser verification: built `hero_os` locally with `FEATURES=web-native` against this branch via a local Cargo `[patch]`. Opening the OSIS island in hero_os now successfully reaches `hero_osis_base` and lists contexts. Requests in DevTools → Network show `POST /hero_osis_base/rpc` with `X-Hero-Context: root`, never `/hero_osis/ui/rpc/...`. ## Notes - Native admin (`make dev-minimal` → `http://127.0.0.1:9988/hero_osis/ui/`) is unaffected. It uses Askama templates + `js/dashboard.js` and does not import `hero_osis_app`. - `rpc.discover` now hits `hero_osis_base` only (instead of all installed domains via the previous — broken — service hub call). The "Domains in context" panel will list only `base.*` methods after a context is selected. Functionally this is a strict improvement over the prior "Service unavailable" failure; restoring full domain aggregation by fanning out to every installed OSIS domain can be tracked as a follow-up.
fix(osis_app): correct RPC URL pattern and context header
Some checks failed
Build Linux / build-linux (linux-amd64-musl, false, x86_64-unknown-linux-musl) (push) Successful in 3m36s
Build and Test / build (push) Has been cancelled
Build and Test / build (pull_request) Has been cancelled
Build Linux / build-linux (linux-amd64-musl, false, x86_64-unknown-linux-musl) (pull_request) Has been cancelled
9982181bcf
The OSIS Dioxus island posted to {base}/rpc/{context} with base hard-coded
to /hero_osis/ui, which routes through hero_router to the hero_osis_ui
HTML server (which has no /rpc/{context} handler) and fails with
"Service unavailable - unexpected response".

Switch to the canonical Hero pattern: build the URL from the JSON-RPC
method's first dotted segment ({api_host}/hero_osis_<domain>/rpc) and
send the execution context via the X-Hero-Context HTTP header. Take the
api_host from IslandContext::api_host (already a prop on HeroOsisApp)
instead of a hard-coded path. When the method namespace is "rpc" (i.e.
rpc.discover), fall back to "base" so the request reaches a real domain
service rather than the non-existent hero_osis_rpc.

#37
format: cargo fmt
All checks were successful
Build Linux / build-linux (linux-amd64-musl, false, x86_64-unknown-linux-musl) (pull_request) Successful in 4m31s
Build Linux / build-linux (linux-amd64-musl, false, x86_64-unknown-linux-musl) (push) Successful in 5m12s
Build and Test / build (pull_request) Successful in 6m13s
Build and Test / build (push) Successful in 7m2s
a913531cf9
fix: clippy warnings
All checks were successful
Build Linux / build-linux (linux-amd64-musl, false, x86_64-unknown-linux-musl) (pull_request) Successful in 4m32s
Build Linux / build-linux (linux-amd64-musl, false, x86_64-unknown-linux-musl) (push) Successful in 5m21s
Build and Test / build (push) Successful in 6m12s
Build and Test / build (pull_request) Successful in 8m31s
4626404cd5
rawan merged commit 1aee7b83bd into development 2026-04-29 11:16:38 +00:00
rawan deleted branch development_fix_osis_island_rpc_url 2026-04-29 11:16:38 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_osis!39
No description provided.