fix(app): disable pairing for all ssh servers

This commit is contained in:
Brendan Allan 2026-09-18 15:40:42 +08:00
parent c7586c0479
commit 5cbead5dd5
No known key found for this signature in database
GPG key ID: 41E835AEA046A32E
2 changed files with 26 additions and 8 deletions

View file

@ -237,9 +237,11 @@ function RootSettings() {
...serverTabs.map((item) => ({
...item,
label: language.t(item.label),
disabled: !single() || (item.value === "pairing" && !!singleEntry()?.ssh),
disabled:
!single() ||
(item.value === "pairing" && (singleEntry()?.connection?.type === "ssh" || !!singleEntry()?.ssh)),
tooltip:
item.value === "pairing" && singleEntry()?.ssh
item.value === "pairing" && (singleEntry()?.connection?.type === "ssh" || singleEntry()?.ssh)
? language.t("settings.pairing.sshUnavailable")
: undefined,
onPrefetch: item.value === "workspaces" ? prefetchWorkspaces : undefined,
@ -259,7 +261,12 @@ function RootSettings() {
})
createEffect(() => {
const view = surface.view()
if (view.type === "root" && view.tab === "pairing" && singleEntry()?.ssh) surface.open("general")
if (
view.type === "root" &&
view.tab === "pairing" &&
(singleEntry()?.connection?.type === "ssh" || singleEntry()?.ssh)
)
surface.open("general")
})
const change = (value: string) => {
@ -358,15 +365,23 @@ function ServerSettings(props: { entry: SettingsServer }) {
...item,
label: item.value === "general" ? props.entry.name : language.t(item.label),
disabled:
item.value !== "general" && (!props.entry.connection || (item.value === "pairing" && !!props.entry.ssh)),
item.value !== "general" &&
(!props.entry.connection ||
(item.value === "pairing" && (props.entry.connection.type === "ssh" || !!props.entry.ssh))),
tooltip:
item.value === "pairing" && props.entry.ssh ? language.t("settings.pairing.sshUnavailable") : undefined,
item.value === "pairing" && (props.entry.connection?.type === "ssh" || props.entry.ssh)
? language.t("settings.pairing.sshUnavailable")
: undefined,
onPrefetch: item.value === "workspaces" ? prefetchWorkspaces : undefined,
})),
},
])
createEffect(() => {
if ((!props.entry.connection || props.entry.ssh) && surface.view().tab === "pairing") surface.select("general")
if (
(!props.entry.connection || props.entry.connection.type === "ssh" || props.entry.ssh) &&
surface.view().tab === "pairing"
)
surface.select("general")
if (!props.entry.connection && surface.view().tab !== "general") surface.select("general")
})
const change = (value: string) => {

View file

@ -51,14 +51,17 @@ export function DesktopPairingCommand() {
const servers = useSettingsServers()
command.register("desktop-pairing", () =>
platform.platform === "desktop" && servers().some((server) => server.connection && !server.ssh)
platform.platform === "desktop" &&
servers().some((server) => server.connection && server.connection.type !== "ssh" && !server.ssh)
? [
{
id: "server.pair",
title: language.t("command.server.pair"),
category: language.t("command.category.server"),
onSelect: () => {
const server = servers().find((item) => item.connection && !item.ssh)
const server = servers().find(
(item) => item.connection && item.connection.type !== "ssh" && !item.ssh,
)
if (server) settings.openServer(server.key, "pairing")
},
},