From 33bfe3451be71d5de82c66cf01c90f365b08be1d Mon Sep 17 00:00:00 2001 From: elashera <135239963+elasheraNTT@users.noreply.github.com> Date: Wed, 11 Feb 2026 10:28:43 +0100 Subject: [PATCH] fix:windows threads --- src-tauri/src/terminal.rs | 22 +++++++++++++++++-- .../threads/hooks/useThreadActions.ts | 10 ++++----- src/features/threads/utils/threadNormalize.ts | 8 +++++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/terminal.rs b/src-tauri/src/terminal.rs index 162c8bb76..6b58fe046 100644 --- a/src-tauri/src/terminal.rs +++ b/src-tauri/src/terminal.rs @@ -50,7 +50,26 @@ async fn get_terminal_session( } fn shell_path() -> String { - std::env::var("SHELL").unwrap_or_else(|_| "/bin/zsh".to_string()) + if let Ok(shell) = std::env::var("SHELL") { + if !shell.trim().is_empty() { + return shell; + } + } + + #[cfg(target_os = "windows")] + { + if let Ok(comspec) = std::env::var("COMSPEC") { + if !comspec.trim().is_empty() { + return comspec; + } + } + return "powershell.exe".to_string(); + } + + #[cfg(not(target_os = "windows"))] + { + "/bin/zsh".to_string() + } } fn resolve_locale() -> String { @@ -179,7 +198,6 @@ pub(crate) async fn terminal_open( let mut cmd = CommandBuilder::new(shell_path()); cmd.cwd(cwd); - cmd.arg("-i"); cmd.env("TERM", "xterm-256color"); let locale = resolve_locale(); cmd.env("LANG", &locale); diff --git a/src/features/threads/hooks/useThreadActions.ts b/src/features/threads/hooks/useThreadActions.ts index 21c003f74..39fd90739 100644 --- a/src/features/threads/hooks/useThreadActions.ts +++ b/src/features/threads/hooks/useThreadActions.ts @@ -24,7 +24,7 @@ import { } from "../../../utils/threadItems"; import { asString, - normalizeRootPath, + normalizeRootPathForCompare, } from "../utils/threadNormalize"; import { saveThreadActivity } from "../utils/threadStorage"; import type { ThreadAction, ThreadState } from "./useThreadsReducer"; @@ -438,7 +438,7 @@ export function useThreadActions({ ) => { const preserveState = options?.preserveState ?? false; const requestedSortKey = options?.sortKey ?? threadSortKey; - const workspacePath = normalizeRootPath(workspace.path); + const workspacePath = normalizeRootPathForCompare(workspace.path); if (!preserveState) { dispatch({ type: "setThreadListLoading", @@ -492,7 +492,7 @@ export function useThreadActions({ matchingThreads.push( ...data.filter( (thread) => - normalizeRootPath(String(thread?.cwd ?? "")) === workspacePath, + normalizeRootPathForCompare(String(thread?.cwd ?? "")) === workspacePath, ), ); cursor = nextCursor; @@ -639,7 +639,7 @@ export function useThreadActions({ if (!nextCursor) { return; } - const workspacePath = normalizeRootPath(workspace.path); + const workspacePath = normalizeRootPathForCompare(workspace.path); const existing = threadsByWorkspace[workspace.id] ?? []; dispatch({ type: "setThreadListPaging", @@ -683,7 +683,7 @@ export function useThreadActions({ matchingThreads.push( ...data.filter( (thread) => - normalizeRootPath(String(thread?.cwd ?? "")) === workspacePath, + normalizeRootPathForCompare(String(thread?.cwd ?? "")) === workspacePath, ), ); cursor = next; diff --git a/src/features/threads/utils/threadNormalize.ts b/src/features/threads/utils/threadNormalize.ts index 4a62be296..5645eb421 100644 --- a/src/features/threads/utils/threadNormalize.ts +++ b/src/features/threads/utils/threadNormalize.ts @@ -36,6 +36,14 @@ export function normalizeRootPath(value: string) { return value.replace(/\\/g, "/").replace(/\/+$/, ""); } +export function normalizeRootPathForCompare(value: string) { + const normalized = normalizeRootPath(value); + if (/^(?:[a-zA-Z]:\/|\\\\|\/\/\?\/)/.test(normalized)) { + return normalized.toLowerCase(); + } + return normalized; +} + export function extractRpcErrorMessage(response: unknown) { if (!response || typeof response !== "object") { return null;