Introducing a new way to review your PRs.

Read the announcement

lencx / chatgpt

❄️ ChatGPT Desktop Application (Mac, Windows and Linux)

View on GitHub

10 documents · Updated Nov 16, 2026

docs / settings-theme-info

Settings theme and app info UI

Covers:

Overview

The settings surface is currently only a placeholder: src/…/Settings.tsx exports a Settings React component that renders a single <div>Settings</div> and does not yet call the hooks in this scope or read/write settings state.

Application environment information is exposed through src/…/useInfo.tsx. useInfo() keeps platform and isMac in React state, then runs handleInfo() once on mount via useEffect. handleInfo() calls Tauri's platform() function from @tauri-apps/plugin-os, stores the platform string, and sets isMac when the returned platform is exactly macos. The hook returns { platform, isMac } for callers that need OS-specific UI behavior.

Theme behavior is exposed through src/…/useTheme.tsx. useTheme() initializes theme to light, then on mount obtains the current Tauri window via getCurrentWindow() from @tauri-apps/api/window. It reads win.theme() to replace the initial value and registers win.onThemeChanged(...) so frontend state tracks future native theme changes. The effect cleanup calls the listener's unlisten function if it was registered. The hook returns the current theme string, which may be light, dark, or an empty string if Tauri reports no current theme.

Both hooks depend on Tauri browser/runtime APIs and are designed for the Tauri frontend context rather than generic server-side rendering.

Coupling

  • If src/…/Settings.tsx starts rendering OS-specific controls, verify it consumes src/…/useInfo.tsx defensively: platform starts as an empty string until the async Tauri call completes, while isMac starts as false and only becomes true after platform() returns macos.
  • If theme values are used for class names or preference persistence, verify callers of src/…/useTheme.tsx handle the initial light value and the later empty-string fallback from win.theme() || ''; otherwise UI can briefly render as light or lose a valid theme state before the Tauri API resolves.

Risks

  • src/…/useInfo.tsx calls TauriPlatform() twice in handleInfo(): once into p and once again for setPlatform. If the plugin call is slow, fails, or ever returns inconsistent values, the displayed platform and derived isMac can diverge.
  • src/…/useTheme.tsx assigns unlisten asynchronously after registering win.onThemeChanged(...). If the component unmounts before registration resolves, cleanup runs before unlisten is assigned and the theme listener may remain registered.