From ccdda0cd161994321845dc87708e8e80dd6ea485 Mon Sep 17 00:00:00 2001 From: OpeOginni Date: Wed, 11 Mar 2026 16:34:46 +0100 Subject: [PATCH 1/4] fix(desktop): set default WebSocket username and prevent repeated calling of terminal spawn properly closing the terminal --- packages/app/src/components/terminal.tsx | 2 +- packages/app/src/pages/session/terminal-panel.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/app/src/components/terminal.tsx b/packages/app/src/components/terminal.tsx index 120af0a1726..fda66917f4b 100644 --- a/packages/app/src/components/terminal.tsx +++ b/packages/app/src/components/terminal.tsx @@ -452,7 +452,7 @@ export const Terminal = (props: TerminalProps) => { url.searchParams.set("directory", sdk.directory) url.searchParams.set("cursor", String(start !== undefined ? start : restore ? -1 : 0)) url.protocol = url.protocol === "https:" ? "wss:" : "ws:" - url.username = server.current?.http.username ?? "" + url.username = server.current?.http.username ?? "opencode" url.password = server.current?.http.password ?? "" const socket = new WebSocket(url) diff --git a/packages/app/src/pages/session/terminal-panel.tsx b/packages/app/src/pages/session/terminal-panel.tsx index a6c3929c10c..4c0fcfc334d 100644 --- a/packages/app/src/pages/session/terminal-panel.tsx +++ b/packages/app/src/pages/session/terminal-panel.tsx @@ -5,6 +5,7 @@ import { Tabs } from "@opencode-ai/ui/tabs" import { ResizeHandle } from "@opencode-ai/ui/resize-handle" import { IconButton } from "@opencode-ai/ui/icon-button" import { TooltipKeybind } from "@opencode-ai/ui/tooltip" +import { showToast } from "@opencode-ai/ui/toast" import { DragDropProvider, DragDropSensors, DragOverlay, SortableProvider, closestCenter } from "@thisbeyond/solid-dnd" import type { DragEvent } from "@thisbeyond/solid-dnd" import { ConstrainDragYAxis, getDraggableId } from "@/utils/solid-dnd" @@ -295,7 +296,14 @@ export function TerminalPanel() { autoFocus={opened()} onConnect={() => terminal.trim(id)} onCleanup={terminal.update} - onConnectError={() => terminal.clone(id)} + onConnectError={async (err) => { + await terminal.close(id) + showToast({ + variant: "error", + title: language.t("terminal.connectionLost.title"), + description: language.t("terminal.connectionLost.description"), + }) + }} /> )} From e1ca6b581b5ae2429ef246d949880c50d67f9dd0 Mon Sep 17 00:00:00 2001 From: OpeOginni Date: Wed, 11 Mar 2026 16:55:31 +0100 Subject: [PATCH 2/4] fix(desktop): revert back to terminal.clone on connection error --- packages/app/src/pages/session/terminal-panel.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/app/src/pages/session/terminal-panel.tsx b/packages/app/src/pages/session/terminal-panel.tsx index 4c0fcfc334d..a6c3929c10c 100644 --- a/packages/app/src/pages/session/terminal-panel.tsx +++ b/packages/app/src/pages/session/terminal-panel.tsx @@ -5,7 +5,6 @@ import { Tabs } from "@opencode-ai/ui/tabs" import { ResizeHandle } from "@opencode-ai/ui/resize-handle" import { IconButton } from "@opencode-ai/ui/icon-button" import { TooltipKeybind } from "@opencode-ai/ui/tooltip" -import { showToast } from "@opencode-ai/ui/toast" import { DragDropProvider, DragDropSensors, DragOverlay, SortableProvider, closestCenter } from "@thisbeyond/solid-dnd" import type { DragEvent } from "@thisbeyond/solid-dnd" import { ConstrainDragYAxis, getDraggableId } from "@/utils/solid-dnd" @@ -296,14 +295,7 @@ export function TerminalPanel() { autoFocus={opened()} onConnect={() => terminal.trim(id)} onCleanup={terminal.update} - onConnectError={async (err) => { - await terminal.close(id) - showToast({ - variant: "error", - title: language.t("terminal.connectionLost.title"), - description: language.t("terminal.connectionLost.description"), - }) - }} + onConnectError={() => terminal.clone(id)} /> )} From 0cd9311d5aede8a94d9c05477e4bc395e4faf089 Mon Sep 17 00:00:00 2001 From: OpeOginni Date: Wed, 11 Mar 2026 17:00:30 +0100 Subject: [PATCH 3/4] fix(desktop): set default username for server connection in dialog select server --- packages/app/src/components/dialog-select-server.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/app/src/components/dialog-select-server.tsx b/packages/app/src/components/dialog-select-server.tsx index 4813ecc45d3..9d77714817b 100644 --- a/packages/app/src/components/dialog-select-server.tsx +++ b/packages/app/src/components/dialog-select-server.tsx @@ -16,6 +16,8 @@ import { usePlatform } from "@/context/platform" import { normalizeServerUrl, ServerConnection, useServer } from "@/context/server" import { checkServerHealth, type ServerHealth } from "@/utils/server-health" +const DEFAULT_USERNAME = "opencode" + interface ServerFormProps { value: string name: string @@ -178,7 +180,7 @@ export function DialogSelectServer() { addServer: { url: "", name: "", - username: "", + username: DEFAULT_USERNAME, password: "", adding: false, error: "", @@ -201,7 +203,7 @@ export function DialogSelectServer() { setStore("addServer", { url: "", name: "", - username: "", + username: DEFAULT_USERNAME, password: "", adding: false, error: "", @@ -441,7 +443,7 @@ export function DialogSelectServer() { showForm: true, url: "", name: "", - username: "", + username: DEFAULT_USERNAME, password: "", error: "", status: undefined, From 47c2b0c32c7ab8e6c624e35729940a185a578da8 Mon Sep 17 00:00:00 2001 From: OpeOginni Date: Wed, 11 Mar 2026 17:12:08 +0100 Subject: [PATCH 4/4] fix(desktop): ensure username is only set when both username and password are provided for server connection --- packages/app/src/components/dialog-select-server.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/src/components/dialog-select-server.tsx b/packages/app/src/components/dialog-select-server.tsx index 9d77714817b..3ecd269104b 100644 --- a/packages/app/src/components/dialog-select-server.tsx +++ b/packages/app/src/components/dialog-select-server.tsx @@ -364,8 +364,8 @@ export function DialogSelectServer() { http: { url: normalized }, } if (store.addServer.name.trim()) conn.displayName = store.addServer.name.trim() - if (store.addServer.username) conn.http.username = store.addServer.username if (store.addServer.password) conn.http.password = store.addServer.password + if (store.addServer.password && store.addServer.username) conn.http.username = store.addServer.username const result = await checkServerHealth(conn.http, fetcher) setStore("addServer", { adding: false }) if (!result.healthy) {