Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions frontend/src/app/app/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ export default function ProfileSettingsPage() {
const { showConfirmDialog, confirmNavigation, cancelNavigation } =
useUnsavedChanges(dirty);

// Populate from fetched prefs
useEffect(() => {
// Populate from fetched prefs — adjust state during render when the
// upstream query result changes (avoids react-hooks/set-state-in-effect).
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
const [prevPrefs, setPrevPrefs] = useState(prefs);
if (prefs !== prevPrefs) {
setPrevPrefs(prefs);
if (prefs) {
setCountry(prefs.country ?? "");
setLanguage((prefs.preferred_language ?? "en") as SupportedLanguage);
}
Comment on lines +57 to 63
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prevPrefs is initialized with prefs, so if React Query returns cached preferences on the first render (likely since RouteGuard already caches queryKeys.preferences), the if (prefs !== prevPrefs) branch will never run and country/language will stay at their default values. This is a behavioral regression vs the previous effect, which populated state even when prefs was available immediately. Consider initializing country/language from prefs via lazy useState initializers, or initialize prevPrefs to a sentinel (e.g., undefined) so the first non-undefined prefs triggers the sync.

Copilot uses AI. Check for mistakes.
}, [prefs]);
}

function markDirty() {
setDirty(true);
Expand Down
Loading