Files
orca/src/main/cli/wsl-cli-registration-operation.ts
T
Jinjing 34a9df7795 Fix wsl cli rc4 migration (#8471)
* fix(cli): migrate managed WSL launchers to native exe

* refactor(cli): reconcile managed WSL registrations

* fix(cli): harden WSL registration reconciliation

* fix(cli): serialize and harden WSL CLI registration lifecycle

- Cap per-distro concurrent repairs and add a filesystem lock so two
  Orca installs can't race the same distro's launcher/bridge files
- Skip re-adopting a legacy managed launcher when its bridge is user-
  owned, avoiding a doomed install retried on every startup
- Track per-distro reconciliation against launcher target + app
  version so unchanged registrations aren't re-probed each boot
- Replace command install with a single atomic rename instead of a
  move-based backup, closing a window where no orca-ide exists
- Remove the registry invalidate-on-persist-failure path now that
  writes are atomic and repair is disk-authoritative
- Add brief negative caching to WSL distro discovery to bound
  wsl.exe respawns on persistently broken hosts
- Extract keyed-promise-queue as a shared serialization primitive
2026-07-12 23:19:15 -07:00

24 lines
837 B
TypeScript

import { runKeyedSerializedOperation } from './keyed-promise-queue'
const operationQueues = new Map<string, Promise<void>>()
/**
* Canonical key for a WSL distro name. The operation queue and the
* registration registry must agree on this to serialize against each other.
*/
export function normalizeWslDistroKey(distro: string): string {
return distro.trim().toLowerCase()
}
/**
* Serializes registration reads and mutations for one WSL distro.
*/
export function runSerializedWslCliRegistrationOperation<T>(
distro: string,
operation: () => Promise<T>
): Promise<T> {
// Why: startup repair continues in the background and can otherwise undo a
// concurrent Settings install/remove or overwrite its ownership metadata.
return runKeyedSerializedOperation(operationQueues, normalizeWslDistroKey(distro), operation)
}