mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-19 07:04:40 +00:00
fix(desktop): set default WebSocket username and prevent repeated calling of terminal spawn properly closing the terminal (#17061)
This commit is contained in:
@@ -16,6 +16,8 @@ import { usePlatform } from "@/context/platform"
|
|||||||
import { normalizeServerUrl, ServerConnection, useServer } from "@/context/server"
|
import { normalizeServerUrl, ServerConnection, useServer } from "@/context/server"
|
||||||
import { checkServerHealth, type ServerHealth } from "@/utils/server-health"
|
import { checkServerHealth, type ServerHealth } from "@/utils/server-health"
|
||||||
|
|
||||||
|
const DEFAULT_USERNAME = "opencode"
|
||||||
|
|
||||||
interface ServerFormProps {
|
interface ServerFormProps {
|
||||||
value: string
|
value: string
|
||||||
name: string
|
name: string
|
||||||
@@ -178,7 +180,7 @@ export function DialogSelectServer() {
|
|||||||
addServer: {
|
addServer: {
|
||||||
url: "",
|
url: "",
|
||||||
name: "",
|
name: "",
|
||||||
username: "",
|
username: DEFAULT_USERNAME,
|
||||||
password: "",
|
password: "",
|
||||||
adding: false,
|
adding: false,
|
||||||
error: "",
|
error: "",
|
||||||
@@ -201,7 +203,7 @@ export function DialogSelectServer() {
|
|||||||
setStore("addServer", {
|
setStore("addServer", {
|
||||||
url: "",
|
url: "",
|
||||||
name: "",
|
name: "",
|
||||||
username: "",
|
username: DEFAULT_USERNAME,
|
||||||
password: "",
|
password: "",
|
||||||
adding: false,
|
adding: false,
|
||||||
error: "",
|
error: "",
|
||||||
@@ -362,8 +364,8 @@ export function DialogSelectServer() {
|
|||||||
http: { url: normalized },
|
http: { url: normalized },
|
||||||
}
|
}
|
||||||
if (store.addServer.name.trim()) conn.displayName = store.addServer.name.trim()
|
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) 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)
|
const result = await checkServerHealth(conn.http, fetcher)
|
||||||
setStore("addServer", { adding: false })
|
setStore("addServer", { adding: false })
|
||||||
if (!result.healthy) {
|
if (!result.healthy) {
|
||||||
@@ -441,7 +443,7 @@ export function DialogSelectServer() {
|
|||||||
showForm: true,
|
showForm: true,
|
||||||
url: "",
|
url: "",
|
||||||
name: "",
|
name: "",
|
||||||
username: "",
|
username: DEFAULT_USERNAME,
|
||||||
password: "",
|
password: "",
|
||||||
error: "",
|
error: "",
|
||||||
status: undefined,
|
status: undefined,
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ export const Terminal = (props: TerminalProps) => {
|
|||||||
url.searchParams.set("directory", sdk.directory)
|
url.searchParams.set("directory", sdk.directory)
|
||||||
url.searchParams.set("cursor", String(start !== undefined ? start : restore ? -1 : 0))
|
url.searchParams.set("cursor", String(start !== undefined ? start : restore ? -1 : 0))
|
||||||
url.protocol = url.protocol === "https:" ? "wss:" : "ws:"
|
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 ?? ""
|
url.password = server.current?.http.password ?? ""
|
||||||
|
|
||||||
const socket = new WebSocket(url)
|
const socket = new WebSocket(url)
|
||||||
|
|||||||
Reference in New Issue
Block a user