Skip to content

Fix deterministic theme initial render#113

Merged
ideav merged 3 commits intomainfrom
issue-112-612890af4be9
Apr 24, 2026
Merged

Fix deterministic theme initial render#113
ideav merged 3 commits intomainfrom
issue-112-612890af4be9

Conversation

@konard
Copy link
Copy Markdown
Collaborator

@konard konard commented Apr 24, 2026

Summary

  • Make the root theme state deterministic on the first render by defaulting to light.
  • Apply the saved localStorage theme after mount instead of during the initial state initializer.
  • Add a regression test that prevents localStorage reads from returning to the initial render path.

Reproduction

The reported React minified errors #418 and #423 are hydration mismatch/recovery errors. The root app could render different markup on the first client render depending on localStorage theme state, because ThemeProvider read localStorage inside the useState initializer.

Verification

  • npm test
  • npm run build

Fixes #112

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #112
@konard konard self-assigned this Apr 24, 2026
@konard konard changed the title [WIP] index.html Ошибка Fix deterministic theme initial render Apr 24, 2026
@konard konard marked this pull request as ready for review April 24, 2026 10:17
@konard
Copy link
Copy Markdown
Collaborator Author

konard commented Apr 24, 2026

Solution summary

Implemented and pushed the fix to issue-112-612890af4be9.

Root cause addressed: ThemeProvider was reading localStorage during the initial useState render, making the first client render depend on browser state. That can trigger React hydration mismatch/recovery errors like #418 and #423. The provider now starts deterministically with light and applies the stored theme after mount.

Added regression coverage in tests/theme-initial-render.test.mjs.

Verification passed:

  • npm test
  • npm run build

PR 113 is updated and marked ready for review: #113


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented Apr 24, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.5
  • Provider: OpenAI
  • Public pricing estimate: $1.005722

📊 Context and tokens usage:

  • 999.3K / 1.1M (95%) input tokens, 6.0K / 130K (5%) output tokens

Total: (72.2K + 927.1K cached) input tokens, 6.0K output tokens, $1.005722 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.5
  • Model: GPT-5.5 (gpt-5.5)

📎 Log file uploaded as Gist (7771KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented Apr 24, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • No CI/CD checks are configured for this repository
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@ideav ideav merged commit dffea31 into main Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

index.html Ошибка

2 participants