feat: more granular local environment checks (#870)

* feat: more granular local environment checks

* refactor: improve PR #870 with i18n, shadcn Select, and testable helpers

- Extract is_valid_shell, is_valid_shell_flag, default_flag_for_shell
  to module-level #[cfg(windows)] functions for testability
- Add unit tests for extracted helper functions
- Replace native <select> with shadcn/ui Select components
- Extract env badge ternary to ENV_BADGE_CONFIG Record lookup
- Add i18n keys for env badges and WSL selectors (zh/en/ja)
- Unify initial useEffect load path with loadAllToolVersions()

* fix: prevent useEffect re-firing on wslShellByTool changes

The useEffect that loads initial tool versions depended on
loadAllToolVersions, which in turn depended on wslShellByTool.
This caused a full re-fetch of all 4 tools every time the user
changed a WSL shell or flag, racing with the single-tool refresh.

Fix: use empty deps [] since this is a mount-only effect. The
refresh button and shell/flag handlers cover subsequent updates.

---------

Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
Kelvin Chiu
2026-02-23 11:26:23 +08:00
committed by GitHub
parent 4c88174cb0
commit d11df17b5d
6 changed files with 471 additions and 58 deletions
+10 -2
View File
@@ -169,15 +169,23 @@ export const settingsApi = {
return await invoke("get_auto_launch_status");
},
async getToolVersions(): Promise<
async getToolVersions(
tools?: string[],
wslShellByTool?: Record<
string,
{ wslShell?: string | null; wslShellFlag?: string | null }
>,
): Promise<
Array<{
name: string;
version: string | null;
latest_version: string | null;
error: string | null;
env_type: "windows" | "wsl" | "macos" | "linux" | "unknown";
wsl_distro: string | null;
}>
> {
return await invoke("get_tool_versions");
return await invoke("get_tool_versions", { tools, wslShellByTool });
},
async getRectifierConfig(): Promise<RectifierConfig> {