Fixed read button functionality in case of standalone running books #100

Merged
fatmaebrahim merged 1 commit from development_read_fix_in_standalone into development 2026-04-26 07:28:43 +00:00
Member

This PR represents a solution for the following problem:

Problem:

The "Read" button on book pages called /hero_agent/ui/api/voice/tts — a hardcoded absolute path that only worked when hero_books was accessed through hero_router (which knows how to route to hero_agent).
When running hero_books standalone, the endpoint didn't exist.

Solution:

  1. page.html — Made the TTS URL dynamic:
    - Behind hero_router: {{ base }} is /hero_books/ui, so it derives /hero_agent/ui/api/voice/tts (direct to hero_agent via router)
    - Standalone: {{ base }} is empty, so it falls back to /api/voice/tts (local proxy)
  2. proxy.rs — Added smart routing in api_proxy: requests to /api/voice/* are forwarded to hero_agent's Unix socket (hero_agent/ui.sock) instead of hero_books_server, added hero_agent_socket() helper to resolve the socket path.
  3. main.rs — No route changes needed; the existing /api/{*rest} catch-all handles it.

Result: TTS works in both modes — via hero_router and standalone — using hero_agent's TTS endpoint in both cases.

This PR represents a solution for the following problem: ### Problem: The "Read" button on book pages called /hero_agent/ui/api/voice/tts — a hardcoded absolute path that only worked when hero_books was accessed through hero_router (which knows how to route to hero_agent). When running hero_books standalone, the endpoint didn't exist. ### Solution: 1. page.html — Made the TTS URL dynamic: - Behind hero_router: {{ base }} is /hero_books/ui, so it derives /hero_agent/ui/api/voice/tts (direct to hero_agent via router) - Standalone: {{ base }} is empty, so it falls back to /api/voice/tts (local proxy) 2. proxy.rs — Added smart routing in api_proxy: requests to /api/voice/* are forwarded to hero_agent's Unix socket (hero_agent/ui.sock) instead of hero_books_server, added hero_agent_socket() helper to resolve the socket path. 3. main.rs — No route changes needed; the existing /api/{*rest} catch-all handles it. Result: TTS works in both modes — via hero_router and standalone — using hero_agent's TTS endpoint in both cases. ### Related Issues: - https://forge.ourworld.tf/lhumina_code/hero_os/issues/77
fix: fixed read button functionality in case of standalone running books
All checks were successful
Test / test (pull_request) Successful in 6m31s
Test / integration (pull_request) Successful in 4m4s
dcc50dafb9
fatmaebrahim merged commit 5847d300f5 into development 2026-04-26 07:28:43 +00:00
fatmaebrahim deleted branch development_read_fix_in_standalone 2026-04-26 07:28:43 +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_books!100
No description provided.