This document tracks issues encountered during the development of the DocuNote application (formerly FileChat AI).
A series of issues were encountered while implementing the theme switching feature.
-
Initial Bug: The theme could only be changed once. Subsequent selections would not work without a page refresh.
- Resolution Attempt 1: Converted
ThemeProviderto a client component ("use client"). This did not fully resolve the issue. - Resolution Attempt 2: Removed
suppressHydrationWarningfrom the<html>tag, which led to a new error.
- Resolution Attempt 1: Converted
-
Hydration Error: After attempting to fix the initial bug, a React hydration error occurred.
- Symptom: The server-rendered HTML for the
<html>tag did not match the client-side rendered HTML. - Resolution: Re-added the
suppressHydrationWarningprop to the<html>tag insrc/app/layout.tsx. This is the correct approach fornext-themes.
- Symptom: The server-rendered HTML for the
-
"Gray" Theme Freezing: Selecting the "Gray" theme option would prevent any further theme changes.
- Symptom: The application would get "stuck" in the gray theme state.
- Cause: The
DropdownMenuItemfor the "Gray" theme was missing itsonClick={() => setTheme("gray")}event handler. - Resolution: Added the missing
onClickhandler tosrc/components/theme-toggle.tsx.
-
"Gray" Theme Styles Not Applying: After fixing the freezing issue, the "Gray" theme's colors would not apply.
- Cause 1: The
ThemeProviderinsrc/app/layout.tsxwas not configured to recognize the "gray" theme. - Resolution 1: Added
"gray"to thethemesarray in theThemeProviderprops. - Cause 2: The
attributeprop onThemeProviderwas set to"class"while the CSS was expecting[data-theme]. - Resolution 2: Changed the
attributeprop to"data-theme". - Cause 3: The CSS in
globals.cssused an incorrect selector (html[data-theme="gray"] { ... }was mistakenly something else). - Resolution 3: Corrected the CSS selector to
html[data-theme='gray'].
- Cause 1: The
-
"Dark" Theme Failure: Selecting the "Dark" theme would result in the light theme being applied.
- Cause: The CSS selector for the dark theme in
globals.csswas.darkinstead of the correcthtml[data-theme='dark']. - Resolution: Updated the CSS selector to match the
data-themeattribute.
- Cause: The CSS selector for the dark theme in
-
Theme Icon Not Updating: The sun/moon icon in the theme toggle button did not change to reflect the current theme.
- Cause: The
tailwind.config.tswas configured withdarkMode: ['class'], but the application was using thedata-themeattribute. - Resolution: Updated
tailwind.config.tstodarkMode: ['attr', 'data-theme']to allow Tailwind'sdark:utility to work with thedata-theme="dark"attribute. The issue persisted and was finally resolved by conditionally rendering the icons based on theuseThemehook's state.
- Cause: The
- AI-Generated Background Not Updating: After generating one AI theme with a background, subsequent theme generations would not change the background image in the "Sources" panel.
- Cause: The component logic was not correctly handling the removal of previously generated AI theme styles. Old
<style>tags were being left in the document head, causing CSS conflicts. - Resolution: Modified the
handleGeneratefunction inai-theme-generator.tsxto query and remove anystyleelements with an ID starting withtheme-ai-before appending the new one.
- Cause: The component logic was not correctly handling the removal of previously generated AI theme styles. Old