feat: improve quick connect system using plugin api

This commit is contained in:
LukeGus committed 2026-09-28 21:23:06 -05:00
1 parent b4457b6121
commit 44062e30d1
5 files changed
+316 -146

No files matched your search

+20
View File
@@ -1,6 +1,7 @@
import type { SSHHostData } from "@/types";
import type { Host } from "@/types/ui-types";
import type { HostProtocolDef } from "./host-protocols";
import { hostActionsFor, type HostActionDef } from "./host-contributions";
type QuickConnectInput = Pick<
Host,
@@ -98,3 +99,22 @@ export function quickConnectHostToPayload(host: Host): SSHHostData {
sshPort: host.sshPort,
};
}
/**
* Every way to reach the address: connect actions (terminal, RDP, VNC...)
* by priority, then tools that opted into Quick Connect. Only actions that
* open a tab work here, since the host is never saved.
*/
export function quickConnectTargets(
all: HostActionDef[],
host: Host,
): HostActionDef[] {
const usable = hostActionsFor(all, host).filter((action) => action.tabType);
const connects = usable
.filter((action) => action.kind === "connect")
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
const tools = usable.filter(
(action) => action.kind !== "connect" && action.quickConnect,
);
return [...connects, ...tools];
}