Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/scripts/windows-pty-table-stress-observer.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ describe('Windows PTY stress observer', () => {
writeFileSync(addon, 'actual-loaded-bytes')
const hashes = loadedStressInputHashes(addon, () => addon)
expect(hashes[0]).toMatchObject({ name: 'conpty.node', bytes: 19 })
expect(hashes[0].sha256).toMatch(/^[a-f0-9]{64}$/)
expect(hashes[0].sha256).toBe(
'e61479b6ebc4f1f1ffd0a3cf819cbae5713843d250a9cbc6ad5fcfde1c922737'
)
expect(hashes[1]).toEqual({ name: 'conpty.dll', unavailable: 'ENOENT' })
expect(hashes[2]).toEqual({ name: 'OpenConsole.exe', unavailable: 'ENOENT' })
expect(hashes.slice(3).every((hash) => hash.sha256 === hashes[0].sha256)).toBe(true)
Expand Down
2 changes: 2 additions & 0 deletions config/scripts/windows-security-reuse-benchmark.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ it.each(['x64', 'arm64'])(
report.samples.every((sample) => sample.fullCommandMs >= sample.buildIncludingReuseProbesMs)
).toBe(true)
const phases = report.phases.map((phase) => phase.label)
expect(phases).toContain('verify-prepared-node')
expect(phases).toContain('warm-compiler-before-measurement')
Comment on lines +364 to +365

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

set -eu
file='config/scripts/windows-security-reuse-benchmark.test.mjs'
printf '%s\n' '--- matching phase references ---'
rg -n -F -e 'phases' -e 'verify-prepared-node' -e 'warm-compiler-before-measurement' "$file" || test "$?" -eq 1
printf '%s\n' '--- surrounding test block ---'
sed -n '300,390p' "$file"
printf '%s\n' '--- changed-file diff against supplied merge base ---'
git diff --unified=40 e30184fa8d383e9ae011e0fa0d3ea89df29f7cb2 2fa9fde5216bda93618a847c882e31e7aa3c3b4e -- "$file"

Repository: stablyai/orca

Length of output: 7856


Assert the relative phase order.

The existing index checks only require both phases to occur before control-full-build-and-probe. They do not require verify-prepared-node to occur before warm-compiler-before-measurement.

Suggested fix
--- "a/config/scripts/windows-security-reuse-benchmark.test.mjs"
+++ "b/config/scripts/windows-security-reuse-benchmark.test.mjs"
@@ -361,8 +361,10 @@
       report.samples.every((sample) => sample.fullCommandMs >= sample.buildIncludingReuseProbesMs)
     ).toBe(true)
     const phases = report.phases.map((phase) => phase.label)
-    expect(phases).toContain('verify-prepared-node')
-    expect(phases).toContain('warm-compiler-before-measurement')
+    const verifyPreparedNode = phases.indexOf('verify-prepared-node')
+    const warmCompiler = phases.indexOf('warm-compiler-before-measurement')
+    expect(verifyPreparedNode).toBeGreaterThanOrEqual(0)
+    expect(warmCompiler).toBeGreaterThan(verifyPreparedNode)
     expect(phases.indexOf('verify-prepared-node')).toBeLessThan(
       phases.indexOf('control-full-build-and-probe')
     )
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(phases).toContain('verify-prepared-node')
expect(phases).toContain('warm-compiler-before-measurement')
const verifyPreparedNode = phases.indexOf('verify-prepared-node')
const warmCompiler = phases.indexOf('warm-compiler-before-measurement')
expect(verifyPreparedNode).toBeGreaterThanOrEqual(0)
expect(warmCompiler).toBeGreaterThan(verifyPreparedNode)

expect(phases.indexOf('verify-prepared-node')).toBeLessThan(
phases.indexOf('control-full-build-and-probe')
)
Expand Down
16 changes: 13 additions & 3 deletions mobile/src/transport/host-credential-cleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function flushMicrotasks(): Promise<void> {

describe('host credential cleanup', () => {
beforeEach(() => {
vi.useRealTimers()
vi.useFakeTimers()
vi.clearAllMocks()
resetHostCredentialCleanupForTests()
storedPendingIds = []
Expand Down Expand Up @@ -75,12 +75,18 @@ describe('host credential cleanup', () => {
})

it('persists cleanup intent before a rejected delete for manual retry', async () => {
const deleteCredential = vi.fn().mockRejectedValue(new Error('keychain unavailable'))
const intentsAtDelete: string[][] = []
const deleteCredential = vi.fn(async (_hostId: string) => {
intentsAtDelete.push([...storedPendingIds])
throw new Error('keychain unavailable')
})
const listener = vi.fn()
const unsubscribe = subscribePendingHostCredentialCleanup(listener)

await scheduleHostCredentialCleanup('host-1', deleteCredential, 20)
await vi.waitFor(() => expect(deleteCredential).toHaveBeenCalledOnce())
expect(deleteCredential).toHaveBeenCalledWith('host-1')
expect(intentsAtDelete).toEqual([['host-1']])
await expect(loadPendingHostCredentialCleanupIds()).resolves.toEqual(['host-1'])
expect(listener).toHaveBeenCalled()
unsubscribe()
Expand Down Expand Up @@ -271,8 +277,12 @@ describe('host credential cleanup', () => {
})

it('soft-loads empty when pending-cleanup storage is malformed', async () => {
vi.mocked(AsyncStorage.getItem).mockResolvedValueOnce('{')
vi.mocked(AsyncStorage.getItem).mockResolvedValue('{')

await expect(loadPendingHostCredentialCleanupIds()).resolves.toEqual([])
await expect(loadPendingHostCredentialCleanup()).resolves.toEqual({
ids: [],
storageUnreadable: true
})
})
})
6 changes: 2 additions & 4 deletions mobile/src/transport/host-edit-navigation.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { describe, expect, it, vi } from 'vitest'
import {
mobileHostEditHostRoute,
mobileHostEditRouteTarget,
navigateToMobileHostEdit,
type MobileHostEditNavigationState
} from './host-edit-navigation'
Expand Down Expand Up @@ -54,7 +52,7 @@ describe('mobile host edit navigation', () => {

navigateToMobileHostEdit(harness.navigation, { push, replace: vi.fn() }, 'host/1')

expect(push).toHaveBeenCalledWith(mobileHostEditHostRoute('host/1'))
expect(push).toHaveBeenCalledWith('/h/host%2F1')
expect(harness.navigation.dispatch).not.toHaveBeenCalled()

// The host route commits before its stack mounts; the old root-only predicate fired here.
Expand All @@ -68,7 +66,7 @@ describe('mobile host edit navigation', () => {
type: 'REPLACE',
target: '/h',
source: 'host-index',
payload: mobileHostEditRouteTarget('host/1')
payload: { name: '[hostId]/edit', params: { hostId: 'host/1' } }
})
})

Expand Down
14 changes: 0 additions & 14 deletions mobile/src/transport/host-endpoint-edit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { describe, expect, it } from 'vitest'
import { displayHostEndpoint } from './host-endpoint'
import { resolveHostEndpointEdit } from './host-endpoint-edit'

function persistedAfterEdit(stored: string, input = displayHostEndpoint(stored)) {
const edit = resolveHostEndpointEdit(stored, input)
return edit.kind === 'changed' ? edit.endpoint : stored
}

describe('resolveHostEndpointEdit', () => {
it.each([
['implicit secure DNS proxy', 'wss://desk.example.com'],
Expand All @@ -26,7 +21,6 @@ describe('resolveHostEndpointEdit', () => {
const edit = resolveHostEndpointEdit(stored, displayHostEndpoint(stored))

expect(edit).toEqual({ kind: 'unchanged', endpoint: stored })
expect(persistedAfterEdit(stored)).toBe(stored)
})

it.each([
Expand Down Expand Up @@ -93,12 +87,4 @@ describe('resolveHostEndpointEdit', () => {
error: 'Use ws:// or wss:// (or host:port).'
})
})

it('stays stable through repeated name-only edits', () => {
const stored = 'wss://desk.example.com/orca?route=runtime'
const once = persistedAfterEdit(stored)

expect(once).toBe(stored)
expect(persistedAfterEdit(once)).toBe(stored)
})
})
4 changes: 0 additions & 4 deletions mobile/src/transport/host-endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ describe('displayHostEndpoint', () => {
it('returns the raw string when not a URL', () => {
expect(displayHostEndpoint('not-a-url')).toBe('not-a-url')
})

it('brackets IPv6 hostnames for round-trip safety', () => {
expect(displayHostEndpoint('ws://[fd7a:115c:a1e0::1]:6768')).toBe('[fd7a:115c:a1e0::1]:6768')
})
})

describe('endpointPort', () => {
Expand Down
7 changes: 6 additions & 1 deletion mobile/src/transport/host-store-endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ describe('relay routing after a host edit', () => {
expect(storage.get('orca:hosts')).toBe(hostsAfterEdit)
expect(SecureStore.setItemAsync).not.toHaveBeenCalled()
const [host] = await loadHosts()
expect(host).toMatchObject({ name: 'Renamed', endpoint: NEW_ENDPOINT, relay: moved })
expect(host).toMatchObject({
name: 'Renamed',
endpoint: NEW_ENDPOINT,
deviceToken: 'device-token',
relay: moved
})
})

it('does not rewrite storage when relay resolution repeats the stored routing', async () => {
Expand Down
2 changes: 2 additions & 0 deletions mobile/src/transport/relay-host-reachability-latch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ describe('RelayHostReachabilityLatch', () => {
const latch = new RelayHostReachabilityLatch()
latch.record(closed(OFFLINE))
latch.record(closed(OFFLINE))
latch.record(closed(1006))
expect(latch.current()).toBe('host-offline')
latch.record(closed(MOBILE_RELAY_CLOSE_CODE.DRAINING))
expect(latch.current()).toBe('host-offline')
latch.record(closed(1006))
Expand Down
9 changes: 6 additions & 3 deletions mobile/src/transport/relay-host-signed-out-supervisor.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { MOBILE_RELAY_CLOSE_CODE } from '../../../src/shared/mobile-relay-close-codes'
import { RELAY_HOST_CLOSE_REASON } from '../../../src/shared/relay-host-close-reason'
import {
RELAY_HOST_CLOSE_REASON,
type RelayHostCloseReason
} from '../../../src/shared/relay-host-close-reason'
import { RelayOuterError } from './mobile-relay-e2ee-link'
import {
dependencies,
Expand All @@ -24,13 +27,13 @@ describe('a signed-out desktop reaches the phone verdict', () => {
})
afterEach(() => vi.useRealTimers())

function supervisorOver(closeReason: string | null) {
function supervisorOver(closeReason: RelayHostCloseReason | null) {
const logical = new FakeLogicalClient('disconnected', 'lan')
const deps = dependencies({
openDirect: vi.fn(() => new FakeRelaySession('disconnected')),
openRelay: vi.fn((_relay, _credential, _confirmReqId, onHostCloseReason) => {
if (closeReason) {
onHostCloseReason?.(closeReason as never)
onHostCloseReason?.(closeReason)
}
return new FakeRelaySession(
'disconnected',
Expand Down
9 changes: 2 additions & 7 deletions mobile/src/transport/relay-host-signed-out-verdict.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('relay close reason on the phone', () => {
})

expect(onHostCloseReason).toHaveBeenCalledWith(RELAY_HOST_CLOSE_REASON.SIGNED_OUT)
expect(onError).toHaveBeenCalledOnce()
expect(onError).toHaveBeenCalledWith(
new RelayOuterError(
MOBILE_RELAY_CLOSE_CODE.HOST_OFFLINE,
Expand Down Expand Up @@ -161,19 +162,13 @@ describe('the sign-out the cell reported outranks a later plain 4404', () => {
const controller = controllerReporting(reported)

controller.assertHostReachability('signed-out')
expect(reported).toEqual(['connecting', 'signed-out'])
controller.registerFailure(new RelayOuterError(MOBILE_RELAY_CLOSE_CODE.HOST_OFFLINE), false)
controller.registerFailure(new RelayOuterError(MOBILE_RELAY_CLOSE_CODE.HOST_OFFLINE), false)

expect(reported).toEqual(['connecting', 'signed-out'])
})

it('needs no streak: one cell close reason is the whole evidence', () => {
const reported: RelayHostReachability[] = []
controllerReporting(reported).assertHostReachability('signed-out')

expect(reported.at(-1)).toBe('signed-out')
})

it('retires on a connection like every other verdict', () => {
const reported: RelayHostReachability[] = []
const controller = controllerReporting(reported)
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/src/lib/browser-workspace-tab-activation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ it('accepts a hostless browser tab when the worktree ID is unambiguous', () => {
executionHostId: 'ssh:remote'
})
).toEqual(browserTab)

useAppStore.setState({
unifiedTabsByWorktree: {
wt: [browserTab],
other: [{ ...browserTab, worktreeId: 'other', contentType: 'terminal', entityId: 'terminal' }]
}
})
expect(
getActivatableBrowserWorkspaceTab({
worktreeId: 'wt',
workspaceId: 'workspace',
executionHostId: 'ssh:remote'
})
).toBeNull()
})

it('includes folder workspaces when rejecting ambiguous hostless activation', () => {
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/src/lib/http-link-destinations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ describe('buildHttpLinkActions', () => {
})

it('falls back to a generic label when no destination is known', () => {
const actions = buildHttpLinkActions(undefined, () => {})
const opened: (string | undefined)[] = []
const actions = buildHttpLinkActions(undefined, (destination) => {
opened.push(destination)
})
expect(actions.primary.label).toBe('Open link')
expect(actions.alternate).toBeUndefined()
void actions.primary.run()
expect(opened).toEqual([undefined])
})
})
3 changes: 3 additions & 0 deletions src/renderer/src/lib/local-path-open-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ describe('getLocalPathOpenOwnerForRoute', () => {
it('spells a route as its owning host', () => {
expect(getLocalPathOpenOwnerForRoute({})).toBe('local')
expect(getLocalPathOpenOwnerForRoute({ runtimeEnvironmentId: ' env-2 ' })).toBe('runtime:env-2')
expect(
getLocalPathOpenOwnerForRoute({ runtimeEnvironmentId: 'env-2', connectionId: 'ssh-1' })
).toBe('runtime:env-2')
expect(getLocalPathOpenOwnerForRoute({ connectionId: 'ssh-1' })).toBe('ssh:ssh-1')
expect(getLocalPathOpenOwnerForRoute({ connectionId: ' ssh-1 ' })).toBe('ssh:ssh-1')
expect(getLocalPathOpenOwnerForRoute({ connectionId: ' ' })).toBe('local')
Expand Down