Skip to content
6 changes: 3 additions & 3 deletions apps/desktop/src/ssh/DesktopSshEnvironment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("sshEnvironment", () => {
yield* fs.makeDirectory(path.join(sshDir, "config.d"), { recursive: true });
yield* fs.writeFileString(
path.join(sshDir, "config"),
["Host devbox", " HostName devbox.example.com", "Include config.d/*.conf", ""].join("\n"),
["Include config.d/*.conf", "Host devbox", " HostName devbox.example.com", ""].join("\n"),
);
yield* fs.writeFileString(
path.join(sshDir, "config.d", "team.conf"),
Expand Down Expand Up @@ -92,7 +92,7 @@ describe("sshEnvironment", () => {
},
{
alias: "devbox",
hostname: "devbox",
hostname: "devbox.example.com",
username: null,
port: null,
source: "ssh-config",
Expand All @@ -106,7 +106,7 @@ describe("sshEnvironment", () => {
},
{
alias: "staging",
hostname: "staging",
hostname: "staging.example.com",
username: null,
port: null,
source: "ssh-config",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/state/desktopSshHosts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ describe("filterDiscoveredSshHosts", () => {
expect(filterDiscoveredSshHosts(suggestions, "PINOT")).toEqual([suggestions[1]]);
});

it("finds a configured alias by its target hostname", () => {
expect(filterDiscoveredSshHosts(hosts, "DEVBOX.LOCAL")).toEqual(hosts);
});

it("returns an empty array when no hosts match", () => {
expect(filterDiscoveredSshHosts(suggestions, "merlot")).toEqual([]);
});
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/state/desktopSshHosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export function filterDiscoveredSshHosts(
const alias = host.alias.toLowerCase();
if (alias.startsWith(normalizedQuery)) {
prefixMatches.push(host);
} else if (alias.includes(normalizedQuery)) {
} else if (
alias.includes(normalizedQuery) ||
host.hostname.toLowerCase().includes(normalizedQuery)
) {
substringMatches.push(host);
}
}
Expand Down
Loading
Loading