+ {lockedWslDistro !== null ? (
+
+ {translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.wslStorageLocked',
+ 'This project is stored inside {{distro}} (\\\\wsl.localhost), so the runtime is locked to that distro. Move the project out of the distro to change it.',
+ { distro: lockedWslDistro }
+ )}
+
+ ) : null}
{runtimeSessionWarning ? (
{runtimeSessionWarning}
) : null}
@@ -219,143 +298,3 @@ export function ProjectWindowsRuntimeSetting({
)
}
-
-function hasActiveRuntimeSessions(summary?: ProjectRuntimeSessionSummary): boolean {
- return (summary?.liveTerminalCount ?? 0) > 0 || (summary?.activeTaskCount ?? 0) > 0
-}
-
-function sameRuntimePreference(
- left: LocalWindowsRuntimePreference,
- right: LocalWindowsRuntimePreference
-): boolean {
- if (left.kind !== right.kind) {
- return false
- }
- return left.kind !== 'wsl' || left.distro === (right.kind === 'wsl' ? right.distro : null)
-}
-
-function joinRuntimeSessionParts(parts: string[]): string {
- if (parts.length <= 1) {
- return parts[0] ?? ''
- }
- return translate(
- 'auto.components.settings.ProjectWindowsRuntimeSetting.runtimeSessionJoin',
- '{{value0}} and {{value1}}',
- { value0: parts.slice(0, -1).join(', '), value1: parts.at(-1) }
- )
-}
-
-function getLiveTerminalCountLabel(count: number): string {
- return translate(
- count === 1
- ? 'auto.components.settings.ProjectWindowsRuntimeSetting.liveTerminalSingular'
- : 'auto.components.settings.ProjectWindowsRuntimeSetting.liveTerminalPlural',
- count === 1 ? '{{count}} live terminal' : '{{count}} live terminals',
- { count }
- )
-}
-
-function getActiveTaskCountLabel(count: number): string {
- return translate(
- count === 1
- ? 'auto.components.settings.ProjectWindowsRuntimeSetting.activeTaskSingular'
- : 'auto.components.settings.ProjectWindowsRuntimeSetting.activeTaskPlural',
- count === 1 ? '{{count}} active task' : '{{count}} active tasks',
- { count }
- )
-}
-
-function getRuntimeSessionWarning(summary?: ProjectRuntimeSessionSummary): string | null {
- const liveTerminalCount = summary?.liveTerminalCount ?? 0
- const activeTaskCount = summary?.activeTaskCount ?? 0
- if (liveTerminalCount === 0 && activeTaskCount === 0) {
- return null
- }
-
- const parts = [
- liveTerminalCount > 0 ? getLiveTerminalCountLabel(liveTerminalCount) : '',
- activeTaskCount > 0 ? getActiveTaskCountLabel(activeTaskCount) : ''
- ].filter((part) => part.length > 0)
-
- return translate(
- 'auto.components.settings.ProjectWindowsRuntimeSetting.runtimeSessionWarning',
- '{{value0}} will keep running in the current runtime. Let tasks finish or restart terminals before continuing.',
- { value0: joinRuntimeSessionParts(parts) }
- )
-}
-
-function getNextProjectWslDistro(
- preference: LocalWindowsRuntimePreference,
- settings: Pick,
- wslDistros: readonly string[]
-): string | null {
- if (preference.kind === 'wsl') {
- return preference.distro
- }
- const globalDistro =
- settings.localWindowsRuntimeDefault.kind === 'wsl'
- ? settings.localWindowsRuntimeDefault.distro
- : null
- if (globalDistro?.trim()) {
- return globalDistro.trim()
- }
- return wslDistros.find((distro) => distro.trim().length > 0) ?? null
-}
-
-function getVisibleDistroOptions(
- preference: LocalWindowsRuntimePreference,
- wslDistros: readonly string[]
-): string[] {
- const options = [...wslDistros]
- if (preference.kind === 'wsl' && !options.includes(preference.distro)) {
- return [preference.distro, ...options]
- }
- return options
-}
-
-function getDefaultRuntimeLabel(
- settings: Pick
-): string {
- const runtimeLabel =
- settings.localWindowsRuntimeDefault.kind === 'wsl'
- ? translate('auto.components.settings.ProjectWindowsRuntimeSetting.wsl', 'WSL')
- : translate('auto.components.settings.ProjectWindowsRuntimeSetting.windows', 'Windows')
-
- return translate(
- 'auto.components.settings.ProjectWindowsRuntimeSetting.defaultRuntime',
- 'Default ({{value0}})',
- { value0: runtimeLabel }
- )
-}
-
-function getProjectRuntimeDescription(
- resolution: ReturnType
-): string {
- if (resolution.status === 'repair-required') {
- return projectRuntimeRepairSentence(resolution.repair, translate)
- }
-
- if (resolution.runtime.kind === 'wsl') {
- return resolution.runtime.reason === 'global-default'
- ? translate(
- 'auto.components.settings.ProjectWindowsRuntimeSetting.inheritedWsl',
- 'No project override. General settings select {{value0}} via WSL.',
- { value0: resolution.runtime.distro }
- )
- : translate(
- 'auto.components.settings.ProjectWindowsRuntimeSetting.projectWsl',
- 'This project runs in {{value0}} via WSL.',
- { value0: resolution.runtime.distro }
- )
- }
-
- return resolution.runtime.reason === 'global-default'
- ? translate(
- 'auto.components.settings.ProjectWindowsRuntimeSetting.inheritedWindows',
- 'No project override. General settings select Windows.'
- )
- : translate(
- 'auto.components.settings.ProjectWindowsRuntimeSetting.projectWindows',
- 'This project runs on Windows.'
- )
-}
diff --git a/src/renderer/src/components/settings/RepositoryPane.tsx b/src/renderer/src/components/settings/RepositoryPane.tsx
index ec635221380c..3390ed4eba0a 100644
--- a/src/renderer/src/components/settings/RepositoryPane.tsx
+++ b/src/renderer/src/components/settings/RepositoryPane.tsx
@@ -330,6 +330,7 @@ export function RepositoryPane({
project={project}
settings={settings}
isLocalWindowsProject={isLocalWindowsProject}
+ repoPath={repo.path}
wslAvailable={wslAvailable}
wslDistros={wslDistros}
wslCapabilitiesLoading={wslCapabilitiesLoading}
diff --git a/src/renderer/src/components/settings/project-runtime-setting-copy.ts b/src/renderer/src/components/settings/project-runtime-setting-copy.ts
new file mode 100644
index 000000000000..4a21a25dc76c
--- /dev/null
+++ b/src/renderer/src/components/settings/project-runtime-setting-copy.ts
@@ -0,0 +1,151 @@
+import type { GlobalSettings } from '../../../../shared/global-settings-types'
+import type {
+ LocalWindowsRuntimePreference,
+ ProjectExecutionRuntimeResolution
+} from '../../../../shared/project-execution-runtime'
+import type { ProjectRuntimeSessionSummary } from './repository/execution/repository-runtime-session-summary'
+import { projectRuntimeRepairSentence } from '../../../../shared/project-runtime-repair-message'
+import { translate } from '@/i18n/i18n'
+
+// Pure display/state helpers for ProjectWindowsRuntimeSetting — extracted so the
+// component body stays under the file line ratchet.
+
+export function hasActiveRuntimeSessions(summary?: ProjectRuntimeSessionSummary): boolean {
+ return (summary?.liveTerminalCount ?? 0) > 0 || (summary?.activeTaskCount ?? 0) > 0
+}
+
+export function sameRuntimePreference(
+ left: LocalWindowsRuntimePreference,
+ right: LocalWindowsRuntimePreference
+): boolean {
+ if (left.kind !== right.kind) {
+ return false
+ }
+ return left.kind !== 'wsl' || left.distro === (right.kind === 'wsl' ? right.distro : null)
+}
+
+export function joinRuntimeSessionParts(parts: string[]): string {
+ if (parts.length <= 1) {
+ return parts[0] ?? ''
+ }
+ return translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.runtimeSessionJoin',
+ '{{value0}} and {{value1}}',
+ { value0: parts.slice(0, -1).join(', '), value1: parts.at(-1) }
+ )
+}
+
+function getLiveTerminalCountLabel(count: number): string {
+ return translate(
+ count === 1
+ ? 'auto.components.settings.ProjectWindowsRuntimeSetting.liveTerminalSingular'
+ : 'auto.components.settings.ProjectWindowsRuntimeSetting.liveTerminalPlural',
+ count === 1 ? '{{count}} live terminal' : '{{count}} live terminals',
+ { count }
+ )
+}
+
+function getActiveTaskCountLabel(count: number): string {
+ return translate(
+ count === 1
+ ? 'auto.components.settings.ProjectWindowsRuntimeSetting.activeTaskSingular'
+ : 'auto.components.settings.ProjectWindowsRuntimeSetting.activeTaskPlural',
+ count === 1 ? '{{count}} active task' : '{{count}} active tasks',
+ { count }
+ )
+}
+
+export function getRuntimeSessionWarning(summary?: ProjectRuntimeSessionSummary): string | null {
+ const liveTerminalCount = summary?.liveTerminalCount ?? 0
+ const activeTaskCount = summary?.activeTaskCount ?? 0
+ if (liveTerminalCount === 0 && activeTaskCount === 0) {
+ return null
+ }
+
+ const parts = [
+ liveTerminalCount > 0 ? getLiveTerminalCountLabel(liveTerminalCount) : '',
+ activeTaskCount > 0 ? getActiveTaskCountLabel(activeTaskCount) : ''
+ ].filter((part) => part.length > 0)
+
+ return translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.runtimeSessionWarning',
+ '{{value0}} will keep running in the current runtime. Let tasks finish or restart terminals before continuing.',
+ { value0: joinRuntimeSessionParts(parts) }
+ )
+}
+
+export function getNextProjectWslDistro(
+ preference: LocalWindowsRuntimePreference,
+ settings: Pick,
+ wslDistros: readonly string[]
+): string | null {
+ if (preference.kind === 'wsl') {
+ return preference.distro
+ }
+ const globalDistro =
+ settings.localWindowsRuntimeDefault.kind === 'wsl'
+ ? settings.localWindowsRuntimeDefault.distro
+ : null
+ if (globalDistro?.trim()) {
+ return globalDistro.trim()
+ }
+ return wslDistros.find((distro) => distro.trim().length > 0) ?? null
+}
+
+export function getVisibleDistroOptions(
+ preference: LocalWindowsRuntimePreference,
+ wslDistros: readonly string[]
+): string[] {
+ const options = [...wslDistros]
+ if (preference.kind === 'wsl' && !options.includes(preference.distro)) {
+ return [preference.distro, ...options]
+ }
+ return options
+}
+
+export function getDefaultRuntimeLabel(
+ settings: Pick
+): string {
+ const runtimeLabel =
+ settings.localWindowsRuntimeDefault.kind === 'wsl'
+ ? translate('auto.components.settings.ProjectWindowsRuntimeSetting.wsl', 'WSL')
+ : translate('auto.components.settings.ProjectWindowsRuntimeSetting.windows', 'Windows')
+
+ return translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.defaultRuntime',
+ 'Default ({{value0}})',
+ { value0: runtimeLabel }
+ )
+}
+
+export function getProjectRuntimeDescription(
+ resolution: ProjectExecutionRuntimeResolution
+): string {
+ if (resolution.status === 'repair-required') {
+ return projectRuntimeRepairSentence(resolution.repair, translate)
+ }
+
+ if (resolution.runtime.kind === 'wsl') {
+ return resolution.runtime.reason === 'global-default'
+ ? translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.inheritedWsl',
+ 'No project override. General settings select {{value0}} via WSL.',
+ { value0: resolution.runtime.distro }
+ )
+ : translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.projectWsl',
+ 'This project runs in {{value0}} via WSL.',
+ { value0: resolution.runtime.distro }
+ )
+ }
+
+ return resolution.runtime.reason === 'global-default'
+ ? translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.inheritedWindows',
+ 'No project override. General settings select Windows.'
+ )
+ : translate(
+ 'auto.components.settings.ProjectWindowsRuntimeSetting.projectWindows',
+ 'This project runs on Windows.'
+ )
+}
diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryWindowsRuntimeSection.tsx b/src/renderer/src/components/settings/repository/execution/RepositoryWindowsRuntimeSection.tsx
index f6f7b520980e..22f490278ce4 100644
--- a/src/renderer/src/components/settings/repository/execution/RepositoryWindowsRuntimeSection.tsx
+++ b/src/renderer/src/components/settings/repository/execution/RepositoryWindowsRuntimeSection.tsx
@@ -12,6 +12,8 @@ type RepositoryWindowsRuntimeSectionProps = {
project: Project | null
settings: Pick | null
isLocalWindowsProject: boolean
+ /** Where this project's files live; a WSL UNC pins the runtime to that distro. */
+ repoPath?: string | null
wslAvailable: boolean
wslDistros: string[]
wslCapabilitiesLoading: boolean
@@ -30,6 +32,7 @@ export function RepositoryWindowsRuntimeSection({
project,
settings,
isLocalWindowsProject,
+ repoPath,
wslAvailable,
wslDistros,
wslCapabilitiesLoading,
@@ -67,6 +70,7 @@ export function RepositoryWindowsRuntimeSection({
project={project}
settings={settings}
isLocalWindowsProject={isLocalWindowsProject}
+ repoPath={repoPath}
wslAvailable={wslAvailable}
wslDistros={wslDistros}
wslCapabilitiesLoading={wslCapabilitiesLoading}
diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json
index bb835618fae9..703b49485077 100644
--- a/src/renderer/src/i18n/locales/en.json
+++ b/src/renderer/src/i18n/locales/en.json
@@ -11818,7 +11818,8 @@
"runtimeSessionWarning": "{{value0}} will keep running in the current runtime. Let tasks finish or restart terminals before continuing.",
"pendingRuntimeChange": "Runtime change pending. New project work will use the selected runtime after you apply.",
"cancel": "Cancel",
- "applyRuntimeChange": "Apply runtime change"
+ "applyRuntimeChange": "Apply runtime change",
+ "wslStorageLocked": "This project is stored inside {{distro}} (\\\\wsl.localhost), so the runtime is locked to that distro. Move the project out of the distro to change it."
},
"PrivacyDiagnosticsRows": {
"5a7cbe069a": "DO_NOT_TRACK=1 is set — creating and sending diagnostic files is disabled.",
diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json
index 9f887e277b6b..e9a1d1a38a4f 100644
--- a/src/renderer/src/i18n/locales/zh.json
+++ b/src/renderer/src/i18n/locales/zh.json
@@ -11525,7 +11525,8 @@
"runtimeSessionWarning": "{{value0}}会继续在当前运行时中运行。继续前请等待任务完成或重启终端。",
"pendingRuntimeChange": "运行时更改待处理。应用后,新项目工作将使用所选运行时。",
"cancel": "取消",
- "applyRuntimeChange": "应用运行时更改"
+ "applyRuntimeChange": "应用运行时更改",
+ "wslStorageLocked": "项目存储在 {{distro}}(\\\\wsl.localhost)内,运行时与其保持一致。将项目移出该 distro 后可更改。"
},
"PrivacyDiagnosticsRows": {
"5a7cbe069a": "已设置 DO_NOT_TRACK=1,创建和发送诊断文件已停用。",