Create file .env.local in the project root with the following content:
VITE_KEYCLOAK_URL="http://keycloak.127.0.0.1.nip.io:8008"
VITE_KEYCLOAK_REALM="ndmspc-dev"
VITE_KEYCLOAK_CLIENT="ndmspc-dev-client"
When the NDMSPC server is started with OIDC/Keycloak authentication enabled
(NDMSPC_OIDC_ISSUER / NDMSPC_OIDC_AUDIENCE, see the server http/README.md),
each WebSocket connection must authenticate before it can exchange traffic:
- the UI connects to
/ws/root.websocketand immediately sends{"event": "authenticate", "token": "<keycloak-access-token>"}as the first frame; - the server replies
{"event": "authenticated", ...}and only then sendswelcome,clients, heartbeats and starts honouring API request/reply messages; - when the Keycloak token is refreshed, the UI re-authenticates on the same
connection (the refreshed token must keep the same JWT
sub).
This handshake is implemented in src/lib/room/NdmspcWsClient.ts. A short grace
period distinguishes anonymous servers (they send welcome immediately) from
auth-enabled ones (they stay silent until authenticated), so servers started
without Keycloak keep working with no code change. When a server demands
sign-in and no valid session exists, the UI shows a Sign in to connect
action and starts the Keycloak login flow.
@ndmspc/ndmspc-ui ships a modular authentication layer supporting Keycloak
(including brokered identity providers), direct OIDC providers and x509
client certificates. The parts can be imported independently:
NdmspcAuthService— framework-agnostic service, usable without React viagetState()/subscribe().NdmspcAuthProvider+useNdmspcAuth()— React bindings; the hook exposesoptions(the sign-in choices) alongside the state.NdmspcLogin— full-page sign-in gate that lists the configured options.NdmspcUserInfo— component that renders the current user / sign-in actions.NdmspcApp— the Next app shell; pass it anauthconfig to gate it behindNdmspcLogin.
The library reads no environment variables; the application passes its
configuration in. Provider setup (Keycloak brokering, direct CERN SSO, Google,
x509) is documented in src/lib/auth/README.md.
import { NdmspcAuthProvider, NdmspcLogin } from "@ndmspc/ndmspc-ui";
<NdmspcAuthProvider
config={{
providers: [
// Official ndmspc Keycloak. `identityProviders` are IdPs already brokered
// in the realm; each becomes an extra button (kc_idp_hint) and still
// yields a token issued by this Keycloak.
{
id: "ndmspc",
label: "NDMSPC",
kind: "keycloak",
url: "http://keycloak.127.0.0.1.sslip.io:8009",
realm: "ndmspc-dev",
clientId: "ndmspc-dev-client",
identityProviders: [
{ alias: "cern", label: "CERN" },
{ alias: "google", label: "Google" },
],
},
// Direct OIDC (e.g. CERN SSO), bypassing the broker. The code→token
// exchange happens in the browser, so the client must allow CORS for this
// app's origin.
{
id: "cern",
label: "CERN",
kind: "oidc",
issuer: "https://auth.cern.ch/auth/realms/cern",
clientId: "ndmspc-ui",
},
// x509: an HTTPS endpoint that requires the client certificate.
{ id: "x509", label: "X.509", kind: "x509", probeUrl: "https://host/api/auth/x509" },
],
}}
>
<NdmspcLogin />
</NdmspcAuthProvider>;init() performs no automatic redirect (keycloak.onLoad is unset), so the
user signs in explicitly. Set keycloak.onLoad to "check-sso" (add
silentCheckSsoRedirectUri to avoid a full redirect) or "login-required" to
opt into automatic SSO. x509 is probed on load only when x509.autoProbe is
set. A direct-OIDC redirect is completed automatically when the browser returns
with a ?code= / ?state= callback — direct providers use the URL query
while Keycloak uses the fragment, so the two never interfere.
In this repo the demo derives that config from .env.local: VITE_KEYCLOAK_*
plus VITE_KEYCLOAK_IDPS="cern|CERN,google|Google" for brokered buttons, direct
CERN via VITE_CERN_OIDC_ISSUER / VITE_CERN_OIDC_CLIENT (optional
VITE_CERN_OIDC_TOKEN_ENDPOINT to route the exchange through a proxy), and
VITE_X509_PROBE_URL. The Next view (NdmspcApp) is gated behind
NdmspcLogin.
NdmspcApp (the Next view) shows the NDMSPC Rooms management UI. It drives the
ndmspc room router over the same MCP endpoint as the ndmspc-room-tui client
(POST {base}/api/mcp, tools room_list / room_open / room_status /
room_close / room_backup / room_restore), so the two always show the same
registry — a room created in the TUI appears in the UI and vice versa. It lists the
router's rooms with their live state (preparing, waiting for cluster resources,
idle, active, failed / killed), creates and deletes rooms — a room it creates
is selected as soon as the router registers it, so the pane shows it while it is still
being prepared — shows each room's client (?room=) and WebSocket URLs, exports/imports
rooms (the whole set, or one room on its own), and polls every 2 s (pausable). A room the
cluster has no room for is pending on the wire and reads as waiting in the view (the router's vocabulary is the
API's; the view keeps one word per state, in the table and the panes alike): it is kept and
comes up on its own once there is room for its pod, and its Enter button stays disabled
until then.
Restoring reviews the document before it creates anything. Choosing a backup file opens a dialog
with what it holds — each room, whose it is, whether a session comes back with it, and the router it
was exported from — and the restore runs only when confirmed. A room the router already has is the one
choice worth making: replace them (the default when there is one) deletes it first, so the document's
session is what it comes back holding, while keep them leaves it as it is — a room in use keeps its
own session, and only the missing rooms are created. While it runs the dialog says so (the router
creates each room and waits for its revision, so it takes a while), and when it finishes each room is
marked restored, live (left alone) or failed with the router's own reason. Rooms the document
does not name are untouched either way.
One room's configuration exports, and imports, on its own. The selected room's pane carries Export — writing that room's configuration: the file it opened, the steps that were run, the size it was created at and what is on screen, and nothing at all about the room (no id, no owner, no link) — and Import, which puts a configuration somebody handed you into the selected room. Since nothing in the file reaches back into the room it came from, it is simply something to pass on: the person importing it gets a room of their own, at the size the configuration names, holding that work.
An import is all or nothing: the room is deleted if it is there and created again carrying the configuration, because a room takes its session once, as it starts, so there is nothing to merge into. The dialog says as much before it runs, and a configuration can also be attached while creating a room, which is the same operation — the room comes up holding that work rather than empty. Only a file is read (nothing is fetched over the network), and a size the deployment does not offer is refused before anything is deleted.
The library reads no environment variables, so the app supplies the router URL: set
VITE_NDMSPC_ROOM_URL (empty/omitted = the UI's own origin). A cross-origin router
must answer the CORS OPTIONS preflight for POST /api/mcp, including the
Authorization header — the istio front door in front of the ndmspc router does; a
bare ROOT server only sets Access-Control-Allow-Origin, so serve the UI from the
router's own origin in that case.
The parts are reusable on their own:
NdmspcRoomClient— the MCP transport (list/open/status/close/backup/restore/import).NdmspcRoomService— framework-agnostic polling store (getState()/subscribe()).useNdmspcRooms()— React binding for the service.NdmspcRooms— the ready-made management component.
import { NdmspcRooms } from "@ndmspc/ndmspc-ui";
// Same-origin, or point it at the router:
<NdmspcRooms baseUrl="http://localhost:8080" refreshSeconds={2} />;Room links carry an access token. A room the router gave tokens to refuses traffic without one,
so the URLs the detail pane shows carry the token of the level being looked at: read-write
(anything) or read-only (GET only — a non-GET is refused with
{"result": "failure", "code": "read_only"}). The tokens arrive as access on a room (rw / ro),
and the pane's link switch picks which one is appended and labels the rows (rw) / (ro), so the
link that gets handed on is chosen where it is copied. A room that reports no access — one created
before this existed — enforces nothing, and then the switch is not shown and the URLs stay as they
were; the same tokens and the same switch are in ndmspc-room-tui, so both views hand out the same
link.
The links are absolute, and the page URL can be handed on. The pane resolves a relative base
against the page's own origin, so with an empty VITE_NDMSPC_ROOM_URL — the UI served from the
router — the page URL reads http://host/?room=…&token=…&access=… instead of a bare ?room=…, and
the api and websocket URLs carry that host too. The page URL is the room's own page (the router
sends a request carrying ?room= to that room, which serves this page), so opening it in another
browser lands in the room: NdmspcRoomLink reads the parameters on load, signs the visitor in first
when a sign-in method is configured (the link survives the provider redirect) and then opens the room
at the level the link names — a read-only link lists no tools rather than asking for them, and the
room refuses the page when access disagrees with token, so an edited level does not open. Back
returns to the app and drops the parameters, token included. Set VITE_NDMSPC_ROOM_LINK_ENABLED=false
to ignore a link and always open the app's own views; the component is exported for an app that
mounts its own shell:
<NdmspcRoomLink authService={auth} baseUrl={routerUrl}>
<App />
</NdmspcRoomLink>The room's name shows what the router knows about it. In the single-room view the name is a
button: it opens the router's account of that room — owner, revision, state, pods, profile, cpu/memory,
last seen, expiry, and why its container last died — the same fields the rooms pane shows, read from
the router (room_list) when the panel opens. The router answers with the rooms its caller may see
(its owner, or every room for an admin), so a room it does not list for you is said to be exactly
that rather than shown as empty. A room whose /api URL names no id (?room=) has nothing to ask
about, and there the name stays a plain title.
Rooms belong to whoever creates them, and the view shows only what its user may see. A room's
owner arrives with it (a user name, or an email when that is all a token carries; absent for a room
created before ownership existed), and it is part of the room's id — mine created by alice is
alice-mine, so the same id can be somebody else's room too. The view claims the identity it has with
every request, and claims both names when it has both (the signed-in user's user name and email),
because the router matches a caller on either while the owner it sends is what names its rooms. The
router then answers with that owner's rooms only, so a non-admin sees the rooms they created — and the
detail pane refuses rather than offers anything else — while an admin sees every room, with an
OWNER column, an owner row to say whose each one is, and an admin badge in the toolbar. The badge
is the router's own answer (room_list reports admin), not a second copy of the list kept here: with
OIDC the router is the only one that can really know. room_open is ensure, so re-creating a room is
not an error: it answers with the id it used and whether it created the room. With nobody signed in the
view has no identity at all, which the router answers with every room, exactly as it answers a script;
an app that knows its user by some other means can say so:
<NdmspcRooms
baseUrl="http://localhost:8080"
admins={["you@example.com"]} // VITE_NDMSPC_ROOM_ADMINS; emails or user names
currentUser="you@example.com" // VITE_NDMSPC_ANONYMOUS_USER; while nobody is signed in
/>currentUser is the fallback for a view with no login: a claimed identity, since nothing verified it,
while a signed-in user always wins over it. It is what a deployment without OIDC sets so its rooms
still belong to someone — and what makes the owner column and the qualified ids appear at all there.
The router is what enforces everything (it holds the same list in NDMSPC_ROOM_ADMINS, and with no
OIDC configured an asserted owner is a convenience rather than a boundary); the view only shows what
comes back. ndmspc-room-tui --owner <email> acts the same way from a terminal.
When the router records usage, the rooms view's Usage button opens the statistics pane. An admin
sees every user the router recorded, and clicking a name in the table narrows the pane to that
person ("Show everyone" returns); anybody else is shown My usage — their own sessions, UI time
and the rooms they own. The router resolves that scope from the caller's identity (scope=me), so
the page never asks for somebody else's numbers and a non-admin cannot read them. A view with no
identity at all (no login, and no VITE_NDMSPC_ANONYMOUS_USER) has no "me" to show: the pane then
falls back to the aggregate (counts only, never a name) and says so.
The library ships its own shadcn/ui primitives in src/lib/components/ui/
(button, input, label, dialog, alert-dialog, tooltip), generated for
Base UI (@base-ui/react); radix-ui backs only the ported tabs primitive.
They are internal: they back the library's components (the room dialogs and
tooltips) and are not exported from the package, so the public surface stays
small.
Consumers therefore need:
@ndmspc/ndmspc-ui/styles.cssloaded (the tokens and the Tailwind output live there) and the.darkclass on an ancestor for dark mode;- the runtime dependencies declared by the package —
@base-ui/react,class-variance-authorityandlucide-reactare kept external, so they resolve from your install rather than being duplicated inside the bundle.
components.json points the shadcn CLI at the library (ui →
@/lib/components/ui, css → src/lib/index.css, style base-nova), so
npx shadcn add <component> adds Base UI primitives next to the existing ones.
The library ships an in-app tutorial, NdmspcTour, mounted once near the app
root: a short guided tour that spotlights the real controls on a browser's
first visit, and a Help panel (opened from a corner button) that replays the
tour and carries a reference for every tool the room offers.
The tour never blocks the app — the spotlight highlights and explains, and the
user does the work (opening a dialog, filling it in, creating the room); the tour
follows along. A step may wait for something the user opens (await), move on by
itself once it appears (advanceOn), or run a tool (run).
The tool reference is generated from the room's own tools/list — its titles,
descriptions, HTTP methods, argument schemas and declared prerequisites — so a
tool the UI has never heard of appears in full with no UI change. Nothing about
any tool is written into the app.
import { NdmspcTour } from "@ndmspc/ndmspc-ui";
// Mount once, beside the boot splash / activity overlay / notifications:
<NdmspcTour
showOn={["rooms"]} // offered only on the rooms view (the workflow it teaches)
availableViews={["room", "rooms", "tools"]} // steps of absent views are dropped
view={activeView}
onNavigate={(key) => setActiveView(key)} // lets a step switch to its own view
/>;A step is plain data ({ id, title, body, target, view, when, run }): target is a
data-tour attribute on the control to spotlight, view the service it lives on,
and when(context) gates it (the default steps show the room-list ones while no
room is open and the in-room ones once one is). The store (setTourContext) is how
a mounted room tells the tour what it advertises — its tools, live form defaults and
combination — and setTourRunner gives the tour a way to invoke a tool.
Per-tool guided tour. A tool declares its own tour on the server
(_meta["ndmspc.io/tutorial"]): a name, a description of what it does, and the
steps to walk. The Help → Tools reference lists every tool that declares one with a
Tour button, and so does the Inspector when the shown group has no session yet —
offered by the tour's own name and description rather than by the tool's name, so what
you pick is what the tour does ("Browse hsimple.root file — Open the hsimple.root sample
and draw a few of its objects"). The UI walks the steps as declared: it points at
Save & Run
(or at the object to click, or at the pads) and the user runs each one — nothing is run
for them, and a step that names an object moves on when the object draws. Nothing about
any tool is written in the UI — a new tool gets a tour the moment it declares one.
The demo app wires it in src/app/NdmspcAppSwitch.tsx. Two environment
variables (documented in .env.example):
VITE_NDMSPC_TOUR_ENABLED— offer the tutorial at all (default on);VITE_NDMSPC_TOUR_FORCE— show the guided tour on every load, ignoring the browser's "already seen" memory (for testing).
First-access memory is per browser, under localStorage
ndmspc:tour:<version>:done, so bumping the tour's version shows it again to
everyone.
npm installnpm run devnpm run build produces the publishable library (dist/ndmspc-ui.es.js,
dist/ndmspc-ui.css, dist/index.d.ts) but no page. The servable page
(index.html + assets/) is built separately:
npm run build:page # -> page-dist/ (index.html, assets/, vite.svg)The build stamps its version into VITE_APP_VERSION (from package.json, or from the environment
when a release pipeline sets it, e.g. VITE_APP_VERSION=1.2.3 npm run build:page). The user menu
shows that version under the token expiry (UI v1.2.3); the dev server shows UI dev, and a local
page build with no stamped version names the entry bundle it is running (UI dev · index-….js).
The room's Server info panel is
about the room, so it shows the ndmspc-server and ROOT versions there, never the UI version.
On every git tag the build-page job builds this page, tars it, and uploads it
to the Generic Package Registry under the tag; the release-page job then
attaches it to the tag's GitLab Release. ndmspc's CMake consumes it instead of
running the npm builds, from the stable URL:
https://gitlab.com/ndmspc/ndmspc-ui/-/releases/<tag>/downloads/ndmspc-ui-page.tar.gz
That URL redirects to the package it was built from, which is downloadable directly if you prefer:
https://gitlab.com/api/v4/projects/ndmspc%2Fndmspc-ui/packages/generic/ndmspc-ui-page/<tag>/ndmspc-ui-page.tar.gz
(use permalink/latest in place of <tag> to always follow the newest release)
Three names describe what is downloadable:
| Name | What it serves | Moved by |
|---|---|---|
v1.4.5 |
that tag's page, never overwritten | the tag's own pipeline |
v1.4-stable |
the newest v1.4.x page, pre-releases included |
every v1.4.* tag (release-stable) |
next |
the newest develop build |
every develop pipeline (release-next) |
v1.4-stable is what lets ndmspc release a 1.4 patch without ndmspc-ui being
tagged again: ndmspc asks for v1.4-stable first, falls back to its exact tag
page (v1.4.5) when the series slot does not exist, and only then to next.
The slot is over-written in place (the previous package version is deleted
first), so downloading it always yields the latest page of the series:
https://gitlab.com/api/v4/projects/ndmspc%2Fndmspc-ui/packages/generic/ndmspc-ui-page/v1.4-stable/ndmspc-ui-page.tar.gz
The page keeps the version of the tag it was built from (a v1.4-stable download
still shows UI v1.4.5 in the user menu). Two consequences: rebuilding an older
series tag after a newer one moves the slot backwards (the last pipeline wins),
and v1.5-stable only appears with the first 1.5 tag. Pin an exact tag when a
byte-identical page matters.
For a rolling development pointer, every build of develop is published by the
release-next job to a single over-writable next slot in the Generic Package
Registry, so the URL always serves the latest develop page:
https://gitlab.com/api/v4/projects/ndmspc%2Fndmspc-ui/packages/generic/ndmspc-ui-page/next/ndmspc-ui-page.tar.gz
Point _ui_url above at that URL instead of the release downloads path to track
develop (substitute the numeric project id for ndmspc%2Fndmspc-ui if you prefer).
The archive extracts to a ready-to-serve web root (index.html + assets/).
A minimal CMake consumption looks like:
set(NDMSPC_UI_TAG "v1.0.0" CACHE STRING "ndmspc-ui release tag")
set(_ui_url
"https://gitlab.com/ndmspc/ndmspc-ui/-/releases/${NDMSPC_UI_TAG}/downloads/ndmspc-ui-page.tar.gz")
set(_ui_archive "${CMAKE_BINARY_DIR}/ndmspc-ui-page.tar.gz")
set(_ui_dir "${CMAKE_BINARY_DIR}/ndmspc-ui-page")
file(DOWNLOAD "${_ui_url}" "${_ui_archive}" SHOW_PROGRESS STATUS _dl_status TLS_VERIFY ON)
list(GET _dl_status 0 _dl_code)
if(NOT _dl_code EQUAL 0)
message(FATAL_ERROR "Failed to download ndmspc-ui page from ${_ui_url}: ${_dl_status}")
endif()
file(MAKE_DIRECTORY "${_ui_dir}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf "${_ui_archive}"
WORKING_DIRECTORY "${_ui_dir}"
RESULT_VARIABLE _untar)
if(NOT _untar EQUAL 0)
message(FATAL_ERROR "Failed to extract ndmspc-ui page")
endif()
install(DIRECTORY "${_ui_dir}/" DESTINATION <web-root>)