Skip to content

Commit e16115f

Browse files
committed
fix(desktop): improve WSL OpenCode updates
1 parent 26bf234 commit e16115f

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

packages/app/src/components/dialog-select-server.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DropdownMenu } from "@opencode-ai/ui/dropdown-menu"
55
import { Icon } from "@opencode-ai/ui/icon"
66
import { IconButton } from "@opencode-ai/ui/icon-button"
77
import { List } from "@opencode-ai/ui/list"
8+
import { Spinner } from "@opencode-ai/ui/spinner"
89
import { TextField } from "@opencode-ai/ui/text-field"
910
import { useMutation } from "@tanstack/solid-query"
1011
import { showToast } from "@opencode-ai/ui/toast"
@@ -717,7 +718,10 @@ export function DialogSelectServer(props: DialogSelectServerProps = {}) {
717718
if (wslDistro) updateWslMutation.mutate(wslDistro)
718719
}}
719720
>
720-
{updating() ? "Updating OpenCode..." : label()}
721+
<Show when={updating()}>
722+
<Spinner class="size-3.5 shrink-0" />
723+
</Show>
724+
{label()}
721725
</Button>
722726
)}
723727
</Show>

packages/app/src/components/dialog-wsl-server.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ export function DialogWslServer(props: DialogWslServerProps = {}) {
9191
})
9292
const installTarget = createMemo(() => installableDistros().find((item) => item.name === store.installTarget) ?? null)
9393
const installingDistro = createMemo(() => current()?.job?.kind === "install-distro")
94+
const installingOpencode = createMemo(() => {
95+
const job = current()?.job
96+
return job?.kind === "install-opencode" && job.distro === store.selectedDistro
97+
})
9498
const wslReady = createMemo(() => !!current()?.runtime?.available && !current()?.pendingRestart)
9599
const distroReady = createMemo(() => {
96100
const probe = selectedProbe()
@@ -523,6 +527,9 @@ export function DialogWslServer(props: DialogWslServerProps = {}) {
523527
disabled={busy()}
524528
onClick={() => runSelectedDistro((distro) => api.installOpencode(distro))}
525529
>
530+
<Show when={installingOpencode()}>
531+
<Spinner class="size-4 shrink-0" />
532+
</Show>
526533
{opencodeCheck()?.resolvedPath ? "Update OpenCode" : "Install OpenCode"}
527534
</Button>
528535
</Show>

packages/desktop-electron/src/main/wsl.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ export type RunWslOptions = {
3333
const DEFAULT_WSL_TIMEOUT_MS = 20_000
3434
const DEFAULT_WSL_INSTALL_TIMEOUT_MS = 15 * 60_000
3535

36-
export function wslArgs(args: string[], distro?: string | null) {
37-
if (distro) return ["-d", distro, "--", ...args]
38-
return ["--", ...args]
36+
export function wslArgs(args: string[], distro?: string | null, user?: string | null) {
37+
return [...(distro ? ["-d", distro] : []), ...(user ? ["--user", user] : []), "--", ...args]
3938
}
4039

4140
export function runWsl(args: string[], opts: RunWslOptions = {}) {
@@ -333,7 +332,7 @@ export async function readWslCommandVersion(command: string, distro: string, opt
333332
export async function upgradeWslOpencode(target: string, command: string, distro: string, opts?: RunWslOptions) {
334333
return runInteractiveCommand(
335334
resolveSystem32Command("wsl.exe"),
336-
wslArgs(["bash", "-lc", `${shellEscape(command)} upgrade ${shellEscape(target)}`], distro),
335+
wslArgs(["bash", "-lc", `${shellEscape(command)} upgrade ${shellEscape(target)}`], distro, "root"),
337336
withTimeout(opts, DEFAULT_WSL_INSTALL_TIMEOUT_MS),
338337
DEFAULT_WSL_INSTALL_TIMEOUT_MS,
339338
)

0 commit comments

Comments
 (0)