mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 00:02:29 +00:00
* Add all-host automations with scoped ownership and multi-authority suppo
Enable automations to run on multiple hosts (SSH targets and local) with
owner-fenced mutations, scoped list queries per host, and conflict
resolution. Introduces desktop and runtime authorities as distinct
automation storage owners, with per-host caching, invalidation, and
retry scheduling on the renderer. Captures registration generations for
SSH hosts to survive re-adoption. Adds CLI support for destination
selection and conflict recovery.
* Filter automation create projects by destination host
Only offer projects available on the selected destination, preventing
the mismatches that would fail at submit time. Auto-adjust the project
selection if it becomes unavailable when the destination changes.
* Add runtime storage authority support for automations
- Support both runtime and desktop as automation storage authorities
- Make owner preconditions optional for legacy-client compatibility
- Cache automation list projections to improve performance
- Add per-row repo/worktree resolution for cross-authority collisions
- Extend automation.list RPC to always include owner metadata
* Replace child_process.execFile with runProcess for external automations
- Migrate external-manager to use cross-platform runProcess wrapper per child-process safety policy
- Abstract electron app/ipcMain APIs in orca-runtime via environment accessors
- Install fake app environment in automation tests for consistent setup
- Reorganize imports to use specific module paths (ssh-target-registry, agent-detection, browser-error)
- Remove external-manager from child-process import allowlists (no longer violates direct import)
* Unify desktop automation CRUD onto the local runtime RPC surface
The desktop authority now speaks the same automation.* RPC contract as
remote runtimes, via callRuntimeRpc({kind:'local'}) -> runtime:call ->
the shared RpcDispatcher. The automations:list/listRuns/create/update/
delete/runNow IPC arms, their preload members, and every renderer
desktop-vs-runtime transport fork are retired; the runtime methods are
the single implementation of scoped lists, owner fencing, and change
publication for both transports (mobile clients already exercised them).
The desktop probe scheduler's priority lease survives the move as an
AutomationService hook the IPC registration installs and the runtime
methods take, so Orca's own automation traffic still parks queued
external-manager probes.
External-manager scope arms and dispatch-loop plumbing stay on IPC by
design; automation change events keep their existing channels (renderer
ingestion already converges them by authority).
* Remove automation ghost SSH tombstone scanning
This functionality for synthesizing tombstones for automation-referenced SSH
targets is no longer needed as part of the automation system refactoring.
* Refuse orphan automations at dispatch time, not migration time
Remove migration-time disabling of orphan automations and the `enabledDecidedBy` field. Dispatch now refuses orphans at runtime instead, simplifying state management and UI. Orphans are left unstamped and enabled; dispatch refuses to run them via `resolveAutomationRunTarget`.
* Show all automations in flat table with unified filter menu
- Replace host picker component with comprehensive Filters menu supporting status, last run, agent, and host filters
- Flatten automation list layout to single table instead of host-grouped sections
- Add Host column to display execution host for each automation
- Display active filters as removable pills below toolbar
- Delete unused AutomationHostPicker* components
* Add automation owner fencing and destination validation
- New AUTOMATION_OWNER_FENCING_RUNTIME_CAPABILITY for owner preconditions; legacy clients get owner metadata snapshotted at RPC boundary for compatibility
- Editor captures and revalidates automation destination before save, preventing silent retargeting if SSH infrastructure changes mid-edit
- SSH target types now isolate renderer-authored fields; generation is server-owned and stripped by IPC handlers
* Route automation recovery actions to the origin host
When an automation action fails due to owner fencing, recovery verbs
("Update server", "Reconnect") must run on the host where the refusal
originated: the row's captured owner for row operations, or the
destination the create dialog captured, not the list's filtered host.
* Remove external manager scope limitation notices
Consolidate create destination eligibility checks with a unified predicate
and fix the bug where desktop repo IDs could be sent to runtime hosts where
they cannot resolve.
* Persist only store-derived automation contexts, not client-perspective o
Store contexts must never be based on client-provided runContext or sourceContext
values—clients speak a different perspective (e.g., 'runtime:<id>' for host IDs
they assign), and persisting those makes the store projection orphan automations
it actually owns. Derived contexts now take precedence in create and update paths,
with explicit null still honored to clear a value. Tests verify this by simulating
drift after storage and confirming that moves re-derive while toggles preserve.
152 lines
6.0 KiB
TypeScript
152 lines
6.0 KiB
TypeScript
import type { Page, TestInfo } from '@stablyai/playwright-test'
|
||
import { test, expect } from './helpers/orca-app'
|
||
import { waitForActiveWorktree, waitForSessionReady, getActiveTabId } from './helpers/store'
|
||
import {
|
||
getTerminalContent,
|
||
sendToTerminal,
|
||
waitForActivePanePtyId,
|
||
waitForActiveTerminalManager,
|
||
waitForPaneIdentitySnapshot
|
||
} from './helpers/terminal'
|
||
import { parkHiddenTabBehindDecoy } from './helpers/terminal-hidden-parking'
|
||
import {
|
||
cleanupDockerSshRelayTarget,
|
||
startDockerSshRelayTarget,
|
||
type DockerSshRelayTarget
|
||
} from './helpers/docker-ssh-relay-target'
|
||
import { connectDockerSshRelayTarget } from './helpers/docker-ssh-relay-connection'
|
||
|
||
const RUN_DOCKER_SSH = process.env.ORCA_E2E_SSH_DOCKER === '1'
|
||
const PARKING_DELAY_MS = Number(process.env.ORCA_E2E_TERMINAL_PARKING_DELAY_MS) || 500
|
||
|
||
async function terminalTailContains(page: Page, marker: string): Promise<boolean> {
|
||
return page.evaluate((expected) => {
|
||
const tabId = window.__store?.getState().activeTabId
|
||
const manager = tabId ? window.__paneManagers?.get(tabId) : undefined
|
||
const pane = manager?.getActivePane?.() ?? manager?.getPanes?.()[0] ?? null
|
||
const buffer = pane?.terminal?.buffer?.active
|
||
if (!buffer) {
|
||
return false
|
||
}
|
||
const firstRow = Math.max(0, buffer.length - 200)
|
||
for (let row = buffer.length - 1; row >= firstRow; row -= 1) {
|
||
if (buffer.getLine(row)?.translateToString(true).includes(expected) === true) {
|
||
return true
|
||
}
|
||
}
|
||
return false
|
||
}, marker)
|
||
}
|
||
|
||
test.use({
|
||
seedTestRepo: false,
|
||
orcaAppExtraEnv: { ORCA_E2E_TERMINAL_PARKING_DELAY_MS: String(PARKING_DELAY_MS) }
|
||
})
|
||
|
||
// C1 slice A: SSH tabs park like local ones and reveal restores content from
|
||
// main's headless model (relay replay is the fallback). This is the SSH
|
||
// park+reveal round-trip fidelity check the design gate required.
|
||
test.describe('SSH terminal hidden view parking', () => {
|
||
test.skip(!RUN_DOCKER_SSH, 'Set ORCA_E2E_SSH_DOCKER=1 to run Docker-backed SSH tests.')
|
||
test.skip(process.platform === 'win32', 'Docker SSH parking uses POSIX SSH tooling.')
|
||
|
||
test('parks a hidden SSH tab and restores its scrollback on reveal', async ({
|
||
orcaPage
|
||
}, testInfo: TestInfo) => {
|
||
test.setTimeout(240_000)
|
||
let target: DockerSshRelayTarget | null = null
|
||
try {
|
||
target = startDockerSshRelayTarget(testInfo)
|
||
await waitForSessionReady(orcaPage)
|
||
const remote = await connectDockerSshRelayTarget(orcaPage, target)
|
||
await expect
|
||
.poll(() => waitForActiveWorktree(orcaPage), { timeout: 30_000 })
|
||
.toBe(remote.worktreeId)
|
||
await waitForActiveTerminalManager(orcaPage, 60_000)
|
||
const sshPtyId = await waitForActivePanePtyId(orcaPage, 60_000)
|
||
const sshTabId = await getActiveTabId(orcaPage)
|
||
if (!sshTabId) {
|
||
throw new Error('SSH terminal tab did not become active')
|
||
}
|
||
const snapshot = await waitForPaneIdentitySnapshot(orcaPage, 1)
|
||
expect(snapshot.panes[0]?.ptyId).toBe(sshPtyId)
|
||
|
||
// Why the ':' terminator: `${marker}_1:` must not substring-match _10/_100.
|
||
const marker = `SSH_PARK_MARKER_${Date.now()}`
|
||
await sendToTerminal(
|
||
orcaPage,
|
||
sshPtyId,
|
||
`for i in $(seq 1 200); do echo "${marker}_$i:"; done\r`
|
||
)
|
||
await expect
|
||
.poll(() => terminalTailContains(orcaPage, `${marker}_200:`), {
|
||
timeout: 30_000,
|
||
message: 'SSH marker output did not render before parking'
|
||
})
|
||
.toBe(true)
|
||
// Why the pad: ~3000 × ~60B ≈ 180KB pushes the early markers past the
|
||
// relay's 100KiB rolling replay buffer while staying inside main's
|
||
// ~5k-row headless model — so a revealed `${marker}_1:` can only have
|
||
// come from the model paint, never the relay fallback.
|
||
await sendToTerminal(
|
||
orcaPage,
|
||
sshPtyId,
|
||
`for i in $(seq 1 3000); do echo "PAD_$i:0123456789012345678901234567890123456789"; done; printf '%s%s\\n' "${marker}" "_PAD_DONE:"\r`
|
||
)
|
||
await expect
|
||
.poll(() => terminalTailContains(orcaPage, `${marker}_PAD_DONE:`), {
|
||
timeout: 60_000,
|
||
message: 'SSH pad output did not finish before parking'
|
||
})
|
||
.toBe(true)
|
||
// The renderer can paint a chunk before the main-owned model ingests it.
|
||
// Wait for that model before parking, which is the source this test verifies.
|
||
await expect
|
||
.poll(
|
||
() =>
|
||
orcaPage.evaluate(async (ptyId) => {
|
||
const snapshot = await window.api.pty.getMainBufferSnapshot(ptyId, {
|
||
scrollbackRows: 5_000
|
||
})
|
||
return snapshot?.data ?? ''
|
||
}, sshPtyId),
|
||
{
|
||
timeout: 60_000,
|
||
message: 'SSH headless model did not ingest the pad before parking'
|
||
}
|
||
)
|
||
.toContain(`${marker}_PAD_DONE:`)
|
||
|
||
await parkHiddenTabBehindDecoy(orcaPage, remote.worktreeId, sshTabId, {
|
||
parkDelayMs: PARKING_DELAY_MS
|
||
})
|
||
|
||
// Reveal: reattach must paint from main's headless model (or relay
|
||
// replay when the model is unavailable) — never a blank pane.
|
||
await orcaPage.evaluate((tabId) => {
|
||
const state = window.__store?.getState()
|
||
state?.setActiveTab(tabId)
|
||
state?.setActiveTabType('terminal')
|
||
}, sshTabId)
|
||
await waitForActiveTerminalManager(orcaPage, 60_000)
|
||
await expect
|
||
.poll(() => terminalTailContains(orcaPage, `${marker}_PAD_DONE:`), {
|
||
timeout: 60_000,
|
||
message: 'revealed SSH tab did not restore the final pad line'
|
||
})
|
||
.toBe(true)
|
||
// Depth proof: `${marker}_1:` predates >100KiB of later output, so its
|
||
// presence after reveal proves the headless-model paint restored
|
||
// scrollback the relay replay cannot hold.
|
||
await expect
|
||
.poll(() => getTerminalContent(orcaPage, 2_000_000), {
|
||
timeout: 15_000,
|
||
message: 'revealed SSH tab lost the pre-pad scrollback only the model paint restores'
|
||
})
|
||
.toContain(`${marker}_1:`)
|
||
} finally {
|
||
cleanupDockerSshRelayTarget(target)
|
||
}
|
||
})
|
||
})
|