Skip to content

Commit eef3ae3

Browse files
Fix/reverception (anomalyco#13166)
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
1 parent fc88dde commit eef3ae3

28 files changed

Lines changed: 773 additions & 701 deletions

File tree

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/session/session-header.tsx

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createEffect, createMemo, createResource, onCleanup, Show } from "solid-js"
1+
import { createEffect, createMemo, onCleanup, Show } from "solid-js"
22
import { createStore } from "solid-js/store"
33
import { Portal } from "solid-js/web"
44
import { useParams } from "@solidjs/router"
@@ -18,7 +18,6 @@ import { IconButton } from "@opencode-ai/ui/icon-button"
1818
import { Button } from "@opencode-ai/ui/button"
1919
import { AppIcon } from "@opencode-ai/ui/app-icon"
2020
import { DropdownMenu } from "@opencode-ai/ui/dropdown-menu"
21-
import { Spinner } from "@opencode-ai/ui/spinner"
2221
import { Tooltip, TooltipKeybind } from "@opencode-ai/ui/tooltip"
2322
import { Popover } from "@opencode-ai/ui/popover"
2423
import { TextField } from "@opencode-ai/ui/text-field"
@@ -168,7 +167,6 @@ export function SessionHeader() {
168167

169168
const [prefs, setPrefs] = persisted(Persist.global("open.app"), createStore({ app: "finder" as OpenApp }))
170169
const [menu, setMenu] = createStore({ open: false })
171-
const [openRequest, setOpenRequest] = createStore({ app: undefined as OpenApp | undefined, version: 0 })
172170

173171
const canOpen = createMemo(() => platform.platform === "desktop" && !!platform.openPath && server.isLocal())
174172
const current = createMemo(() => options().find((o) => o.id === prefs.app) ?? options()[0])
@@ -181,32 +179,20 @@ export function SessionHeader() {
181179
setPrefs("app", options()[0]?.id ?? "finder")
182180
})
183181

184-
const [openTask] = createResource(
185-
() => openRequest.app && openRequest.version,
186-
async () => {
187-
const app = openRequest.app
188-
const directory = projectDirectory()
189-
if (!app || !directory || !canOpen()) return
190-
191-
const item = options().find((o) => o.id === app)
192-
const openWith = item && "openWith" in item ? item.openWith : undefined
193-
await platform.openPath?.(directory, openWith)
194-
},
195-
)
196-
197-
createEffect(() => {
198-
const err = openTask.error
199-
if (!err) return
200-
showToast({
201-
variant: "error",
202-
title: language.t("common.requestFailed"),
203-
description: err instanceof Error ? err.message : String(err),
204-
})
205-
})
206-
207182
const openDir = (app: OpenApp) => {
208-
if (openTask.loading) return
209-
setOpenRequest({ app, version: openRequest.version + 1 })
183+
const directory = projectDirectory()
184+
if (!directory) return
185+
if (!canOpen()) return
186+
187+
const item = options().find((o) => o.id === app)
188+
const openWith = item && "openWith" in item ? item.openWith : undefined
189+
Promise.resolve(platform.openPath?.(directory, openWith)).catch((err: unknown) => {
190+
showToast({
191+
variant: "error",
192+
title: language.t("common.requestFailed"),
193+
description: err instanceof Error ? err.message : String(err),
194+
})
195+
})
210196
}
211197

212198
const copyPath = () => {
@@ -362,18 +348,12 @@ export function SessionHeader() {
362348
<div class="flex h-[24px] box-border items-center rounded-md border border-border-base bg-surface-panel overflow-hidden">
363349
<Button
364350
variant="ghost"
365-
class="rounded-none h-full py-0 pr-3 pl-2 gap-1.5 border-none shadow-none disabled:!cursor-default"
366-
classList={{
367-
"bg-surface-raised-base-active": openTask.loading,
368-
}}
351+
class="rounded-none h-full py-0 pr-3 pl-2 gap-1.5 border-none shadow-none"
369352
onClick={() => openDir(current().id)}
370-
disabled={openTask.loading}
371353
aria-label={language.t("session.header.open.ariaLabel", { app: current().label })}
372354
>
373355
<div class="flex size-5 shrink-0 items-center justify-center">
374-
<Show when={openTask.loading} fallback={<AppIcon id={current().icon} class="size-4" />}>
375-
<Spinner class="size-3.5 text-icon-base" />
376-
</Show>
356+
<AppIcon id={current().icon} class="size-4" />
377357
</div>
378358
<span class="text-12-regular text-text-strong">Open</span>
379359
</Button>
@@ -388,11 +368,7 @@ export function SessionHeader() {
388368
as={IconButton}
389369
icon="chevron-down"
390370
variant="ghost"
391-
disabled={openTask.loading}
392-
class="rounded-none h-full w-[24px] p-0 border-none shadow-none data-[expanded]:bg-surface-raised-base-active disabled:!cursor-default"
393-
classList={{
394-
"bg-surface-raised-base-active": openTask.loading,
395-
}}
371+
class="rounded-none h-full w-[24px] p-0 border-none shadow-none data-[expanded]:bg-surface-raised-base-active"
396372
aria-label={language.t("session.header.open.menu")}
397373
/>
398374
<DropdownMenu.Portal>
@@ -409,7 +385,6 @@ export function SessionHeader() {
409385
{options().map((o) => (
410386
<DropdownMenu.RadioItem
411387
value={o.id}
412-
disabled={openTask.loading}
413388
onSelect={() => {
414389
setMenu("open", false)
415390
openDir(o.id)

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",

0 commit comments

Comments
 (0)