Files
vercel__workflow/packages/web/registry.d.ts
Pranay Prakash 25715d4521 [RFC] feat(nitro): embed observability dashboard in-process at /_workflow (#2548)
* feat(nitro): embed observability dashboard in-process at /_workflow

Serve the @workflow/web observability UI inside the Nitro process at a
configurable route (default /_workflow) instead of spawning a separate
web server and 302-redirecting to it. Enabled in dev, omitted from
production builds by default (so prod bundles carry no @workflow/web
import). Never mounted on Vercel deploys (use the hosted dashboard).

- @workflow/web: add a framework-neutral `@workflow/web/handler`
  (createWorkflowWebHandler) that serves SSR + static client assets +
  RPC as one Web Request->Response handler under a runtime basename
  (asset manifest URLs + publicPath are reprefixed so the dashboard is
  self-contained under its mount). Add `@workflow/web/registry` for
  embedded-dashboard discovery; make the RPC/stream client basename-aware.
- @workflow/nitro: mount the handler in-process (Nitro v2 h3 + v3 native
  paths), gated by a new `dashboard` option (default = dev).
- @workflow/cli: `workflow web` / `inspect --web` defer to a running
  embedded dashboard instead of starting a redundant server; pass
  `--standalone` to force the standalone UI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor(nitro): normalize dashboard path once, use isNitroV2() helper

Address review feedback on the embedded dashboard:

- Normalize the dashboard mount path in one place before it feeds both
  the Nitro route registration (`[path, path + '/**']`) and the handler
  `basename`. Force a single leading slash, strip trailing slashes, and
  reject the root mount, so a custom `path` can't make the route and the
  handler's internal `normalizeBasename` disagree.
- Replace the handler-level `!nitro.routing` v2 checks with the existing
  `isNitroV2()` helper for consistent v2/v3 detection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
2026-07-29 13:58:59 -07:00

30 lines
1.0 KiB
TypeScript

/** A recorded embedded-dashboard instance. */
export interface DashboardRegistryEntry {
/** Public base URL the dashboard is reachable at (e.g. `http://localhost:3000/_workflow`). */
url: string;
/** Mount path the dashboard is served under (e.g. `/_workflow`; `""` at root). */
basename: string;
/** World backend identifier, for display (e.g. `local`, `@workflow/world-postgres`). */
world: string;
/** PID of the process hosting the dashboard. */
pid: number;
/** ISO timestamp the entry was recorded. */
startedAt: string;
}
/** Absolute path of the registry file for the current working directory. */
export function dashboardRegistryPath(): string;
/** Read the registry entries (always returns an array; never throws). */
export function readDashboardRegistry(): DashboardRegistryEntry[];
/**
* Record this process's embedded dashboard (idempotent per process). Entirely
* best-effort — never throws.
*/
export function recordDashboard(entry: {
url: string;
basename?: string;
world?: string;
}): void;