Repository navigation
fix(ssr): the logo's gradient id named its tree position, not its gradient - #678
Merged
Merged
Conversation
…dient Closes #625. Every SSR route in the app shell reported a hydration mismatch on the logo's gradient id. #625 read that as "server renders logged-out, client hydrates logged-in, the trees differ". Measuring says otherwise, in two ways. React's message is "A tree hydrated but some attributes ... didn't match ... This won't be patched up" — the attribute warning, not the tree-regeneration error. Hydration SUCCEEDS; the DOM matches. And the only thing it names is the gradient id: + client id="logo-gradient-_R_2qjaqb9_" - server id="logo-gradient-_R_badb9d6_" `useId` was the right fix for #582, where the id came from `Math.random()`. But `useId` encodes the component's POSITION in the React tree, and server and client do not agree on that position here. Position is the wrong key anyway: - Two logos with the SAME colours want the same gradient. Sharing one `<linearGradient>` is the correct output, not a collision. - Two logos with DIFFERENT colours must not share one — and the colours are props, so a single hardcoded id would have been wrong. So the id now names the gradient, derived from its colours: `logo-gradient-76EAFF-239CB2`. Deterministic on both sides, no tree dependence, distinct exactly when the gradients differ. Verified against the running app, logged in, three routes: /dashboard hydration messages: 0 /office/applications hydration messages: 0 /office/ats/metrics hydration messages: 0 and scripts/audit/smoke-hydration.mjs now reports "no hydration errors in either case" instead of failing the logged-in leg. The tests get the invariant they previously could not express. The old file noted it could NOT assert byte-identity across two separate `render()` calls, because two roots legitimately produce different `useId` values — two roots being exactly the situation the server and client render are in. Position is no longer an input, so that assertion is now both possible and the point. One thing this does NOT fix, and I checked rather than assumed: the underlying server/client tree-position divergence is real and still there. Emitting a throwaway `useId` alongside the fixed id still shows `+ _R_2qjaqb9_` against `- _R_badb9d6_`. Nothing in the shell depends on position any more, so it has no way to show itself today — but a future `useId` in the shell would bring it straight back. Filed separately with the evidence and the probe technique. Typecheck 12/12. test:unit 7/7 with --skip-nx-cache.
This was referenced Sep 1, 2026
Open
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.
Closes #625.
The issue's diagnosis was wrong, and the difference matters
#625 read the mismatch as "the server renders the logged-out tree, the client hydrates the logged-in tree, the trees differ" and concluded the whole page is thrown away on every authenticated load. Measuring says otherwise, in two ways.
React's message is the attribute warning, not the tree-regeneration error:
Hydration succeeds. The DOM matches. Nothing is regenerated.
And the server does not render a logged-out tree. A plain
curl /dashboardwith no session comes back with the drawer nav and the logo in it. The only thing React names in the whole diff is the id:Why
useIdwas the wrong keyuseIdwas the right fix for #582, where the id came fromMath.random(). ButuseIdencodes the component's position in the React tree, and server and client don't agree on that position here.Position is the wrong thing to key on regardless of that disagreement:
<linearGradient>is the correct output, not a collision — the two defs would be byte-identical.props, so a single hardcoded id would have been wrong.So the id now names the gradient, derived from its colours —
logo-gradient-76EAFF-239CB2. Deterministic on both sides, no tree dependence, distinct exactly when the gradients differ.Verified
Against the running app, logged in:
/dashboard/office/applications/office/ats/metricsscripts/audit/smoke-hydration.mjsnow reportsVERDICT: no hydration errors in either case— it was failing its logged-in leg, and it is the release gate for this.Server and client now emit the identical id:
logo-gradient-76EAFF-239CB2.Tests get the invariant they couldn't express
The old file said explicitly that it could not assert byte-identity across two separate
render()calls, because two roots legitimately produce differentuseIdvalues — and two roots is exactly the situation the server render and the client render are in. Position is no longer an input, so that assertion is now both possible and the whole point:is identical across two independent roots— the fix(ssr): every authenticated page fails hydration — server renders logged-out, client hydrates logged-in #625 invariantdoes not depend on where in the tree the logo sitslets two logos of the same colour share one gradient def— replaces the old "gives two logos distinct ids", which asserted the behaviour this PR deliberately changesseparates logos whose gradients actually differ— where distinctness genuinely mattersWhat this does NOT fix
I checked rather than assumed. The underlying server/client tree-position divergence is real and still there. Emitting a throwaway
useIdalongside the fixed id still shows:ScaffaldLogowas the onlyuseIdconsumer in the shell —packages/ui'suseIdis exported but used by no component — so nothing depends on position any more and it has no way to show itself today. A futureuseIdin the shell brings it straight back. Filed separately with the evidence and the probe technique.Typecheck 12/12.
test:unit7/7 with--skip-nx-cache.🤖 Generated with Claude Code