feat(ui): export a composeBoot seam so the analytics/clients boot order is testable (RIG-2874) - #1096
Merged
Merged
Conversation
…er is testable (RIG-2874)
|
😎 This pull request was merged. |
rigel-mintaka
added this pull request to stack #1098
September 11, 2026 18:25
|
Compass engineering docs preview: https://compass-ui-rig-2874-composeb.compass-eng-docs.pages.dev Deployed from |
This was referenced Sep 11, 2026
mattwilkinsonn
approved these changes
Sep 11, 2026
|
This pull request was merged into |
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.
This PR is part of a stack containing 4 PRs:
mainMakes the analytics/clients boot order testable. Matt approved exporting
this seam directly; it closes the one open item from #1055 that had no
automated coverage.
Why the order was untestable
main(root, connection)(index.tsx:87) is a module-privateasync functionthat renders into a live DOM root and performs a WhoAmI round-trip before it
returns, and importing the module executes the top-level boot branch at
:59.So no test could reach the construction pair.
Worse, a wrong order is invisible to every automated signal, because both
correlation directions are lazy getters:
traceId: () => clients.traceId.current— a forward reference intoclients, safe only because it fires at capture time, after the nextstatement binds.
sessionId: () => analytics.sessionId()Invert the two and it still typechecks, still renders, and still passes the
visual smoke. It fails only at the TLS network door, as a missing
X-POSTHOG-SESSION-IDheader — and the dev door produces a false negativeindistinguishable from a broken UI half. That is why T4's acceptance was
manual.
The change
composeBoot(deps)inapps/ui/src/compose-boot.tstakes the connection plusoptional factory overrides (defaulting to the real
createAnalytics/createLiveClients/analyticsConfigFromEnv) and returns both built objects.main()now destructures it. Production behaviour is unchanged: sameorder, same two lazy getters, same forward reference.
Why a separate module, not inside
index.tsxindex.tsxcannot be imported underbun test— it drags in the./mount→Apprender graph. Verified with a throwaway probe:mock.modulewas not used as a workaround: it leaks process-wide, whichtest-setup.tswarns about. Placement only — the exported symbol andsignature are the approved ones.
The test is real
compose-boot.test.tsasserts observable consequences, not call order: theclients did not exist when analytics was built; the
sessionIdgetter theclients received resolves through to the analytics instance; the
traceIdgetter the analytics received resolves through to the clients' slot (the
forward reference, live). Fakes are a real in-memory
LiveClientsovercreateRouterTransport— noascast.Proven by inverting the two construction lines and re-running:
Order restored (file confirmed byte-identical via
cmp), 1 pass.Gates
Re-run after rebasing onto current
main(332a733f), which had moved.bun testcompose-boot + analytics + live/client — 30 pass / 0 failbunx tsc --noEmit(apps/ui) — rc=0bunx biome check(3 files) — rc=0RIG-2874