Skip to content

fix: clear and reload saved account when switching region#11

Merged
lshw54 merged 14 commits intomainfrom
fix/region-switch-account-autofill
Apr 21, 2026
Merged

fix: clear and reload saved account when switching region#11
lshw54 merged 14 commits intomainfrom
fix/region-switch-account-autofill

Conversation

@lshw54
Copy link
Copy Markdown
Owner

@lshw54 lshw54 commented Apr 21, 2026

Problem

Switching region on the login page kept stale credentials from the previous region instead of loading the correct saved account for the new region.

Cause

Introduced during the dependency upgrade PR — when fixing the react-hooks/set-state-in-effect lint error in NormalLoginForm.tsx, the region-change branch was changed to skip auto-filling saved accounts (if (!regionChanged && last)). This meant:

  1. Old account/password fields were never cleared
  2. The new region's last saved account was never loaded

Fix

On region change, the effect now:

  1. Immediately clears account, password, remember, and savedAccounts state
  2. Loads and auto-fills the last saved account for the new region (backend returns region-scoped data)

lshw54 added 14 commits April 21, 2026 04:23
Major version bumps:
- vite: 6.4.2 -> 8.0.9 (Rolldown/Oxc engine)
- tailwindcss: 3.4.19 -> 4.2.2 (CSS-first config)
- typescript: 5.7.3 -> 6.0.3 (new defaults, deprecations)
- eslint: 9.39.4 -> 10.2.1 (new config lookup, JSX tracking)
- @eslint/js: 9.39.4 -> 10.0.1
- @vitejs/plugin-react: 4.7.0 -> 6.0.1
- eslint-plugin-react-hooks: 5.2.0 -> 7.1.1 (React Compiler rules)
- eslint-plugin-react-refresh: 0.4.26 -> 0.5.2
- globals: 15.15.0 -> 17.5.0
- prettier-plugin-tailwindcss: 0.6.14 -> 0.7.2

Minor/patch bumps:
- @tanstack/react-query: 5.99.0 -> 5.99.2
- fast-check: 4.6.0 -> 4.7.0
- prettier: 3.8.2 -> 3.8.3
- typescript-eslint: 8.58.2 -> 8.59.0

Removed (no longer needed with Tailwind v4):
- autoprefixer
- postcss

Added:
- @tailwindcss/vite (Tailwind v4 Vite plugin)
- @types/node (for vite.config.ts under TS 6.0)
- Replace @tailwind directives with @import 'tailwindcss'
- Move custom theme colors to @theme inline block using CSS variables
- Delete tailwind.config.js (CSS-first config in v4)
- Delete postcss.config.js (Tailwind v4 Vite plugin handles everything)
- Add tailwindStylesheet option to .prettierrc for prettier-plugin-tailwindcss v0.7
- Replace 'path' import with 'node:path' protocol
- Replace __dirname with import.meta.dirname (ESM-native)
- Replace minify: 'esbuild' with minify: true (esbuild deprecated in Vite 8)
- Add @tailwindcss/vite plugin to Vite config
- Update target ES2020 -> ES2024, lib ES2020 -> ES2024
- Remove DOM.Iterable from lib (now included in DOM in TS 6.0)
- Remove deprecated baseUrl option (paths now works without it)
- Add tsconfig.node.json with composite: true for vite/vitest configs
- Add project reference from tsconfig.json to tsconfig.node.json
React Compiler rules introduced in eslint-plugin-react-hooks v7:

- App.tsx: replace setState-in-effect with derived state for 'ready'
- AccountContextMenu.tsx: replace Date.now() in render with useState
  initializer (react-hooks/purity)
- SessionTabs.tsx: convert drag ref reads during render to state
  variables (react-hooks/refs)
- NormalLoginForm.tsx: restructure region-change effect to avoid
  synchronous setState calls (react-hooks/set-state-in-effect)
- QrLoginForm.tsx: add eslint-disable for intentional setState in
  mount effect (react-hooks/set-state-in-effect)
- VerifyForm.tsx: move loadPage function declaration before useEffect
  that references it (react-hooks/immutability)
- use-auth.ts: attach original error as cause when re-throwing
  (preserve-caught-error)
Automatic class reordering by prettier-plugin-tailwindcss v0.7
with Tailwind v4 CSS-first config. No functional changes.
- Change 'tsc -b --noEmit' to 'tsc -b' (--noEmit conflicts with
  composite: true in tsconfig.node.json)
- Add tsconfig.node.json to paths-filter for frontend checks
Ignore tsbuildinfo, vite.config.js, vite.config.d.ts,
vitest.config.js, vitest.config.d.ts generated by tsc -b
with composite project references.
Major version bumps:
- reqwest: 0.12 -> 0.13 (rustls default, added native-tls + form features)
- rand: 0.8 -> 0.9 (thread_rng -> rng, gen -> random)
- sha2: 0.10 -> 0.11
- des: 0.8 -> 0.9 (cipher trait renames)
- cookie_store: 0.21 -> 0.22
- winreg: 0.55 -> 0.56
- windows-sys: 0.59 -> 0.61

Minor/patch bumps:
- tokio: 1.50.0 -> 1.52.1 (via lockfile)
- tracing-appender: 0.2.4 -> 0.2.5 (via lockfile)
- tauri-plugin-dialog: 2.6.0 -> 2.7.0 (via lockfile)
- tauri-plugin-fs: 2.4.5 -> 2.5.0 (via lockfile)
- open: 5.3.3 -> 5.3.4
- uuid: 1.23.0 -> 1.23.1 (via lockfile)
- Plus transitive deps: cc, fastrand, hyper-rustls, libc, libredox,
  muda, openssl, openssl-sys, pkg-config, rustls, rustls-webpki,
  semver, typenum, wasip2, web_atoms, writeable

Not upgraded (pinned to match Tauri 2.10.3):
- webview2-com: stays at 0.38 (Tauri uses 0.38 internally)
- windows-core: stays at 0.61 (Tauri uses 0.61 internally)
- dpapi.rs: thread_rng() -> rng(), gen::<u8>() -> random::<u8>()
- crypto.rs: BlockDecrypt -> BlockCipherDecrypt,
  BlockEncrypt -> BlockCipherEncrypt,
  generic_array::GenericArray -> Array via TryFrom
Updated via npm update:
- @humanfs/core: 0.19.1 -> 0.19.2
- @humanfs/node: 0.16.7 -> 0.16.8
- baseline-browser-mapping: 2.10.18 -> 2.10.20
- caniuse-lite: 1.0.30001787 -> 1.0.30001788
- electron-to-chromium: 1.5.335 -> 1.5.340
- std-env: 4.0.0 -> 4.1.0
rand 0.10:
- Rng trait renamed to RngExt (dpapi.rs updated)
- rng() and random() API unchanged

Cargo.toml direct dep bumps:
- rand: 0.9 -> 0.10
- tauri-plugin-dialog: 2.6.0 -> 2.7.0 (via lockfile)
- tauri-plugin-fs: 2.4.5 -> 2.5.0 (via lockfile)

Transitive deps updated via cargo update:
- tokio: 1.50.0 -> 1.52.1
- tracing-appender: 0.2.4 -> 0.2.5
- uuid: 1.23.0 -> 1.23.1
- cc: 1.2.58 -> 1.2.60
- fastrand: 2.3.0 -> 2.4.1
- libc: 0.2.184 -> 0.2.185
- libredox: 0.1.15 -> 0.1.16
- muda: 0.17.1 -> 0.17.2
- openssl: 0.10.76 -> 0.10.78
- openssl-sys: 0.9.112 -> 0.9.114
- pkg-config: 0.3.32 -> 0.3.33
- semver: 1.0.27 -> 1.0.28
- typenum: 1.19.0 -> 1.20.0
- wasip2: 1.0.2 -> 1.0.3
- web_atoms: 0.2.3 -> 0.2.4
- writeable: 0.6.2 -> 0.6.3

Not upgraded (pinned to Tauri 2.10.3):
- webview2-com: stays at 0.38 (Tauri internal dep)
- windows-core: stays at 0.61 (Tauri internal dep)
When switching region, the login form now correctly:
1. Clears the account/password fields immediately
2. Reloads the last saved account for the new region

Previously, after the eslint-plugin-react-hooks v7 migration,
the region-change branch skipped loading the new region's saved
account, leaving stale cross-region credentials in the form.
# Conflicts:
#	src/features/login/NormalLoginForm.tsx
@lshw54 lshw54 merged commit 8b84376 into main Apr 21, 2026
3 checks passed
@lshw54 lshw54 deleted the fix/region-switch-account-autofill branch April 21, 2026 03:35
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.

1 participant