Make frontend build-type aware (OTEL + HTMX)#2714
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Replace manual JSON string interpolation with System.Text.Json source generator (FrontendConfigJsonContext), which is AOT-safe and avoids hand-rolled escaping. Co-authored-by: Cursor <cursoragent@cursor.com>
Mpdreamz
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The frontend currently hardcodes assembler-specific values: OTEL always initializes with
docs-frontendas service name and/docsas base URL, and HTMX link handling only understands/docs/...URL patterns. This means Codex builds send telemetry under the wrong service name and HTMX navigation breaks on Codex URL structures (/r/{repo},/g/{group}).What this changes
Server-injected frontend config
The server now injects a small JSON config (
window.__DOCS_CONFIG__) into the page based on the currentBuildType. This tells the frontend which build it is running in, what OTEL service name to use, and whether telemetry should be enabled at all.docs-frontend/docscodex-frontenddocs-frontendOTEL is now conditional
main.tsonly callsinitializeOtel()when the config says telemetry is enabled. The service name and base URL come from the config instead of being hardcoded. This keeps Isolated builds free of telemetry overhead and gives Codex its own service name in traces and logs.HTMX URL handling uses a strategy pattern
The URL logic in
utils.tswas tightly coupled to/docs/...paths. This PR extracts it into anHtmxUrlStrategyinterface with three implementations (assembler, codex, isolated). The correct strategy is selected at startup based on the injected config. This keepsutils.tssimple and makes each build type's URL behavior explicit and testable.