Skip to content

Commit 213a872

Browse files
authored
feat(desktop): add WSL backend mode (anomalyco#12914)
1 parent d98bd4b commit 213a872

File tree

27 files changed

+688
-352
lines changed

27 files changed

+688
-352
lines changed

packages/app/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function UiI18nBridge(props: ParentProps) {
4343

4444
declare global {
4545
interface Window {
46-
__OPENCODE__?: { updaterEnabled?: boolean; serverPassword?: string; deepLinks?: string[] }
46+
__OPENCODE__?: { updaterEnabled?: boolean; serverPassword?: string; deepLinks?: string[]; wsl?: boolean }
4747
}
4848
}
4949

packages/app/src/components/settings-general.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,34 @@ export const SettingsGeneral: Component = () => {
367367
</div>
368368
</div>
369369

370+
<Show when={platform.platform === "desktop" && platform.os === "windows" && platform.getWslEnabled}>
371+
{(_) => {
372+
const [enabledResource, actions] = createResource(() => platform.getWslEnabled?.())
373+
const enabled = () => (enabledResource.state === "pending" ? undefined : enabledResource.latest)
374+
375+
return (
376+
<div class="flex flex-col gap-1">
377+
<h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.desktop.section.wsl")}</h3>
378+
379+
<div class="bg-surface-raised-base px-4 rounded-lg">
380+
<SettingsRow
381+
title={language.t("settings.desktop.wsl.title")}
382+
description={language.t("settings.desktop.wsl.description")}
383+
>
384+
<div data-action="settings-wsl">
385+
<Switch
386+
checked={enabled() ?? false}
387+
disabled={enabledResource.state === "pending"}
388+
onChange={(checked) => platform.setWslEnabled?.(checked)?.finally(() => actions.refetch())}
389+
/>
390+
</div>
391+
</SettingsRow>
392+
</div>
393+
</div>
394+
)
395+
}}
396+
</Show>
397+
370398
{/* Updates Section */}
371399
<div class="flex flex-col gap-1">
372400
<h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.updates")}</h3>

packages/app/src/context/platform.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ export type Platform = {
5757
/** Set the default server URL to use on app startup (platform-specific) */
5858
setDefaultServerUrl?(url: string | null): Promise<void> | void
5959

60+
/** Get the configured WSL integration (desktop only) */
61+
getWslEnabled?(): Promise<boolean>
62+
63+
/** Set the configured WSL integration (desktop only) */
64+
setWslEnabled?(config: boolean): Promise<void> | void
65+
6066
/** Get the preferred display backend (desktop only) */
6167
getDisplayBackend?(): Promise<DisplayBackend | null> | DisplayBackend | null
6268

packages/app/src/i18n/ar.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ export const dict = {
508508
"settings.section.server": "الخادم",
509509
"settings.tab.general": "عام",
510510
"settings.tab.shortcuts": "اختصارات",
511+
"settings.desktop.section.wsl": "WSL",
512+
"settings.desktop.wsl.title": "WSL integration",
513+
"settings.desktop.wsl.description": "Run the OpenCode server inside WSL on Windows.",
511514

512515
"settings.general.section.appearance": "المظهر",
513516
"settings.general.section.notifications": "إشعارات النظام",

packages/app/src/i18n/br.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ export const dict = {
512512
"settings.section.server": "Servidor",
513513
"settings.tab.general": "Geral",
514514
"settings.tab.shortcuts": "Atalhos",
515+
"settings.desktop.section.wsl": "WSL",
516+
"settings.desktop.wsl.title": "WSL integration",
517+
"settings.desktop.wsl.description": "Run the OpenCode server inside WSL on Windows.",
515518

516519
"settings.general.section.appearance": "Aparência",
517520
"settings.general.section.notifications": "Notificações do sistema",

packages/app/src/i18n/bs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ export const dict = {
539539
"settings.section.server": "Server",
540540
"settings.tab.general": "Opšte",
541541
"settings.tab.shortcuts": "Prečice",
542+
"settings.desktop.section.wsl": "WSL",
543+
"settings.desktop.wsl.title": "WSL integration",
544+
"settings.desktop.wsl.description": "Run the OpenCode server inside WSL on Windows.",
542545

543546
"settings.general.section.appearance": "Izgled",
544547
"settings.general.section.notifications": "Sistemske obavijesti",

packages/app/src/i18n/da.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ export const dict = {
512512
"settings.section.server": "Server",
513513
"settings.tab.general": "Generelt",
514514
"settings.tab.shortcuts": "Genveje",
515+
"settings.desktop.section.wsl": "WSL",
516+
"settings.desktop.wsl.title": "WSL integration",
517+
"settings.desktop.wsl.description": "Run the OpenCode server inside WSL on Windows.",
515518

516519
"settings.general.section.appearance": "Udseende",
517520
"settings.general.section.notifications": "Systemmeddelelser",

packages/app/src/i18n/de.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ export const dict = {
556556
"settings.section.server": "Server",
557557
"settings.tab.general": "Allgemein",
558558
"settings.tab.shortcuts": "Tastenkombinationen",
559+
"settings.desktop.section.wsl": "WSL",
560+
"settings.desktop.wsl.title": "WSL integration",
561+
"settings.desktop.wsl.description": "Run the OpenCode server inside WSL on Windows.",
559562

560563
"settings.general.section.appearance": "Erscheinungsbild",
561564
"settings.general.section.notifications": "Systembenachrichtigungen",

packages/app/src/i18n/en.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ export const dict = {
583583
"settings.section.server": "Server",
584584
"settings.tab.general": "General",
585585
"settings.tab.shortcuts": "Shortcuts",
586+
"settings.desktop.section.wsl": "WSL",
587+
"settings.desktop.wsl.title": "WSL integration",
588+
"settings.desktop.wsl.description": "Run the OpenCode server inside WSL on Windows.",
586589

587590
"settings.general.section.appearance": "Appearance",
588591
"settings.general.section.notifications": "System notifications",

packages/app/src/i18n/es.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ export const dict = {
515515
"settings.section.server": "Servidor",
516516
"settings.tab.general": "General",
517517
"settings.tab.shortcuts": "Atajos",
518+
"settings.desktop.section.wsl": "WSL",
519+
"settings.desktop.wsl.title": "WSL integration",
520+
"settings.desktop.wsl.description": "Run the OpenCode server inside WSL on Windows.",
518521

519522
"settings.general.section.appearance": "Apariencia",
520523
"settings.general.section.notifications": "Notificaciones del sistema",

0 commit comments

Comments
 (0)