Files
orca/cloud/apps/push/src/push-execution-host-routing.test.ts
T
Jinwoo Hong 43645e5274 feat(push): carry a notification's workspace server to the phone (#26516)
A desktop relays alerts for agents on its paired servers, but the push named
only the server's worktree, so a tap opened it on the desktop and bounced.
The gateway accepts an optional runtime execution host and forwards it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
2026-10-11 02:09:36 -04:00

36 lines
1.3 KiB
TypeScript

import { expect, it } from 'vitest'
import { PushNotificationSchema } from '@orca-cloud/push-contract'
import { buildPushDelivery, orcaDataStrings } from './push-delivery-message.js'
const base = {
notificationSeq: 1,
notificationEpoch: 'epoch',
source: 'agent-task-complete',
agentState: 'finished',
title: 'Done',
body: '',
worktreeId: 'repo-1::/srv/work'
}
it('carries the workspace server to APNs and FCM, and accepts older messages without one', () => {
const executionHost = 'runtime:env%201'
for (const extra of [{}, { executionHost }]) {
const delivery = buildPushDelivery({
notification: PushNotificationSchema.parse({ ...base, ...extra }),
hostFingerprint: 'host',
registrationId: 'phone',
expiresAt: Date.now() + 300000
})
const expected = 'executionHost' in extra ? executionHost : undefined
expect(delivery.orca.executionHost).toBe(expected)
expect(orcaDataStrings(delivery.orca).executionHost).toBe(expected)
}
})
it('accepts only runtime execution hosts', () => {
const invalid = ['local', 'ssh:box', 'runtime:', 'runtime:a|b', `runtime:${'x'.repeat(2048)}`]
for (const executionHost of invalid) {
expect(PushNotificationSchema.safeParse({ ...base, executionHost }).success).toBe(false)
}
})