Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
Docs Host Visibility — implementation plan
Spec / source: .ai/specs/2026-09-02-docs-host-visibility.md
Branch: feat/docs-link-visibility
Worktree: /Users/aashu/work/carbon/carbon-feat-docs-link-visibility
Mode: ship-it autonomous
Progress
- Task 1: Extract
parseBaseUrlinto a shared module - Task 2: Make
basenullable + ingest?host=inApiConfigProvider - Task 3: Add
<your-host>substitution toapplyBase/applyConfig - Task 4: Build the
HostPlaceholderclickable control - Task 5: Add the "unknown" third mode to the Configurator
- Task 6: Render the placeholder in
BaseUrl,CodePanel,config-inline - Task 7: Route the MCP page's hardcoded
ENDPOINTthrough the config - Task 8: ERP — pass
CARBON_API_URLas?host=on the docs links - Task 9: Typecheck + lint
- Task 10: End-to-end verification against the acceptance criteria
Dependencies
- Task 1 → Task 2 (provider imports the shared validator)
- Tasks 2, 3 → Tasks 4, 5, 6, 7 (they consume the nullable
base+ new helpers) - Task 4 → Task 6 (placeholder component used by consumers)
- Task 8 is independent of Tasks 1–7 (different app) — may run in parallel
- Tasks 9, 10 last
Environment note
This worktree had no node_modules; pnpm install was started at plan time.
All Verify blocks require it to have finished. If turbo is still "not found",
wait for the install to complete before treating a failure as real.
Task 1: Extract parseBaseUrl into a shared module
Depends on: none Files:
- Create:
docs/components/api/base-url-parse.ts - Modify:
docs/components/api/configurator.tsx— delete the localparseBaseUrl(lines ~48–67) and import it from the new module instead.
Steps:
- Create
docs/components/api/base-url-parse.tscontaining exactly the existingparseBaseUrlimplementation moved verbatim fromconfigurator.tsx, exported:
/** Validate/normalize a user-entered base URL. Returns the cleaned URL or an error message. */
export function parseBaseUrl(raw: string): { url: string } | { error: string } {
const v = raw.trim();
if (!v) return { error: "Enter a URL" };
const withScheme = /^https?:\/\//i.test(v) ? v : `https://${v}`;
let u: URL;
try {
u = new URL(withScheme);
} catch {
return { error: "Not a valid URL" };
}
if (u.protocol !== "http:" && u.protocol !== "https:") {
return { error: "Use http:// or https://" };
}
const host = u.hostname;
const isIp = /^\d{1,3}(\.\d{1,3}){3}$/.test(host);
if (host !== "localhost" && !isIp && !host.includes(".")) {
return { error: "Enter a valid host (e.g. rest.carbon.ms)" };
}
return { url: (u.origin + u.pathname).replace(/\/+$/, "") };
}
- In
configurator.tsx, remove the local definition and addimport { parseBaseUrl } from "./base-url-parse";. - Do not change the validation rules. The
javascript:scheme is already rejected by thehttp:/https:check — that is the guard acceptance criterion 7 depends on.
Verify:
grep -c "function parseBaseUrl" docs/components/api/configurator.tsx
# Expected: 0
grep -c "export function parseBaseUrl" docs/components/api/base-url-parse.ts
# Expected: 1
Out of scope: changing validation behaviour; the rest of configurator.tsx.
Task 2: Make base nullable and ingest the ?host= param
Depends on: Task 1 Files:
- Modify:
docs/components/api/config-context.tsx
Steps:
- Change the context type so unknown is representable:
type Ctx = {
base: string | null; // null = host unknown
setBase: (v: string | null) => void;
isDefault: boolean; // true only when base === DEFAULT_API_BASE
isUnknown: boolean; // true when base === null
apiKey: string;
setApiKey: (v: string) => void;
openConfigurator: () => void; // lets any consumer open the dialog
configuratorOpen: boolean;
setConfiguratorOpen: (v: boolean) => void;
};
- Default the state to
null(unknown), NOTDEFAULT_API_BASE. - In the mount effect, resolve in this precedence order (spec Part 2):
localStorage.getItem("carbon-api-base")— if present and non-empty, use it.- Otherwise read
?host=fromwindow.location.search, validate withparseBaseUrlfrom./base-url-parse, and if valid use it and persist it tolocalStorageunder the same key. - Otherwise leave
null. Wrap all storage access intry {} catch {}, matching the existing style.
setBaseacceptsnull: when null,localStorage.removeItem(BASE_STORAGE_KEY)and set state to null; otherwise trim/strip trailing slashes as today. Note the current|| DEFAULT_API_BASEfallback must be removed so an explicit null is not coerced back to Cloud.- Add the
configuratorOpenstate here (the Configurator will consume it) so any component can trigger the dialog. - Keep
DEFAULT_API_BASEexported and unchanged. - Update
appOriginto acceptstring | null; whennull, returnnullso callers render the placeholder rather thanapp.carbon.ms.
Verify:
grep -n "base: string | null" docs/components/api/config-context.tsx
# Expected: a match in the Ctx type
grep -n "useState<string | null>(null)" docs/components/api/config-context.tsx
# Expected: a match — unknown is the initial state
Out of scope: the applyBase/applyConfig bodies (Task 3); UI components.
Escape hatch: if localStorage currently holds https://rest.carbon.ms
from a previous visit, that is a legitimate explicit Cloud choice and must be
honoured as Cloud, not converted to unknown.
Task 3: Add <your-host> substitution to applyBase/applyConfig
Depends on: Task 2 Files:
- Modify:
docs/components/api/config-context.tsx
Steps:
- Add the placeholder constant beside the existing one:
export const HOST_PLACEHOLDER = "<your-host>";
applyBase(text, base)— whenbaseisnull, replace occurrences ofDEFAULT_API_BASEwithHOST_PLACEHOLDER; when it is a string, keep today's behaviour (replace withbase, no-op when it equals the default).applyConfig(text, base, apiKey, html)— same nullable handling, and it must also swap the MCP endpoint. Whenbaseis null,DEFAULT_MCP_ENDPOINTbecomes`${HOST_PLACEHOLDER}/api/mcp`.- Encoding-proof substitution (critical). In the
htmlpath the sample is shiki HTML where</>are entity-encoded. The inserted placeholder must be encoded the same way or it will be swallowed as a bogus tag. Emit<your-host>whenhtmlis true and the literal<your-host>when it is false, exactly mirroring how<api-key>is handled today. Reuse the existingescapeHtmlhelper for any substituted real value. - Copy-to-clipboard uses the non-html path, so criterion 9 (clipboard contains
literal
<your-host>, no<) follows from step 4.
Verify:
grep -n "HOST_PLACEHOLDER" docs/components/api/config-context.tsx
# Expected: at least 3 matches (definition, applyBase, applyConfig)
grep -n "<your-host>" docs/components/api/config-context.tsx
# Expected: at least 1 match — the html-encoded emission path
Out of scope: generate-api-docs.mjs and the generated JSON — the build-time
BASE literal stays exactly as it is; all swapping is at render time.
Task 4: Build the HostPlaceholder clickable control
Depends on: Tasks 2, 3 Files:
- Create:
docs/components/api/host-placeholder.tsx - Copy from (precedent):
docs/components/api/base-url.tsx(client-component shape +ed-*token usage) anddocs/components/api/configurator.tsx(trigger button styling:border-ed-warm-300,hover:border-ed-warm-500).
Steps:
- Create a
"use client"component:
"use client";
import { HOST_PLACEHOLDER, useApiConfig } from "./config-context";
/** The `<your-host>` stand-in shown when the reader's instance is unknown.
* Clicking it opens the API configuration dialog. */
export function HostPlaceholder() {
const { openConfigurator } = useApiConfig();
return (
<button
type="button"
onClick={openConfigurator}
title="Set your Carbon instance"
className="rounded-[5px] border border-dashed border-ed-warm-500 bg-ed-brand/7 px-[5px] py-px font-mono text-ed-brand-ink transition-colors hover:border-ed-brand hover:bg-ed-brand/12"
>
{HOST_PLACEHOLDER}
</button>
);
}
- Plain English copy — the docs app uses no Lingui (spec Design Decisions).
- Only
ed-*tokens already present in this directory; introduce no new colors.
Verify:
grep -n "openConfigurator" docs/components/api/host-placeholder.tsx
# Expected: 1 match
grep -rn "ed-brand-ink\|ed-warm-500" docs/components/api/configurator.tsx | head -2
# Expected: matches, proving the tokens used already exist in this directory
Out of scope: using it in consumers (Task 6).
Task 5: Add the "unknown" third mode to the Configurator
Depends on: Tasks 2, 3 Files:
- Modify:
docs/components/api/configurator.tsx
Steps:
- Widen the mode state:
useState<"unknown" | "cloud" | "self">. - Seed it in
onOpenChange:isUnknown ? "unknown" : isDefault ? "cloud" : "self". - The Environment section currently renders two
ModeCards in agrid-cols-2. Add a third card and change togrid-cols-3:- title
"Not sure", sub"Show <your-host>", active whenmode === "unknown". Keep the existingModeCardcomponent as-is — it already takesactive/onClick/title/sub.
- title
- In
save():mode === "unknown"→setBase(null);"cloud"→setBase(DEFAULT_API_BASE);"self"→ validate andsetBase(result.url)(unchanged). reset()setsmodeto"unknown"(the honest default) instead of"cloud".- The trigger button shows
hostderived frombase; whenbaseis null show the literal<your-host>string there instead of a hostname, so the sidebar reflects the unknown state. - Drive
Dialog.Rootfrom the context'sconfiguratorOpen/setConfiguratorOpen(added in Task 2) instead of localopenstate, soHostPlaceholdercan open it. KeeponOpenChangedoing its draft-seeding work. - Both layouts render
<Configurator />twice (mobile + sidebar). The mobile one inMainHeadersits outsideApiConfigProviderin bothdocs/app/api-reference/layout.tsxanddocs/app/mcp/layout.tsx. Moving the provider is out of scope; instead ensureuseApiConfig's default context value keeps that instance harmless — it already returns defaults rather than throwing. Set the default context'sbasetonullandopenConfiguratorto a no-op so the outside-provider instance renders the unknown state and does not crash.
Verify:
grep -n "grid-cols-3" docs/components/api/configurator.tsx
# Expected: 1 match in the Environment section
grep -n '"unknown"' docs/components/api/configurator.tsx
# Expected: several matches (state type, seed, save, reset)
Out of scope: restructuring the layouts or moving ApiConfigProvider.
Task 6: Render the placeholder in BaseUrl, CodePanel, config-inline
Depends on: Tasks 3, 4 Files:
- Modify:
docs/components/api/base-url.tsx— show<HostPlaceholder />+ real path whenbaseis null. - Modify:
docs/components/api/code-panel.tsx— the header currently rendersapplyBase(fullPath, base); when unknown, render<HostPlaceholder />followed by the path portion. - Modify:
docs/components/api/config-inline.tsx—McpEndpointandApiKeysLinkmust handle a nullappOrigin.
Steps:
base-url.tsx: whenisUnknown, render the same chip but with<HostPlaceholder />in place of the{base}text;{path}is unchanged. Paths stay real in every state (spec Part 3).code-panel.tsx:fullPatharrives as`${base}${endpoint.path}`built server-side with the build-time base. WhenisUnknown, strip theDEFAULT_API_BASEprefix and render<HostPlaceholder />+ the remainder, so the method/path header reads<your-host>/part. The<CopyButton>and the shikidangerouslySetInnerHTMLblocks keep callingapplyConfig, which Task 3 already made unknown-aware — do not hand-edit their HTML.config-inline.tsx:McpEndpointrenders<Code><HostPlaceholder />/api/mcp</Code>whenappOrigin(base)is null.ApiKeysLinkcannot produce a working href for an unknown host — render it as aHostPlaceholder-triggered button (same affordance, opens the configurator) instead of a dead link.AuthHeaderis host-independent; leave it unchanged.
Verify:
grep -ln "HostPlaceholder" docs/components/api/base-url.tsx docs/components/api/code-panel.tsx docs/components/api/config-inline.tsx
# Expected: all three files listed
Out of scope: endpoint-section.tsx — it is a server component and keeps
passing the build-time base; the client components do the swapping.
Task 7: Route the MCP page's hardcoded ENDPOINT through the config
Depends on: Tasks 3, 6 Files:
- Modify:
docs/app/mcp/page.tsx— line 25const ENDPOINT = "https://app.carbon.ms/api/mcp";
Steps:
- Leave
ENDPOINTas the literal used to build theCLAUDE_CODEandCURSORsample strings at module scope — those are passed to<CodeBlock>, whoseapplyConfigcall already rewritesDEFAULT_MCP_ENDPOINT(Task 3). Confirm the literal is byte-identical toDEFAULT_MCP_ENDPOINTinconfig-context.tsxso the substitution actually matches. - If it differs in any way, import
DEFAULT_MCP_ENDPOINTand use it, rather than duplicating the string. - The prose
<McpEndpoint />on line 107 is already reactive via Task 6.
Verify:
grep -n "api/mcp" docs/app/mcp/page.tsx docs/components/api/config-context.tsx
# Expected: the page's ENDPOINT and DEFAULT_MCP_ENDPOINT are the same URL string
Out of scope: .mdx prose under docs/content/** mentioning app.carbon.ms
in self-hosting/architecture contexts, where the literal is correct (spec Non-Goals).
Task 8: ERP — pass CARBON_API_URL as ?host= on the docs links
Depends on: none (independent of Tasks 1–7; different app) Files:
- Modify:
apps/erp/app/utils/path.ts— line 320apiDocs, line 1383mcpDocs - Modify:
apps/erp/app/components/AvatarMenu.tsx— line 122 link
Steps:
- In
path.ts, convert both constants to functions taking an optional host:
apiDocs: (host?: string) =>
host
? `https://docs.carbon.ms/api-reference?host=${encodeURIComponent(host)}`
: "https://docs.carbon.ms/api-reference",
and the same shape for mcpDocs with https://docs.carbon.ms/mcp. Keep them
at their existing alphabetical positions in the object.
2. Find every existing reference and update it to a call:
grep -rn "path.to.apiDocs\|path.to.mcpDocs" apps/erp/app. Known site:
AvatarMenu.tsx:122. Update all matches the grep returns.
3. In AvatarMenu.tsx, read the client-safe CARBON_API_URL that
apps/erp/app/root.tsx already puts in its loader env payload
(root.tsx:84,115), using the useRouteData idiom already used across the
app, e.g.:
const rootData = useRouteData<{ env: { CARBON_API_URL?: string } }>("/");
Confirm the actual root route id/path used by other useRouteData callers in
this app and match it exactly — do not guess the route key.
4. Pass it: <a href={path.to.apiDocs(rootData?.env?.CARBON_API_URL)} ...>.
The link keeps target="_blank" rel="noreferrer" — the param carries the
host, so the referrer is deliberately not relied upon.
5. Do not add or change any user-facing string here, so no new Lingui messages
are introduced. The existing <Trans>API Documentation</Trans> is untouched.
Verify:
grep -rn "path.to.apiDocs\|path.to.mcpDocs" apps/erp/app
# Expected: every occurrence is a call with parentheses, no bare constant use
Out of scope: packages/onboarding and packages/react/src/LabelWithHelp.tsx
docs links — they target the docs site itself, not a customer API host (spec Non-Goals).
Escape hatch: if CARBON_API_URL turns out not to be present in the root
loader's env payload at runtime, re-decide using the ship-it resolution ladder
(next candidate: SUPABASE_URL, the value CARBON_API_URL already falls back
to), record it in the spec's Autonomous Decisions, and continue. Do not silently
hardcode a host.
Task 9: Typecheck and lint
Depends on: Tasks 1–8 Files: none (verification only)
Steps:
- Ensure
pnpm installhas completed in this worktree. - Run the scoped typechecks and the linter. Whole-repo
typecheckis documented inAGENTS.mdas OOM-prone — keep it filtered.
Verify:
pnpm exec turbo run typecheck --filter=docs
# Expected: docs:typecheck exits 0, no TS errors
pnpm exec turbo run typecheck --filter=erp
# Expected: erp:typecheck exits 0, no TS errors
pnpm exec biome check docs/components/api apps/erp/app/components/AvatarMenu.tsx apps/erp/app/utils/path.ts
# Expected: no errors
Out of scope: unrelated pre-existing failures elsewhere in the repo — report them, do not fix them in this change.
Task 10: End-to-end verification against the acceptance criteria
Depends on: Task 9 Files: none (verification only)
Steps:
- Start the docs app:
pnpm --filter docs dev(serves on port 3002; the script runsgenerate-api-docs.mjsfirst). - Walk the spec's 10 acceptance criteria in a browser, in order. In particular:
- Criterion 1: clear
localStorageforlocalhost:3002first, then load/api-reference/items/partand confirm<your-host>/part, notrest.carbon.ms. - Criterion 6: set
carbon-api-basetohttps://api.foo.comin devtools, then load?host=https://api.bar.comand confirmapi.foo.comsurvives. - Criterion 7: load
?host=javascript:alert(1)and?host=notaurl, confirm both fall back to unknown and neither is rendered. - Criterion 9: in the unknown state, click Copy on a cURL sample and confirm
the clipboard has literal
<your-host>and no</<.
- Criterion 1: clear
- Report each criterion pass/fail with the observed output. Do not claim a
criterion passes without having exercised it (
AGENTS.md: evidence before assertions).
Verify:
pnpm --filter docs dev
# Expected: "Ready" on http://localhost:3002; then manual checks above
Out of scope: committing. Per the user's standing rule, do not run
git commit — report the change and wait for explicit approval.
Execution deviations
Task 8 — simpler than planned (implemented, verified). The plan had
apiDocs/mcpDocs become functions taking a host, with AvatarMenu reading the
value through useRouteData. While implementing, two facts made that unnecessary:
path.to.apiDocshas seven call sites, not one (AvatarMenu,HelpMenu,ApiKeysTable, and four inWebhooksTable). Converting it to a function would have required editing all seven for no gain.CARBON_API_URLis declared onwindow.env(packages/env/src/index.ts:9), read bygetEnvin the browser (index.ts:101-103), and re-exported by@carbon/auth(whoseconfig/env.tsisexport * from "@carbon/env").path.tsalready importsSUPABASE_URLfrom@carbon/auththe same way and uses it at line 2235.
So apiDocs/mcpDocs stay plain strings, built once through a new withDocsHost()
helper in path.ts. Every call site — not just the avatar menu — now carries the
host, which is strictly better coverage than the plan specified. AvatarMenu.tsx
needed no change at all, so no Lingui strings were touched.
Resolution ladder rung 2 (codebase precedent). Recorded in the spec's Autonomous Decisions as decision 9.
Verification results (Task 9 + 10)
Gates
pnpm exec turbo run typecheck --filter=docs→ passpnpm exec turbo run typecheck --filter=erp→ pass (neededturbo run typegen --filter=erpfirst; this worktree had no generated route types, unrelated to this change)pnpm --filter docs lint→ pass;biome check apps/erp/app/utils/path.ts→ pass
Acceptance criteria — exercised against the real modules via tsx, plus the
running dev server on :3002. No browser automation is installed in this repo, so
the two criteria that are purely about click behaviour (2 and 4) are verified
structurally rather than by clicking.
| # | Criterion | Result |
|---|---|---|
| 1 | Unconfigured visitor sees <your-host>/part, not rest.carbon.ms |
PASS — rendered page shows curl … '<your-host>/part?select=*&limit=10'; zero rest.carbon.ms outside the inert hydration payload |
| 2 | Clicking the chip opens the dialog | PASS (structural) — chip renders as <button title="Set your Carbon instance"> bound to openConfigurator, which drives Dialog.Root open={configuratorOpen} |
| 3 | Saved host resolves everywhere + persists | PASS — applyBase/applyConfig substitute it; provider writes it to localStorage |
| 4 | Carbon Cloud mode still shows rest.carbon.ms |
PASS (structural) — applyBase(…, DEFAULT_API_BASE) returns the sample unchanged; the cloud ModeCard calls setBase(DEFAULT_API_BASE) |
| 5 | ?host= adopted with empty storage |
PASS — adopted and persisted |
| 6 | Saved choice beats ?host= |
PASS — api.foo.com survives ?host=api.bar.com |
| 7 | Invalid ?host= rejected → unknown |
PASS — javascript:, data:, notaurl, empty all rejected and not persisted |
| 8 | ERP link carries CARBON_API_URL |
PASS — withDocsHost encodes it and round-trips through URLSearchParams |
| 9 | Copied sample has literal <your-host>, no entities |
PASS — copy path yields <your-host>; html path yields <your-host> |
| 10 | Typecheck + lint | PASS |
Also verified: MCP endpoint swaps in both states (<your-host>/api/mcp, and
app.acme.com derived from rest.acme.com); API key and host substitute together;
appOrigin(null) returns null so no app.carbon.ms leaks into the unknown state;
a stored rest.carbon.ms is honoured as an explicit Cloud choice (escape hatch).
Routes /api-reference/items/part, /mcp, /mcp/authentication and the
?host= variant all return 200 with no server errors.
Not committed — per the user's standing rule, no git commit was run.
Post-review fixes (thermo-nuclear-review)
Three findings, all fixed and browser-verified on real Chrome (desktop 1400x900
and mobile 390x844) via playwright-core + system Chrome. Playwright was
installed in the scratchpad only — no repo dependency was added.
1. Mobile Configurator was inert (regression introduced by this branch).
Lifting dialog state into context broke the Configurator inside MainHeader's
mobile drawer, which renders outside ApiConfigProvider and so received the
default context's no-op setters. Browser testing showed it was worse than a dead
dialog: it opened, accepted a typed host, closed on Save — and silently discarded
it (localStorage stayed null). Fixed in two parts:
ApiConfigProvidernow wrapsMainHeadertoo in both layouts, so the drawer's Configurator gets the realsetBase/setApiKey.- Dialog open state moved back to local
useStatein each Configurator; the context exposes anopenRequestcounter instead of a shared boolean. Two Configurators are mounted at once, so a shared boolean opened BOTH dialogs on one placeholder click (observed, then fixed). Each instance answers a bump only when its own trigger is the visible one, via atriggerRefoffset check.
2. Host not escaped on the html path. applyConfig substituted a non-null
base into shiki HTML without escapeHtml, while the API key on the same path
was escaped. new URL() leaves & and ' intact, so a host containing <
rendered as a literal <. Not exploitable as XSS — <, >, " are
percent-encoded by new URL(), so no tag can be opened — but it displayed a host
the reader never entered and disagreed with the copy button. Fixed by collapsing
the two branches into one: const host = base ?? HOST_PLACEHOLDER; then
html ? escapeHtml(host) : host.
3. appOrigin dropped the path prefix parseBaseUrl preserves. An instance
at https://acme.com/api/v1 got correct REST samples but an MCP endpoint and
Settings link with /api/v1 missing. Now returns (origin + pathname) with the
trailing slash stripped, matching parseBaseUrl. Pre-existing, but this branch
widened its reach by routing the MCP page's ENDPOINT through it.
Verification after fixes
- 21/21 unit assertions against the real modules (
applyBase,applyConfig,appOrigin,parseBaseUrl) — includes new regression tests for fixes 2 and 3. - 14/14 browser assertions: single dialog per click on both viewports, mobile save
now persists, host-with-path renders,
?host=adopted, saved choice beats the param, hostile param falls back to unknown, zero page errors. typecheck --filter=docs,typecheck --filter=erp, docs lint, biome onpath.ts— all pass.
Still not committed.
Post-review fixes (CodeRabbit)
1. App origin was guessed from the REST host. appOrigin rewrote rest. to
app., but ERP_URL and CARBON_API_URL are separate settings that need not
share a domain, so MCP endpoints and Settings links could point somewhere wrong.
The ERP now sends both origins (?host= and ?app=), appOrigin(base, appBase)
prefers the explicit value, and the rewrite remains only as a fallback for a
host the reader typed themselves.
2. Client-module constant used by a server component. docs/app/mcp/page.tsx
is a server component that interpolated DEFAULT_MCP_ENDPOINT from the
"use client" config module into build-time samples. Constants moved to a new
neutral config-constants.ts that both sides import; config-context.tsx
re-exports them so existing imports keep working.
3. Credential exposure via ?host=. A reader with a saved API key who
followed a crafted ?host=evil link (with no host of their own saved) got
samples pasting their real key at the attacker's host, and parseBaseUrl accepts
http:, so a key could go out in cleartext. A link-supplied host is now
display-only: never persisted, and never credential-trusted. The key is also
withheld from any cleartext host except loopback. Trust is derived at render
from where the base came from plus its scheme, rather than kept in a parallel
state flag — the first attempt used a keyTrusted state variable and immediately
desynced, withholding the key from legitimately saved hosts too.
Pre-existing bug found while verifying #3
The configured API key never appeared in rendered code samples at all, on main
as well as this branch. Shiki escapes only what HTML requires, so the placeholder
comes back as <api-key> — < hex-encoded, > raw — while applyConfig
matched only fully-encoded pairs (<api-key>). Now matched with a
regex accepting either bracket in any form. In scope because this change touches
that exact substitution path; verified against all five encodings.
Verification after these fixes
- 16 unit assertions for the app-origin and constants changes, plus the original 21 — all pass.
- 11 browser assertions for credential handling: key withheld from a link-supplied host, withheld over cleartext, still rendered for a saved https host, still rendered for loopback, param host not persisted.
- The full 14-assertion browser suite still passes.
typecheck --filter=docs,typecheck --filter=erp, docs lint, biome onpath.ts— all pass.