[nu-demo] hero_slides: hardcoded /Volumes/T7 path in dashboard.js — should derive from $CODEROOT #122

Closed
opened 2026-04-23 23:08:21 +00:00 by mik-tf · 1 comment
Owner

Symptom

Opening Slides island in hero_os shows a default scan path of /Volumes/T7/code0/hero_slides/examples in the scan input. This is the maintainer's personal macOS SSD volume name, baked into a static JS file served by hero_slides_ui. Any host that isn't that Mac sees a broken default.

See also: hero_slides#29 filed earlier on same topic.

Root cause

hero_slides/crates/hero_slides_ui/static/js/dashboard.js:4073:

scanInput.value = saved || '/Volumes/T7/code0/hero_slides/examples';

Static JS can't know the server's $CODEROOT at runtime. No server-side injection, no defaults endpoint.

Demo workaround (applied 2026-04-23 on heronu.gent01.grid.tf)

sed -i 's|/Volumes/T7/code0/hero_slides/examples|/home/driver/hero/code0/hero_slides/examples|g' crates/hero_slides_ui/static/js/dashboard.js then rebuilt + restarted hero_slides_ui. Matches the VM's CODEROOT. Not portable.

Proper fix

The nu-shell init main flow already cascades DISKS_EXTERNALROOTDIRCODEROOT = $ROOTDIR/code0 into env. hero_slides_ui just needs to surface that to the browser.

One of:

  1. Template injection (recommended) — Askama templates render index.html. Add scan_path_default: String to the template context populated from std::env::var("CODEROOT") at request time; emit as <meta name="hero-scan-default" content="{{ scan_path_default }}/hero_slides/examples"> or <body data-scan-default="…">. JS reads the meta/data attribute as fallback instead of the hardcoded literal.
  2. Defaults JSON endpointGET /api/defaults returns {"scanPath": "$CODEROOT/hero_slides/examples"}. JS fetches on load.

Same treatment needed in any other UI that hardcodes filesystem paths (search the workspace for /Volumes/ to find them).

Wider ask

This is one instance of a broader pattern: UIs should derive paths from the Hero env cascade, not hardcoded developer-machine paths. Worth a dedicated architectural pass across hero_*_ui crates. Either:

  • Grep-and-fix each site, OR
  • Establish a shared helper crate (hero_ui_defaults?) exposing codroot(), assets_dir(), webdav_storage(), etc., that every _ui uses for browser-side defaults.

Env to use

Reference:

Env var Who sets Example on VM
ROOTDIR nu init main from DISKS_EXTERNAL /home/driver/hero
CODEROOT nu init main = $ROOTDIR/code0 /home/driver/hero/code0
BUILDDIR nu init main = $ROOTDIR/build /home/driver/hero/build
CARGO_TARGET_DIR nu init main = $BUILDDIR/cargo /home/driver/hero/build/cargo

Filed from the 2026-04-23 nu-shell-stack demo bring-up on heronu.gent01.grid.tf. Signed-off-by: mik-tf

## Symptom Opening **Slides** island in hero_os shows a default scan path of `/Volumes/T7/code0/hero_slides/examples` in the scan input. This is the maintainer's personal macOS SSD volume name, baked into a static JS file served by hero_slides_ui. Any host that isn't that Mac sees a broken default. See also: [hero_slides#29](https://forge.ourworld.tf/lhumina_code/hero_slides/issues/29) filed earlier on same topic. ## Root cause `hero_slides/crates/hero_slides_ui/static/js/dashboard.js:4073`: ```javascript scanInput.value = saved || '/Volumes/T7/code0/hero_slides/examples'; ``` Static JS can't know the server's `$CODEROOT` at runtime. No server-side injection, no defaults endpoint. ## Demo workaround (applied 2026-04-23 on heronu.gent01.grid.tf) `sed -i 's|/Volumes/T7/code0/hero_slides/examples|/home/driver/hero/code0/hero_slides/examples|g' crates/hero_slides_ui/static/js/dashboard.js` then rebuilt + restarted `hero_slides_ui`. Matches the VM's CODEROOT. Not portable. ## Proper fix The nu-shell `init main` flow already cascades `DISKS_EXTERNAL` → `ROOTDIR` → `CODEROOT = $ROOTDIR/code0` into env. `hero_slides_ui` just needs to surface that to the browser. One of: 1. **Template injection (recommended)** — Askama templates render `index.html`. Add `scan_path_default: String` to the template context populated from `std::env::var("CODEROOT")` at request time; emit as `<meta name="hero-scan-default" content="{{ scan_path_default }}/hero_slides/examples">` or `<body data-scan-default="…">`. JS reads the meta/data attribute as fallback instead of the hardcoded literal. 2. **Defaults JSON endpoint** — `GET /api/defaults` returns `{"scanPath": "$CODEROOT/hero_slides/examples"}`. JS fetches on load. Same treatment needed in any other UI that hardcodes filesystem paths (search the workspace for `/Volumes/` to find them). ## Wider ask This is one instance of a broader pattern: **UIs should derive paths from the Hero env cascade, not hardcoded developer-machine paths**. Worth a dedicated architectural pass across `hero_*_ui` crates. Either: - Grep-and-fix each site, OR - Establish a shared helper crate (`hero_ui_defaults`?) exposing `codroot()`, `assets_dir()`, `webdav_storage()`, etc., that every `_ui` uses for browser-side defaults. ## Env to use Reference: | Env var | Who sets | Example on VM | |---|---|---| | `ROOTDIR` | nu `init main` from `DISKS_EXTERNAL` | `/home/driver/hero` | | `CODEROOT` | nu `init main` = `$ROOTDIR/code0` | `/home/driver/hero/code0` | | `BUILDDIR` | nu `init main` = `$ROOTDIR/build` | `/home/driver/hero/build` | | `CARGO_TARGET_DIR` | nu `init main` = `$BUILDDIR/cargo` | `/home/driver/hero/build/cargo` | Filed from the 2026-04-23 nu-shell-stack demo bring-up on `heronu.gent01.grid.tf`. Signed-off-by: mik-tf
Author
Owner

Moved to hero_demo#13 — see lhumina_code/hero_demo#13

Moved to hero_demo#13 — see https://forge.ourworld.tf/lhumina_code/hero_demo/issues/13
Sign in to join this conversation.
No labels
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/home#122
No description provided.