Repository navigation
Description
With dark on, /office/applications renders half dark: the page ground, drawer, sidebar and the ScreenHeader title stay in light-mode colours, while the Lane rows, stage titles and the transparency strip render in dark-mode colours. Because the light ground stayed and the row text switched to text[dark].primary (white), every candidate name and stage title is white-on-white and invisible.
Measured, not a race
First seen in the first dark run of smoke-authed.mjs --scheme dark (#833). To rule out a mid-transition frame, the harness now waits until <html data-theme> is stamped and the loading overlay is gone, then settles 2.5 s, before it screenshots (fixed in the #966 PR). The re-run is pixel-identical: data-theme="dark" on all 8 routes, and the same split frame.
So two components in the same tree, under the same provider, are reading opposite themes at the same instant.
| rendered light (stale) | rendered dark (correct) |
|---|---|
page ground (OfficeLayout) |
transparency strip (CANDIDATES CAN SEE IN) |
drawer / sidebar (DrawerLayout, colors.bg[theme].default) |
Lane row titles (text[dark].primary → white) |
ScreenHeader <H2> title (colors.text[theme].primary → near-black) |
stage names, stage dots, overdue amber |
| sidebar nav labels | metric figures in the strip |
The split is not by package — DrawerLayout (scf-core) is stale and Lane titles (composed in scf-core) are correct. It lines up with mount time: everything that mounts with the shell is stale; everything that mounts after the api responds (rows, strip) is right. That reads as "the provider's value changed from light to dark after first paint, and already-mounted consumers did not re-render".
One confirmed, one hypothesis
Confirmed, regardless of the above: packages/scf-core/components/layouts/OfficeLayout.tsx:233 paints the office content area with colors.gray[50] — a light-only literal with no theme dimension. Even once propagation is right, the office ground stays light. That is a one-line token fix.
Hypothesis, not tested — do not take it as the diagnosis: since #957, useThemeSetting() calls useSegments() and forces light when isLightOnlySurface(segments). segments is [] before the router has resolved the route, and [] is exactly the landing-page case that helper treats as light-only. If the first render of a protected route happens under [], the app starts light and flips to dark a tick later — which would explain when the flip happens, and would be a regression #957 introduced for every dark user, not just this screen. It would not by itself explain why mounted consumers fail to pick up the flip; that is a second question (memoisation somewhere between the ui ThemeProvider's controlled setResolved and the shell), and I have not looked for it. Verify before acting on either: log useSegments() on the first render of /office/applications, and check whether useThemeContext().theme changes for an already-mounted shell component when the provider flips.
Why #833's own verification did not catch it
That verification measured document.body background and data-theme on /, /terms and /auth — the auth screen rendered dark correctly. The body and the stamp are right here too; it is the component tree underneath that is split, and nothing measured a component. The lesson is already written into the smoke's theme assertion: a stamp is not a render.
Acceptance
-
useSegments()on the first render of a protected route is logged and the hypothesis confirmed or refuted on the issue - With dark on, every component on
/office/applicationsreads the same theme — verified by computed colour on a ScreenHeader title and a Lane title in the same frame -
OfficeLayout.tsx:233usescolors.bg[theme].*, notcolors.gray[50] -
smoke-authed.mjs --scheme darkcaptures of the four ATS routes show no light shell
This is the first finding of #840's per-screen pass, and it is the blocking one: until the shell follows the theme, no other dark finding on these screens can be read.
Activity
thinkclay commentedon Oct 6, 2026
Correction on the hypothesis, measured. The
useSegments() === []lead is refuted. With a trace inuseThemeSettingand the smoke's own session path on/office/applications, every call on the route reportedsegments: ["(admin)","office","applications"],lightOnly: false, and resolved dark. The[]readings I saw earlier all coincided withpathname: "/"— a seeding load and a redirect, not the route. So #957 is not the cause.What is measured, in one frame on the route:
The provider is right and the component under it is wrong — and only one
ThemeProviderrenders (src/index.tsandsrc/theme/index.tsexport the same module;H2rendersstyle={[computedStyle, style]}so the caller's colour wins).Then the lead that matters: after adding a one-line
console.logtoScreenHeader.tsxandDrawerLayout.tsx— nothing else — both loggedsees darkand the title measured a dark token, on the same server, minutes apart. The only difference was that Metro re-transformed those two files. This worktree'spackages/uisubmodule pointer moved this morning (rebased onto main), and Metro keys its transform cache on path + content, so unchanged ui files could keep transforms from the previous ui commit while changed ones get fresh ones — a bundle stitched from two ui versions, which would produce twoThemeContextinstances and exactly this symptom.Testing that now with a full cache wipe and a cold rebuild. If the split does not reappear, this issue narrows to the one confirmed code defect —
OfficeLayout.tsx:233'scolors.gray[50]— plus a harness rule: wipe Metro's cache whenever the ui submodule pointer moves, and record that in the smoke's prerequisites.[-]Dark mode: the office shell stays light while content mounted later goes dark — names render white-on-white[/-][+]Dark mode on web: SSR renders light and hydration keeps the server's styles, so the whole shell stays white[/+]thinkclay commentedon Oct 6, 2026
Root cause, measured. Retitling. This is neither a theme-context split nor a Metro-cache artefact, and my two earlier leads (#957's
useSegments, duplicateThemeContext) are both refuted by measurement.The mechanism
Web SSR renders the app light unconditionally, and React does not patch attribute mismatches on hydration.
Three independent readings on
/office/applications, dark preference, dark OS, warm bundle, fully wiped Metro cache:ThemeProvidercontainer, the navigatorBackground, theCustomDrawersidebar, theOfficeApplicationsScreenstack — carrybackgroundColor: rgba(22,17,13,1.00)in their React style prop. Their computed CSS isrgb(255,255,255). Every traced producer agrees:useThemeSetting → dark,ThemeBridge → dark,ui ThemeProvider → controlled, resolved: dark,(admin)/_layout → #16110d,DrawerLayout → #16110d,ScreenHeader sees dark.curl http://localhost:8094/office/applications: 11 inlinebackground-color:rgba(255,255,255,1.00), 0 dark, nodata-theme, and the loading overlay in the markup. The server has no storage and nowindow, soresolveThemePreferenceyields light there every time.So every node that exists in the server HTML keeps its white
style; every node that mounts after hydration (Lane rows once the api responds, the transparency strip) is created client-side and gets dark. That is exactly the split in the capture, and it explains why touching a source file "fixed" that component — HMR remounted it client-side. It also means the Loading overlay in #967 is white for the same reason, not a resolution race.Scope
Every SSR'd route, every dark user on web, every first load. Client-side navigation after the first load is fine (no SSR). The native app is unaffected (no SSR). Light users are unaffected (server and client agree), which is why nothing in release 3 caught it.
Two fix shapes
(a) Make the server render the right theme. The theme has to be known server-side: a cookie written by the client whenever the preference resolves (and on first visit from
prefers-color-schemevia a tiny inline script), read in the root loader the wayviewportLoaderalready renders per device (#785). Server and client then agree, hydration is clean, no flash. This is the correct fix and matches the repo's SSR architecture.(b) Force a client re-render after hydration when the themes disagree. e.g. key the themed subtree on
resolvedThemeonce mounted, so a client theme that differs from the server's remounts and rewrites every style. One-liner-ish, but it is a visible light→dark flash on every dark load and a full remount of the navigator — which.radium/app-expo.md's navigator-wrapper rule exists to forbid. A mitigation, not a fix.(c) Independent of both:
OfficeLayout.tsx:233paintscolors.gray[50], a theme-less light literal; it stays light under either fix. One-line token change.Acceptance
curlof an SSR route with the dark cookie/preference returns dark inline grounds, or the server output is theme-agnostic/office/applicationsin darkOfficeLayout.tsx:233on a theme tokenFound by the #840 per-screen pass; this is the first thing it has to clear.
thinkclay commentedon Oct 6, 2026
Independent verification of #999, with the instrument that found this. On main at
65e36341d, warm bundle, fully wiped Metro cache, dark preference + dark OS,/office/applications:Before #999 the same probe read six white divs all carrying the dark ground in their React style prop, and three "attributes … didn't match … won't be patched up" warnings. Fixed.
What remains is a flash, not a bug. The server still renders light — the raw HTML carries 11 white inline grounds and 0 dark — and the body ground goes from unset at 60 ms to
#16110dat 1,083 ms. So a dark visitor sees roughly one second of the light shell on every full page load (not on client-side navigation).Removing it means the server knowing the theme, and the only server-side channel is loader data, as the viewport hint does (#785). That reaches the public routes and
/, which have loaders — and none of the 134 route files under(protected)and(admin), which have no loader and no layout-level equivalent in expo-router. Filing the flash separately so the cost is weighed on its own rather than under a closed bug.