diff --git a/config/repo-host-read-baseline.txt b/config/repo-host-read-baseline.txt index 8bafaca3f0c..f6ee237acf8 100644 --- a/config/repo-host-read-baseline.txt +++ b/config/repo-host-read-baseline.txt @@ -2,19 +2,16 @@ # This is a RATCHET: counts may only go DOWN. Resolve the host instead (see fix text). # A lower bound: destructured and differently named rows are not counted. # Prune after a fix: pnpm check:repo-host-read-ratchet --prune -1 src/cli/automation-destination.ts -1 src/main/workspaces/catalog/folder-repo-git-conversion.ts 1 src/main/github/account-binding-required-host.ts 3 src/main/ipc/ephemeral-vm-recipe-context.ts 2 src/main/ipc/filesystem/filesystem-source-control-ai-targets.ts 1 src/main/ipc/folder-repo-git-upgrade.ts +1 src/main/ipc/local-worktree-runtime-options.ts +4 src/main/ipc/repos/local-repo-registration.ts +1 src/main/ipc/repos/nested-repo-import-handler.ts 2 src/main/ipc/source-control/github-repo-routing.ts 1 src/main/ipc/source-control/github-work-item-args.ts 1 src/main/ipc/source-control/gitlab-repo-access.ts -1 src/main/ipc/local-worktree-runtime-options.ts -1 src/main/ipc/worktrees/removal/registered-worktree-root-owner.ts -4 src/main/ipc/repos/local-repo-registration.ts -1 src/main/ipc/repos/nested-repo-import-handler.ts 2 src/main/ipc/workspace-cleanup/workspace-cleanup-candidate.ts 1 src/main/ipc/workspace-cleanup/workspace-cleanup-disconnected-ssh.ts 1 src/main/ipc/worktrees-test-metadata-pruning-store.ts @@ -24,6 +21,7 @@ 2 src/main/ipc/worktrees/removal/nested-worktree-removal.ts 2 src/main/ipc/worktrees/removal/register-worktree-forget-handlers.ts 1 src/main/ipc/worktrees/removal/register-worktree-removal-handlers.ts +1 src/main/ipc/worktrees/removal/registered-worktree-root-owner.ts 1 src/main/ipc/worktrees/repo-host-ownership.ts 2 src/main/orca-profiles/profile-project-transfer-payload.ts 1 src/main/orca-profiles/profile-project-worktree-identity.ts @@ -36,16 +34,17 @@ 1 src/main/ports/ssh-advertised-url-enrichment.ts 2 src/main/ports/workspace-port-ownership.ts 5 src/main/project-groups/folder-workspace-path-status.ts -1 src/main/workspaces/catalog/provisioned-root-ssh-adoption.ts -2 src/main/workspaces/catalog/repo-git-username-enrichment.ts 1 src/main/runtime/rpc/methods/agent-launch/agent-launch-worktree-creation.ts -1 src/main/runtime/workspaces/catalog/runtime-managed-worktree-queries.ts 3 src/main/runtime/runtime-reference-agents.ts +1 src/main/runtime/workspaces/catalog/runtime-managed-worktree-queries.ts 1 src/main/runtime/workspaces/catalog/runtime-worktree-selection.ts 1 src/main/ssh/targets/ssh-target-orcad-claims.ts -1 src/main/workspaces/space-analysis/workspace-space-worktree-row.ts +1 src/main/workspaces/catalog/folder-repo-git-conversion.ts +1 src/main/workspaces/catalog/provisioned-root-ssh-adoption.ts +2 src/main/workspaces/catalog/repo-git-username-enrichment.ts 1 src/main/workspaces/creation/worktree-create-base-prefetch.ts 2 src/main/workspaces/removal/retirement/worktree-name-retirement.ts +1 src/main/workspaces/space-analysis/workspace-space-worktree-row.ts 1 src/shared/endpoint-catalog-adoption.ts 1 src/shared/folder-workspaces/folder-workspace-execution-host.ts 1 src/shared/github/github-cache-key.ts diff --git a/mobile/src/automations/automation-reply-schema.ts b/mobile/src/automations/automation-reply-schema.ts index d49d4fcd87f..5de365b48e5 100644 --- a/mobile/src/automations/automation-reply-schema.ts +++ b/mobile/src/automations/automation-reply-schema.ts @@ -146,7 +146,8 @@ export const sshInventorySchema = z.object({ z.object({ id: z.string(), label: z.string(), - generation: z.number().int().positive().optional() + generation: z.number().int().positive().optional(), + managedServer: z.literal(true).optional().catch(undefined) }) ) }) diff --git a/mobile/src/automations/automation-run-presentation.ts b/mobile/src/automations/automation-run-presentation.ts index 1802ccaca63..d322bc30bbc 100644 --- a/mobile/src/automations/automation-run-presentation.ts +++ b/mobile/src/automations/automation-run-presentation.ts @@ -93,6 +93,12 @@ const COPY: Record< translate('automations.runFailures.wslMoveInProgress', EN.wslMoveInProgress), wslMoveOwnedByHost: () => translate('automations.runFailures.wslMoveOwnedByHost', EN.wslMoveOwnedByHost), + managedHostServer: (params) => { + const host = params?.host + return typeof host === 'string' + ? translate('automations.runFailures.managedHostServer', EN.managedHostServer, { host }) + : null + }, missedGraceWindow: () => translate('automations.runFailures.missedGraceWindow', EN.missedGraceWindow), targetMissing: () => translate('automations.runFailures.targetMissing', EN.targetMissing), diff --git a/mobile/src/automations/automation-target-inventory.ts b/mobile/src/automations/automation-target-inventory.ts index da4505cb900..a3748d48180 100644 --- a/mobile/src/automations/automation-target-inventory.ts +++ b/mobile/src/automations/automation-target-inventory.ts @@ -57,8 +57,17 @@ export async function loadAutomationTargets(client: RpcClient, limit = 200) { }) const repoLookup = createRepoRowExecutionHostLookup(repoRows) const projectRows = automationProjectsRead.interpret(projects).projects + const sshTargets = automationSshTargetsRead.interpret(ssh).targets return { setups: automationSetupsRead.interpret(setups).setups.flatMap((setup) => { + // A managed SSH host's automations live on its Orca server; pick that host instead. + const host = parseExecutionHostId(setup.hostId) + if ( + host?.kind === 'ssh' && + sshTargets.some((target) => target.id === host.targetId && target.managedServer) + ) { + return [] + } const repo = repoRows.find( (repo) => repo.id === setup.repoId && @@ -94,7 +103,7 @@ export async function loadAutomationTargets(client: RpcClient, limit = 200) { truncated: workspaceReply.truncated, hostScope: workspaceReply.hostScope }, - sshTargets: automationSshTargetsRead.interpret(ssh).targets + sshTargets } } export type AutomationTargets = Awaited> diff --git a/mobile/src/i18n/en-runtime-required.json b/mobile/src/i18n/en-runtime-required.json index fdf854169b9..4f0861c1fe5 100644 --- a/mobile/src/i18n/en-runtime-required.json +++ b/mobile/src/i18n/en-runtime-required.json @@ -53,7 +53,8 @@ "workspaceHostAmbiguous": "The automation workspace spans more than one host, so Orca cannot tell which one to run it on.", "wslDistroStopped": "The WSL distro {{distro}} is stopped, so this scheduled run did not start it. Start the distro or use Run now; later runs go ahead while it runs.", "wslMoveInProgress": "This automation's project is moving to its WSL host, so Orca skipped this run. Runs resume when the move finishes.", - "wslMoveOwnedByHost": "This automation's project now runs on its WSL host, which runs this automation there. Orca no longer runs this local copy." + "wslMoveOwnedByHost": "This automation's project now runs on its WSL host, which runs this automation there. Orca no longer runs this local copy.", + "managedHostServer": "Needs migration to {{host}}" } }, "chat": { diff --git a/mobile/src/i18n/locales/de.json b/mobile/src/i18n/locales/de.json index f11df01312d..ae32df2db05 100644 --- a/mobile/src/i18n/locales/de.json +++ b/mobile/src/i18n/locales/de.json @@ -4075,6 +4075,7 @@ "noRunnableHost": "Dieser Automatisierung fehlt ein Host zur Ausführung.", "wslMoveInProgress": "Das Projekt dieser Automatisierung wird auf seinen WSL-Host verschoben. Deshalb hat Orca diese Ausführung übersprungen. Die Ausführungen werden nach Abschluss des Verschiebens fortgesetzt.", "wslMoveOwnedByHost": "Das Projekt dieser Automatisierung läuft jetzt auf seinem WSL-Host, der die Automatisierung dort ausführt. Orca führt diese lokale Kopie nicht mehr aus.", + "managedHostServer": "Migration zu {{host}} erforderlich", "missedGraceWindow": "Bei der nächsten Prüfung durch Orca war die Nachholfrist für diese verpasste Ausführung bereits abgelaufen.", "targetMissing": "Der Host der Automatisierung ist nicht mehr registriert. Daher gibt es für diese Automatisierung keinen Ausführungsort.", "targetReplaced": "Der Host der Automatisierung wurde entfernt und erneut registriert. Daher muss diese Automatisierung vor der Ausführung erneut zugeordnet werden.", diff --git a/mobile/src/i18n/locales/en.json b/mobile/src/i18n/locales/en.json index 7a7506f53ee..0c9bca6bce1 100644 --- a/mobile/src/i18n/locales/en.json +++ b/mobile/src/i18n/locales/en.json @@ -4649,6 +4649,7 @@ "noRunnableHost": "This automation has no host to run on.", "wslMoveInProgress": "This automation's project is moving to its WSL host, so Orca skipped this run. Runs resume when the move finishes.", "wslMoveOwnedByHost": "This automation's project now runs on its WSL host, which runs this automation there. Orca no longer runs this local copy.", + "managedHostServer": "Needs migration to {{host}}", "missedGraceWindow": "This run was past its missed-run grace window when Orca next checked.", "targetMissing": "The automation host is no longer registered, so this automation has nowhere to run.", "targetReplaced": "The automation host was removed and re-registered, so this automation must be re-adopted before it can run.", diff --git a/mobile/src/i18n/locales/es.json b/mobile/src/i18n/locales/es.json index 73ce5371647..4c0f716daab 100644 --- a/mobile/src/i18n/locales/es.json +++ b/mobile/src/i18n/locales/es.json @@ -4173,6 +4173,7 @@ "noRunnableHost": "Esta automatización no tiene host donde ejecutarse.", "wslMoveInProgress": "El proyecto de esta automatización se está moviendo a su host WSL, por lo que Orca omitió esta ejecución. Las ejecuciones se reanudarán cuando termine el traslado.", "wslMoveOwnedByHost": "El proyecto de esta automatización ahora se ejecuta en su host WSL, que ejecuta allí esta automatización. Orca ya no ejecuta esta copia local.", + "managedHostServer": "Requiere migración a {{host}}", "missedGraceWindow": "Cuando Orca volvió a comprobarlo, ya había vencido el período de gracia para recuperar esta ejecución omitida.", "targetMissing": "El host de la automatización ya no está registrado, por lo que esta automatización no tiene dónde ejecutarse.", "targetReplaced": "El host de la automatización se eliminó y se volvió a registrar, por lo que hay que volver a vincular esta automatización antes de poder ejecutarla.", diff --git a/mobile/src/i18n/locales/fr.json b/mobile/src/i18n/locales/fr.json index 8f7d3e7ea41..37d58de80ce 100644 --- a/mobile/src/i18n/locales/fr.json +++ b/mobile/src/i18n/locales/fr.json @@ -4173,6 +4173,7 @@ "noRunnableHost": "Cette automatisation n’a pas d’hôte sur lequel s’exécuter.", "wslMoveInProgress": "Le projet de cette automatisation est en cours de déplacement vers son hôte WSL. Orca a donc ignoré cette exécution. Les exécutions reprendront à la fin du déplacement.", "wslMoveOwnedByHost": "Le projet de cette automatisation s’exécute désormais sur son hôte WSL, qui y exécute cette automatisation. Orca n’exécute plus cette copie locale.", + "managedHostServer": "Migration vers {{host}} requise", "missedGraceWindow": "Lors de la vérification suivante par Orca, la marge de rattrapage de cette exécution manquée était déjà dépassée.", "targetMissing": "L’hôte de l’automatisation n’est plus enregistré. Cette automatisation n’a donc plus d’hôte sur lequel s’exécuter.", "targetReplaced": "L’hôte de l’automatisation a été supprimé puis réenregistré. Cette automatisation doit donc être rattachée à nouveau avant de pouvoir s’exécuter.", diff --git a/mobile/src/i18n/locales/ja.json b/mobile/src/i18n/locales/ja.json index 8a1ec60fc62..542b4989398 100644 --- a/mobile/src/i18n/locales/ja.json +++ b/mobile/src/i18n/locales/ja.json @@ -4071,6 +4071,7 @@ "noRunnableHost": "このオートメーションには実行するホストがありません。", "wslMoveInProgress": "このオートメーションのプロジェクトを WSL ホストへ移動中のため、Orca は今回の実行をスキップしました。移動が完了すると実行が再開されます。", "wslMoveOwnedByHost": "このオートメーションのプロジェクトは現在 WSL ホスト上で動作しており、オートメーションもそこで実行されます。Orca はこのローカルコピーを実行しなくなりました。", + "managedHostServer": "{{host}} への移行が必要", "missedGraceWindow": "Orca が次に確認した時点で、この実行は実行漏れの猶予時間を過ぎていました。", "targetMissing": "オートメーションのホストは登録されていないため、このオートメーションを実行する場所がありません。", "targetReplaced": "オートメーションのホストが削除され、再登録されたため、実行するにはこのオートメーションを再度関連付ける必要があります。", diff --git a/mobile/src/i18n/locales/ko.json b/mobile/src/i18n/locales/ko.json index d0556babd51..c35be7ede91 100644 --- a/mobile/src/i18n/locales/ko.json +++ b/mobile/src/i18n/locales/ko.json @@ -4071,6 +4071,7 @@ "noRunnableHost": "이 자동화에는 실행할 호스트가 없습니다.", "wslMoveInProgress": "이 자동화의 프로젝트를 WSL 호스트로 옮기는 중이어서 Orca가 이번 실행을 건너뛰었습니다. 이동이 끝나면 실행이 재개됩니다.", "wslMoveOwnedByHost": "이 자동화의 프로젝트는 이제 WSL 호스트에서 실행되며, 해당 호스트가 그곳에서 이 자동화를 실행합니다. Orca는 더 이상 이 로컬 사본을 실행하지 않습니다.", + "managedHostServer": "{{host}}(으)로 마이그레이션 필요", "missedGraceWindow": "Orca가 다시 확인했을 때 이 실행을 보충할 수 있는 유예 시간이 이미 지나 있었습니다.", "targetMissing": "자동화 호스트가 더 이상 등록되어 있지 않아 이 자동화를 실행할 곳이 없습니다.", "targetReplaced": "자동화 호스트가 제거된 후 다시 등록되었으므로, 이 자동화를 실행하려면 다시 연결해야 합니다.", diff --git a/mobile/src/i18n/locales/pt.json b/mobile/src/i18n/locales/pt.json index 95ca5cfbaf4..4aa19e63f2d 100644 --- a/mobile/src/i18n/locales/pt.json +++ b/mobile/src/i18n/locales/pt.json @@ -4173,6 +4173,7 @@ "noRunnableHost": "Esta automação não tem host onde ser executada.", "wslMoveInProgress": "O projeto desta automação está sendo movido para seu host WSL, por isso o Orca ignorou esta execução. As execuções serão retomadas quando a movimentação terminar.", "wslMoveOwnedByHost": "O projeto desta automação agora é executado em seu host WSL, que também executa esta automação. O Orca não executa mais esta cópia local.", + "managedHostServer": "Requer migração para {{host}}", "missedGraceWindow": "Quando o Orca verificou novamente, o período de tolerância para recuperar esta execução perdida já havia expirado.", "targetMissing": "O host da automação não está mais registrado, então esta automação não tem onde ser executada.", "targetReplaced": "O host da automação foi removido e registrado novamente, então esta automação precisa ser vinculada novamente antes de poder ser executada.", diff --git a/mobile/src/i18n/locales/ru.json b/mobile/src/i18n/locales/ru.json index 4a17cf0f4a8..1b6ef261eb4 100644 --- a/mobile/src/i18n/locales/ru.json +++ b/mobile/src/i18n/locales/ru.json @@ -4271,6 +4271,7 @@ "noRunnableHost": "У этой автоматизации нет сервера выполнения.", "wslMoveInProgress": "Проект этой автоматизации переносится на свой сервер WSL, поэтому Orca пришлось пропустить этот запуск. Запуски возобновятся после завершения переноса.", "wslMoveOwnedByHost": "Проект этой автоматизации теперь работает на своём сервере WSL, который выполняет эту автоматизацию там. Orca больше не запускает эту локальную копию.", + "managedHostServer": "Требуется перенос на {{host}}", "missedGraceWindow": "При следующей проверке Orca допустимая задержка для этого пропущенного запуска уже была превышена.", "targetMissing": "Сервер автоматизации больше не зарегистрирован, поэтому эту автоматизацию негде запускать.", "targetReplaced": "Сервер автоматизации был удалён и зарегистрирован заново, поэтому перед запуском эту автоматизацию нужно повторно привязать.", diff --git a/mobile/src/i18n/locales/tr.json b/mobile/src/i18n/locales/tr.json index 030cd0b438c..57c9cda3b53 100644 --- a/mobile/src/i18n/locales/tr.json +++ b/mobile/src/i18n/locales/tr.json @@ -4075,6 +4075,7 @@ "noRunnableHost": "Bu otomasyonun çalışacağı bir sunucu yok.", "wslMoveInProgress": "Bu otomasyonun projesi WSL ana makinesine taşınıyor. Bu nedenle Orca bu çalıştırmayı atladı. Taşıma tamamlandığında çalıştırmalar devam edecek.", "wslMoveOwnedByHost": "Bu otomasyonun projesi artık WSL ana makinesinde çalışıyor ve bu otomasyon da orada ana makine tarafından çalıştırılıyor. Orca artık bu yerel kopyayı çalıştırmıyor.", + "managedHostServer": "{{host}} üzerine taşınması gerekiyor", "missedGraceWindow": "Orca'nın bir sonraki kontrolünde bu çalıştırma, kaçırılan çalıştırmalar için tanınan tolerans süresini aşmıştı.", "targetMissing": "Otomasyon sunucusu artık kayıtlı olmadığından bu otomasyonun çalışacağı bir yer yok.", "targetReplaced": "Otomasyon sunucusu kaldırılıp yeniden kaydedildiği için bu otomasyonun çalıştırılmadan önce yeniden ilişkilendirilmesi gerekiyor.", diff --git a/mobile/src/i18n/locales/zh-Hant.json b/mobile/src/i18n/locales/zh-Hant.json index 88ae1a94589..cad84154164 100644 --- a/mobile/src/i18n/locales/zh-Hant.json +++ b/mobile/src/i18n/locales/zh-Hant.json @@ -4071,6 +4071,7 @@ "noRunnableHost": "此自動化沒有可供執行的主機。", "wslMoveInProgress": "此自動化的專案正在移至其 WSL 主機,因此 Orca 略過了此次執行。移動完成後便會恢復執行。", "wslMoveOwnedByHost": "此自動化的專案現在在其 WSL 主機上執行,自動化本身也由該主機執行。Orca 不再執行這個本機副本。", + "managedHostServer": "需要遷移到 {{host}}", "missedGraceWindow": "Orca 再次檢查時,此次執行的補執行寬限期已過。", "targetMissing": "自動化主機已不在註冊清單中,因此已無處執行此自動化。", "targetReplaced": "自動化主機已被移除並重新註冊,因此必須為此自動化重新建立關聯後才能執行。", diff --git a/mobile/src/i18n/locales/zh.json b/mobile/src/i18n/locales/zh.json index 4b2c3b7831b..d69ed39eacf 100644 --- a/mobile/src/i18n/locales/zh.json +++ b/mobile/src/i18n/locales/zh.json @@ -4071,6 +4071,7 @@ "noRunnableHost": "此自动化没有可运行的主机。", "wslMoveInProgress": "此自动化的项目正在移到其 WSL 主机,因此 Orca 跳过了此次运行。移动完成后将恢复运行。", "wslMoveOwnedByHost": "此自动化的项目现在在其 WSL 主机上运行,自动化本身也由该主机运行。Orca 不再运行此本地副本。", + "managedHostServer": "需要迁移到 {{host}}", "missedGraceWindow": "Orca 再次检查时,此次运行的补跑宽限期已过。", "targetMissing": "自动化主机已不在注册列表中,因此此自动化已无处运行。", "targetReplaced": "自动化主机已被移除并重新注册,因此必须重新关联此自动化后才能运行。", diff --git a/src/cli/automation-destination.ts b/src/cli/automation-destination.ts index ac5ef81b553..6c4ec24adb6 100644 --- a/src/cli/automation-destination.ts +++ b/src/cli/automation-destination.ts @@ -8,7 +8,10 @@ import type { AutomationDestination } from '../shared/automation-owner-precondit import type { RuntimeWorktreeRecord } from '../shared/runtime-types' import type { SshTargetSummary } from '../shared/ssh-types' import type { Repo } from '../shared/repo-types' -import type { RuntimeClient } from './runtime-client' +import { getRepoRoutingConnectionId } from '../shared/execution-host' +import { getManagedOrcadSshTargetId } from '../shared/managed-orcad-execution-host' +import { listEnvironments } from '../shared/remote-runtime/host-store/runtime-environment-store' +import { RuntimeClient } from './runtime-client' import { fetchSshTargetSummaries } from './host-selector-alternatives' /** Empty selectors mean the execution host cannot change. */ @@ -17,17 +20,21 @@ export type AutomationDestinationTarget = { repo?: string; workspace?: string } async function resolveTargetRepo( client: RuntimeClient, target: AutomationDestinationTarget -): Promise { +): Promise<{ repo: Repo; worktreeId?: string }> { if (target.repo) { - return (await client.call<{ repo: Repo }>('repo.show', { repo: target.repo })).result.repo + return { + repo: (await client.call<{ repo: Repo }>('repo.show', { repo: target.repo })).result.repo + } } const worktree = ( await client.call<{ worktree: RuntimeWorktreeRecord }>('worktree.show', { worktree: target.workspace }) ).result.worktree - return (await client.call<{ repo: Repo }>('repo.show', { repo: `id:${worktree.repoId}` })).result - .repo + const { repo } = ( + await client.call<{ repo: Repo }>('repo.show', { repo: `id:${worktree.repoId}` }) + ).result + return { repo, worktreeId: worktree.id } } // A registered target without a generation needs no fence; an unregistered target is gone. @@ -43,20 +50,77 @@ async function sshTargetGeneration( return match.generation } +type AutomationWriteTarget = { + destination?: AutomationDestination + repo?: Repo + worktreeId?: string +} + +async function resolveAutomationWriteTarget( + client: RuntimeClient, + target: AutomationDestinationTarget +): Promise { + if (!target.repo && !target.workspace) { + return {} + } + const { repo, worktreeId } = await resolveTargetRepo(client, target) + const connectionId = getRepoRoutingConnectionId(repo) + if (!connectionId) { + return { destination: { selector: { kind: 'self' } }, repo, worktreeId } + } + const generation = await sshTargetGeneration(client, connectionId) + return generation === undefined + ? { repo, worktreeId } + : { + destination: { + selector: { kind: 'ssh', targetId: connectionId, targetGeneration: generation } + }, + repo, + worktreeId + } +} + +/** The destination an edit names; the desktop refuses one on a managed SSH host. */ export async function resolveAutomationDestination( client: RuntimeClient, target: AutomationDestinationTarget ): Promise { - if (!target.repo && !target.workspace) { - return undefined + return (await resolveAutomationWriteTarget(client, target)).destination +} + +/** A local CLI creates a managed SSH host's automation on its Orca server (#24863), by the ids both share. */ +export async function routeAutomationCreate< + TCreate extends { repo?: string; workspace?: string; runContext?: unknown } +>( + client: RuntimeClient, + target: AutomationDestinationTarget, + create: TCreate +): Promise<{ writer: RuntimeClient; params: TCreate & { destination?: AutomationDestination } }> { + const { destination, repo, worktreeId } = await resolveAutomationWriteTarget(client, target) + const here = { writer: client, params: { ...create, ...(destination ? { destination } : {}) } } + const connectionId = repo ? getRepoRoutingConnectionId(repo) : null + const server = + repo && connectionId && client.isRemote === false + ? listEnvironments(client.userDataPath).find( + (environment) => getManagedOrcadSshTargetId(environment) === connectionId + ) + : undefined + if (!repo || !server) { + return here } - const repo = await resolveTargetRepo(client, target) - const connectionId = repo.connectionId?.trim() - if (!connectionId) { - return { selector: { kind: 'self' } } + const writer = new RuntimeClient(client.userDataPath, undefined, null, server.id) + const { repos } = (await writer.call<{ repos: Pick[] }>('repo.list')).result + // A project only on the desktop's copy goes to the desktop, which refuses it. + if (!repos.some((entry) => entry.id === repo.id)) { + return here } - const generation = await sshTargetGeneration(client, connectionId) - return generation === undefined - ? undefined - : { selector: { kind: 'ssh', targetId: connectionId, targetGeneration: generation } } + return { + writer, + params: { + ...create, + runContext: undefined, + repo: create.repo === undefined ? undefined : `id:${repo.id}`, + ...(worktreeId ? { workspace: `id:${worktreeId}` } : {}) + } + } } diff --git a/src/cli/handlers/automations.ts b/src/cli/handlers/automations.ts index 675af56219a..1dbf5c33af9 100644 --- a/src/cli/handlers/automations.ts +++ b/src/cli/handlers/automations.ts @@ -26,7 +26,7 @@ import { getOptionalStringFlag, getRequiredStringFlag } from '../flags' -import { resolveAutomationDestination } from '../automation-destination' +import { resolveAutomationDestination, routeAutomationCreate } from '../automation-destination' import { AUTOMATION_RUNS_PAGE_SIZE, automationRunsRpc, @@ -199,11 +199,11 @@ export const AUTOMATION_HANDLERS: Record = { ...schedule } satisfies AutomationCreateParams await assertAutomationFieldsSupported(client, create) - const destination = await resolveAutomationDestination(client, target) - const result = await client.call<{ automation: Automation }>('automation.create', { - ...create, - ...(destination ? { destination } : {}) - }) + const { writer, params } = await routeAutomationCreate(client, target, create) + if (writer !== client) { + await assertAutomationFieldsSupported(writer, create) + } + const result = await writer.call<{ automation: Automation }>('automation.create', params) printResult(result, json, formatAutomationShow) }, 'automations edit': async ({ flags, client, cwd, json }) => { diff --git a/src/main/automations/orcad-fenced-automation.ts b/src/main/automations/orcad-fenced-automation.ts index b8c2b07bab0..da212405c31 100644 --- a/src/main/automations/orcad-fenced-automation.ts +++ b/src/main/automations/orcad-fenced-automation.ts @@ -1,11 +1,14 @@ import { getAppEnvironment } from '../../shared/app-environment' import type { Automation } from '../../shared/automations-types' +import type { SshTarget } from '../../shared/ssh-types' import type { Store } from '../persistence/loading-store/store' +import { isManagedOrcadSshTarget } from '../ssh/connection/ssh-connection-store' +import { moveProjectToManagedHostFirst } from '../../shared/managed-orcad-ssh-owner' import { listOrcadMigrationCutoverChainForTarget } from '../ssh/orcad-migration-cutover-journal' export const ORCAD_FENCED_AUTOMATION = "This automation now runs on its SSH host's Orca server." -/** While a move is in flight, or once it took this row, any desktop write would break or duplicate it. Rows Move anyway left behind stay runnable here. */ +/** While a move is in flight, or once it took this row, any desktop write would break or duplicate it. Rows Move anyway left behind stay listed, skipped by managedOrcadHostOf. */ export function isOrcadFencedAutomation( store: Pick, automation: Pick, @@ -33,3 +36,46 @@ export function isOrcadFencedAutomation( ) ) } + +/** A desktop row on a host its managed Orca server now serves: it can never run here (#27499). */ +export function managedOrcadHostOf( + store: Pick, + automation: Pick +): SshTarget | null { + // The owner selector also covers local rows pinned to an SSH workspace. + const selector = store.automationOwnerPrecondition(automation.id)?.selector + const targetId = + selector?.kind === 'ssh' + ? selector.targetId + : automation.executionTargetType === 'ssh' + ? automation.executionTargetId + : null + const target = targetId ? store.getSshTarget(targetId) : undefined + return target && isManagedOrcadSshTarget(target) ? target : null +} + +type SshLandingRow = Pick +type SshLandingPin = { targetId: string } | null | undefined + +/** The SSH host a row runs on: its own target, or the one its workspace is pinned to. */ +function landingSshTargetId(row: SshLandingRow, pin: SshLandingPin): string | undefined { + return row.executionTargetType === 'ssh' ? row.executionTargetId : pin?.targetId +} + +/** A desktop row may not newly land on a managed host: it could never run here. */ +export function refuseManagedOrcadHost( + state: { sshTargets?: readonly SshTarget[] }, + row: SshLandingRow, + pin: SshLandingPin, + previousRow?: SshLandingRow, + previousPin?: SshLandingPin +): void { + const targetId = landingSshTargetId(row, pin) + if (!targetId || (previousRow && landingSshTargetId(previousRow, previousPin) === targetId)) { + return + } + const target = state.sshTargets?.find((entry) => entry.id === targetId) + if (target && isManagedOrcadSshTarget(target)) { + throw new Error(moveProjectToManagedHostFirst(target.label)) + } +} diff --git a/src/main/automations/run-target-resolution.test.ts b/src/main/automations/run-target-resolution.test.ts index 274b94ad1e7..e11ced95138 100644 --- a/src/main/automations/run-target-resolution.test.ts +++ b/src/main/automations/run-target-resolution.test.ts @@ -171,3 +171,59 @@ describe('resolveAutomationRunTarget projectId drift', () => { }) }) }) + +describe('resolveAutomationRunTarget on a managed SSH host', () => { + it('skips a desktop row whose SSH host now runs automations on its Orca server', () => { + const sshContext = { hostId: 'ssh:box', path: '/srv/repo' } as const + const store = makeStore( + [makeSetup(sshContext)], + [makeRepo({ connectionId: 'box', path: '/srv/repo' })] + ) + store.getSshTarget = (id: string) => + id === 'box' + ? { + id, + label: 'Build box', + host: 'box', + port: 22, + username: 'me', + orcadFence: { environmentId: 'env-1' } + } + : undefined + const automation = makeAutomation(makeRunContext(sshContext), { + executionTargetType: 'ssh', + executionTargetId: 'box' + }) + + expect(resolveAutomationRunTarget(store, automation)).toMatchObject({ + ok: false, + errorCode: 'managedHostServer', + errorParams: { host: 'Build box' } + }) + }) +}) + +describe('resolveAutomationRunTarget on a managed SSH workspace pin', () => { + it('skips a local row whose pinned workspace is on a managed SSH host', () => { + const store = makeStore([makeSetup()], [makeRepo()]) + store.automationOwnerPrecondition = () => ({ + selector: { kind: 'ssh', targetId: 'box', targetGeneration: 7 } + }) + store.getSshTarget = (id: string) => + id === 'box' + ? { + id, + label: 'Build box', + host: 'box', + port: 22, + username: 'me', + orcadFence: { environmentId: 'env-1' } + } + : undefined + + expect(resolveAutomationRunTarget(store, makeAutomation(makeRunContext()))).toMatchObject({ + ok: false, + errorCode: 'managedHostServer' + }) + }) +}) diff --git a/src/main/automations/run-target-resolution.ts b/src/main/automations/run-target-resolution.ts index 2030ab24064..a7b83db01cf 100644 --- a/src/main/automations/run-target-resolution.ts +++ b/src/main/automations/run-target-resolution.ts @@ -21,7 +21,11 @@ import { type AutomationRunFailure } from '../../shared/automation-run-failure-copy' import { AutomationDispatchCancelledError } from './automation-dispatch-cancelled-error' -import { isOrcadFencedAutomation, ORCAD_FENCED_AUTOMATION } from './orcad-fenced-automation' +import { + isOrcadFencedAutomation, + managedOrcadHostOf, + ORCAD_FENCED_AUTOMATION +} from './orcad-fenced-automation' export type AutomationRunTargetResult = | { ok: true; cwd: string; repo: Repo; setup?: ProjectHostSetup } @@ -151,6 +155,10 @@ export function resolveAutomationRunTarget( automation: Automation, options: AutomationRunTargetOptions = {} ): AutomationRunTargetResult { + const managedHost = managedOrcadHostOf(store, automation) + if (managedHost) { + return { ok: false, ...automationRunFailure('managedHostServer', { host: managedHost.label }) } + } const context = automation.runContext ?? null if (!context) { return resolveLegacyAutomationRunTarget(store, automation) diff --git a/src/main/persistence/scheduling-automations/automation-definition-operations.ts b/src/main/persistence/scheduling-automations/automation-definition-operations.ts index 05844d8c0a7..f3f7aa360bb 100644 --- a/src/main/persistence/scheduling-automations/automation-definition-operations.ts +++ b/src/main/persistence/scheduling-automations/automation-definition-operations.ts @@ -42,6 +42,7 @@ import { normalizeAutomationSessionReuse, normalizeAutomationSetupDecisionForWorkspaceMode } from './automation-context-migration' +import { refuseManagedOrcadHost } from '../../automations/orcad-fenced-automation' import { automationProjectionContext, automationWorkspaceSshPin, @@ -93,6 +94,7 @@ export function createAutomation( ), workspaceSshPin }) + refuseManagedOrcadHost(operations.state, executionTarget, workspaceSshPin) if (options?.destination) { const context = automationProjectionContext( operations.state, @@ -289,6 +291,7 @@ export function updateAutomation( workspaceSshPin, workspaceSshPinMoved }) + refuseManagedOrcadHost(operations.state, executionTarget, workspaceSshPin, current, previousPin) if (options?.destination) { assertExecutionTargetMatchesDestination(executionTarget, options.destination, workspaceSshPin) } diff --git a/src/main/persistence/scheduling-automations/automation-managed-host-boundary.test.ts b/src/main/persistence/scheduling-automations/automation-managed-host-boundary.test.ts new file mode 100644 index 00000000000..226ca6db029 --- /dev/null +++ b/src/main/persistence/scheduling-automations/automation-managed-host-boundary.test.ts @@ -0,0 +1,51 @@ +import { describe, expect, it } from 'vitest' +import type { AutomationCreateInput } from '../../../shared/automations-types' +import { getDefaultPersistedState } from '../../../shared/constants' +import { createAutomation } from './automation-definition-operations' + +// Desktop rows on a managed SSH host never run; the desktop store refuses new ones for any caller. +describe('desktop automation create on a managed SSH host', () => { + it('refuses the write and keeps the store unchanged', () => { + const state = getDefaultPersistedState('/home/me') + state.sshTargets = [ + { + id: 'box', + label: 'Build box', + host: 'box', + port: 22, + username: 'me', + generation: 3, + orcadFence: { environmentId: 'env-1' } + } + ] + state.repos = [ + { + id: 'repo-1', + path: '/srv/repo', + displayName: 'Repo', + badgeColor: '#000', + addedAt: 1, + connectionId: 'box' + } + ] + const input: AutomationCreateInput = { + name: 'Nightly', + prompt: 'Run checks', + agentId: 'claude', + projectId: 'repo-1', + workspaceMode: 'new_per_run', + rrule: 'FREQ=DAILY', + dtstart: 1, + timezone: 'UTC' + } + const operations = { + state, + storageAuthority: 'desktop' as const, + flush: () => undefined, + recordCreated: () => undefined + } + + expect(() => createAutomation(operations, input)).toThrow() + expect(state.automations ?? []).toEqual([]) + }) +}) diff --git a/src/main/runtime/rpc/methods/ssh/ssh.ts b/src/main/runtime/rpc/methods/ssh/ssh.ts index c4a2e6a8ecb..551d6a80a56 100644 --- a/src/main/runtime/rpc/methods/ssh/ssh.ts +++ b/src/main/runtime/rpc/methods/ssh/ssh.ts @@ -33,7 +33,10 @@ import { } from '../../../../../shared/rpc-contract/ssh-params' // Keep generation optional so older server rows still key by target id. -function toSshTargetSummary({ id, label, generation }: SshTargetRecord): SshTargetSummary { +function toSshTargetSummary( + target: SshTargetRecord +): SshTargetSummary & Pick { + const { id, label, generation } = target const state = getRegisteredSshState(id) const remotePlatform = state?.remotePlatform return { @@ -42,7 +45,8 @@ function toSshTargetSummary({ id, label, generation }: SshTargetRecord): SshTarg ...(generation === undefined ? {} : { generation }), connected: state?.status === 'connected', ...(state?.status === undefined ? {} : { connectionStatus: state.status }), - ...(remotePlatform === undefined ? {} : { remotePlatform }) + ...(remotePlatform === undefined ? {} : { remotePlatform }), + ...(isManagedOrcadSshTarget(target) ? { managedServer: true as const } : {}) } } diff --git a/src/renderer/src/components/automations/AutomationDetail.tsx b/src/renderer/src/components/automations/AutomationDetail.tsx index 05e65c6c6af..78b2dc31794 100644 --- a/src/renderer/src/components/automations/AutomationDetail.tsx +++ b/src/renderer/src/components/automations/AutomationDetail.tsx @@ -38,6 +38,9 @@ type AutomationDetailProps = { now: number onRunNow: (automation: Automation) => void onEdit: (automation: Automation) => void + /** Moves a row its host's Orca server now serves onto that server. */ + onMigrate?: (automation: Automation) => void + isMigrating?: boolean onToggle: (automation: Automation) => void onDelete: (automation: Automation) => void } @@ -123,6 +126,8 @@ export function AutomationDetail({ now, onRunNow, onEdit, + onMigrate, + isMigrating, onToggle, onDelete }: AutomationDetailProps): React.JSX.Element { @@ -177,9 +182,14 @@ export function AutomationDetail({

{automation.name}

- {automation.enabled - ? translate('auto.components.automations.AutomationDetail.eaa02014f8', 'Enabled') - : translate('auto.components.automations.enablement.paused', 'Paused')} + {!automation.enabled + ? translate('auto.components.automations.enablement.paused', 'Paused') + : hostEntry?.servedBy + ? translate( + 'auto.components.automations.AutomationDetail.needsMigration', + 'Needs migration' + ) + : translate('auto.components.automations.AutomationDetail.eaa02014f8', 'Enabled')}

@@ -245,7 +255,26 @@ export function AutomationDetail({ - {automation.executionTargetType === 'ssh' ? ( + {hostEntry?.servedBy ? ( +

+ + {translate( + 'auto.components.automations.AutomationDetail.migrateNotice', + '{{host}} was upgraded to a new remote host. Migrate this automation to keep it running.', + { host: hostEntry.label } + )} + + +
+ ) : automation.executionTargetType === 'ssh' ? (
{translate( 'auto.components.automations.AutomationDetail.dbef8dc110', @@ -254,7 +283,7 @@ export function AutomationDetail({
) : null} - {runNowAvailability?.canRunNow === false ? ( + {runNowAvailability?.canRunNow === false && !hostEntry?.servedBy ? (
{runNowAvailability.message}
diff --git a/src/renderer/src/components/automations/AutomationListLocalRow.tsx b/src/renderer/src/components/automations/AutomationListLocalRow.tsx index 6c3856c3cce..07d2be98e93 100644 --- a/src/renderer/src/components/automations/AutomationListLocalRow.tsx +++ b/src/renderer/src/components/automations/AutomationListLocalRow.tsx @@ -46,7 +46,7 @@ import { AutomationListLastRunCell } from './AutomationListLastRunCell' import { formatAutomationDateTimeWithRelative } from './automation-page-parts' import { getAutomationTargetAvailability } from './automation-target-availability' import { getAgentLabel } from './automation-draft-model' -import type { AutomationListRow } from './automation-list-row-identity' +import { automationProjectName, type AutomationListRow } from './automation-list-row-identity' import { formatAutomationUsageSummary } from './automation-usage-model' import { AUTOMATIONS_TABLE_GRID_CLASS } from './automations-table-layout' import { @@ -78,6 +78,7 @@ export type AutomationListLocalRowProps = { hostTargetFor: (row: AutomationListRow) => AutomationHostTarget | null hostLabelById?: ReadonlyMap isActionEnabled?: (row: AutomationListRow, action: AutomationRowAction) => boolean + needsMigration?: (row: AutomationListRow) => boolean onSelect: (rowKey: string) => void onRunNow: (row: AutomationListRow) => void onEdit: (row: AutomationListRow) => void @@ -105,6 +106,7 @@ export function AutomationListLocalRow({ hostTargetFor, hostLabelById = EMPTY_HOST_LABELS, isActionEnabled, + needsMigration, onSelect, onRunNow, onEdit, @@ -134,7 +136,7 @@ export function AutomationListLocalRow({ automationHostTarget: hostTargetFor(row) }) const projectLabel = - automationRepo?.displayName ?? + automationProjectName(automation, automationRepo, repoMap, !!needsMigration?.(row)) ?? translate('auto.components.automations.AutomationsPage.13118faadf', 'Unknown project') const scheduleLabel = formatUiAutomationSchedule(automation.rrule) const nextRunLabel = automation.enabled @@ -264,7 +266,11 @@ export function AutomationListLocalRow({ {nextRunLabel} - + ) } + if (enabled && needsMigration) { + const label = translate( + 'auto.components.automations.AutomationDetail.needsMigration', + 'Needs migration' + ) + return ( + + {label} + + ) + } if (enabled) { return ( diff --git a/src/renderer/src/components/automations/AutomationsDetailPane.tsx b/src/renderer/src/components/automations/AutomationsDetailPane.tsx index 2707759e403..ec6c00bc4f8 100644 --- a/src/renderer/src/components/automations/AutomationsDetailPane.tsx +++ b/src/renderer/src/components/automations/AutomationsDetailPane.tsx @@ -53,6 +53,8 @@ type AutomationsDetailPaneProps = { ) => void runNow: (automation: Automation) => void openEditDialog: (automation: Automation) => void + migrateAutomation?: (automation: Automation) => void + isMigrating?: boolean toggleAutomation: (automation: Automation) => void requestDeleteAutomation: (automation: Automation) => void openAutomationRunPage: (run: AutomationRun) => void @@ -79,6 +81,8 @@ export function AutomationsDetailPane({ requestExternalAction, runNow, openEditDialog, + migrateAutomation, + isMigrating, toggleAutomation, requestDeleteAutomation, openAutomationRunPage, @@ -192,6 +196,8 @@ export function AutomationsDetailPane({ now={relativeNow} onRunNow={(automation) => void runNow(automation)} onEdit={(automation) => void openEditDialog(automation)} + onMigrate={migrateAutomation} + isMigrating={isMigrating} onToggle={(automation) => void toggleAutomation(automation)} onDelete={requestDeleteAutomation} /> diff --git a/src/renderer/src/components/automations/AutomationsListPanel.tsx b/src/renderer/src/components/automations/AutomationsListPanel.tsx index fbb19ce085f..5b9a0812079 100644 --- a/src/renderer/src/components/automations/AutomationsListPanel.tsx +++ b/src/renderer/src/components/automations/AutomationsListPanel.tsx @@ -91,6 +91,7 @@ export type AutomationsListPanelProps = { hostTargetFor: (row: AutomationListRow) => AutomationHostTarget | null hostLabelById?: ReadonlyMap isActionEnabled: (row: AutomationListRow, action: AutomationRowAction) => boolean + needsMigration?: (row: AutomationListRow) => boolean externalActionKey: string | null selectAutomationRow: (rowKey: string | null) => void selectExternalKey: (externalKey: string | null) => void @@ -144,6 +145,7 @@ export function AutomationsListPanel(props: AutomationsListPanelProps): React.JS hostTargetFor, hostLabelById, isActionEnabled, + needsMigration, externalActionKey, selectAutomationRow, selectExternalKey, @@ -273,6 +275,7 @@ export function AutomationsListPanel(props: AutomationsListPanelProps): React.JS hostTargetFor, hostLabelById, isActionEnabled, + needsMigration, onSelect: (rowKey: string) => { selectExternalKey(null) selectAutomationRow(rowKey) diff --git a/src/renderer/src/components/automations/AutomationsPageListPanel.tsx b/src/renderer/src/components/automations/AutomationsPageListPanel.tsx index c8f10040085..0d96218f90d 100644 --- a/src/renderer/src/components/automations/AutomationsPageListPanel.tsx +++ b/src/renderer/src/components/automations/AutomationsPageListPanel.tsx @@ -96,6 +96,7 @@ export function AutomationsPageListPanel({ hostTargetFor={destination.automationHostTargetFor} hostLabelById={presentation.hostLabelById} isActionEnabled={destination.isAutomationRowActionEnabled} + needsMigration={(row) => !!destination.rowRecoveryHost(row.key)?.servedBy} externalActionKey={externalActionKey} selectAutomationRow={list.selectAutomationRow} selectExternalKey={local.selectExternalKey} diff --git a/src/renderer/src/components/automations/AutomationsPageSurface.tsx b/src/renderer/src/components/automations/AutomationsPageSurface.tsx index 3fc4cb615e0..ed59bdefb64 100644 --- a/src/renderer/src/components/automations/AutomationsPageSurface.tsx +++ b/src/renderer/src/components/automations/AutomationsPageSurface.tsx @@ -5,7 +5,7 @@ import { AutomationEditorDialog } from './AutomationEditorDialog' import { AutomationsDetailPane } from './AutomationsDetailPane' import { AutomationsPageSkeleton } from './AutomationsPageSkeleton' import { getAutomationAuthorityTarget } from './automation-host-client' -import type { AutomationListRow } from './automation-list-row-identity' +import { automationProjectName, type AutomationListRow } from './automation-list-row-identity' import type { AutomationHostRecoveryAction } from './automation-host-status-descriptors' import { AutomationsPageTopBar } from './AutomationsPageTopBar' import type { AutomationsPageController } from './use-automations-page-controller' @@ -32,6 +32,7 @@ export function AutomationsPageSurface({ draftEffects, editorActions, saveAutomation, + migrateAction, managementActions, runActions, externalActions, @@ -268,7 +269,13 @@ export function AutomationsPageSurface({ relativeNow={relativeNow} externalActionKey={externalActionKey} selectedRepoDisplayName={ - presentation.selectedRepo?.displayName ?? + (selected && + automationProjectName( + selected, + presentation.selectedRepo, + repoMap, + !!destination.rowRecoveryHost(selectedRow?.key ?? null)?.servedBy + )) ?? translate('auto.components.automations.AutomationsPage.13118faadf', 'Unknown project') } selectedRepoDefaultBaseRef={presentation.selectedRepo?.worktreeBaseRef ?? null} @@ -291,6 +298,8 @@ export function AutomationsPageSurface({ requestExternalAction={externalActions.requestExternalAction} runNow={() => runSelectedRowAction(runActions.runNow)} openEditDialog={() => runSelectedRowAction(editorActions.openEditDialog)} + migrateAutomation={() => runSelectedRowAction(migrateAction.migrateAutomation)} + isMigrating={!!selectedRow && migrateAction.migratingRowKey === selectedRow.key} toggleAutomation={() => runSelectedRowAction(managementActions.toggleAutomation)} requestDeleteAutomation={() => runSelectedRowAction(managementActions.requestDeleteAutomation) diff --git a/src/renderer/src/components/automations/automation-create-destination.test.ts b/src/renderer/src/components/automations/automation-create-destination.test.ts new file mode 100644 index 00000000000..006ce63d56c --- /dev/null +++ b/src/renderer/src/components/automations/automation-create-destination.test.ts @@ -0,0 +1,48 @@ +import { describe, expect, it } from 'vitest' +import { buildAutomationHostCatalog } from './automation-host-catalog' +import type { AutomationCatalogSshMirrorInput } from './automation-host-catalog-types' +import { + automationCreateHostOffered, + preselectAutomationCreateHost +} from './automation-create-destination' + +function mirror( + targets: AutomationCatalogSshMirrorInput['targets'] +): AutomationCatalogSshMirrorInput { + return { + targetsHydrated: true, + targets, + removedTargetLabels: new Map(), + connectionStatusByTargetId: new Map() + } +} + +describe('create destination on a managed SSH host', () => { + it("lists only the host's server and lands its desktop SSH key there", () => { + const { entries } = buildAutomationHostCatalog({ + desktop: { + label: 'Local Mac', + ssh: mirror([{ targetId: 'box', label: 'Build box', generation: 2 }]) + }, + runtimes: [ + { + environmentId: 'env-1', + label: 'Build box', + pairingRevision: 3, + authorityHealth: 'fresh', + querySupport: 'scoped', + ssh: mirror([]), + managedSshTargetId: 'box' + } + ], + runtimeCatalogSettled: true + }) + const desktopSshKey = 'host:desktop:ssh:box' + + const desktopSsh = entries.find((entry) => entry.stableKey === desktopSshKey) + expect(desktopSsh && automationCreateHostOffered(desktopSsh)).toBe(false) + expect(preselectAutomationCreateHost(entries, desktopSshKey, null)?.stableKey).toBe( + 'host:runtime:env-1:self' + ) + }) +}) diff --git a/src/renderer/src/components/automations/automation-create-destination.ts b/src/renderer/src/components/automations/automation-create-destination.ts index 52ba67d88d0..9a5f1c527f0 100644 --- a/src/renderer/src/components/automations/automation-create-destination.ts +++ b/src/renderer/src/components/automations/automation-create-destination.ts @@ -42,12 +42,29 @@ export type AutomationCreateDestinationResolution = export function automationCreateHostEligible( entry: AutomationHostCatalogEntry ): entry is AutomationHostCatalogEntry & { owner: AutomationOwnerRef } { - return entry.kind !== 'orphan' && entry.owner !== null && entry.querySupport === 'scoped' + return ( + entry.kind !== 'orphan' && + entry.owner !== null && + entry.querySupport === 'scoped' && + entry.servedBy === undefined + ) } -/** Offer ineligible hosts disabled with reasons so they do not appear gone; hide only removed targets and the orphan bucket. */ +/** The entry that holds new automations for a host key: a managed SSH host's is its Orca server's. */ +export function automationCreateHostFor( + entries: readonly AutomationHostCatalogEntry[], + stableKey: string | null | undefined +): AutomationHostCatalogEntry | null { + const entry = stableKey ? entries.find((candidate) => candidate.stableKey === stableKey) : null + const server = entry?.servedBy + ? entries.find((candidate) => candidate.stableKey === entry.servedBy) + : null + return server ?? entry ?? null +} + +/** Offer ineligible hosts disabled with reasons so they do not appear gone; hide removed targets, the orphan bucket, and SSH hosts their Orca server stands for. */ export function automationCreateHostOffered(entry: AutomationHostCatalogEntry): boolean { - return entry.kind !== 'orphan' && entry.catalogState !== 'removed' + return entry.kind !== 'orphan' && entry.catalogState !== 'removed' && entry.servedBy === undefined } /** Name only authorities repaired by a server update; disabled tooltips are unreachable, and unverified targets need reconnect instead. */ @@ -88,11 +105,7 @@ export function preselectAutomationCreateHost( selectedStableKey: string | null, activeWorkspaceStableKey: string | null ): AutomationHostCatalogEntry | null { - const key = selectedStableKey ?? activeWorkspaceStableKey - if (!key) { - return null - } - return entries.find((entry) => entry.stableKey === key) ?? null + return automationCreateHostFor(entries, selectedStableKey ?? activeWorkspaceStableKey) } /** Revalidate against the live catalog; report a changed incarnation without silently following it or discarding the form. */ diff --git a/src/renderer/src/components/automations/automation-host-catalog-source.ts b/src/renderer/src/components/automations/automation-host-catalog-source.ts index beb816922b6..79efc7ab804 100644 --- a/src/renderer/src/components/automations/automation-host-catalog-source.ts +++ b/src/renderer/src/components/automations/automation-host-catalog-source.ts @@ -30,6 +30,7 @@ export type AutomationCatalogRuntimeSource = { /** Undefined until this client has probed the environment at all. */ status: { status: RuntimeStatus | null } | undefined ssh: AutomationCatalogSshSource | undefined + managedSshTargetId?: string } export type AutomationHostCatalogSource = { @@ -129,6 +130,7 @@ export function buildAutomationHostCatalogSource( authorityHealth: runtimeAuthorityHealth(runtime), querySupport: runtimeQuerySupport(runtime), ssh: toSshMirror(runtime.ssh ?? EMPTY_SSH), + ...(runtime.managedSshTargetId ? { managedSshTargetId: runtime.managedSshTargetId } : {}), ...withOrphanCount(orphanCountFor(source, authority)) } }), diff --git a/src/renderer/src/components/automations/automation-host-catalog-types.ts b/src/renderer/src/components/automations/automation-host-catalog-types.ts index f7b9b8adeae..0d45901e03a 100644 --- a/src/renderer/src/components/automations/automation-host-catalog-types.ts +++ b/src/renderer/src/components/automations/automation-host-catalog-types.ts @@ -53,6 +53,8 @@ export type AutomationHostCatalogEntry = { querySupport: AutomationHostQuerySupport /** Present only while `querySupport` is degraded; explains which repair, if any, applies. */ scopeGap?: AutomationHostScopeGap + /** A desktop SSH host whose managed Orca server owns its automations: that server's self entry. */ + servedBy?: string } export type AutomationCatalogSshTargetInput = { @@ -91,6 +93,8 @@ export type AutomationRuntimeAuthorityInput = { querySupport: AutomationHostQuerySupport ssh: AutomationCatalogSshMirrorInput orphanCount?: number + /** The desktop SSH target this runtime is the managed Orca server for. */ + managedSshTargetId?: string } export type AutomationHostCatalogInput = { diff --git a/src/renderer/src/components/automations/automation-host-catalog.ts b/src/renderer/src/components/automations/automation-host-catalog.ts index 6d9bb8639ae..05523b0f6c8 100644 --- a/src/renderer/src/components/automations/automation-host-catalog.ts +++ b/src/renderer/src/components/automations/automation-host-catalog.ts @@ -41,6 +41,8 @@ type AuthorityProjectionContext = { ssh: AutomationCatalogSshMirrorInput referenced: ReferencedAuthorityScope orphanCount: number | undefined + /** Desktop SSH target id to the self entry of the managed Orca server that serves it. */ + servedBy?: ReadonlyMap } const EMPTY_SCOPE: ReferencedAuthorityScope = { targetIds: new Set(), orphan: false } @@ -100,6 +102,10 @@ function withScopeGap(scopeGap: AutomationHostScopeGap | undefined): { return scopeGap === undefined ? {} : { scopeGap } } +function withServedBy(servedBy: string | undefined): { servedBy?: string } { + return servedBy === undefined ? {} : { servedBy } +} + /** The authority's own contract; the only gap an entry with no target can have. */ function authorityScopeGap( querySupport: AutomationHostQuerySupport @@ -202,7 +208,8 @@ function projectSshEntries(ctx: AuthorityProjectionContext): AutomationHostCatal // Why: without a registration generation the entry keys on target id alone, so it stays view-only. querySupport: ctx.querySupport === 'scoped' && !scoped ? 'legacy-unscoped' : ctx.querySupport, - ...withScopeGap(resolveSshScopeGap(ctx.querySupport, catalogState, generation)) + ...withScopeGap(resolveSshScopeGap(ctx.querySupport, catalogState, generation)), + ...withServedBy(ctx.servedBy?.get(targetId)) } ) ) @@ -255,7 +262,22 @@ export function buildAutomationHostCatalog( pairingRevision: null, ssh: input.desktop.ssh, referenced: referenced.get(automationAuthorityCatalogKey(desktopAuthority)) ?? EMPTY_SCOPE, - orphanCount: input.desktop.orphanCount + orphanCount: input.desktop.orphanCount, + servedBy: new Map( + input.runtimes.flatMap((runtime) => + runtime.managedSshTargetId + ? [ + [ + runtime.managedSshTargetId, + hostStableKey({ + authority: { kind: 'runtime', environmentId: runtime.environmentId }, + selector: { kind: 'self' } + }) + ] as const + ] + : [] + ) + ) } const contexts: AuthorityProjectionContext[] = [ ...(desktopAliasEnvironmentId === undefined ? [desktopContext] : []), diff --git a/src/renderer/src/components/automations/automation-list-row-identity.ts b/src/renderer/src/components/automations/automation-list-row-identity.ts index 2ef78ec0f13..c8d85de3e73 100644 --- a/src/renderer/src/components/automations/automation-list-row-identity.ts +++ b/src/renderer/src/components/automations/automation-list-row-identity.ts @@ -68,6 +68,19 @@ export function unscopedAutomationListRows( })) } +/** A project moved to its host's Orca server keeps its id, so a leftover still names it. */ +export function automationProjectName( + automation: Automation, + repo: Repo | null | undefined, + repoMap: ReadonlyMap, + leftover: boolean +): string | undefined { + return ( + repo?.displayName ?? + (leftover ? repoMap.get(getAutomationRunRepoId(automation))?.displayName : undefined) + ) +} + export function automationRepoForRow( row: AutomationListRow, repos: readonly Repo[] diff --git a/src/renderer/src/components/automations/automation-orca-save.ts b/src/renderer/src/components/automations/automation-orca-save.ts index fd5b6b45fb0..b3fb1882666 100644 --- a/src/renderer/src/components/automations/automation-orca-save.ts +++ b/src/renderer/src/components/automations/automation-orca-save.ts @@ -47,7 +47,6 @@ export async function saveOrcaAutomation( draft, editingAutomationId, editingRowKey, - editingDestination, draftAtOpen, setEditorNotice, setEditorNoticeHost, @@ -60,7 +59,8 @@ export async function saveOrcaAutomation( rowRecoveryHost, createDestination } = destination - const { dialogRepos, editHostResolution, automationDialogTarget } = destinationForm + const { dialogRepos, editHostResolution, automationDialogTarget, editingDestination } = + destinationForm // Fence the destination before hook probes/trust prompts or any other transaction side effect. const createCheck = editingAutomationId === null ? createDestination.check(draft.projectId) : null diff --git a/src/renderer/src/components/automations/automation-run-error-copy.ts b/src/renderer/src/components/automations/automation-run-error-copy.ts index 7606c225dbb..e11801967db 100644 --- a/src/renderer/src/components/automations/automation-run-error-copy.ts +++ b/src/renderer/src/components/automations/automation-run-error-copy.ts @@ -42,6 +42,12 @@ const COPY: Record< translate('automations.runFailures.wslMoveInProgress', EN.wslMoveInProgress), wslMoveOwnedByHost: () => translate('automations.runFailures.wslMoveOwnedByHost', EN.wslMoveOwnedByHost), + managedHostServer: (params) => { + const host = params?.host + return typeof host === 'string' + ? translate('automations.runFailures.managedHostServer', EN.managedHostServer, { host }) + : null + }, missedGraceWindow: () => translate('automations.runFailures.missedGraceWindow', EN.missedGraceWindow), targetMissing: () => translate('automations.runFailures.targetMissing', EN.targetMissing), diff --git a/src/renderer/src/components/automations/use-automation-editor-actions.ts b/src/renderer/src/components/automations/use-automation-editor-actions.ts index 2e3db1074ca..bc665c3e05f 100644 --- a/src/renderer/src/components/automations/use-automation-editor-actions.ts +++ b/src/renderer/src/components/automations/use-automation-editor-actions.ts @@ -6,6 +6,7 @@ import { AUTOMATION_DEFAULT_TIME, getDefaultWorktree } from './automation-draft- import type { AutomationTemplate } from './automation-templates' import { dispatchAutomationReread } from './automation-row-action-dispatch' import { listAutomationsForTarget } from './automation-host-client' +import { automationCreateHostFor } from './automation-create-destination' import type { AutomationDraft } from './AutomationEditorDialog' import type { AutomationListRow } from './automation-list-row-identity' import type { AutomationsPageDestinationState } from './use-automations-page-destination-state' @@ -42,7 +43,8 @@ export function useAutomationEditorActions({ editingHostStableKey } = local const { getDefaultTarget, automationDispatchContext, rowRecoveryHost } = destination - const { destinationForProject, editHostResolution, editDestinationControl } = destinationForm + const { destinationForProject, editHostResolution, editDestinationControl, editHostEntries } = + destinationForm const openCreateDialog = (template?: AutomationTemplate): void => { editRequestRef.current += 1 @@ -89,7 +91,11 @@ export function useAutomationEditorActions({ setCreateOpen(true) } - const openEditDialog = async (row: AutomationListRow): Promise => { + /** Resolves true once the edit session is set; headless keeps the dialog closed for Migrate. */ + const openEditDialog = async ( + row: AutomationListRow, + { headless = false }: { headless?: boolean } = {} + ): Promise => { const requestId = (editRequestRef.current += 1) const automationId = row.automation.id const reread = await dispatchAutomationReread( @@ -102,25 +108,34 @@ export function useAutomationEditorActions({ ) if (!reread.ok && reread.notice.severity === 'owner') { destination.reportOwnerAction(row.key, reread.notice) - return + return false } const latest = (reread.ok ? reread.value : null) ?? row.automation if (requestId !== editRequestRef.current) { - return + return false } setEditingAutomationId(latest.id) setEditingRowKey(row.key) - const initialHostStableKey = rowRecoveryHost(row.key)?.stableKey ?? null - const initialDestination = destinationForProject(latest.projectId, initialHostStableKey) + const rowHostStableKey = rowRecoveryHost(row.key)?.stableKey ?? null + const initialHost = automationCreateHostFor(editHostEntries, rowHostStableKey) + // A managed SSH host's row can only be saved by moving it to that host's Orca server. + const movingToServer = initialHost !== null && initialHost.stableKey !== rowHostStableKey + const initialDestination = destinationForProject( + latest.projectId, + initialHost?.stableKey ?? null + ) setEditingDestination( initialDestination ? { projectId: latest.projectId, destination: initialDestination } : null ) - setEditingHostStableKey(initialDestination?.entry.stableKey ?? null) + setEditingHostStableKey( + initialDestination?.entry.stableKey ?? (movingToServer ? initialHost.stableKey : null) + ) const nextDraft = buildAutomationEditDraft(latest) setDraft(nextDraft) setDraftAtOpen(nextDraft) - setTargetEdited(false) - setCreateOpen(true) + setTargetEdited(movingToServer) + setCreateOpen(!headless) + return true } const handleProjectChange = useCallback( diff --git a/src/renderer/src/components/automations/use-automation-host-catalog-source-state.ts b/src/renderer/src/components/automations/use-automation-host-catalog-source-state.ts index 5b659092b40..9691cf56152 100644 --- a/src/renderer/src/components/automations/use-automation-host-catalog-source-state.ts +++ b/src/renderer/src/components/automations/use-automation-host-catalog-source-state.ts @@ -2,6 +2,7 @@ import { useMemo } from 'react' import { useAppStore } from '@/store' import { getPairedWebClientEnvironmentId } from '@/lib/paired-web-client-host' import type { PublicKnownRuntimeEnvironment } from '../../../../shared/remote-runtime/host-catalog/runtime-environments' +import { getManagedOrcadSshTargetId } from '../../../../shared/managed-orcad-execution-host' import type { AutomationCatalogRuntimeSource, AutomationCatalogSshSource, @@ -55,6 +56,7 @@ export function useAutomationHostCatalogSourceState({ runtimeEnvironments.map((environment) => { const bucket = sshStateByEnvironment.get(environment.id) const status = runtimeStatusByEnvironmentId.get(environment.id) + const managedSshTargetId = getManagedOrcadSshTargetId(environment) return { environmentId: environment.id, label: environment.name, @@ -69,7 +71,8 @@ export function useAutomationHostCatalogSourceState({ removedTargetLabels: bucket.removedTargetLabels, connectionStates: bucket.connectionStates } - : undefined + : undefined, + ...(managedSshTargetId ? { managedSshTargetId } : {}) } }), [runtimeEnvironments, runtimeStatusByEnvironmentId, sshStateByEnvironment] diff --git a/src/renderer/src/components/automations/use-automation-migrate-action.ts b/src/renderer/src/components/automations/use-automation-migrate-action.ts new file mode 100644 index 00000000000..5f1ff3f8662 --- /dev/null +++ b/src/renderer/src/components/automations/use-automation-migrate-action.ts @@ -0,0 +1,62 @@ +import { useEffect, useEffectEvent, useState } from 'react' +import { toast } from 'sonner' +import { resolveAutomationCreateDestination } from './automation-create-destination' +import { createAutomationSaveAction } from './automation-save-action' +import type { AutomationSaveContext } from './automation-save-context' +import type { AutomationListRow } from './automation-list-row-identity' +import type { AutomationEditorActions } from './use-automation-editor-actions' + +/** Migrate: the editor's own move-to-server save, run without opening the dialog. */ +export function useAutomationMigrateAction( + context: AutomationSaveContext, + editorActions: AutomationEditorActions +) { + const [migration, setMigration] = useState<{ rowKey: string; opened: boolean } | null>(null) + + // Runs on the render that holds the headless edit session, so Save reads it like the dialog would. + const saveMigration = useEffectEvent(async () => { + const save = createAutomationSaveAction({ + ...context, + local: { + ...context.local, + // No dialog is open to show editor notices. + setEditorNotice: (notice) => { + if (notice && typeof notice !== 'function') { + toast.error(notice.message) + } + }, + setEditorNoticeHost: () => {} + } + }) + try { + await save() + } finally { + setMigration(null) + } + }) + useEffect(() => { + if (migration?.opened) { + void saveMigration() + } + }, [migration]) + + const migrateAutomation = async (row: AutomationListRow): Promise => { + setMigration({ rowKey: row.key, opened: false }) + let opened = false + try { + const servedBy = context.destination.rowRecoveryHost(row.key)?.servedBy + const server = resolveAutomationCreateDestination( + context.list.hostCatalog.entries.find((entry) => entry.stableKey === servedBy) + ) + // Save checks the project against the server's repo table, which may not be loaded yet. + if (server.status === 'ready' && server.authority.kind === 'runtime') { + await context.store.fetchRuntimeEnvironmentRepos(server.authority.environmentId) + } + opened = await editorActions.openEditDialog(row, { headless: true }) + } finally { + setMigration(opened ? { rowKey: row.key, opened: true } : null) + } + } + + return { migrateAutomation, migratingRowKey: migration?.rowKey ?? null } +} diff --git a/src/renderer/src/components/automations/use-automations-page-controller.ts b/src/renderer/src/components/automations/use-automations-page-controller.ts index d6524febeca..a31c26e0bf6 100644 --- a/src/renderer/src/components/automations/use-automations-page-controller.ts +++ b/src/renderer/src/components/automations/use-automations-page-controller.ts @@ -4,6 +4,7 @@ import { createAutomationRunWorkspaceAction } from './automation-run-workspace-a import { createAutomationSaveAction } from './automation-save-action' import { useAutomationDraftEffects } from './use-automation-draft-effects' import { useAutomationEditorActions } from './use-automation-editor-actions' +import { useAutomationMigrateAction } from './use-automation-migrate-action' import { useAutomationRunPageState } from './use-automation-run-page-state' import { useAutomationsPageEscape } from './use-automations-page-escape' import { useAutomationsPageListState } from './use-automations-page-list-state' @@ -69,15 +70,9 @@ export function useAutomationsPageController() { destination, destinationForm }) - const saveAutomation = createAutomationSaveAction({ - store, - local, - list, - setup, - destination, - destinationForm, - pageRefresh - }) + const saveContext = { store, local, list, setup, destination, destinationForm, pageRefresh } + const saveAutomation = createAutomationSaveAction(saveContext) + const migrateAction = useAutomationMigrateAction(saveContext, editorActions) const actionContext = { store, local, @@ -108,6 +103,7 @@ export function useAutomationsPageController() { draftEffects, editorActions, saveAutomation, + migrateAction, managementActions, runActions, externalActions, diff --git a/src/renderer/src/components/automations/use-automations-page-destination-form.ts b/src/renderer/src/components/automations/use-automations-page-destination-form.ts index df808b5b54f..e2856098260 100644 --- a/src/renderer/src/components/automations/use-automations-page-destination-form.ts +++ b/src/renderer/src/components/automations/use-automations-page-destination-form.ts @@ -11,6 +11,7 @@ import { automationWorktreesForRepo } from './automation-list-row-identity' import { getAutomationCreateRepos } from './automation-create-projects' import { automationCreateEligibleProjects, + automationCreateHostFor, automationCreateHostStableKey, automationCreateProjectMismatch, resolveAutomationCreateDestination, @@ -129,10 +130,18 @@ export function useAutomationsPageDestinationForm({ automationAuthorityCatalogKey(editHostResolution.authority) !== dialogAuthorityKey ? editHostResolution.entry : null + // A host's project table can load after the editor opened on it; the chosen project then holds. + const editingDestination = + local.editingDestination ?? + (editHostResolution.status === 'ready' && + draft.projectId && + !automationCreateProjectMismatch(repoTables, editHostResolution, draft.projectId) + ? { projectId: draft.projectId, destination: editHostResolution } + : null) const editSaveDestination = resolveAutomationEditDestination({ currentAutomation: editingRow?.automation ?? null, editingAutomationId, - editingDestination: local.editingDestination, + editingDestination, draft, targetEdited: local.targetEdited, rowKey: editingRowKey, @@ -252,10 +261,10 @@ export function useAutomationsPageDestinationForm({ if (!runContext) { return null } - const stableKey = automationCreateHostStableKey(runContext.hostId) - const entry = stableKey - ? hostCatalog.entries.find((candidate) => candidate.stableKey === stableKey) - : undefined + const entry = automationCreateHostFor( + hostCatalog.entries, + automationCreateHostStableKey(runContext.hostId) + ) const resolved = resolveAutomationCreateDestination(entry) return resolved.status === 'ready' ? resolved : null }, @@ -264,6 +273,7 @@ export function useAutomationsPageDestinationForm({ return { editingRow, + editingDestination, editorSaveAuthority, recordedTargetSelected, editingRowCapturedOwner, diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index db9fb5b8757..2f050d34829 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -1316,7 +1316,8 @@ "workspaceHostAmbiguous": "The automation workspace spans more than one host, so Orca cannot tell which one to run it on.", "wslDistroStopped": "The WSL distro {{distro}} is stopped, so this scheduled run did not start it. Start the distro or use Run now; later runs go ahead while it runs.", "wslMoveInProgress": "This automation's project is moving to its WSL host, so Orca skipped this run. Runs resume when the move finishes.", - "wslMoveOwnedByHost": "This automation's project now runs on its WSL host, which runs this automation there. Orca no longer runs this local copy." + "wslMoveOwnedByHost": "This automation's project now runs on its WSL host, which runs this automation there. Orca no longer runs this local copy.", + "managedHostServer": "Needs migration to {{host}}" } }, "browser": { diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index 02c94c30152..7316fd6caa5 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -17556,7 +17556,10 @@ "reuseLiveSession": "Laufende Sitzung wiederverwenden", "freshEachRun": "Bei jeder Ausführung neu", "precheckEnabled": "Aktiviert, {{timeout}}", - "precheckNone": "Keine" + "precheckNone": "Keine", + "migrate": "Migrieren", + "migrateNotice": "{{host}} wurde auf einen neuen Remote-Host umgestellt. Migriere diese Automatisierung, damit sie weiterläuft.", + "needsMigration": "Migration erforderlich" }, "AutomationEditorDialog": { "fb1896a5e7": "Abbrechen", @@ -23018,6 +23021,7 @@ "noRunnableHost": "Dieser Automatisierung fehlt ein Host zur Ausführung.", "wslMoveInProgress": "Das Projekt dieser Automatisierung wird auf seinen WSL-Host verschoben. Deshalb hat Orca diese Ausführung übersprungen. Die Ausführungen werden nach Abschluss des Verschiebens fortgesetzt.", "wslMoveOwnedByHost": "Das Projekt dieser Automatisierung läuft jetzt auf seinem WSL-Host, der die Automatisierung dort ausführt. Orca führt diese lokale Kopie nicht mehr aus.", + "managedHostServer": "Migration zu {{host}} erforderlich", "missedGraceWindow": "Bei der nächsten Prüfung durch Orca war die Nachholfrist für diese verpasste Ausführung bereits abgelaufen.", "targetMissing": "Der Host der Automatisierung ist nicht mehr registriert. Daher gibt es für diese Automatisierung keinen Ausführungsort.", "targetReplaced": "Der Host der Automatisierung wurde entfernt und erneut registriert. Daher muss diese Automatisierung vor der Ausführung erneut zugeordnet werden.", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 0b049cc14c8..f6ccc22c087 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -17952,7 +17952,10 @@ "reuseLiveSession": "Reuse live session", "freshEachRun": "Fresh each run", "precheckEnabled": "Enabled, {{timeout}}", - "precheckNone": "None" + "precheckNone": "None", + "migrate": "Migrate", + "migrateNotice": "{{host}} was upgraded to a new remote host. Migrate this automation to keep it running.", + "needsMigration": "Needs migration" }, "AutomationEditorDialog": { "fb1896a5e7": "Cancel", @@ -23770,6 +23773,7 @@ "noRunnableHost": "This automation has no host to run on.", "wslMoveInProgress": "This automation's project is moving to its WSL host, so Orca skipped this run. Runs resume when the move finishes.", "wslMoveOwnedByHost": "This automation's project now runs on its WSL host, which runs this automation there. Orca no longer runs this local copy.", + "managedHostServer": "Needs migration to {{host}}", "missedGraceWindow": "This run was past its missed-run grace window when Orca next checked.", "targetMissing": "The automation host is no longer registered, so this automation has nowhere to run.", "targetReplaced": "The automation host was removed and re-registered, so this automation must be re-adopted before it can run.", diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index c5139663abe..9089a095fcb 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -17319,7 +17319,10 @@ "reuseLiveSession": "Reutilizar sesión activa", "freshEachRun": "Nueva en cada ejecución", "precheckEnabled": "Activada, {{timeout}}", - "precheckNone": "Ninguna" + "precheckNone": "Ninguna", + "migrate": "Migrar", + "migrateNotice": "{{host}} se actualizó a un nuevo host remoto. Migra esta automatización para que siga ejecutándose.", + "needsMigration": "Requiere migración" }, "AutomationEditorDialog": { "fb1896a5e7": "Cancelar", @@ -23455,6 +23458,7 @@ "noRunnableHost": "Esta automatización no tiene host donde ejecutarse.", "wslMoveInProgress": "El proyecto de esta automatización se está moviendo a su host WSL, por lo que Orca omitió esta ejecución. Las ejecuciones se reanudarán cuando termine el traslado.", "wslMoveOwnedByHost": "El proyecto de esta automatización ahora se ejecuta en su host WSL, que ejecuta allí esta automatización. Orca ya no ejecuta esta copia local.", + "managedHostServer": "Requiere migración a {{host}}", "missedGraceWindow": "Cuando Orca volvió a comprobarlo, ya había vencido el período de gracia para recuperar esta ejecución omitida.", "targetMissing": "El host de la automatización ya no está registrado, por lo que esta automatización no tiene dónde ejecutarse.", "targetReplaced": "El host de la automatización se eliminó y se volvió a registrar, por lo que hay que volver a vincular esta automatización antes de poder ejecutarla.", diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index 5e805a2ea3a..7f911d3ffb8 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -17514,7 +17514,10 @@ "reuseLiveSession": "Réutiliser la session active", "freshEachRun": "Nouvelle à chaque exécution", "precheckEnabled": "Activée, {{timeout}}", - "precheckNone": "Aucune" + "precheckNone": "Aucune", + "migrate": "Migrer", + "migrateNotice": "{{host}} a été mis à niveau vers un nouvel hôte distant. Migrez cette automatisation pour qu'elle continue de s'exécuter.", + "needsMigration": "Migration requise" }, "AutomationEditorDialog": { "fb1896a5e7": "Annuler", @@ -23455,6 +23458,7 @@ "noRunnableHost": "Cette automatisation n’a pas d’hôte sur lequel s’exécuter.", "wslMoveInProgress": "Le projet de cette automatisation est en cours de déplacement vers son hôte WSL. Orca a donc ignoré cette exécution. Les exécutions reprendront à la fin du déplacement.", "wslMoveOwnedByHost": "Le projet de cette automatisation s’exécute désormais sur son hôte WSL, qui y exécute cette automatisation. Orca n’exécute plus cette copie locale.", + "managedHostServer": "Migration vers {{host}} requise", "missedGraceWindow": "Lors de la vérification suivante par Orca, la marge de rattrapage de cette exécution manquée était déjà dépassée.", "targetMissing": "L’hôte de l’automatisation n’est plus enregistré. Cette automatisation n’a donc plus d’hôte sur lequel s’exécuter.", "targetReplaced": "L’hôte de l’automatisation a été supprimé puis réenregistré. Cette automatisation doit donc être rattachée à nouveau avant de pouvoir s’exécuter.", diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index a80e1956bc1..46f716e01a9 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -16902,7 +16902,10 @@ "reuseLiveSession": "実行中のセッションを再利用", "freshEachRun": "実行ごとに新規作成", "precheckEnabled": "有効、{{timeout}}", - "precheckNone": "なし" + "precheckNone": "なし", + "migrate": "移行", + "migrateNotice": "{{host}} は新しいリモートホストにアップグレードされました。実行を続けるには、この自動化を移行してください。", + "needsMigration": "移行が必要" }, "AutomationEditorDialog": { "fb1896a5e7": "キャンセル", @@ -22765,6 +22768,7 @@ "noRunnableHost": "このオートメーションには実行するホストがありません。", "wslMoveInProgress": "このオートメーションのプロジェクトを WSL ホストへ移動中のため、Orca は今回の実行をスキップしました。移動が完了すると実行が再開されます。", "wslMoveOwnedByHost": "このオートメーションのプロジェクトは現在 WSL ホスト上で動作しており、オートメーションもそこで実行されます。Orca はこのローカルコピーを実行しなくなりました。", + "managedHostServer": "{{host}} への移行が必要", "missedGraceWindow": "Orca が次に確認した時点で、この実行は実行漏れの猶予時間を過ぎていました。", "targetMissing": "オートメーションのホストは登録されていないため、このオートメーションを実行する場所がありません。", "targetReplaced": "オートメーションのホストが削除され、再登録されたため、実行するにはこのオートメーションを再度関連付ける必要があります。", diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index 107ae7def0a..31e72d748db 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -16902,7 +16902,10 @@ "reuseLiveSession": "활성 세션 재사용", "freshEachRun": "실행마다 새로 시작", "precheckEnabled": "활성화됨, {{timeout}}", - "precheckNone": "없음" + "precheckNone": "없음", + "migrate": "마이그레이션", + "migrateNotice": "{{host}}이(가) 새 원격 호스트로 업그레이드되었습니다. 계속 실행하려면 이 자동화를 마이그레이션하세요.", + "needsMigration": "마이그레이션 필요" }, "AutomationEditorDialog": { "fb1896a5e7": "취소", @@ -22765,6 +22768,7 @@ "noRunnableHost": "이 자동화에는 실행할 호스트가 없습니다.", "wslMoveInProgress": "이 자동화의 프로젝트를 WSL 호스트로 옮기는 중이어서 Orca가 이번 실행을 건너뛰었습니다. 이동이 끝나면 실행이 재개됩니다.", "wslMoveOwnedByHost": "이 자동화의 프로젝트는 이제 WSL 호스트에서 실행되며, 해당 호스트가 그곳에서 이 자동화를 실행합니다. Orca는 더 이상 이 로컬 사본을 실행하지 않습니다.", + "managedHostServer": "{{host}}(으)로 마이그레이션 필요", "missedGraceWindow": "Orca가 다시 확인했을 때 이 실행을 보충할 수 있는 유예 시간이 이미 지나 있었습니다.", "targetMissing": "자동화 호스트가 더 이상 등록되어 있지 않아 이 자동화를 실행할 곳이 없습니다.", "targetReplaced": "자동화 호스트가 제거된 후 다시 등록되었으므로, 이 자동화를 실행하려면 다시 연결해야 합니다.", diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index f26ed6c5092..80ed18ea1b7 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -14394,7 +14394,10 @@ "reuseLiveSession": "Reutilizar sessão ativa", "freshEachRun": "Nova a cada execução", "precheckEnabled": "Ativada, {{timeout}}", - "precheckNone": "Nenhuma" + "precheckNone": "Nenhuma", + "migrate": "Migrar", + "migrateNotice": "{{host}} foi atualizado para um novo host remoto. Migre esta automação para que ela continue em execução.", + "needsMigration": "Requer migração" }, "ExternalAutomationManagers": { "e02f970595": "Nenhum gerenciador de automação externa encontrado.", @@ -23428,6 +23431,7 @@ "noRunnableHost": "Esta automação não tem host onde ser executada.", "wslMoveInProgress": "O projeto desta automação está sendo movido para seu host WSL, por isso o Orca ignorou esta execução. As execuções serão retomadas quando a movimentação terminar.", "wslMoveOwnedByHost": "O projeto desta automação agora é executado em seu host WSL, que também executa esta automação. O Orca não executa mais esta cópia local.", + "managedHostServer": "Requer migração para {{host}}", "missedGraceWindow": "Quando o Orca verificou novamente, o período de tolerância para recuperar esta execução perdida já havia expirado.", "targetMissing": "O host da automação não está mais registrado, então esta automação não tem onde ser executada.", "targetReplaced": "O host da automação foi removido e registrado novamente, então esta automação precisa ser vinculada novamente antes de poder ser executada.", diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index e8b8c112aa5..cd656375331 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -18066,7 +18066,10 @@ "reuseLiveSession": "Повторно использовать активную сессию", "freshEachRun": "Новая при каждом запуске", "precheckEnabled": "Включена, {{timeout}}", - "precheckNone": "Нет" + "precheckNone": "Нет", + "migrate": "Перенести", + "migrateNotice": "{{host}} обновлён до нового удалённого хоста. Перенесите эту автоматизацию, чтобы она продолжала работать.", + "needsMigration": "Требуется перенос" }, "AutomationEditorDialog": { "fb1896a5e7": "Отмена", @@ -23772,6 +23775,7 @@ "noRunnableHost": "У этой автоматизации нет сервера выполнения.", "wslMoveInProgress": "Проект этой автоматизации переносится на свой сервер WSL, поэтому Orca пришлось пропустить этот запуск. Запуски возобновятся после завершения переноса.", "wslMoveOwnedByHost": "Проект этой автоматизации теперь работает на своём сервере WSL, который выполняет эту автоматизацию там. Orca больше не запускает эту локальную копию.", + "managedHostServer": "Требуется перенос на {{host}}", "missedGraceWindow": "При следующей проверке Orca допустимая задержка для этого пропущенного запуска уже была превышена.", "targetMissing": "Сервер автоматизации больше не зарегистрирован, поэтому эту автоматизацию негде запускать.", "targetReplaced": "Сервер автоматизации был удалён и зарегистрирован заново, поэтому перед запуском эту автоматизацию нужно повторно привязать.", diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index 627edee82cc..6368e88cea5 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -17540,7 +17540,10 @@ "reuseLiveSession": "Etkin oturumu yeniden kullan", "freshEachRun": "Her çalıştırmada yeni", "precheckEnabled": "Etkin, {{timeout}}", - "precheckNone": "Yok" + "precheckNone": "Yok", + "migrate": "Taşı", + "migrateNotice": "{{host}} yeni bir uzak ana bilgisayara yükseltildi. Çalışmaya devam etmesi için bu otomasyonu taşıyın.", + "needsMigration": "Taşınması gerekiyor" }, "AutomationEditorDialog": { "fb1896a5e7": "İptal", @@ -22999,6 +23002,7 @@ "noRunnableHost": "Bu otomasyonun çalışacağı bir sunucu yok.", "wslMoveInProgress": "Bu otomasyonun projesi WSL ana makinesine taşınıyor. Bu nedenle Orca bu çalıştırmayı atladı. Taşıma tamamlandığında çalıştırmalar devam edecek.", "wslMoveOwnedByHost": "Bu otomasyonun projesi artık WSL ana makinesinde çalışıyor ve bu otomasyon da orada ana makine tarafından çalıştırılıyor. Orca artık bu yerel kopyayı çalıştırmıyor.", + "managedHostServer": "{{host}} üzerine taşınması gerekiyor", "missedGraceWindow": "Orca'nın bir sonraki kontrolünde bu çalıştırma, kaçırılan çalıştırmalar için tanınan tolerans süresini aşmıştı.", "targetMissing": "Otomasyon sunucusu artık kayıtlı olmadığından bu otomasyonun çalışacağı bir yer yok.", "targetReplaced": "Otomasyon sunucusu kaldırılıp yeniden kaydedildiği için bu otomasyonun çalıştırılmadan önce yeniden ilişkilendirilmesi gerekiyor.", diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index 8804235ff2c..8046f0667db 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -17323,7 +17323,10 @@ "reuseLiveSession": "重複使用執行中的工作階段", "freshEachRun": "每次執行都新建", "precheckEnabled": "已啟用,{{timeout}}", - "precheckNone": "無" + "precheckNone": "無", + "migrate": "遷移", + "migrateNotice": "{{host}} 已升級為新的遠端主機。請遷移此自動化以繼續執行。", + "needsMigration": "需要遷移" }, "AutomationEditorDialog": { "fb1896a5e7": "取消", @@ -22684,6 +22687,7 @@ "noRunnableHost": "此自動化沒有可供執行的主機。", "wslMoveInProgress": "此自動化的專案正在移至其 WSL 主機,因此 Orca 略過了此次執行。移動完成後便會恢復執行。", "wslMoveOwnedByHost": "此自動化的專案現在在其 WSL 主機上執行,自動化本身也由該主機執行。Orca 不再執行這個本機副本。", + "managedHostServer": "需要遷移到 {{host}}", "missedGraceWindow": "Orca 再次檢查時,此次執行的補執行寬限期已過。", "targetMissing": "自動化主機已不在註冊清單中,因此已無處執行此自動化。", "targetReplaced": "自動化主機已被移除並重新註冊,因此必須為此自動化重新建立關聯後才能執行。", diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index c00b4692fde..4aa4746dc26 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -16902,7 +16902,10 @@ "reuseLiveSession": "复用活动会话", "freshEachRun": "每次运行新建", "precheckEnabled": "已启用,{{timeout}}", - "precheckNone": "无" + "precheckNone": "无", + "migrate": "迁移", + "migrateNotice": "{{host}} 已升级为新的远程主机。请迁移此自动化以继续运行。", + "needsMigration": "需要迁移" }, "AutomationEditorDialog": { "fb1896a5e7": "取消", @@ -22765,6 +22768,7 @@ "noRunnableHost": "此自动化没有可运行的主机。", "wslMoveInProgress": "此自动化的项目正在移到其 WSL 主机,因此 Orca 跳过了此次运行。移动完成后将恢复运行。", "wslMoveOwnedByHost": "此自动化的项目现在在其 WSL 主机上运行,自动化本身也由该主机运行。Orca 不再运行此本地副本。", + "managedHostServer": "需要迁移到 {{host}}", "missedGraceWindow": "Orca 再次检查时,此次运行的补跑宽限期已过。", "targetMissing": "自动化主机已不在注册列表中,因此此自动化已无处运行。", "targetReplaced": "自动化主机已被移除并重新注册,因此必须重新关联此自动化后才能运行。", diff --git a/src/shared/automation-run-failure-copy.ts b/src/shared/automation-run-failure-copy.ts index e9061d9e7d6..59ae91a82a8 100644 --- a/src/shared/automation-run-failure-copy.ts +++ b/src/shared/automation-run-failure-copy.ts @@ -8,6 +8,7 @@ export const AUTOMATION_RUN_FAILURE_COPY = { "This automation's project is moving to its WSL host, so Orca skipped this run. Runs resume when the move finishes.", wslMoveOwnedByHost: "This automation's project now runs on its WSL host, which runs this automation there. Orca no longer runs this local copy.", + managedHostServer: 'Needs migration to {{host}}', missedGraceWindow: 'This run was past its missed-run grace window when Orca next checked.', targetMissing: 'The automation host is no longer registered, so this automation has nowhere to run.', @@ -49,7 +50,10 @@ export type AutomationRunFailureCodeFields = { export type AutomationRunFailure = { error: string } & AutomationRunFailureCodeFields export function automationRunFailure( - errorCode: Exclude + errorCode: Exclude< + AutomationRunFailureCode, + 'projectSetupNotReady' | 'wslDistroStopped' | 'managedHostServer' + > ): AutomationRunFailure export function automationRunFailure( errorCode: 'projectSetupNotReady', @@ -59,6 +63,10 @@ export function automationRunFailure( errorCode: 'wslDistroStopped', params: { distro: string } ): AutomationRunFailure +export function automationRunFailure( + errorCode: 'managedHostServer', + params: { host: string } +): AutomationRunFailure export function automationRunFailure( errorCode: AutomationRunFailureCode, params?: Record diff --git a/src/shared/managed-orcad-ssh-owner.ts b/src/shared/managed-orcad-ssh-owner.ts index 7964e813f29..07ba727a44d 100644 --- a/src/shared/managed-orcad-ssh-owner.ts +++ b/src/shared/managed-orcad-ssh-owner.ts @@ -31,3 +31,8 @@ export function managedOrcadServerName(target: Pick