Skip to content

Comments

Make frontend build-type aware (OTEL + HTMX)#2714

Merged
reakaleek merged 4 commits intomainfrom
feature/build-type-aware-frontend
Feb 17, 2026
Merged

Make frontend build-type aware (OTEL + HTMX)#2714
reakaleek merged 4 commits intomainfrom
feature/build-type-aware-frontend

Conversation

@reakaleek
Copy link
Member

@reakaleek reakaleek commented Feb 16, 2026

Why

The frontend currently hardcodes assembler-specific values: OTEL always initializes with docs-frontend as service name and /docs as 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 current BuildType. This tells the frontend which build it is running in, what OTEL service name to use, and whether telemetry should be enabled at all.

Build type Service name Telemetry Root path
Assembler docs-frontend on /docs
Codex codex-frontend on (empty)
Isolated docs-frontend off (empty)

OTEL is now conditional

main.ts only calls initializeOtel() 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.ts was tightly coupled to /docs/... paths. This PR extracts it into an HtmxUrlStrategy interface with three implementations (assembler, codex, isolated). The correct strategy is selected at startup based on the injected config. This keeps utils.ts simple and makes each build type's URL behavior explicit and testable.

@reakaleek reakaleek requested a review from a team as a code owner February 16, 2026 21:19
@reakaleek reakaleek requested a review from Mpdreamz February 16, 2026 21:19
@reakaleek reakaleek marked this pull request as draft February 16, 2026 21:28
reakaleek and others added 2 commits February 16, 2026 22:33
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>
@reakaleek reakaleek added the fix label Feb 16, 2026
@reakaleek reakaleek marked this pull request as ready for review February 16, 2026 21:49
@reakaleek reakaleek merged commit 649fbd7 into main Feb 17, 2026
30 of 32 checks passed
@reakaleek reakaleek deleted the feature/build-type-aware-frontend branch February 17, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants