diff --git a/src/main/ipc/wsl-host-handlers.ts b/src/main/ipc/wsl-host-handlers.ts index 7ea178234805..861fbfa55b7b 100644 --- a/src/main/ipc/wsl-host-handlers.ts +++ b/src/main/ipc/wsl-host-handlers.ts @@ -19,11 +19,8 @@ import { WslHostService } from '../wsl/wsl-host-service' import { WslHostVisibleWorkByWindow } from './wsl-host-visible-work-windows' import type { WslHostAutomationWake } from '../wsl/wsl-host-automation-wake' import { createWslHostAutomationWake } from './wsl-host-automation-wake-wiring' -import { - WSL_HOSTS_NEW_WORK_PAUSED_MESSAGE, - wslHostsGateOpen, - wslHostsServing -} from '../wsl/wsl-host-gate' +import { wslHostsGateOpen, wslHostsServing } from '../wsl/wsl-host-gate' +import { wslHostAddRefusal } from '../wsl/wsl-host-add-admission' import { getWslHostService, setWslHostPhoneGate, @@ -256,7 +253,7 @@ export function registerWslHostHandlers(args: WslHostHandlerArgs): void { ): Promise => { // Serve-only keeps saved hosts working but admits none. if (!wslHostsGateOpen()) { - return { ok: false, kind: 'disabled', message: WSL_HOSTS_NEW_WORK_PAUSED_MESSAGE } + return wslHostAddRefusal('disabled', 'newWorkPaused') } const result = await wsl.add(request) if (result.ok) { diff --git a/src/main/wsl/wsl-distro-unsupported.ts b/src/main/wsl/wsl-distro-unsupported.ts index b11d819d1692..f936b05235a4 100644 --- a/src/main/wsl/wsl-distro-unsupported.ts +++ b/src/main/wsl/wsl-distro-unsupported.ts @@ -5,32 +5,18 @@ import { OrcadHostUnsupportedError } from '../orcad/orcad-host-unavailable' import { OrcadHostGlibcUnsupportedError } from '../managed-server/lifecycle/orcad-runtime-target' import { RemoteNodeRuntimeSelfTestError } from '../ssh/orcad-remote-node-runtime-report' - -export function wsl1DistroMessage(distro: string): string { - return ( - `${distro} runs WSL 1, which Orca no longer supports. ` + - `Convert it to WSL 2 in a Windows terminal with: wsl --set-version ${distro} 2` - ) -} - -export function wslDistroNotRegisteredMessage(distro: string): string { - return ( - `${distro} is not an installed WSL distro. ` + - 'Run wsl --list --verbose in a Windows terminal to see the installed ones, ' + - 'or reinstall it and try again.' - ) -} +import { wslHostAddRefusalText } from '../../shared/wsl-host-failure-copy' /** Keeps OrcadHostUnsupportedError's name, so callers that classify by name still see it. */ export class WslDistroVersion1Error extends OrcadHostUnsupportedError { - constructor(distro: string) { - super(wsl1DistroMessage(distro)) + constructor(readonly distro: string) { + super(wslHostAddRefusalText('wsl1', { distro }).text) } } export class WslDistroNotRegisteredError extends OrcadHostUnsupportedError { - constructor(distro: string) { - super(wslDistroNotRegisteredMessage(distro)) + constructor(readonly distro: string) { + super(wslHostAddRefusalText('notRegistered', { distro }).text) } } diff --git a/src/main/wsl/wsl-host-add-admission.ts b/src/main/wsl/wsl-host-add-admission.ts index 227f71717bfd..01b5bba14986 100644 --- a/src/main/wsl/wsl-host-add-admission.ts +++ b/src/main/wsl/wsl-host-add-admission.ts @@ -1,15 +1,29 @@ /** Why a distro cannot be added as a WSL host, decided before anything runs in it. */ -import type { WslHostAddResult } from '../../shared/wsl-host-types' +import type { WslHostAddFailureKind, WslHostAddResult } from '../../shared/wsl-host-types' +import { + WSL_HOST_ADD_REFUSAL_COPY, + wslHostAddRefusalText, + type WslHostAddRefusalCode, + type WslHostCopyParams +} from '../../shared/wsl-host-failure-copy' import type { WslHostDistroCandidate } from './wsl-host-distro-list' import { wslDistroHolderKey } from './wsl-distro-holder-record' -import { wsl1DistroMessage, wslDistroNotRegisteredMessage } from './wsl-distro-unsupported' -export const WSL_HOSTS_DISABLED_MESSAGE = 'WSL hosts are turned off in Settings → Experimental.' -export const WSL_HOST_SERVER_FILES_MISSING_MESSAGE = - 'This build of Orca can’t run WSL hosts (server files missing).' +export const WSL_HOSTS_DISABLED_MESSAGE = WSL_HOST_ADD_REFUSAL_COPY.turnedOff +export const WSL_HOST_SERVER_FILES_MISSING_MESSAGE = WSL_HOST_ADD_REFUSAL_COPY.serverFilesMissing type WslHostAddRefusal = Extract +/** A refusal whose English `message` and translation code come from one table. */ +export function wslHostAddRefusal( + kind: WslHostAddFailureKind, + code: WslHostAddRefusalCode, + params?: WslHostCopyParams +): WslHostAddRefusal { + const { text, code: errorCode, params: errorParams } = wslHostAddRefusalText(code, params) + return { ok: false, kind, message: text, errorCode, ...(errorParams ? { errorParams } : {}) } +} + export const WSL_HOST_REMOVING_MESSAGE = 'This WSL host is being removed.' export function wslHostNotConnectedMessage(distro: string): string { @@ -45,12 +59,12 @@ export function wslHostRunRefusal(gate: { hasServerFiles: () => boolean }): WslHostAddRefusal | null { if (!gate.isEnabled()) { - return { ok: false, kind: 'disabled', message: WSL_HOSTS_DISABLED_MESSAGE } + return wslHostAddRefusal('disabled', 'turnedOff') } // Reject missing packaged templates before C4 deploy emits an opaque deep failure. return gate.hasServerFiles() ? null - : { ok: false, kind: 'server-files-missing', message: WSL_HOST_SERVER_FILES_MISSING_MESSAGE } + : wslHostAddRefusal('server-files-missing', 'serverFilesMissing') } export function sameWslDistro(left: string, right: string): boolean { @@ -66,28 +80,16 @@ export function admitWslHostDistro(args: { }): { distro: WslHostDistroCandidate } | WslHostAddRefusal { const distro = args.candidates.find((candidate) => sameWslDistro(candidate.name, args.requested)) if (!distro) { - return { - ok: false, - kind: 'failed', - message: wslDistroNotRegisteredMessage(args.requested) - } + return wslHostAddRefusal('failed', 'notRegistered', { distro: args.requested }) } if (distro.version === 1) { - return { - ok: false, - kind: 'unsupported-wsl1', - message: wsl1DistroMessage(distro.name) - } + return wslHostAddRefusal('unsupported-wsl1', 'wsl1', { distro: distro.name }) } if (args.alreadyAdded(distro.name)) { - return { ok: false, kind: 'already-added', message: `${distro.name} is already a host.` } + return wslHostAddRefusal('already-added', 'alreadyAdded', { distro: distro.name }) } if (distro.state === 'stopped' && !args.startIfStopped) { - return { - ok: false, - kind: 'distro-stopped', - message: `${distro.name} stopped since the list was read. Choose Start and add to start it.` - } + return wslHostAddRefusal('distro-stopped', 'distroStopped', { distro: distro.name }) } return { distro } } diff --git a/src/main/wsl/wsl-host-connection-record.test.ts b/src/main/wsl/wsl-host-connection-record.test.ts index aa8faf0846f6..7fcc87fb38f6 100644 --- a/src/main/wsl/wsl-host-connection-record.test.ts +++ b/src/main/wsl/wsl-host-connection-record.test.ts @@ -33,4 +33,35 @@ describe('toWslHostStatus', () => { ).toBeNull() expect(toWslHostStatus(record, { state: 'connecting' }).deferredUpdate).toBeNull() }) + + it('codes an unverifiable reason as a sentence, and keeps verbatim connect errors uncoded', () => { + expect( + toWslHostStatus(record, { + state: 'unverifiable', + reason: 'guest-unanswered', + terminals: 'unverifiable' + }) + ).toMatchObject({ + detail: 'The distro is running but didn’t answer Orca’s check.', + detailCode: 'guestUnanswered' + }) + const failed = toWslHostStatus(record, { + state: 'failed', + reason: 'bridge refused', + terminals: 'unverifiable' + }) + expect(failed.detail).toBe('bridge refused') + expect(failed).not.toHaveProperty('detailCode') + const pendingStop = { + since: 1, + reason: 'The WSL service did not confirm whether the distro runs.', + reasonCode: 'serviceUnconfirmed', + verdict: 'unverifiable' as const + } + expect(toWslHostStatus({ ...record, pendingStop }, { state: 'closed' })).toMatchObject({ + detail: pendingStop.reason, + detailCode: 'serviceUnconfirmed', + removalPending: true + }) + }) }) diff --git a/src/main/wsl/wsl-host-connection-record.ts b/src/main/wsl/wsl-host-connection-record.ts index 37703535faf7..977c6845f073 100644 --- a/src/main/wsl/wsl-host-connection-record.ts +++ b/src/main/wsl/wsl-host-connection-record.ts @@ -3,9 +3,15 @@ import { readWslHostDeployments, type WslHostDeploymentRecord } from '../../shared/wsl-host-deployment-store' +import { + wslHostStatusDetailText, + type WslHostCopyParams, + type WslHostStatusDetailCode +} from '../../shared/wsl-host-failure-copy' import type { WslHostStatus } from '../../shared/wsl-host-types' import type { WslOrcadConnection } from './wsl-orcad-connection' import type { WslOrcadConnectionStatus } from './wsl-orcad-connection-status' +import type { WslLivenessUnverifiableReason } from './wsl-orcad-liveness-verdict' /** Saves an explicit re-pair or a moved bridge; true when the pairing changed. */ export function persistWslHostConnection( @@ -46,10 +52,7 @@ export function toWslHostStatus( environmentId: record.environmentId, distro: record.distro, state: status.state, - detail: - status.state === 'failed' || status.state === 'unverifiable' - ? status.reason - : (record.pendingStop?.reason ?? null), + ...wslHostStatusDetail(record, status), // Ready serves the incumbent; deferred serves nothing, so retain its Update/Force explanation. deferredUpdate: status.state === 'ready' @@ -61,6 +64,41 @@ export function toWslHostStatus( } } +const UNVERIFIABLE_DETAIL_CODES: Record = { + 'running-list-unavailable': 'runningListUnavailable', + 'guest-unanswered': 'guestUnanswered', + 'orcad-unanswered': 'orcadUnanswered' +} + +type WslHostStatusDetail = Pick + +function codedDetail( + detail: string, + code: string | undefined, + params: WslHostCopyParams | undefined +): WslHostStatusDetail { + return { + detail, + ...(code ? { detailCode: code } : {}), + ...(code && params ? { detailParams: params } : {}) + } +} + +function wslHostStatusDetail( + record: WslHostDeploymentRecord, + status: WslOrcadConnectionStatus +): WslHostStatusDetail { + if (status.state === 'unverifiable') { + const { text, code } = wslHostStatusDetailText(UNVERIFIABLE_DETAIL_CODES[status.reason]) + return { detail: text, detailCode: code } + } + if (status.state === 'failed') { + return codedDetail(status.reason, status.reasonCode, status.reasonParams) + } + const stop = record.pendingStop + return stop ? codedDetail(stop.reason, stop.reasonCode, stop.reasonParams) : { detail: null } +} + /** The registered WSL hosts; an unreadable store reads as none rather than failing the caller. */ export function readWslHostRecordsQuietly(userDataPath: string): WslHostDeploymentRecord[] { try { diff --git a/src/main/wsl/wsl-host-connector.ts b/src/main/wsl/wsl-host-connector.ts index 4f29c70d440f..2da70532a450 100644 --- a/src/main/wsl/wsl-host-connector.ts +++ b/src/main/wsl/wsl-host-connector.ts @@ -30,6 +30,7 @@ import { createWslOrcadLivenessSupervisor } from './wsl-orcad-liveness-wiring' import type { WslOrcadLivenessSupervisor } from './wsl-orcad-liveness-supervisor' import { confirmsRunning } from './wsl-orcad-liveness-evidence' import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { wslHostServerStopReason } from '../../shared/wsl-host-failure-copy' function targetFor(distro: string): WslOrcadHostTarget { return { kind: 'wsl', id: defaultWslOrcadEnvironmentId(distro), distro, label: distro } @@ -206,7 +207,7 @@ export function createWslHostConnector(options: { if (reachability === 'unavailable') { return { stopped: false, - reason: 'The WSL service did not confirm whether the distro runs.', + ...wslHostServerStopReason('serviceUnconfirmed'), verdict: 'unverifiable' } } diff --git a/src/main/wsl/wsl-host-first-connect.test.ts b/src/main/wsl/wsl-host-first-connect.test.ts new file mode 100644 index 000000000000..1228f0ddb717 --- /dev/null +++ b/src/main/wsl/wsl-host-first-connect.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it, vi } from 'vitest' +import { WslDistroVersion1Error } from './wsl-distro-unsupported' +import { connectForWslHostAdd } from './wsl-host-first-connect' + +describe('connectForWslHostAdd', () => { + it('refuses a WSL 1 distro with the English message and its translation code', async () => { + const connector = { + connect: vi.fn().mockRejectedValue(new WslDistroVersion1Error('Ubuntu')), + disconnect: vi.fn().mockResolvedValue(undefined), + releaseHolder: vi.fn().mockResolvedValue(undefined) + } + await expect(connectForWslHostAdd(connector, 'Ubuntu', () => null)).resolves.toEqual({ + ok: false, + kind: 'unsupported-wsl1', + message: + 'Ubuntu runs WSL 1, which Orca no longer supports. Convert it to WSL 2 in a Windows terminal with: wsl --set-version Ubuntu 2', + errorCode: 'wsl1', + errorParams: { distro: 'Ubuntu' } + }) + expect(connector.releaseHolder).toHaveBeenCalledWith('Ubuntu') + }) +}) diff --git a/src/main/wsl/wsl-host-first-connect.ts b/src/main/wsl/wsl-host-first-connect.ts index b3b2afe6d3ca..0f8c7b5b70a9 100644 --- a/src/main/wsl/wsl-host-first-connect.ts +++ b/src/main/wsl/wsl-host-first-connect.ts @@ -4,7 +4,12 @@ import type { WslHostAddResult } from '../../shared/wsl-host-types' import { OrcadHostUnsupportedError } from '../orcad/orcad-host-unavailable' import type { WslHostConnector } from './wsl-host-service' import { WslOrcadLaunchDeferredError } from './wsl-orcad-connection-errors' -import { WslDistroVersion1Error, wslUnsupportedDistroFixMessage } from './wsl-distro-unsupported' +import { + WslDistroNotRegisteredError, + WslDistroVersion1Error, + wslUnsupportedDistroFixMessage +} from './wsl-distro-unsupported' +import { wslHostAddRefusal } from './wsl-host-add-admission' import { RemoteNodeRuntimeSelfTestError } from '../ssh/orcad-remote-node-runtime-report' import type { WslOrcadConnection } from './wsl-orcad-connection' @@ -30,6 +35,12 @@ export async function connectForWslHostAdd( if (error instanceof WslOrcadLaunchDeferredError) { return { ok: false, kind: 'deferred', message: error.launch.reason } } + if (error instanceof WslDistroVersion1Error) { + return wslHostAddRefusal('unsupported-wsl1', 'wsl1', { distro: error.distro }) + } + if (error instanceof WslDistroNotRegisteredError) { + return wslHostAddRefusal('unsupported-distro', 'notRegistered', { distro: error.distro }) + } return { ok: false, kind: connectFailureKind(error), @@ -46,9 +57,6 @@ export async function connectForWslHostAdd( /** A distro Orca can't run in reads apart from a connect that may work on retry. */ function connectFailureKind(error: unknown): WslHostAddRefusal['kind'] { - if (error instanceof WslDistroVersion1Error) { - return 'unsupported-wsl1' - } return error instanceof OrcadHostUnsupportedError || error instanceof RemoteNodeRuntimeSelfTestError ? 'unsupported-distro' diff --git a/src/main/wsl/wsl-host-gate.ts b/src/main/wsl/wsl-host-gate.ts index 33b8f61a33f4..2b02c95ca127 100644 --- a/src/main/wsl/wsl-host-gate.ts +++ b/src/main/wsl/wsl-host-gate.ts @@ -12,8 +12,6 @@ import type { OrcadDeploymentLink } from '../../shared/runtime-environments' import type { WslHostsPolicyState } from '../../shared/wsl-hosts-policy' export const WSL_HOSTS_GATED_OFF_MESSAGE = 'WSL hosts are not available in this build.' -export const WSL_HOSTS_NEW_WORK_PAUSED_MESSAGE = - 'Adding WSL hosts and moving projects onto them is paused in this build. Your saved WSL hosts keep working.' // Fixed for the run once main reads the disk; nothing can create a host or a move while not open. let promoted: { hasSavedWslHost: boolean; hasWslMoveCutover: boolean } | null = null diff --git a/src/main/wsl/wsl-host-registration.ts b/src/main/wsl/wsl-host-registration.ts index 10eeb4d157e6..d95be3b5c997 100644 --- a/src/main/wsl/wsl-host-registration.ts +++ b/src/main/wsl/wsl-host-registration.ts @@ -3,11 +3,7 @@ import { errorMessage } from '../../shared/error-message' import { addWslHostEnvironment } from '../../shared/runtime-environment-wsl-host-store' import type { WslHostDeploymentRecord } from '../../shared/wsl-host-deployment-store' import { wslHostEnvironmentLabel, type WslHostAddResult } from '../../shared/wsl-host-types' -import { - admitWslHostDistro, - WSL_HOSTS_DISABLED_MESSAGE, - wslHostRunRefusal -} from './wsl-host-add-admission' +import { admitWslHostDistro, wslHostAddRefusal, wslHostRunRefusal } from './wsl-host-add-admission' import { abandonWslHostAdd, connectForWslHostAdd } from './wsl-host-first-connect' import type { WslHostConnector, WslHostServiceDependencies } from './wsl-host-service' import { wslHostSshManagedRefusal } from './wsl-host-ssh-orcad-conflict' @@ -56,7 +52,7 @@ export async function registerWslHost( const connected = await connectForWslHostAdd(context.wsl(), distro.name, () => generation === context.disableGeneration() ? wslHostRunRefusal(context.deps) - : { ok: false, kind: 'disabled', message: WSL_HOSTS_DISABLED_MESSAGE } + : wslHostAddRefusal('disabled', 'turnedOff') ) if (!('connection' in connected)) { return connected diff --git a/src/main/wsl/wsl-host-removal.ts b/src/main/wsl/wsl-host-removal.ts index 1b44b291d361..3c2efa9e3c64 100644 --- a/src/main/wsl/wsl-host-removal.ts +++ b/src/main/wsl/wsl-host-removal.ts @@ -4,6 +4,7 @@ * Dropping it would strand a still-running server that blocks the next add's activation. */ import { errorMessage } from '../../shared/error-message' +import { wslHostServerStopReason } from '../../shared/wsl-host-failure-copy' import { removeWslHostEnvironment, setWslHostPendingStop @@ -52,9 +53,12 @@ export async function removeWslHostServer( noteWslHostUserAction({ kind: 'removed', distro: record.distro }) return { serverStop, removed: true } } + const { reason, reasonCode, reasonParams } = serverStop setWslHostPendingStop(userDataPath, record.environmentId, { since: Date.now(), - reason: serverStop.reason, + reason, + ...(reasonCode ? { reasonCode } : {}), + ...(reasonCode && reasonParams ? { reasonParams } : {}), verdict: serverStop.verdict ?? 'unverifiable' }) return { serverStop: { ...serverStop, kept: true }, removed: false } @@ -81,7 +85,7 @@ function noteServerKeptForPeers( return { stopped: false, verdict: serverStop.keptForOtherDesktops ? 'live' : 'unverifiable', - reason: `Orca couldn’t record what this Remove left running: ${errorMessage(error)}` + ...wslHostServerStopReason('removalUnrecorded', { detail: errorMessage(error) }) } } } diff --git a/src/main/wsl/wsl-host-server-stop.ts b/src/main/wsl/wsl-host-server-stop.ts index e5c013e75bb4..ded2711f6e8d 100644 --- a/src/main/wsl/wsl-host-server-stop.ts +++ b/src/main/wsl/wsl-host-server-stop.ts @@ -5,6 +5,7 @@ import type { OrcadDecommissionResult } from '../../shared/orcad-decommission' import { ORCAD_MANAGED_REMOTE_PORT } from '../../shared/orcad-managed-runtime' import type { OrcadTerminalCensus } from '../../shared/orcad-terminal-census' import type { RuntimeTerminalListResult } from '../../shared/runtime-terminal-contracts' +import { wslHostServerStopReason } from '../../shared/wsl-host-failure-copy' import type { WslHostServerStop } from '../../shared/wsl-host-types' import type { OrcadHostTransport } from '../ssh/orcad-host-transport' import { readRemoteOrcadManagedStopTarget } from '../managed-server/lifecycle/orcad-managed-remote-stop' @@ -57,7 +58,7 @@ export async function stopWslHostServer(steps: WslHostServerStopSteps): Promise< return { stopped: false, verdict: 'unverifiable', - reason: `Orca couldn’t ask the WSL host whether another Orca on this computer still uses it: ${errorMessage(error)}` + ...wslHostServerStopReason('peerCheckFailed', { detail: errorMessage(error) }) } } if (peers.kind === 'shared') { diff --git a/src/main/wsl/wsl-host-service.test.ts b/src/main/wsl/wsl-host-service.test.ts index be8a33e587dc..4afa75676c24 100644 --- a/src/main/wsl/wsl-host-service.test.ts +++ b/src/main/wsl/wsl-host-service.test.ts @@ -14,7 +14,6 @@ import { getPreferredPairingOffer } from '../../shared/runtime-environments' import type { WslHostStatus } from '../../shared/wsl-host-types' import { OrcadHostUnsupportedError } from '../orcad/orcad-host-unavailable' import { RemoteNodeRuntimeSelfTestError } from '../ssh/orcad-remote-node-runtime-report' -import { wsl1DistroMessage, WslDistroVersion1Error } from './wsl-distro-unsupported' import { WslHostService, type WslHostConnector } from './wsl-host-service' import { wakeRememberedWslHosts } from './wsl-host-early-wake' import { WslOrcadLaunchDeferredError } from './wsl-orcad-connection-errors' @@ -314,7 +313,8 @@ describe('WslHostService', () => { await expect(service.add({ distro: 'Debian' })).resolves.toEqual({ ok: false, kind: 'server-files-missing', - message: 'This build of Orca can’t run WSL hosts (server files missing).' + message: 'This build of Orca can’t run WSL hosts (server files missing).', + errorCode: 'serverFilesMissing' }) expect(connector.listDistros).not.toHaveBeenCalled() await expect(service.connect('wsl:ubuntu')).rejects.toThrow('server files missing') @@ -775,7 +775,6 @@ describe('WslHostService', () => { }) it.each([ - ['unsupported-wsl1', () => new WslDistroVersion1Error('Ubuntu'), wsl1DistroMessage('Ubuntu')], [ 'unsupported-distro', () => new OrcadHostUnsupportedError('No Orca runtime supports linux-arm64-glibc.'), diff --git a/src/main/wsl/wsl-host-ssh-orcad-conflict.ts b/src/main/wsl/wsl-host-ssh-orcad-conflict.ts index abe27a2ce1a7..3e25dfd9e11e 100644 --- a/src/main/wsl/wsl-host-ssh-orcad-conflict.ts +++ b/src/main/wsl/wsl-host-ssh-orcad-conflict.ts @@ -9,6 +9,7 @@ import { } from '../../shared/runtime-environments' import type { OrcadHostTransport } from '../ssh/orcad-host-transport' import { execCommand } from '../ssh/remote-exec/remote-exec-command' +import { wslHostAddRefusal } from './wsl-host-add-admission' // Prints only the public half; the private key never leaves the distro. const READ_PUBLIC_KEY = `sed -n 's/.*"publicKeyB64"[[:space:]]*:[[:space:]]*"\\([A-Za-z0-9+/=]*\\)".*/\\1/p' "$HOME/.orca/${E2EE_KEYPAIR_FILENAME}" 2>/dev/null | head -n 1` @@ -51,11 +52,7 @@ export async function wslHostSshManagedRefusal( await readPublicKey(distro) ) return sharing - ? { - ok: false, - kind: 'ssh-managed', - message: `${distro} already runs the Orca server for “${sharing.name}”, which this computer reaches over SSH. Remove that server first; moving it to a WSL host isn’t supported yet.` - } + ? wslHostAddRefusal('ssh-managed', 'sshManaged', { distro, server: sharing.name }) : null } catch (error) { return { diff --git a/src/main/wsl/wsl-orcad-connection-status.ts b/src/main/wsl/wsl-orcad-connection-status.ts index 8fc35c3c22bb..4a8c0081c5c0 100644 --- a/src/main/wsl/wsl-orcad-connection-status.ts +++ b/src/main/wsl/wsl-orcad-connection-status.ts @@ -1,5 +1,6 @@ import type { OrcadTerminalCensus } from '../../shared/orcad-terminal-census' import type { WslHostConnectIntent, WslHostDeferredUpdate } from '../../shared/wsl-host-types' +import type { WslHostCopyParams } from '../../shared/wsl-host-failure-copy' import type { WslLivenessUnverifiableReason } from './wsl-orcad-liveness-verdict' /** C7 publishes terminal verdicts proven by the distro; null leaves ownership to orcad, whose reconnect census reports surviving daemon sessions. */ @@ -30,6 +31,9 @@ export type WslOrcadConnectionStatus = | { state: 'failed' reason: string + /** `reason`'s WSL_HOST_STATUS_DETAIL_COPY code; absent for verbatim connect errors. */ + reasonCode?: string + reasonParams?: WslHostCopyParams terminals: 'exited' | 'unverifiable' /** A connect the host deferred: what Update or Force would retry, since nothing serves. */ deferredUpdate?: WslHostDeferredUpdate diff --git a/src/main/wsl/wsl-orcad-liveness-recovery.ts b/src/main/wsl/wsl-orcad-liveness-recovery.ts index 7a3db38a771d..35c7c27f535e 100644 --- a/src/main/wsl/wsl-orcad-liveness-recovery.ts +++ b/src/main/wsl/wsl-orcad-liveness-recovery.ts @@ -1,5 +1,6 @@ /** C4 recovery uses bounded relaunch backoff, then census before publishing terminal verdicts. Recovery is never a user action, so it needs a confirmed-running distro and never boots one (E9). */ import type { OrcadTerminalCensus } from '../../shared/orcad-terminal-census' +import { wslHostStatusDetailText } from '../../shared/wsl-host-failure-copy' import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' import { wslDistroHolderKey } from './wsl-distro-holder-record' import type { WslOrcadConnection, WslOrcadConnectOptions } from './wsl-orcad-connection' @@ -33,9 +34,15 @@ export async function recoverWslOrcad( for (;;) { const decision = context.backoff.next(context.now()) if (decision.kind === 'give-up') { + const gaveUp = wslHostStatusDetailText('restartGaveUp', { + distro: context.distro, + count: decision.attempts + }) context.publish({ state: 'failed', - reason: `Could not restart the Orca server in ${context.distro} after ${decision.attempts} attempts`, + reason: gaveUp.text, + reasonCode: gaveUp.code, + reasonParams: gaveUp.params, terminals }) return null diff --git a/src/renderer/src/components/settings/WslHostsSection.tsx b/src/renderer/src/components/settings/WslHostsSection.tsx index 2141b388ab4e..2e79896120c7 100644 --- a/src/renderer/src/components/settings/WslHostsSection.tsx +++ b/src/renderer/src/components/settings/WslHostsSection.tsx @@ -31,6 +31,7 @@ import { getWslHostsPausedLabel, getWslHostsTurnedOffLabel } from '../sidebar/wsl-host-row-status' +import { wslHostStatusDetailMessage } from '../sidebar/wsl-host-failure-text' import { Badge } from '../ui/badge' import { Button } from '../ui/button' import { DropdownMenuItem } from '../ui/dropdown-menu' @@ -200,7 +201,9 @@ export function WslHostsSection({ { version: deferred.candidateVersion } )} ${managedServerOutcomeLabel({ outcome: 'deferred', code: deferred.code })}` : `${unavailableLabel ?? getWslHostRowDetail(status)}${ - !unavailableLabel && status?.detail ? ` — ${status.detail}` : '' + !unavailableLabel && status?.detail + ? ` — ${wslHostStatusDetailMessage(status)}` + : '' }`} } diff --git a/src/renderer/src/components/sidebar/AddWslHostDialogBody.tsx b/src/renderer/src/components/sidebar/AddWslHostDialogBody.tsx index fbcea74ada96..439b21d311e0 100644 --- a/src/renderer/src/components/sidebar/AddWslHostDialogBody.tsx +++ b/src/renderer/src/components/sidebar/AddWslHostDialogBody.tsx @@ -6,6 +6,7 @@ import { AddWslHostFormPanel, canAddWslDistro } from './AddWslHostFormPanel' import { useWslDistroList } from './use-wsl-distro-list' import { useWslHostServerFilesMissing } from './use-wsl-hosts-enabled' import { readIpcErrorDetail } from '@/lib/ipc-error' +import { wslHostAddRefusalMessage } from './wsl-host-failure-text' export function AddWslHostDialogBody({ adding, @@ -49,7 +50,7 @@ export function AddWslHostDialogBody({ startIfStopped: selected.state === 'stopped' }) if (!result.ok) { - setError(result.message) + setError(wslHostAddRefusalMessage(result)) if (result.kind === 'distro-stopped') { // It stopped after the list was read; the fresh state turns the button into Start and add. list.refresh() diff --git a/src/renderer/src/components/sidebar/wsl-host-failure-text.test.ts b/src/renderer/src/components/sidebar/wsl-host-failure-text.test.ts new file mode 100644 index 000000000000..3a9599953719 --- /dev/null +++ b/src/renderer/src/components/sidebar/wsl-host-failure-text.test.ts @@ -0,0 +1,83 @@ +import { afterEach, describe, expect, it } from 'vitest' +import { i18n } from '@/i18n/i18n' +import es from '@/i18n/locales/es.json' +import { + wslHostAddRefusalText, + wslHostServerStopReason, + wslHostStatusDetailText +} from '../../../../shared/wsl-host-failure-copy' +import { + wslHostAddRefusalMessage, + wslHostStatusDetailMessage, + wslHostStopReasonMessage +} from './wsl-host-failure-text' + +const originalLanguage = i18n.language + +afterEach(async () => { + await i18n.changeLanguage(originalLanguage) +}) + +async function useSpanish(): Promise { + i18n.addResourceBundle('es', 'translation', es) + await i18n.changeLanguage('es') +} + +describe('WSL host failure text', () => { + it('keeps the English wire text and translates it by code, commands verbatim', async () => { + await useSpanish() + const wsl1 = wslHostAddRefusalText('wsl1', { distro: 'Ubuntu' }) + expect(wsl1.text).toBe( + 'Ubuntu runs WSL 1, which Orca no longer supports. Convert it to WSL 2 in a Windows terminal with: wsl --set-version Ubuntu 2' + ) + const translated = wslHostAddRefusalMessage({ + message: wsl1.text, + errorCode: wsl1.code, + errorParams: wsl1.params + }) + expect(translated).toBe( + es.sidebar.wslHosts.addErrors.wsl1 + .replace('{{distro}}', 'Ubuntu') + .replace('{{command}}', 'wsl --set-version Ubuntu 2') + ) + expect(translated).not.toBe(wsl1.text) + }) + + it('translates status details, including plural restarts and verbatim stop errors', async () => { + await useSpanish() + const gaveUp = wslHostStatusDetailText('restartGaveUp', { distro: 'Ubuntu', count: 5 }) + expect(gaveUp.text).toBe('Could not restart the Orca server in Ubuntu after 5 attempts') + expect( + wslHostStatusDetailMessage({ + detail: gaveUp.text, + detailCode: gaveUp.code, + detailParams: gaveUp.params + }) + ).toBe( + es.sidebar.wslHosts.statusDetails.restartGaveUp_other + .replace('{{distro}}', 'Ubuntu') + .replace('{{count}}', '5') + ) + const unrecorded = wslHostServerStopReason('removalUnrecorded', { detail: 'EACCES' }) + expect(wslHostStopReasonMessage(unrecorded)).toBe( + es.sidebar.wslHosts.statusDetails.removalUnrecorded.replace('{{detail}}', 'EACCES') + ) + }) + + it('shows the English text for uncoded, unknown, or incomplete codes', async () => { + await useSpanish() + expect(wslHostAddRefusalMessage({ message: 'bridge refused' })).toBe('bridge refused') + expect(wslHostAddRefusalMessage({ message: 'Newer', errorCode: 'futureCode' })).toBe('Newer') + expect(wslHostAddRefusalMessage({ message: 'English', errorCode: 'alreadyAdded' })).toBe( + 'English' + ) + expect(wslHostAddRefusalMessage({ message: 'English', errorCode: 'toString' })).toBe('English') + expect( + wslHostStatusDetailMessage({ + detail: 'English', + detailCode: 'restartGaveUp', + detailParams: { distro: 'Ubuntu', count: '5' } + }) + ).toBe('English') + }) +}) diff --git a/src/renderer/src/components/sidebar/wsl-host-failure-text.ts b/src/renderer/src/components/sidebar/wsl-host-failure-text.ts new file mode 100644 index 000000000000..24e3d9b9375d --- /dev/null +++ b/src/renderer/src/components/sidebar/wsl-host-failure-text.ts @@ -0,0 +1,155 @@ +import { translate } from '@/i18n/i18n' +import { + WSL_HOST_ADD_REFUSAL_COPY as ADD, + WSL_HOST_STATUS_DETAIL_COPY as DETAIL, + WSL_LIST_DISTROS_COMMAND, + wslSetVersion2Command, + type WslHostAddRefusalCode, + type WslHostCopyParams, + type WslHostStatusDetailCode +} from '../../../../shared/wsl-host-failure-copy' +import { + getWslHostsPausedLabel, + getWslHostServerFilesMissingLabel, + getWslHostsTurnedOffLabel +} from './wsl-host-row-status' + +type Values = { text: (name: string) => string | null; count: (name: string) => number | null } + +// null = required params missing; the caller shows the host's English text. +const ADD_COPY: Record string | null> = { + turnedOff: () => getWslHostsTurnedOffLabel(), + newWorkPaused: () => getWslHostsPausedLabel(), + serverFilesMissing: () => getWslHostServerFilesMissingLabel(), + alreadyAdded: ({ text }) => { + const distro = text('distro') + return distro === null + ? null + : translate('sidebar.wslHosts.addErrors.alreadyAdded', ADD.alreadyAdded, { distro }) + }, + distroStopped: ({ text }) => { + const distro = text('distro') + return distro === null + ? null + : translate('sidebar.wslHosts.addErrors.distroStopped', ADD.distroStopped, { distro }) + }, + wsl1: ({ text }) => { + const distro = text('distro') + return distro === null + ? null + : translate('sidebar.wslHosts.addErrors.wsl1', ADD.wsl1, { + distro, + command: wslSetVersion2Command(distro) + }) + }, + notRegistered: ({ text }) => { + const distro = text('distro') + return distro === null + ? null + : translate('sidebar.wslHosts.addErrors.notRegistered', ADD.notRegistered, { + distro, + command: WSL_LIST_DISTROS_COMMAND + }) + }, + sshManaged: ({ text }) => { + const distro = text('distro') + const server = text('server') + return distro === null || server === null + ? null + : translate('sidebar.wslHosts.addErrors.sshManaged', ADD.sshManaged, { distro, server }) + } +} + +const DETAIL_COPY: Record string | null> = { + runningListUnavailable: () => + translate( + 'sidebar.wslHosts.statusDetails.runningListUnavailable', + DETAIL.runningListUnavailable + ), + guestUnanswered: () => + translate('sidebar.wslHosts.statusDetails.guestUnanswered', DETAIL.guestUnanswered), + orcadUnanswered: () => + translate('sidebar.wslHosts.statusDetails.orcadUnanswered', DETAIL.orcadUnanswered), + restartGaveUp: ({ text, count: readCount }) => { + const distro = text('distro') + const count = readCount('count') + if (distro === null || count === null) { + return null + } + return count === 1 + ? translate('sidebar.wslHosts.statusDetails.restartGaveUp_one', DETAIL.restartGaveUp.one, { + distro, + count + }) + : translate( + 'sidebar.wslHosts.statusDetails.restartGaveUp_other', + DETAIL.restartGaveUp.other, + { distro, count } + ) + }, + serviceUnconfirmed: () => + translate('sidebar.wslHosts.statusDetails.serviceUnconfirmed', DETAIL.serviceUnconfirmed), + peerCheckFailed: ({ text }) => { + const detail = text('detail') + return detail === null + ? null + : translate('sidebar.wslHosts.statusDetails.peerCheckFailed', DETAIL.peerCheckFailed, { + detail + }) + }, + removalUnrecorded: ({ text }) => { + const detail = text('detail') + return detail === null + ? null + : translate('sidebar.wslHosts.statusDetails.removalUnrecorded', DETAIL.removalUnrecorded, { + detail + }) + } +} + +function isCopyCode(copy: Record, code: unknown): code is Code { + return typeof code === 'string' && Object.hasOwn(copy, code) +} + +function codedText( + copy: Record string | null>, + english: string, + code: unknown, + params: WslHostCopyParams | undefined +): string { + if (!isCopyCode(copy, code)) { + return english + } + const values: Values = { + text: (name) => (typeof params?.[name] === 'string' ? params[name] : null), + count: (name) => (typeof params?.[name] === 'number' ? params[name] : null) + } + return copy[code](values) ?? english +} + +/** Unknown codes (newer main) and uncoded refusals (verbatim errors) show main's English. */ +export function wslHostAddRefusalMessage(refusal: { + message: string + errorCode?: string + errorParams?: WslHostCopyParams +}): string { + return codedText(ADD_COPY, refusal.message, refusal.errorCode, refusal.errorParams) +} + +export function wslHostStatusDetailMessage(status: { + detail: string | null + detailCode?: string + detailParams?: WslHostCopyParams +}): string | null { + return status.detail === null + ? null + : codedText(DETAIL_COPY, status.detail, status.detailCode, status.detailParams) +} + +export function wslHostStopReasonMessage(stop: { + reason: string + reasonCode?: string + reasonParams?: WslHostCopyParams +}): string { + return codedText(DETAIL_COPY, stop.reason, stop.reasonCode, stop.reasonParams) +} diff --git a/src/renderer/src/components/sidebar/wsl-host-removal.ts b/src/renderer/src/components/sidebar/wsl-host-removal.ts index 79ef949540c2..130ef5803239 100644 --- a/src/renderer/src/components/sidebar/wsl-host-removal.ts +++ b/src/renderer/src/components/sidebar/wsl-host-removal.ts @@ -5,6 +5,7 @@ import { translate } from '@/i18n/i18n' import { useAppStore } from '@/store' import { runEnclosingWorktreeRemoval } from '@/store/active-worktree-deselection-intent' import { workspaceOwnerHostId } from '@/lib/workspace-row-owner-host' +import { wslHostStopReasonMessage } from './wsl-host-failure-text' /** Stop terminals/server, remove records and refresh hosts; report anything still running that keeps the distro alive. */ async function removeWslHostImpl(environmentId: string): Promise { @@ -54,7 +55,7 @@ export function warnWslHostServerStop(serverStop: WslHostServerStop | undefined) translate( 'auto.components.sidebar.wslHostRemoval.pending', 'Orca didn’t remove the host yet: {{value0}} Remove it again to retry, or connect it to keep it.', - { value0: serverStop.reason } + { value0: wslHostStopReasonMessage(serverStop) } ), { duration: Infinity } ) @@ -65,7 +66,7 @@ export function warnWslHostServerStop(serverStop: WslHostServerStop | undefined) translate( 'auto.components.sidebar.wslHostRemoval.partial', 'The host was removed, but something in the distro is still running: {{value0}}', - { value0: serverStop.reason } + { value0: wslHostStopReasonMessage(serverStop) } ), { duration: Infinity } ) diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index ccbdd49bd1c5..daa504a820d1 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -1794,6 +1794,25 @@ "targetNotEmpty": "\"{{name}}\" already exists at this location and is not empty.", "targetNotFolder": "\"{{name}}\" already exists at this location and is not a folder." } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} is already a host.", + "distroStopped": "{{distro}} stopped since the list was read. Choose Start and add to start it.", + "notRegistered": "{{distro}} is not an installed WSL distro. Run {{command}} in a Windows terminal to see the installed ones, or reinstall it and try again.", + "sshManaged": "{{distro}} already runs the Orca server for “{{server}}”, which this computer reaches over SSH. Remove that server first; moving it to a WSL host isn’t supported yet.", + "wsl1": "{{distro}} runs WSL 1, which Orca no longer supports. Convert it to WSL 2 in a Windows terminal with: {{command}}" + }, + "statusDetails": { + "guestUnanswered": "The distro is running but didn’t answer Orca’s check.", + "orcadUnanswered": "Orca’s server in the distro didn’t answer.", + "peerCheckFailed": "Orca couldn’t ask the WSL host whether another Orca on this computer still uses it: {{detail}}", + "removalUnrecorded": "Orca couldn’t record what this Remove left running: {{detail}}", + "restartGaveUp_one": "Could not restart the Orca server in {{distro}} after {{count}} attempt", + "restartGaveUp_other": "Could not restart the Orca server in {{distro}} after {{count}} attempts", + "runningListUnavailable": "Windows didn’t report whether the distro is running.", + "serviceUnconfirmed": "The WSL service did not confirm whether the distro runs." + } } }, "sourceControl": { diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index ef53d8e5bebe..094198b74693 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -119,6 +119,25 @@ "gitInitFailed": "Git-Repository konnte nicht initialisiert werden: {{detail}}", "initialCommitFailed": "Erster Commit konnte nicht erstellt werden: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} ist bereits ein Host.", + "distroStopped": "{{distro}} wurde nach dem Einlesen der Liste gestoppt. Zum Starten „Starten und hinzufügen“ auswählen.", + "wsl1": "{{distro}} läuft unter WSL 1, das Orca nicht mehr unterstützt. In einem Terminal unter Windows mit folgendem Befehl auf WSL 2 umstellen: {{command}}", + "notRegistered": "{{distro}} ist keine installierte WSL-Distribution. In einem Terminal unter Windows {{command}} ausführen, um die installierten Distributionen anzuzeigen, oder die Distribution neu installieren und erneut versuchen.", + "sshManaged": "In {{distro}} läuft bereits der Orca-Server für „{{server}}“, den dieser Computer über SSH erreicht. Diesen Server zuerst entfernen; der Wechsel zu einem WSL-Host wird noch nicht unterstützt." + }, + "statusDetails": { + "runningListUnavailable": "Windows hat nicht gemeldet, ob die Distribution läuft.", + "guestUnanswered": "Die Distribution läuft, hat aber nicht auf Orcas Prüfanfrage geantwortet.", + "orcadUnanswered": "Der Orca-Server in der Distribution hat nicht geantwortet.", + "restartGaveUp_one": "Der Orca-Server in {{distro}} konnte nach {{count}} Versuch nicht neu gestartet werden", + "restartGaveUp_other": "Der Orca-Server in {{distro}} konnte nach {{count}} Versuchen nicht neu gestartet werden", + "serviceUnconfirmed": "Der WSL-Dienst hat nicht bestätigt, ob die Distribution läuft.", + "peerCheckFailed": "Orca konnte den WSL-Host nicht fragen, ob eine andere Orca-Instanz auf diesem Computer ihn noch nutzt: {{detail}}", + "removalUnrecorded": "Orca konnte nicht erfassen, was nach dem Entfernen noch läuft: {{detail}}" + } } }, "app": { diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index cdb97b1cb618..d032cc67fb19 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -119,6 +119,25 @@ "gitInitFailed": "Failed to initialize git repository: {{detail}}", "initialCommitFailed": "Failed to create initial commit: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} is already a host.", + "distroStopped": "{{distro}} stopped since the list was read. Choose Start and add to start it.", + "wsl1": "{{distro}} runs WSL 1, which Orca no longer supports. Convert it to WSL 2 in a Windows terminal with: {{command}}", + "notRegistered": "{{distro}} is not an installed WSL distro. Run {{command}} in a Windows terminal to see the installed ones, or reinstall it and try again.", + "sshManaged": "{{distro}} already runs the Orca server for “{{server}}”, which this computer reaches over SSH. Remove that server first; moving it to a WSL host isn’t supported yet." + }, + "statusDetails": { + "runningListUnavailable": "Windows didn’t report whether the distro is running.", + "guestUnanswered": "The distro is running but didn’t answer Orca’s check.", + "orcadUnanswered": "Orca’s server in the distro didn’t answer.", + "restartGaveUp_one": "Could not restart the Orca server in {{distro}} after {{count}} attempt", + "restartGaveUp_other": "Could not restart the Orca server in {{distro}} after {{count}} attempts", + "serviceUnconfirmed": "The WSL service did not confirm whether the distro runs.", + "peerCheckFailed": "Orca couldn’t ask the WSL host whether another Orca on this computer still uses it: {{detail}}", + "removalUnrecorded": "Orca couldn’t record what this Remove left running: {{detail}}" + } } }, "app": { diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index a7d2f8508d03..ace826362762 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -20793,6 +20793,26 @@ "gitInitFailed": "No se pudo inicializar el repositorio Git: {{detail}}", "initialCommitFailed": "No se pudo crear el commit inicial: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} ya es un host.", + "distroStopped": "{{distro}} se detuvo después de que se leyera la lista. Elige «Iniciar y agregar» para iniciarla.", + "wsl1": "{{distro}} usa WSL 1, que Orca ya no admite. Conviértela a WSL 2 en una terminal de Windows con: {{command}}", + "notRegistered": "{{distro}} no es una distro WSL instalada. Ejecuta {{command}} en una terminal de Windows para ver las instaladas, o reinstálala e inténtalo de nuevo.", + "sshManaged": "{{distro}} ya ejecuta el servidor Orca de «{{server}}», al que este equipo accede por SSH. Elimina primero ese servidor; aún no se admite moverlo a un host WSL." + }, + "statusDetails": { + "runningListUnavailable": "Windows no indicó si la distro está en ejecución.", + "guestUnanswered": "La distro está en ejecución, pero no respondió a la comprobación de Orca.", + "orcadUnanswered": "El servidor Orca de la distro no respondió.", + "restartGaveUp_one": "No se pudo reiniciar el servidor Orca en {{distro}} después de {{count}} intento", + "restartGaveUp_other": "No se pudo reiniciar el servidor Orca en {{distro}} después de {{count}} intentos", + "restartGaveUp_many": "No se pudo reiniciar el servidor Orca en {{distro}} después de {{count}} intentos", + "serviceUnconfirmed": "El servicio WSL no confirmó si la distro está en ejecución.", + "peerCheckFailed": "Orca no pudo consultar al host WSL si otro Orca en este equipo aún lo usa: {{detail}}", + "removalUnrecorded": "Orca no pudo registrar qué quedó en ejecución tras esta eliminación: {{detail}}" + } } }, "rendererRecovery": { diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index 29525d84683f..0dbdf0934c20 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -20562,6 +20562,26 @@ "gitInitFailed": "Impossible d’initialiser le dépôt Git : {{detail}}", "initialCommitFailed": "Impossible de créer le commit initial : {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} est déjà un hôte.", + "distroStopped": "{{distro}} s'est arrêtée depuis la lecture de la liste. Choisissez « Démarrer et ajouter » pour la démarrer.", + "wsl1": "{{distro}} utilise WSL 1, qu'Orca ne prend plus en charge. Convertissez-la en WSL 2 dans un terminal Windows avec : {{command}}", + "notRegistered": "{{distro}} n'est pas une distro WSL installée. Exécutez {{command}} dans un terminal Windows pour voir celles qui sont installées, ou réinstallez-la et réessayez.", + "sshManaged": "{{distro}} exécute déjà le serveur Orca de « {{server}} », auquel cet ordinateur accède via SSH. Supprimez d'abord ce serveur ; son déplacement vers un hôte WSL n'est pas encore pris en charge." + }, + "statusDetails": { + "runningListUnavailable": "Windows n'a pas indiqué si la distro est en cours d'exécution.", + "guestUnanswered": "La distro est en cours d'exécution, mais n'a pas répondu à la vérification d'Orca.", + "orcadUnanswered": "Le serveur Orca dans la distro n'a pas répondu.", + "restartGaveUp_one": "Impossible de redémarrer le serveur Orca dans {{distro}} après {{count}} tentative", + "restartGaveUp_other": "Impossible de redémarrer le serveur Orca dans {{distro}} après {{count}} tentatives", + "restartGaveUp_many": "Impossible de redémarrer le serveur Orca dans {{distro}} après {{count}} tentatives", + "serviceUnconfirmed": "Le service WSL n'a pas confirmé si la distro est en cours d'exécution.", + "peerCheckFailed": "Orca n'a pas pu demander à l'hôte WSL si un autre Orca sur cet ordinateur l'utilise encore : {{detail}}", + "removalUnrecorded": "Orca n'a pas pu enregistrer ce qui est resté en cours d'exécution après cette suppression : {{detail}}" + } } }, "editor": { diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index bd4e8d78e7f3..7c7327a3d8b9 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -19927,6 +19927,24 @@ "gitInitFailed": "Git リポジトリを初期化できませんでした: {{detail}}", "initialCommitFailed": "最初のコミットを作成できませんでした: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} はすでにホストです。", + "distroStopped": "一覧の読み取り後に {{distro}} が停止しました。「起動して追加」を選択して起動してください。", + "wsl1": "{{distro}} は Orca がサポートを終了した WSL 1 を使用しています。Windows のターミナルで次のコマンドを実行し、WSL 2 に変換してください: {{command}}", + "notRegistered": "{{distro}} はインストール済みの WSL ディストリビューションではありません。Windows のターミナルで {{command}} を実行してインストール済みのものを確認するか、再インストールしてからやり直してください。", + "sshManaged": "{{distro}} ではすでに「{{server}}」の Orca サーバーが実行されており、このコンピューターは SSH 経由で接続しています。先にそのサーバーを削除してください。WSL ホストへの移行はまだサポートされていません。" + }, + "statusDetails": { + "runningListUnavailable": "Windows からディストリビューションの実行状態が報告されませんでした。", + "guestUnanswered": "ディストリビューションは実行中ですが、Orca の確認に応答しませんでした。", + "orcadUnanswered": "ディストリビューション内の Orca サーバーが応答しませんでした。", + "restartGaveUp_other": "{{count}} 回試行しましたが、{{distro}} 内の Orca サーバーを再起動できませんでした", + "serviceUnconfirmed": "WSL サービスからディストリビューションが実行中かどうかの確認が得られませんでした。", + "peerCheckFailed": "Orca は WSL ホストに、このコンピューター上の別の Orca がまだ使用しているかを問い合わせられませんでした: {{detail}}", + "removalUnrecorded": "Orca は、今回の削除後も実行中のものを記録できませんでした: {{detail}}" + } } }, "editor": { diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index 648765904cef..d4862a0c9e11 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -19927,6 +19927,24 @@ "gitInitFailed": "Git 리포지토리를 초기화하지 못했습니다: {{detail}}", "initialCommitFailed": "초기 commit을 생성하지 못했습니다: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}}은(는) 이미 호스트입니다.", + "distroStopped": "목록을 읽은 후 {{distro}}이(가) 중지되었습니다. 시작하려면 “시작 및 추가”를 선택하세요.", + "wsl1": "{{distro}}은(는) Orca에서 더 이상 지원하지 않는 WSL 1을 사용합니다. Windows 터미널에서 다음 명령으로 WSL 2로 변환하세요: {{command}}", + "notRegistered": "{{distro}}은(는) 설치된 WSL 배포판이 아닙니다. Windows 터미널에서 {{command}}을(를) 실행해 설치된 배포판을 확인하거나, 다시 설치한 후 재시도하세요.", + "sshManaged": "{{distro}}에서 이미 “{{server}}”의 Orca 서버가 실행 중이며, 이 컴퓨터는 SSH로 해당 서버에 연결합니다. 먼저 해당 서버를 제거하세요. WSL 호스트로 옮기는 기능은 아직 지원되지 않습니다." + }, + "statusDetails": { + "runningListUnavailable": "Windows에서 배포판의 실행 여부를 보고하지 않았습니다.", + "guestUnanswered": "배포판이 실행 중이지만 Orca의 확인 요청에 응답하지 않았습니다.", + "orcadUnanswered": "배포판 내 Orca 서버가 응답하지 않았습니다.", + "restartGaveUp_other": "{{count}}회 시도 후에도 {{distro}}의 Orca 서버를 다시 시작하지 못했습니다", + "serviceUnconfirmed": "WSL 서비스가 배포판의 실행 여부를 확인해 주지 않았습니다.", + "peerCheckFailed": "Orca가 WSL 호스트에 이 컴퓨터의 다른 Orca가 아직 사용 중인지 확인을 요청하지 못했습니다: {{detail}}", + "removalUnrecorded": "Orca가 이번 제거 후에도 계속 실행 중인 항목을 기록하지 못했습니다: {{detail}}" + } } }, "editor": { diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index c60164011a7a..6d1265618b29 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -249,6 +249,26 @@ "gitInitFailed": "Não foi possível inicializar o repositório Git: {{detail}}", "initialCommitFailed": "Não foi possível criar o commit inicial: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} já é um host.", + "distroStopped": "{{distro}} parou após a leitura da lista. Escolha “Iniciar e adicionar” para iniciá-la.", + "wsl1": "{{distro}} usa WSL 1, que o Orca não suporta mais. Converta-a para WSL 2 em um terminal do Windows com: {{command}}", + "notRegistered": "{{distro}} não é uma distribuição WSL instalada. Execute {{command}} em um terminal do Windows para ver as instaladas ou reinstale-a e tente novamente.", + "sshManaged": "{{distro}} já executa o servidor Orca de “{{server}}”, que este computador acessa por SSH. Remova esse servidor primeiro; ainda não há suporte para movê-lo para um host WSL." + }, + "statusDetails": { + "runningListUnavailable": "O Windows não informou se a distribuição está em execução.", + "guestUnanswered": "A distribuição está em execução, mas não respondeu à verificação do Orca.", + "orcadUnanswered": "O servidor Orca na distribuição não respondeu.", + "restartGaveUp_one": "Não foi possível reiniciar o servidor Orca em {{distro}} após {{count}} tentativa", + "restartGaveUp_other": "Não foi possível reiniciar o servidor Orca em {{distro}} após {{count}} tentativas", + "restartGaveUp_many": "Não foi possível reiniciar o servidor Orca em {{distro}} após {{count}} tentativas", + "serviceUnconfirmed": "O serviço WSL não confirmou se a distribuição está em execução.", + "peerCheckFailed": "O Orca não conseguiu consultar o host WSL para saber se outro Orca neste computador ainda o usa: {{detail}}", + "removalUnrecorded": "O Orca não conseguiu registrar o que continuou em execução após esta remoção: {{detail}}" + } } }, "tray": { diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index 442be64a03af..1f4145342605 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -119,6 +119,27 @@ "gitInitFailed": "Не удалось инициализировать репозиторий Git: {{detail}}", "initialCommitFailed": "Не удалось создать начальный коммит: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} уже добавлен как сервер.", + "distroStopped": "{{distro}} остановился после чтения списка. Выберите «Запустить и добавить», чтобы запустить его.", + "wsl1": "{{distro}} использует WSL 1, которую Orca больше не поддерживает. Преобразуйте его в WSL 2 в терминале Windows командой: {{command}}", + "notRegistered": "{{distro}} не является установленным дистрибутивом WSL. Выполните {{command}} в терминале Windows, чтобы увидеть установленные дистрибутивы, или переустановите его и повторите попытку.", + "sshManaged": "В {{distro}} уже работает сервер Orca для «{{server}}», к которому этот компьютер подключается по SSH. Сначала удалите этот сервер; перенос на сервер WSL пока не поддерживается." + }, + "statusDetails": { + "runningListUnavailable": "Windows не сообщила, запущен ли дистрибутив.", + "guestUnanswered": "Дистрибутив запущен, но не ответил на проверочный запрос Orca.", + "orcadUnanswered": "Сервер Orca в дистрибутиве не ответил.", + "restartGaveUp_one": "Не удалось перезапустить сервер Orca в {{distro}} после {{count}} попытки", + "restartGaveUp_other": "Не удалось перезапустить сервер Orca в {{distro}} после {{count}} попытки", + "serviceUnconfirmed": "Служба WSL не подтвердила, запущен ли дистрибутив.", + "peerCheckFailed": "Orca не удалось спросить у сервера WSL, использует ли его ещё другой экземпляр Orca на этом компьютере: {{detail}}", + "removalUnrecorded": "Orca не удалось записать, что осталось работать после этого удаления: {{detail}}", + "restartGaveUp_few": "Не удалось перезапустить сервер Orca в {{distro}} после {{count}} попыток", + "restartGaveUp_many": "Не удалось перезапустить сервер Orca в {{distro}} после {{count}} попыток" + } } }, "app": { diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index fff07a37cf25..6d01e9b62f14 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -119,6 +119,25 @@ "gitInitFailed": "Git repository'si başlatılamadı: {{detail}}", "initialCommitFailed": "İlk commit oluşturulamadı: {{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} zaten ana makine olarak ekli.", + "distroStopped": "Liste okunduktan sonra {{distro}} durdu. Başlatmak için “Başlat ve ekle” seçeneğini seçin.", + "wsl1": "{{distro}}, Orca'nın artık desteklemediği WSL 1'i kullanıyor. Windows terminalinde şu komutla WSL 2'ye dönüştürün: {{command}}", + "notRegistered": "{{distro}} yüklü bir WSL dağıtımı değil. Yüklü dağıtımları görmek için Windows terminalinde {{command}} komutunu çalıştırın veya dağıtımı yeniden yükleyip tekrar deneyin.", + "sshManaged": "{{distro}} içinde zaten “{{server}}” için Orca sunucusu çalışıyor ve bu bilgisayar ona SSH üzerinden bağlanıyor. Önce bu sunucuyu kaldırın; WSL ana makinesine taşıma henüz desteklenmiyor." + }, + "statusDetails": { + "runningListUnavailable": "Windows, dağıtımın çalışıp çalışmadığını bildirmedi.", + "guestUnanswered": "Dağıtım çalışıyor ancak Orca'nın kontrolüne yanıt vermedi.", + "orcadUnanswered": "Dağıtım içindeki Orca sunucusu yanıt vermedi.", + "restartGaveUp_one": "{{count}} denemeden sonra {{distro}} içindeki Orca sunucusu yeniden başlatılamadı", + "restartGaveUp_other": "{{count}} denemeden sonra {{distro}} içindeki Orca sunucusu yeniden başlatılamadı", + "serviceUnconfirmed": "WSL hizmeti dağıtımın çalışıp çalışmadığını doğrulamadı.", + "peerCheckFailed": "Orca tarafından WSL ana makinesine bu bilgisayardaki başka bir Orca'nın onu hâlâ kullanıp kullanmadığı sorulamadı: {{detail}}", + "removalUnrecorded": "Bu kaldırma işleminden sonra nelerin çalışmaya devam ettiği Orca tarafından kaydedilemedi: {{detail}}" + } } }, "app": { diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index 9af85457fd73..7218f94c744a 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -119,6 +119,24 @@ "gitInitFailed": "無法初始化 Git 存放庫:{{detail}}", "initialCommitFailed": "無法建立初始提交:{{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} 已是主機。", + "distroStopped": "讀取清單後,{{distro}} 已停止。選擇「啟動並新增」以啟動它。", + "wsl1": "{{distro}} 使用 WSL 1,Orca 已不再支援。請在 Windows 終端機中使用以下命令將其轉換為 WSL 2:{{command}}", + "notRegistered": "{{distro}} 不是已安裝的 WSL 發行版。請在 Windows 終端機中執行 {{command}} 查看已安裝的發行版,或重新安裝它後再試一次。", + "sshManaged": "{{distro}} 已在為「{{server}}」執行 Orca 伺服器,此電腦透過 SSH 存取該伺服器。請先移除該伺服器;目前尚不支援將其移轉為 WSL 主機。" + }, + "statusDetails": { + "runningListUnavailable": "Windows 未回報此發行版是否正在執行。", + "guestUnanswered": "發行版正在執行,但未回應 Orca 的檢查。", + "orcadUnanswered": "發行版中的 Orca 伺服器未回應。", + "restartGaveUp_other": "嘗試 {{count}} 次後仍無法重新啟動 {{distro}} 中的 Orca 伺服器", + "serviceUnconfirmed": "WSL 服務未確認此發行版是否正在執行。", + "peerCheckFailed": "Orca 無法向 WSL 主機詢問此電腦上的另一個 Orca 是否仍在使用該主機:{{detail}}", + "removalUnrecorded": "Orca 無法記錄此次移除後仍在執行的項目:{{detail}}" + } } }, "app": { diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index 99fab1c27aec..d29bae450439 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -19927,6 +19927,24 @@ "gitInitFailed": "初始化 Git 仓库失败:{{detail}}", "initialCommitFailed": "创建初始提交失败:{{detail}}" } + }, + "wslHosts": { + "addErrors": { + "alreadyAdded": "{{distro}} 已是主机。", + "distroStopped": "读取列表后,{{distro}} 已停止。选择“启动并添加”以启动它。", + "wsl1": "{{distro}} 使用 WSL 1,Orca 已不再支持。请在 Windows 终端中使用以下命令将其转换为 WSL 2:{{command}}", + "notRegistered": "{{distro}} 不是已安装的 WSL 发行版。请在 Windows 终端中运行 {{command}} 查看已安装的发行版,或重新安装它后重试。", + "sshManaged": "{{distro}} 已在为“{{server}}”运行 Orca 服务器,此电脑通过 SSH 访问该服务器。请先移除该服务器;暂不支持将其迁移为 WSL 主机。" + }, + "statusDetails": { + "runningListUnavailable": "Windows 未报告该发行版是否正在运行。", + "guestUnanswered": "发行版正在运行,但未响应 Orca 的检查。", + "orcadUnanswered": "发行版中的 Orca 服务器未响应。", + "restartGaveUp_other": "尝试 {{count}} 次后仍无法重启 {{distro}} 中的 Orca 服务器", + "serviceUnconfirmed": "WSL 服务未确认该发行版是否正在运行。", + "peerCheckFailed": "Orca 无法向 WSL 主机询问此电脑上的另一个 Orca 是否仍在使用该主机:{{detail}}", + "removalUnrecorded": "Orca 无法记录此次移除后仍在运行的内容:{{detail}}" + } } }, "editor": { diff --git a/src/shared/wsl-host-deployment-store.ts b/src/shared/wsl-host-deployment-store.ts index 1b18cc75260a..c49f49ea50a1 100644 --- a/src/shared/wsl-host-deployment-store.ts +++ b/src/shared/wsl-host-deployment-store.ts @@ -22,6 +22,9 @@ const MAX_WSL_HOST_DEPLOYMENTS_FILE_BYTES = 256 * 1024 export const WslHostPendingStopSchema = z.object({ since: z.number().finite(), reason: z.string().max(4_096), + /** `reason`'s WSL_HOST_STATUS_DETAIL_COPY code; older builds drop it and show `reason`. */ + reasonCode: z.string().max(128).optional(), + reasonParams: z.record(z.string(), z.union([z.string().max(4_096), z.number()])).optional(), verdict: z.enum(['live', 'unverifiable']) }) diff --git a/src/shared/wsl-host-failure-copy.ts b/src/shared/wsl-host-failure-copy.ts new file mode 100644 index 000000000000..656b1b559b4a --- /dev/null +++ b/src/shared/wsl-host-failure-copy.ts @@ -0,0 +1,91 @@ +// One English table for WSL host refusals and status details: main builds the English wire text, the renderer translates by code. +export const WSL_HOST_ADD_REFUSAL_COPY = { + turnedOff: 'WSL hosts are turned off in Settings → Experimental.', + newWorkPaused: + 'Adding WSL hosts and moving projects onto them is paused in this build. Your saved WSL hosts keep working.', + serverFilesMissing: 'This build of Orca can’t run WSL hosts (server files missing).', + alreadyAdded: '{{distro}} is already a host.', + distroStopped: '{{distro}} stopped since the list was read. Choose Start and add to start it.', + wsl1: '{{distro}} runs WSL 1, which Orca no longer supports. Convert it to WSL 2 in a Windows terminal with: {{command}}', + notRegistered: + '{{distro}} is not an installed WSL distro. Run {{command}} in a Windows terminal to see the installed ones, or reinstall it and try again.', + sshManaged: + '{{distro}} already runs the Orca server for “{{server}}”, which this computer reaches over SSH. Remove that server first; moving it to a WSL host isn’t supported yet.' +} as const + +export type WslHostAddRefusalCode = keyof typeof WSL_HOST_ADD_REFUSAL_COPY + +export const WSL_HOST_STATUS_DETAIL_COPY = { + runningListUnavailable: 'Windows didn’t report whether the distro is running.', + guestUnanswered: 'The distro is running but didn’t answer Orca’s check.', + orcadUnanswered: 'Orca’s server in the distro didn’t answer.', + restartGaveUp: { + one: 'Could not restart the Orca server in {{distro}} after {{count}} attempt', + other: 'Could not restart the Orca server in {{distro}} after {{count}} attempts' + }, + serviceUnconfirmed: 'The WSL service did not confirm whether the distro runs.', + peerCheckFailed: + 'Orca couldn’t ask the WSL host whether another Orca on this computer still uses it: {{detail}}', + removalUnrecorded: 'Orca couldn’t record what this Remove left running: {{detail}}' +} as const + +export type WslHostStatusDetailCode = keyof typeof WSL_HOST_STATUS_DETAIL_COPY + +export type WslHostCopyParams = Record + +/** A coded English sentence: `text` for older readers, `code`/`params` for translation. */ +export type WslHostCodedText = { text: string; code: string; params?: WslHostCopyParams } + +export const WSL_LIST_DISTROS_COMMAND = 'wsl --list --verbose' + +export function wslSetVersion2Command(distro: string): string { + return `wsl --set-version ${distro} 2` +} + +// One pass, so a distro name containing "{{detail}}" stays verbatim. +function fillWslHostCopy(template: string, values: WslHostCopyParams): string { + return template.replace(/\{\{(\w+)\}\}/g, (slot, name: string) => + Object.hasOwn(values, name) ? String(values[name]) : slot + ) +} + +/** Commands stay out of translation; they derive from the distro on both sides. */ +export function wslHostAddRefusalValues( + code: WslHostAddRefusalCode, + params: WslHostCopyParams +): WslHostCopyParams { + if (code === 'wsl1' && typeof params.distro === 'string') { + return { ...params, command: wslSetVersion2Command(params.distro) } + } + return code === 'notRegistered' ? { ...params, command: WSL_LIST_DISTROS_COMMAND } : params +} + +export function wslHostAddRefusalText( + code: WslHostAddRefusalCode, + params: WslHostCopyParams = {} +): WslHostCodedText { + const text = fillWslHostCopy( + WSL_HOST_ADD_REFUSAL_COPY[code], + wslHostAddRefusalValues(code, params) + ) + return { text, code, ...(Object.keys(params).length > 0 ? { params } : {}) } +} + +export function wslHostStatusDetailText( + code: WslHostStatusDetailCode, + params: WslHostCopyParams = {} +): WslHostCodedText { + const entry = WSL_HOST_STATUS_DETAIL_COPY[code] + const template = typeof entry === 'string' ? entry : params.count === 1 ? entry.one : entry.other + const text = fillWslHostCopy(template, params) + return { text, code, ...(Object.keys(params).length > 0 ? { params } : {}) } +} + +/** A coded Remove stop reason: English `reason` for older readers, code and params to translate it. */ +export function wslHostServerStopReason( + code: WslHostStatusDetailCode, + params?: WslHostCopyParams +): { reason: string; reasonCode: string; reasonParams?: WslHostCopyParams } { + const { text, params: reasonParams } = wslHostStatusDetailText(code, params) + return { reason: text, reasonCode: code, ...(reasonParams ? { reasonParams } : {}) } +} diff --git a/src/shared/wsl-host-types.ts b/src/shared/wsl-host-types.ts index 2c95c873ee79..783f5e5ed522 100644 --- a/src/shared/wsl-host-types.ts +++ b/src/shared/wsl-host-types.ts @@ -1,4 +1,5 @@ /** Desktop-only WSL host IPC; never part of the wire protocol (C7). */ +import type { WslHostCopyParams } from './wsl-host-failure-copy' export const WSL_HOST_STATUS_CHANNEL = 'wslHosts:statusChanged' @@ -26,6 +27,9 @@ export type WslHostStatus = { state: WslHostConnectionState /** Why it failed or is unverifiable, in the main process's words. */ detail: string | null + /** `detail`'s WSL_HOST_STATUS_DETAIL_COPY code; absent when `detail` is verbatim diagnostic text. */ + detailCode?: string + detailParams?: WslHostCopyParams /** An app update the running server waits to take (e.g. live terminals); Update/Force retry it. */ deferredUpdate?: WslHostDeferredUpdate | null /** A Remove that could not prove the server stopped; `detail` says why. Remove retries it. */ @@ -65,7 +69,15 @@ export type WslHostCapability = { export type WslHostServerStop = /** `keptForOtherDesktops`: another Orca shares the server, so only this desktop let go of it. */ | { stopped: true; keptForOtherDesktops?: string[] } - | { stopped: false; reason: string; verdict?: 'live' | 'unverifiable'; kept?: boolean } + | { + stopped: false + reason: string + /** `reason`'s WSL_HOST_STATUS_DETAIL_COPY code, when it is one coded sentence. */ + reasonCode?: string + reasonParams?: WslHostCopyParams + verdict?: 'live' | 'unverifiable' + kept?: boolean + } export type WslHostAddFailureKind = | 'unsupported-wsl1' @@ -81,7 +93,14 @@ export type WslHostAddFailureKind = export type WslHostAddResult = | { ok: true; environmentId: string } - | { ok: false; kind: WslHostAddFailureKind; message: string } + | { + ok: false + kind: WslHostAddFailureKind + message: string + /** `message`'s WSL_HOST_ADD_REFUSAL_COPY code; absent when `message` is verbatim error text. */ + errorCode?: string + errorParams?: WslHostCopyParams + } export function wslHostEnvironmentLabel(distro: string): string { return `${distro} (WSL)`