Add three dev-mode visibility affordances so MDX authors learn when
their embeds render nothing or when stub components silently discard
props:
- stub(name) helper wraps children-only shims and warns once per
(component, propKeys) pair when non-children props are passed.
Applied to Inspector and MCPApps as representative cases.
- warnSilentNull() + visible dev-mode fallback for FeatureIntegrations
when no deployed integrations support the requested feature.
- InlineDemo now warns (missing props, unknown slug, or not-deployed)
so authors see why their live demo didn't appear.
- Snippet base stub now emits a visible '[Snippet] runtime override
required' placeholder in dev so missing DocsPageView override is
obvious.
All warnings are gated on NODE_ENV !== 'production' and deduped so
HMR re-renders don't spam the console.
Slug paths reaching loadDoc and buildBreadcrumbs come straight from
URL segments. Before this change, path.join(CONTENT_DIR, slugPath)
would silently escape CONTENT_DIR when slugPath contained '..'
segments (e.g. /docs/..%2F..%2Fsecrets), letting an attacker read
arbitrary files the server process has access to.
- Add a tiny safe-fs helper (resolveWithinDir / safeExistsSync /
safeReadFileSync) that resolves a relative path under a declared
base and returns null when the resolved path escapes.
- Route loadDoc and buildBreadcrumbs through resolveWithinDir so any
traversal attempt collapses to a clean 'not found' fall-through.
- Apply the same guard to inlineSnippets' SNIPPETS_DIR reads for
defense-in-depth, even though its inputs are currently internal.
- Replace the silent empty `catch {}` with a proper error state:
clipboard write failures now set state to "error", surface a
"Copy blocked" label for 2s, and log the original error so devs
can debug (permissions, insecure context, etc.) instead of the
button failing invisibly.
- Collapse the two booleans into a single `CopyState` so idle/copied/
error styling and aria-label stay in sync.
- Guard `reg.code` as a string before rendering; malformed
`demo-content.json` (missing `code`, stale bundle) now produces a
visible WarningBox instead of crashing React on `undefined`.
- `resolveHljsLanguage` warns once per unknown language via a
module-scope Set, so authors learn the right names to use and stop
relying on hljs.highlightAuto guessing wrong.
- hljs try/catch now logs key/file/language + original error instead of
swallowing silently, so authors can spot bad snippets.
- When highlighting fails, drop the `hljs language-*` class so the
escaped plain-text fallback isn't styled as though it were highlighted.
- Defense-in-depth non-string hljs return guard.
- `regionFromFile` normalizes by stripping a single trailing newline
once, then splits — trailing-newline shape is consistent whether or
not `lines=` is supplied, so CopyButton text is predictable.
- Clamp `end` via `effectiveEnd = Math.min(end, allLines.length)` and
warn when an explicit range drifts past the file.
- Move the `WarningMessage` interface up next to the other type decls.
- Escape every interpolated value in convertMarkdownTableToHtml to
close an XSS vector: MDX table cells with HTML-significant characters
(e.g. <script>, &) previously landed raw in the generated markup.
- Scope readTitle and loadDoc title/description lookups to the
frontmatter block so a 'title:' / 'description:' that happens to
appear inside the MDX body (code samples, example config) can't
override the real frontmatter.
- Export a small escapeHtml helper for reuse within this module;
duplicated rather than imported from snippet.tsx to keep
docs-render server-only.
The img and video MDX shims spread props then overrode className to
undefined, silently dropping any className from authors' MDX. Remove the
bogus override so user-supplied className flows through.
Button had no type attribute, defaulting to type="submit" inside a
form (unintentional submits). Default to type="button", accept and
forward onClick/disabled/aria-label, and emit a dev-mode warning when
rendered without onClick so MDX authors learn their Button is
non-interactive.
IframeSwitcher had no sandbox attribute, letting user-controlled MDX embed
malicious-origin iframes with full browser capabilities. Mirror the
InlineDemo sandbox policy (scripts/same-origin/forms/popups) and add an
a11y title.
YouTubeVideo was missing both a title (screen readers announced only the
URL) and a sandbox policy. Add sandbox tuned for YouTube embeds
(scripts/same-origin/presentation/popups) and title fallback.
React 19 / Next 15 expects modern runtimes; ES2017 is stale. ES2022 gives
us top-level await, class fields, and error cause without needing additional
helpers. `next build` still passes.
- Add `engines.node >=18.18` to match Next.js 15 runtime requirements.
- Align `npm run start` with the dev port (3003) for local parity; the
Docker runner sets PORT=10000 via ENV and is unaffected.
- Drop unused dependencies that are not imported anywhere in shell-docs:
`react-markdown`, `react-syntax-highlighter`, `rehype-raw`, and
`@types/react-syntax-highlighter`. These are used in showcase/shell/
but not here; removing them keeps the dependency surface honest.
- Regenerate package-lock.json to match.
Add `.env*.local` and `*.log` entries so accidental secrets and debug
logs never land in the tree. Matches the pattern used by showcase/shell.
Leave the generated /src/data/*.json files tracked, as they are today.
- Re-declare COMMIT_SHA and BRANCH ARGs in the runner stage so ENV
interpolation resolves (ARGs do not cross stages in multi-stage builds).
- Declare NEXT_PUBLIC_BASE_URL as a build-time ARG/ENV so CI can pass it
via --build-arg for the production `next build` (next.config.ts requires it).
- Copy lockfile for shell-docs and switch to `npm ci` for reproducible installs.
scripts/ has no committed lockfile yet, so keep `npm install` there.
- Add .dockerignore so local .next/, node_modules/, .git, logs, and .env*
are not slurped into the build context.
- Invoke next via node_modules/.bin/next (both build and CMD) instead of
npx to avoid runtime network-fallback risk.
- Document the required build context at the top of the Dockerfile.
- Note the libc6-compat discussion: the slim base is Debian (glibc), so
no compat shim is required; note how to enable it if we ever move to
node:20-alpine.
The component's name, comments, and stated purpose are to highlight the
user's remembered framework pick on the docs root pivot. The code was
keying off 'framework' (strictly URL-derived), which is always null on
/docs/* where this component is actually mounted — the 'Your choice'
badge and accent ring NEVER rendered.
Now reads 'storedFramework' (the remembered advisory preference) and
compares it against the card's slug, which is what the rest of the file
already documents it doing.
Functional regressions in the docs router pivot:
1. The redirect effect was reading 'framework' (URL-derived) only. On
/docs/<feature> the URL prefix 'docs' is never in knownFrameworks, so
'framework' is always null and the effect never fired. The whole
'picked-once, sticks' feature was silently broken — users with a
stored preference were never redirected. Now prefers URL framework,
falling back to storedFramework, as a single 'target' signal.
2. The 'Loading <framework> view...' placeholder was unreachable for the
same reason. Now renders when 'target' is set.
3. The supported/unsupported filters disagreed on whether 'deployed'
applied. supported = withCell (ignored deployed); unsupported =
!withCell && deployed. Now both require deployed; undeployed
integrations are omitted entirely rather than surfacing dead links.
4. FrameworkGuardedContent previously returned null whenever 'framework'
was null, which on /docs/* is always. The MDX body was permanently
hidden. Now it hides only while a redirect is imminent (URL framework
set, or storedFramework set — both cases are about to navigate away);
users with no stored preference see the pivot alongside the MDX body.
- Move highlight.js @import ahead of @import "tailwindcss" so Tailwind
utility layers can still override specific hljs selectors when needed
rather than being silently shadowed in Tailwind v4's layer ordering.
- Scope the dark-dimmed theme via prefers-color-scheme so it only
paints when the user's system is in dark mode. shell-docs does not
yet ship a dark theme, but this makes syntax blocks correct the
moment it does.
- useFramework() now throws when called outside FrameworkProvider instead
of returning a silent no-op context. Silent fallback was masking wiring
bugs where components rendered outside the provider would report no
framework forever.
- readStoredFramework / writeStoredFramework now log once per session on
failure (guarded by module-scope flags) instead of swallowing errors
entirely. localStorage may still be unavailable (SSR, private mode),
but devs get a warning the first time.
- Dropped 'stored' from the URL-persist effect's deps. It was causing
redundant re-check cycles every time we called setStored from within.
The internal !== guard still short-circuits the no-op case.
- setStoredFramework now validates against knownFrameworks. Previously
any string could poison the stored preference (e.g. a route segment
like 'docs'); invalid slugs now warn and no-op.
`docs_pageview` was firing on every matched request — HEAD probes,
POSTs, and Next.js router prefetches all counted as pageviews, which
inflated counts and polluted funnels. Next.js App Router prefetches
links via low-priority fetches that still hit middleware, so they're
especially noisy on pages with long link lists.
We now bail out of tracking when:
- the method is not GET
- `next-router-prefetch: 1` is set (Next.js App Router)
- `purpose: prefetch` is set (generic prefetch hint)
The response is still served normally; only the PostHog capture is
skipped.
- Add aria-hidden=true so the SHA is not announced by screen readers.
- Shorten to the conventional 7-char git short-sha (was 9).
- Distinguish 'dev' (NEXT_PUBLIC_COMMIT_SHA undefined) from 'unknown'
(env present but empty string) so Docker ARG-scope bugs surface as
something other than a misleading 'dev' label in production.
Three smaller cleanups to the middleware:
1. Matcher regex: `(?!api|...)` matched `/apidocs` as well as `/api`,
dropping analytics for any docs path whose first segment starts with
'api'. The pattern now uses `api/` with a terminator, and also
excludes `robots.txt`, `sitemap.xml`, `manifest.webmanifest`, and
the `.well-known/` prefix, which some static-path tooling expects
to reach without middleware interception.
2. Capture errors are now logged via `console.warn` rather than
silently swallowed. PostHog 401/403/5xx, DNS failures, etc. were
invisible to operators.
3. The missing-`POSTHOG_PROJECT_KEY` warning now fires once at module
load rather than via a module-scoped mutable flag. Edge runtime
isolates are short-lived and per-request, so the in-memory
warn-once flag was unreliable. Module-load is the cleanest
available single-fire hook.
If a registry integration ever ships a slug matching a top-level route
segment (docs, ag-ui, reference, api, matrix, integrations), the
FrameworkProvider.urlFramework resolver would treat the route as a
framework scope and hijack navigation. Filter those slugs out in the
root layout and log a dev-only console.error so the collision is
visible to the maintainer.
The previous hard-coded distinct_id ("docs-pageview-tracker") collapsed
every visitor into a single synthetic PostHog person, which destroyed
unique-visitor analytics.
Each visitor now gets a stable UUID minted on first visit, persisted
in a first-party `ph_distinct_id` cookie (Lax, Secure, ~2 year TTL)
and read back on subsequent requests. This avoids IP+UA hashing and
the PII concerns that come with it.
Also wraps the PostHog capture POST in `event.waitUntil()` — the
middleware signature now takes `NextFetchEvent` — so the Edge runtime
keeps the request alive until the POST resolves. A bare fire-and-forget
fetch can be torn down as soon as `NextResponse.next()` returns,
dropping events.
Matches shell/ and shell-dashboard/ which commit their npm lockfiles to
pin standalone (non-pnpm-workspace) install closures. Ensures reproducible
Docker builds in CI.
shell-docs renders pure MDX docs with iframed live demos (via <InlineDemo>
and <IframeSwitcher>) — it never instantiates the live copilot runtime
inline, so it doesn't need @copilotkitnext/react or its styles. Dropping
the import also removes the package from shell-docs's dep closure, keeping
the docs shell lean.
These files were added in #4085 but landed in showcase/shell/src/content/docs/
after the MDX-docs extraction had already moved the rest of content/docs into
shell-docs. Follow The Rule (MDX docs content belongs in shell-docs) and
relocate them so they render correctly on docs.showcase.copilotkit.ai.
Extracts everything that exists to render MDX documentation (docs/[[...slug]],
[framework]/[[...slug]], ag-ui/[[...slug]], reference/[...slug]) out of shell
into the new shell-docs package that will serve docs.showcase.copilotkit.ai.
Moves (git mv preserves history):
- App routes: /docs, /[framework], /ag-ui, /reference
- Docs-only components: docs-page-view, docs-callout, docs-steps, docs-tabs,
mdx-components, framework-tabs, framework-selector, sidebar-*, snippet,
property-reference, router-pivot, stored-framework-highlight, react/*
- Docs-only libs: lib/docs-render, lib/mdx-registry
- All content: content/docs, content/ag-ui, content/reference, content/snippets
- .docs-sync-sha marker (follows the content)
Duplicates into shell-docs (both shells need them):
- brand-nav, search-modal, search-trigger, copy-button, framework-provider
- lib/registry.ts, data/registry.json, data/demo-content.json,
data/search-index.json
- app/layout.tsx + globals.css + public/{images,logos}
shell-docs gets its own minimal middleware (PostHog-only — no SEO redirect
table, docs host never served legacy URLs). shell keeps seo-redirects.ts
for the legacy-URL migration table; framework-scope protection in its
middleware is now effectively dead but harmless (next.config.ts redirects
fire before middleware ever sees /<framework>/ paths).
InlineDemo updated for cross-host context: 'Open full demo' link points
at the shell host (showcase.copilotkit.ai) since the integration profile
route only exists there.