mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 00:03:46 +00:00
* feat(ssh): add SSH config host picker for add-host form Users can now click 'Fill from ~/.ssh/config…' to browse available SSH config hosts in a picker, select one, and have the form automatically prefill with resolved connection details (hostname, port, username, auth). Previously, an 'import' button provided bulk sync on this form—confusing and unhelpful when everything was already synced. That action is now available as a secondary 'Add all' option in the picker. * fix(ssh): import filter preservation and label fallback - Reuse search loader on import completion to preserve active filter inside generation guard - Fall back to hostname when manual host has no label, not empty string - Make alias duplicate detection case-insensitive to match config picker behavior - Validate host availability when restoring project group selection - Add aria-selected attribute to picker options for accessibility * fix(ssh): harden config picker import, alias folding, and host targeting Review findings on the ~/.ssh/config picker + bulk add: - Guard config-host resolution with a generation counter so a late resolve cannot overwrite a later pick or a form the user backed out of; freeze the other rows while a pick resolves. - Stop "Add all N" from re-adopting deleted hosts — it now imports without reAdopt, matching the new-host count it advertises. Settings → Import keeps the explicit re-adopt path. - Fold SSH aliases through a shared normalizeSshConfigAlias for import ownership, delete tombstones, reclaim, picker search, and the save-time duplicate check, which now occupies configHost *and* label like the picker. - Persist GSSAPIAuthentication only when a parsed Host entry asks for it, not when `ssh -G` merely echoes the /etc/ssh system default. - Fail closed with unavailable/setup-not-found when an explicit projectHostSetupId names a non-actionable host instead of silently creating the workspace on a sibling host. - Cache the parsed config for the picker session (refresh on open/retry) so filter keystrokes no longer reparse and Include-expand the file, keep the filter usable during loads, add a Retry on load errors, explain an empty Identity file after a config fill, and drop the always-false aria-selected. * refactor(ssh): centralize host result limit and extract folder group val Move SSH_CONFIG_HOST_RESULT_LIMIT to shared types so the renderer's limit message cannot drift from the host's query limit. Extract findActionableFolderProjectGroup to avoid repeating the folder-host-availability check across the composer hook. * fix(ssh): pass -F to ssh -G when HOME differs from passwd home In E2E tests and sandboxes, isolated HOME can differ from the system passwd home. OpenSSH resolves the default config via getpwuid (passwd), while Node's loadUserSshConfig uses os.homedir() (HOME-aware). Pass -F to explicitly specify the config path when they diverge, so ssh -G and the picker resolve the same file. * fix(ssh): verify config host exists before resolving with ssh -G When a user edits ~/.ssh/config and removes a host, the import picker should not fall back to ssh -G's echoed response (which treats any alias as valid). Check the reloaded config file before resolving. - Force reload config on each resolve to catch user edits post-open - Reject aliases not in the current config before calling ssh -G - Add test for deleted alias edge case - Fix workspace-target fallback to honor explicit host selection * fix(ssh): let tombstoned aliases be re-picked in the config picker Allow users to reclaim a deleted SSH host by re-picking it from ~/.ssh/config. Tombstoned aliases now appear in the picker with a "Removed from Orca" badge and remain pickable, but don't count toward "Add all" operations — ensuring passive import never resurrects a deleted alias while still giving the user a recovery path.
203 lines
8.1 KiB
TypeScript
203 lines
8.1 KiB
TypeScript
/**
|
|
* E2E: SSH config bulk import (picker "Add all") vs Settings Import re-adopt.
|
|
* Covers plan cases P5, P6, P7, P9. Picker list/filter/select live in
|
|
* ssh-config-host-picker.spec.ts.
|
|
*/
|
|
|
|
import type { ElectronApplication, Page } from '@stablyai/playwright-test'
|
|
import { expect, test } from './helpers/orca-app'
|
|
import { waitForSessionReady } from './helpers/store'
|
|
import {
|
|
buildSshConfigBody,
|
|
configHostRow,
|
|
expectSshHostAbsentFromSettings,
|
|
expectSshHostListedInSettings,
|
|
makeSshConfigHostPrefix,
|
|
openSshConfigHostPicker,
|
|
openSshHostSettings,
|
|
removeSshTargetByAlias,
|
|
removeSshTargetsByPrefix,
|
|
returnToAppShell,
|
|
seedIsolatedSshConfig,
|
|
seedOrcaSshTargetMatchingAlias,
|
|
type SeededSshConfigHost
|
|
} from './helpers/ssh-config-host-picker'
|
|
|
|
// Why: afterEach deletes every target carrying this prefix; workers loading the
|
|
// module in the same millisecond must not collide on a shared Date.now().
|
|
const HOST_PREFIX = makeSshConfigHostPrefix()
|
|
|
|
function pairHosts(prefix: string): { alpha: SeededSshConfigHost; bravo: SeededSshConfigHost } {
|
|
return {
|
|
alpha: {
|
|
alias: `${prefix}-alpha`,
|
|
hostname: `${prefix}-alpha.example.test`,
|
|
user: 'deploy',
|
|
port: 22
|
|
},
|
|
bravo: {
|
|
alias: `${prefix}-bravo`,
|
|
hostname: `${prefix}-bravo.example.test`,
|
|
user: 'ops',
|
|
port: 2222
|
|
}
|
|
}
|
|
}
|
|
|
|
async function seedPairConfig(
|
|
electronApp: ElectronApplication,
|
|
prefix: string
|
|
): Promise<{ alpha: SeededSshConfigHost; bravo: SeededSshConfigHost }> {
|
|
const hosts = pairHosts(prefix)
|
|
await seedIsolatedSshConfig(electronApp, buildSshConfigBody([hosts.alpha, hosts.bravo]))
|
|
return hosts
|
|
}
|
|
|
|
/** Import both config hosts via picker, then suppress `alias` (removeTarget tombstone). */
|
|
async function importPairThenDeleteAlias(
|
|
page: Page,
|
|
electronApp: ElectronApplication,
|
|
prefix: string,
|
|
aliasToDelete: string
|
|
): Promise<{ alpha: SeededSshConfigHost; bravo: SeededSshConfigHost }> {
|
|
const hosts = await seedPairConfig(electronApp, prefix)
|
|
const picker = await openSshConfigHostPicker(page)
|
|
await expect(picker.getByRole('button', { name: 'Add all 2 to Orca' })).toBeEnabled()
|
|
await picker.getByRole('button', { name: 'Add all 2 to Orca' }).click()
|
|
await expect(page.getByText('Added 2 hosts to Orca.')).toBeVisible({ timeout: 15_000 })
|
|
await expect(page.getByRole('dialog', { name: 'Choose from ~/.ssh/config' })).toBeHidden({
|
|
timeout: 10_000
|
|
})
|
|
await expect(page.getByRole('dialog', { name: 'Add SSH host' })).toBeHidden({
|
|
timeout: 10_000
|
|
})
|
|
await removeSshTargetByAlias(page, aliasToDelete)
|
|
return hosts
|
|
}
|
|
|
|
test.describe('SSH config host import (bulk + settings re-adopt)', () => {
|
|
test.beforeEach(async ({ orcaPage }) => {
|
|
await waitForSessionReady(orcaPage)
|
|
})
|
|
|
|
test.afterEach(async ({ orcaPage }) => {
|
|
await removeSshTargetsByPrefix(orcaPage, HOST_PREFIX).catch(() => undefined)
|
|
})
|
|
|
|
// ── P5 ─────────────────────────────────────────────────────────────
|
|
test('P5: already-in-Orca badge, disabled row, and Add all counts only new hosts', async ({
|
|
electronApp,
|
|
orcaPage
|
|
}) => {
|
|
const hosts = await seedPairConfig(electronApp, HOST_PREFIX)
|
|
await seedOrcaSshTargetMatchingAlias(orcaPage, {
|
|
alias: hosts.alpha.alias,
|
|
hostname: hosts.alpha.hostname,
|
|
username: hosts.alpha.user,
|
|
port: hosts.alpha.port
|
|
})
|
|
|
|
const picker = await openSshConfigHostPicker(orcaPage)
|
|
const alphaRow = configHostRow(picker, hosts.alpha)
|
|
const bravoRow = configHostRow(picker, hosts.bravo)
|
|
|
|
await expect(alphaRow).toBeVisible()
|
|
await expect(alphaRow).toBeDisabled()
|
|
await expect(alphaRow.getByText('In Orca', { exact: true })).toBeVisible()
|
|
|
|
await expect(bravoRow).toBeVisible()
|
|
await expect(bravoRow).toBeEnabled()
|
|
await expect(bravoRow.getByText('In Orca', { exact: true })).toHaveCount(0)
|
|
|
|
await expect(picker.getByRole('button', { name: 'Add all 1 to Orca' })).toBeEnabled()
|
|
await expect(picker.getByRole('button', { name: 'Add all 2 to Orca' })).toHaveCount(0)
|
|
})
|
|
|
|
// ── P6 ─────────────────────────────────────────────────────────────
|
|
test('P6: Add all N to Orca imports new hosts; re-open shows all in Orca', async ({
|
|
electronApp,
|
|
orcaPage
|
|
}) => {
|
|
const hosts = await seedPairConfig(electronApp, HOST_PREFIX)
|
|
const picker = await openSshConfigHostPicker(orcaPage)
|
|
|
|
await expect(configHostRow(picker, hosts.alpha)).toBeVisible()
|
|
await expect(configHostRow(picker, hosts.bravo)).toBeVisible()
|
|
await expect(picker.getByRole('button', { name: 'Add all 2 to Orca' })).toBeEnabled()
|
|
|
|
await picker.getByRole('button', { name: 'Add all 2 to Orca' }).click()
|
|
await expect(orcaPage.getByText('Added 2 hosts to Orca.')).toBeVisible({ timeout: 15_000 })
|
|
await expect(orcaPage.getByRole('dialog', { name: 'Choose from ~/.ssh/config' })).toBeHidden({
|
|
timeout: 10_000
|
|
})
|
|
await expect(orcaPage.getByRole('dialog', { name: 'Add SSH host' })).toBeHidden({
|
|
timeout: 10_000
|
|
})
|
|
|
|
const sshSection = await openSshHostSettings(orcaPage)
|
|
await expectSshHostListedInSettings(sshSection, hosts.alpha)
|
|
await expectSshHostListedInSettings(sshSection, hosts.bravo)
|
|
|
|
await returnToAppShell(orcaPage)
|
|
const reopened = await openSshConfigHostPicker(orcaPage)
|
|
await expect(configHostRow(reopened, hosts.alpha)).toBeDisabled()
|
|
await expect(
|
|
configHostRow(reopened, hosts.alpha).getByText('In Orca', { exact: true })
|
|
).toBeVisible()
|
|
await expect(configHostRow(reopened, hosts.bravo)).toBeDisabled()
|
|
await expect(
|
|
configHostRow(reopened, hosts.bravo).getByText('In Orca', { exact: true })
|
|
).toBeVisible()
|
|
await expect(reopened.getByRole('button', { name: 'All hosts already in Orca' })).toBeDisabled()
|
|
})
|
|
|
|
// ── P7 ─────────────────────────────────────────────────────────────
|
|
test('P7: Add all does not re-adopt deleted config hosts (suppress tombstones)', async ({
|
|
electronApp,
|
|
orcaPage
|
|
}) => {
|
|
const hosts = await importPairThenDeleteAlias(
|
|
orcaPage,
|
|
electronApp,
|
|
HOST_PREFIX,
|
|
`${HOST_PREFIX}-alpha`
|
|
)
|
|
|
|
const picker = await openSshConfigHostPicker(orcaPage)
|
|
// Suppressed aliases are omitted from the picker entirely.
|
|
await expect(configHostRow(picker, hosts.alpha)).toHaveCount(0)
|
|
await expect(configHostRow(picker, hosts.bravo)).toBeVisible()
|
|
await expect(
|
|
configHostRow(picker, hosts.bravo).getByText('In Orca', { exact: true })
|
|
).toBeVisible()
|
|
await expect(picker.getByRole('button', { name: 'All hosts already in Orca' })).toBeDisabled()
|
|
await expect(picker.getByRole('button', { name: /Add all \d+ to Orca/ })).toHaveCount(0)
|
|
|
|
await returnToAppShell(orcaPage)
|
|
const sshSection = await openSshHostSettings(orcaPage)
|
|
// Pane auto-syncs without reAdopt — deleted alpha must stay gone.
|
|
await expectSshHostListedInSettings(sshSection, hosts.bravo)
|
|
await expectSshHostAbsentFromSettings(sshSection, hosts.alpha)
|
|
})
|
|
|
|
// ── P9 ─────────────────────────────────────────────────────────────
|
|
test('P9: Settings Import re-adopts deleted config hosts', async ({ electronApp, orcaPage }) => {
|
|
const hosts = await importPairThenDeleteAlias(
|
|
orcaPage,
|
|
electronApp,
|
|
HOST_PREFIX,
|
|
`${HOST_PREFIX}-alpha`
|
|
)
|
|
|
|
const sshSection = await openSshHostSettings(orcaPage)
|
|
await expectSshHostListedInSettings(sshSection, hosts.bravo)
|
|
await expectSshHostAbsentFromSettings(sshSection, hosts.alpha)
|
|
|
|
await sshSection.getByRole('button', { name: 'Import' }).click()
|
|
await expect(orcaPage.getByText(/Synced \d+ servers?/i)).toBeVisible({ timeout: 15_000 })
|
|
|
|
await expectSshHostListedInSettings(sshSection, hosts.alpha)
|
|
await expectSshHostListedInSettings(sshSection, hosts.bravo)
|
|
})
|
|
})
|