[migrate] upgrade to TypeScript 6, Node.js 24, PNPM 11, Next.js 16, Koa 3, MobX-React-helper 0.5, MobX-GitHub 0.7, Undici 8, Globals 17, Lint-Staged 17, ESLint 10, Sentry 10 & other latest Upstream packages/actions - #59
Merged
Conversation
Closed
…action Dark theme failed to apply on first page load when the user's system preference was dark. This happened because MobX `reaction` only fires when the observed value *changes* — if `colorScheme` was already `'dark'` from the `matchMedia` initialiser, no change event ever fired, so `document.documentElement.dataset.bsTheme` was never set. Replacing `reaction` with `autorun` ensures the theme attribute is applied immediately when the store is first instantiated on the client, and re-applied on every subsequent change. Also added optional chaining (`?.`) on `matchColorScheme()` calls to guard against `undefined` when `matchMedia` is unavailable (e.g. SSR), and wrapped the disposer in an `!isServer()` guard to prevent referencing `document` during server-side rendering.
1. models/System.ts — Dark theme not applied on first load (closes #54): - Replace MobX `reaction` with `autorun` so the Bootstrap `data-bs-theme` attribute is set immediately on client-side init, not only on changes. - Add `!isServer()` guard so `document` is never accessed during SSR. - Add optional chaining `?.` on `matchColorScheme()` calls to prevent a TypeError when `matchMedia` is unavailable (e.g. SSR environment). 2. pages/api/core.ts — Build failure on Node.js 24: - `Dirent.path` is `undefined` in Node.js ≥ 24; use `Dirent.parentPath` with a backward-compat fallback so the article page pre-renders correctly.
Copilot
AI
changed the title
[WIP] Fix dark theme not applying on article page
fix: dark theme not applied on initial page load; fix Node.js 24 build failure in article page
Aug 3, 2026
MobX-React-helper 0.5, MobX-GitHub 0.7, Undici 8, Globals 17, Lint-Staged 17, ESLint 10, Sentry 10 & other latest Upstream packages/actions
[optimize] Folder structure & Library modules
TechQuery
marked this pull request as ready for review
August 3, 2026 23:13
[fix] some detail bugs
TechQuery
approved these changes
Aug 6, 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.
Dark theme failed to activate on first load when the user's OS preference was dark — requiring a manual toggle to trigger it. Additionally, the production build was broken on Node.js 24 due to a removed
DirentAPI.Dark theme (
models/System.ts)MobX
reactiononly fires on changes, not on initial value. IfcolorSchemewas already'dark'(frommatchMediaat init time), no change ever occurred, sodocument.documentElement.dataset.bsThemewas never set.Fix: Replace
reactionwithautorun, which runs immediately on registration and on every subsequent change:Also adds
!isServer()guard (preventsdocumentaccess during SSR) and optional chaining onmatchColorScheme()calls.Article page build (
pages/api/core.ts)Dirent.pathreturnsundefinedin Node.js ≥ 24 — it was replaced byDirent.parentPath. This causedreaddirto be called with'pagesundefined/...', crashing static generation for/article.Fix: Use
node.parentPathwith a fallback to the legacynode.pathfor backward compatibility:Human changes