Hero OS OpenRPC Backend #12

Open
opened 2026-02-23 10:40:15 +00:00 by despiegk · 5 comments
Owner
  • window manager features
  • url features, open something somewhere
  • manage spaces (crud)
  • ...

everything which is relevant

keep state

- window manager features - url features, open something somewhere - manage spaces (crud) - ... everything which is relevant keep state
despiegk added this to the ACTIVE project 2026-02-23 10:40:15 +00:00
timur changed title from full openrpc support on heroos, also link support to Hero OS Backend 2026-03-09 10:30:19 +00:00
timur changed title from Hero OS Backend to Hero OS OpenRPC Backend 2026-03-09 10:30:35 +00:00
Owner

basically we want an openrpc backend for Hero OS so we can keep state of windows etc, and open windows in contexts and stuff in our backend instead of in the browser or memory.

basically we want an openrpc backend for Hero OS so we can keep state of windows etc, and open windows in contexts and stuff in our backend instead of in the browser or memory.
Owner

Implementation Plan: Hero OS OpenRPC Backend Migration

Summary

Migrate hero_os_server to use the new OServer::run_cli() pattern from hero_rpc#7, rename "contexts" to "spaces" for end-user friendliness, and ensure desktop state is persisted server-side (currently only in browser localStorage).

Current State

  • hero_os_server uses UnixRpcServer::new() directly (old pattern)
  • Frontend manages desktop state entirely in browser localStorage — no server round-trip for window state
  • Three RPC services exist: DesktopService, WindowService, LayoutService (529 lines of custom logic in rpc.rs)
  • bin/hero_os_service orchestrator exists but becomes redundant after migration

Tasks

1. Migrate to OServer::run_cli() (hero_rpc#7)

  • Replace UnixRpcServer::new() in main.rs with OServer::run_cli()
  • Gets zinit lifecycle for free: hero_os_server start/stop/status/logs/run
  • Scaffold regeneration is safe — write_preserved() skips existing files
  • Preserve rpc.rs (custom service implementations) — it won't be touched by regeneration
  • Update Cargo.toml to depend on hero_rpc_server

2. Rename "contexts" → "spaces" everywhere

  • CLI: --contexts--spaces
  • API: context_namespace_name in RPC methods
  • DB paths: db/{context}/db/{space}/
  • Socket paths: sockets/{context}/sockets/{space}/
  • Frontend: update all references
  • OSchema: update field names in DesktopState
  • This is user-facing terminology; internally "space" = what was "context"

3. Server-side state persistence

  • Frontend currently uses localStorage only — no backend round-trip
  • Wire frontend save_desktop_state()/load_desktop_state() to call server RPC instead of localStorage
  • Server already has full CRUD for DesktopState and WindowState
  • This achieves the issue goal: "keep state in our backend instead of in the browser or memory"

4. Remove hero_os_service

  • bin/hero_os_service becomes redundant — hero_os_server start handles zinit registration
  • Remove from workspace, update Makefile

Files to modify

File Change
crates/hero_os_server/src/main.rs Replace UnixRpcServer with OServer::run_cli()
crates/hero_os_server/Cargo.toml Add hero_rpc_server dependency
crates/hero_os_server/src/desktop/rpc.rs Rename context_name → space_name
crates/hero_os/schemas/desktop.oschema Rename context_name → space_name
crates/hero_os_app/src/storage.rs Replace localStorage with RPC calls
crates/hero_os_app/src/controller.rs Wire state ops through server
crates/hero_os_client/ Rename context → space in SDK
bin/hero_os_service/ Remove
Makefile Update targets

Reference

  • hero_rpc#7: Zinit lifecycle implementation
  • hero_skills#51: New skill for this pattern
  • OServer::run_cli() in hero_rpc/crates/server/src/server/server.rs
## Implementation Plan: Hero OS OpenRPC Backend Migration ### Summary Migrate hero_os_server to use the new `OServer::run_cli()` pattern from hero_rpc#7, rename "contexts" to "spaces" for end-user friendliness, and ensure desktop state is persisted server-side (currently only in browser localStorage). ### Current State - **hero_os_server** uses `UnixRpcServer::new()` directly (old pattern) - **Frontend** manages desktop state entirely in browser localStorage — no server round-trip for window state - Three RPC services exist: `DesktopService`, `WindowService`, `LayoutService` (529 lines of custom logic in `rpc.rs`) - `bin/hero_os_service` orchestrator exists but becomes redundant after migration ### Tasks #### 1. Migrate to OServer::run_cli() (hero_rpc#7) - Replace `UnixRpcServer::new()` in `main.rs` with `OServer::run_cli()` - Gets zinit lifecycle for free: `hero_os_server start/stop/status/logs/run` - Scaffold regeneration is safe — `write_preserved()` skips existing files - Preserve `rpc.rs` (custom service implementations) — it won't be touched by regeneration - Update `Cargo.toml` to depend on `hero_rpc_server` #### 2. Rename "contexts" → "spaces" everywhere - CLI: `--contexts` → `--spaces` - API: `context_name` → `space_name` in RPC methods - DB paths: `db/{context}/` → `db/{space}/` - Socket paths: `sockets/{context}/` → `sockets/{space}/` - Frontend: update all references - OSchema: update field names in DesktopState - This is user-facing terminology; internally "space" = what was "context" #### 3. Server-side state persistence - Frontend currently uses localStorage only — no backend round-trip - Wire frontend `save_desktop_state()`/`load_desktop_state()` to call server RPC instead of localStorage - Server already has full CRUD for DesktopState and WindowState - This achieves the issue goal: "keep state in our backend instead of in the browser or memory" #### 4. Remove hero_os_service - `bin/hero_os_service` becomes redundant — `hero_os_server start` handles zinit registration - Remove from workspace, update Makefile ### Files to modify | File | Change | |------|--------| | `crates/hero_os_server/src/main.rs` | Replace UnixRpcServer with OServer::run_cli() | | `crates/hero_os_server/Cargo.toml` | Add hero_rpc_server dependency | | `crates/hero_os_server/src/desktop/rpc.rs` | Rename context_name → space_name | | `crates/hero_os/schemas/desktop.oschema` | Rename context_name → space_name | | `crates/hero_os_app/src/storage.rs` | Replace localStorage with RPC calls | | `crates/hero_os_app/src/controller.rs` | Wire state ops through server | | `crates/hero_os_client/` | Rename context → space in SDK | | `bin/hero_os_service/` | Remove | | `Makefile` | Update targets | ### Reference - hero_rpc#7: Zinit lifecycle implementation - hero_skills#51: New skill for this pattern - OServer::run_cli() in `hero_rpc/crates/server/src/server/server.rs`
Owner

Progress update: OServer migration + spaces rename

Branch: development_timur — commit c14b6c7

What changed

  1. Server migrated to OServer::run_cli()hero_os_server/src/main.rs rewritten from manual UnixRpcServer to the unified OServer::run_cli() pattern from hero_rpc_server. This gives us CLI subcommands: start, stop, run, status, logs, ui, zinit.

  2. Contexts → Spaces rename — All user-facing context_name fields renamed to space_name across:

    • OSchema (schemas/desktop/desktop.oschema)
    • Generated types, client, server code
    • App code (8 files in hero_os_app)
  3. Build system updatedbuild.rs now uses hero_rpc_generator (moved from hero_rpc_osis). herolib_sid aligned to development_kristof branch.

  4. Removed bin/hero_os_service/ — Redundant standalone binary, replaced by OServer::run_cli() in hero_os_server.

  5. New trigger hooks — Added trigger_get_pre and trigger_list_pre methods required by updated generator.

Verification

  • cargo check — full workspace compiles (28 files changed, 587+, 546-)
  • cargo test -p hero_os_server — 3/3 tests pass

Upstream fixes pushed

  • hero_rpc (development): restored db module in hero_rpc_osis (derive macro fix)
  • hero_fossil/hero_foundry (development): renamed herofossil_webdav_clienthero_foundry_webdav_client
## Progress update: OServer migration + spaces rename Branch: `development_timur` — commit `c14b6c7` ### What changed 1. **Server migrated to `OServer::run_cli()`** — `hero_os_server/src/main.rs` rewritten from manual `UnixRpcServer` to the unified `OServer::run_cli()` pattern from `hero_rpc_server`. This gives us CLI subcommands: `start`, `stop`, `run`, `status`, `logs`, `ui`, `zinit`. 2. **Contexts → Spaces rename** — All user-facing `context_name` fields renamed to `space_name` across: - OSchema (`schemas/desktop/desktop.oschema`) - Generated types, client, server code - App code (8 files in `hero_os_app`) 3. **Build system updated** — `build.rs` now uses `hero_rpc_generator` (moved from `hero_rpc_osis`). `herolib_sid` aligned to `development_kristof` branch. 4. **Removed `bin/hero_os_service/`** — Redundant standalone binary, replaced by `OServer::run_cli()` in `hero_os_server`. 5. **New trigger hooks** — Added `trigger_get_pre` and `trigger_list_pre` methods required by updated generator. ### Verification - `cargo check` — full workspace compiles (28 files changed, 587+, 546-) - `cargo test -p hero_os_server` — 3/3 tests pass ### Upstream fixes pushed - `hero_rpc` (`development`): restored `db` module in `hero_rpc_osis` (derive macro fix) - `hero_fossil/hero_foundry` (`development`): renamed `herofossil_webdav_client` → `hero_foundry_webdav_client`
Owner

The server binary already uses OServer::run_cli() (see crates/hero_os_server/src/main.rs), but the Makefile and README still document the old make run / make service flow. This is misleading — cleaning up now:

  • Remove obsolete run, stop, run-server, service, install Makefile targets
  • Update README to document hero_os_server run / hero_os_server start as the way to run the backend
  • Keep build and quality targets (make web, make check, make fmt, etc.)
The server binary already uses `OServer::run_cli()` (see `crates/hero_os_server/src/main.rs`), but the Makefile and README still document the old `make run` / `make service` flow. This is misleading — cleaning up now: - Remove obsolete `run`, `stop`, `run-server`, `service`, `install` Makefile targets - Update README to document `hero_os_server run` / `hero_os_server start` as the way to run the backend - Keep build and quality targets (`make web`, `make check`, `make fmt`, etc.)
Owner

Zinit Lifecycle Adopted

Both hero_os_server and hero_os_ui now use the standardized zinit lifecycle:

  • run — developer command (start + stream logs + stop on Ctrl-C)
  • start — background start via zinit
  • serve — internal (zinit calls this, never run manually)

hero_os_ui uses ZinitLifecycle directly (non-OpenRPC binary pattern).
hero_os_server uses OServer::run_cli() which handles everything.

Makefile updated: make run delegates to cargo run -p hero_os_server -- run (built-in log streaming). make start runs cargo update first to pick up git dep changes.

Commit: 4fa4073 on development_timur

## Zinit Lifecycle Adopted Both `hero_os_server` and `hero_os_ui` now use the standardized zinit lifecycle: - `run` — developer command (start + stream logs + stop on Ctrl-C) - `start` — background start via zinit - `serve` — internal (zinit calls this, never run manually) `hero_os_ui` uses `ZinitLifecycle` directly (non-OpenRPC binary pattern). `hero_os_server` uses `OServer::run_cli()` which handles everything. Makefile updated: `make run` delegates to `cargo run -p hero_os_server -- run` (built-in log streaming). `make start` runs `cargo update` first to pick up git dep changes. Commit: 4fa4073 on development_timur
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
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_os#12
No description provided.