Files
orca/tests/e2e/helpers/nested-runtime-same-id-pairing.ts
506d116ee3 Move saved server reads and writes off the main thread (#42253)
* Move environment store operations off the main thread

* Preserve CLI startup speed with the serialized environment owner

* Handle absent paired host labels in the producer regression fixture

* Preserve publication ownership and copy selected environment results

* Correct publication and WSL readiness regression fixtures

* Include environment store worker in deployed server artifacts

* Check fresh listing publication across an intervening store update

* Await store-backed results in new recovery coverage

* Retire failed page publications and retain CLI worker support entries

* Unpack environment store support modules for the installed CLI

* Align async store callers with their return contracts

* Avoid hardening work for absent environment store files

* Keep permission repair bounded to one hardening attempt

* Align store test fixtures and await pairing replacement

* Use the semantic store operation for external pairing fixtures

* Provide the live sender frame in the timed subscription fixture

* Share pending server lookups and settle retired phone requests

* Keep the relay error type import

* Keep status ownership and transport imports acyclic

* Await replacement pairing in status retirement cases

* Keep asynchronous server rows bound to their admitted pairing

* Keep inventory snapshots and queued delivery at one publication boundary

* Await saved-host and graph test setup through publication completion

* Finish async fixture types and remove foreground timing probe

* Await renderer surface transitions in process identity coverage

* Await nested graph publication fixtures through their callers

* Await restored pane graph publication before hook assertions

* Include imported store worker and sidebar files in web typecheck

* Prepare saved host storage in source-based WSL test rigs

* Await saved server lookups in the source retirement diagnostic

* Preserve newer WSL status across async saved-host reads

* Fence stopped probes when a newer WSL Ready arrives

* Keep saved WSL host selection covered when admission is off

* Check WSL probe ownership after async admission

* Preserve WSL stop authority without cancelling Ready persistence

* Prune removed WSL E2E real-time wait from flaky-test baseline

* Limit WSL callback invalidation to confirmed stops

* Retire pending WSL notices on every confirmed stop

* Close the WSL picker dialog explicitly between scenarios

* perf(layout): skip unused normalization reports in pane commands (#42615)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Clarify cleanup pinning and ignored-file protection (#42616)

* test: remove 55 low-value suites and assertion driver (#42605)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>

* fix(skills): skip Claude sync scratch folders during skill discovery (#42610)

Claude Code parks replaced skill copies in `.trash` and in-progress syncs
in `.staging` under its skills roots. Discovery walked into both, so each
synced skill showed up as duplicates. Prune those directory names in the
native file walk and in the generated WSL `find` command.

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>

* test: remove 78 low-value suites and trim redundant cases (#42621)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>

* Keep quit teardown within the source line budget

---------

Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: OrcaWin <alpha-eng@stably.ai>
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
Co-authored-by: BingZ <zzb@gxsmjx.com>
Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
2026-11-15 02:45:45 -08:00

59 lines
2.7 KiB
TypeScript

import type { Page } from '@stablyai/playwright-test'
import { updateEnvironmentFromPairingCode } from '../../../src/shared/remote-runtime/host-store/runtime-environment-store-operations'
export type SameIdPairingReplacement = {
environmentId: string
previousPairingRevision: number
nextPairingRevision: number
}
export async function replaceRuntimePairingInPlace(args: {
environmentId: string
page: Page
pairingUrl: string
userDataDir: string
}): Promise<SameIdPairingReplacement> {
const previous = await args.page.evaluate((selector) => {
return window.api.runtimeEnvironments.resolve({ selector })
}, args.environmentId)
await args.page.evaluate(async (selector) => {
await window.api.runtimeEnvironments.disconnect({ selector })
}, args.environmentId)
const updated = updateEnvironmentFromPairingCode(args.userDataDir, args.environmentId, {
pairingCode: args.pairingUrl
})
const hydrated = await args.page.evaluate(async (selector) => {
const store = window.__store
if (!store) {
throw new Error('Paired desktop store is unavailable during same-ID re-pair')
}
const connection = await window.api.runtimeEnvironments.connect({ selector })
if (!connection.ok) {
throw new Error(`Same-ID re-pair reconnect failed: ${JSON.stringify(connection.error)}`)
}
const environments = await window.api.runtimeEnvironments.list()
store.getState().setRuntimeEnvironments(environments)
if (!(await store.getState().refreshRuntimeEnvironmentStatus(selector))) {
throw new Error('Same-ID re-paired desktop could not reach the HUB runtime')
}
if (!(await store.getState().setActiveRuntimeEnvironmentPreference(selector))) {
throw new Error('Same-ID re-paired desktop could not select the HUB runtime')
}
// Why: same-ID selection is a no-op, so explicitly rehydrate the graph from the replacement transport.
await store.getState().fetchRepos({ runtimeEnvironmentId: selector, throwOnError: true })
await store.getState().fetchAllWorktrees()
await store.getState().fetchWorktreeLineage()
return window.api.runtimeEnvironments.resolve({ selector })
}, args.environmentId)
const previousPairingRevision = previous.pairingRevision ?? previous.createdAt
const nextPairingRevision = hydrated.pairingRevision ?? hydrated.createdAt
if (updated.id !== args.environmentId || hydrated.id !== args.environmentId) {
throw new Error('Same-ID re-pair unexpectedly changed the environment identity')
}
if (nextPairingRevision <= previousPairingRevision) {
throw new Error('Same-ID re-pair did not advance the pairing revision')
}
return { environmentId: args.environmentId, previousPairingRevision, nextPairingRevision }
}