Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { describe, expect, it } from 'vitest'
import {
getNotificationNavigationTarget,
notificationCredentialRecoveryRoute
} from './notification-routing'
describe('notification routing', () => {
// Identities stay raw: the target is dispatched as navigator params, not a URL.
it('routes notification taps to the worktree terminal screen', () => {
expect(
getNotificationNavigationTarget({
hostId: 'host-1',
worktreeId: 'repo::/Users/me/orca/workspaces/feature'
})
).toEqual({
hostId: 'host-1',
sessionTarget: {
name: '[hostId]/session/[worktreeId]',
params: { hostId: 'host-1', worktreeId: 'repo::/Users/me/orca/workspaces/feature' }
}
})
})
it('falls back to the host screen when the payload has no worktree id', () => {
expect(getNotificationNavigationTarget({ hostId: 'host-1' })).toEqual({
hostId: 'host-1',
sessionTarget: null
})
})
it('ignores payloads that cannot identify the paired host', () => {
expect(getNotificationNavigationTarget({ worktreeId: 'repo::/tmp/worktree' })).toBeNull()
})
it('ignores payloads for hosts that are no longer paired', () => {
expect(
getNotificationNavigationTarget(
{ hostId: 'removed-host', worktreeId: 'repo::/tmp/worktree' },
{ knownHostIds: new Set(['host-1']) }
)
).toBeNull()
})
it.each([
['missing', 're-pair'],
['temporarily-unavailable', 'retry']
] as const)('routes %s host credentials to %s recovery', (status, recovery) => {
const target = getNotificationNavigationTarget(
{ hostId: 'host-1', worktreeId: 'repo::/tmp/worktree' },
{
knownHostIds: new Set(['host-1']),
credentialStatusByHostId: new Map([['host-1', status]])
}
)
expect(target).toMatchObject({ hostId: 'host-1', credentialRecovery: recovery })
expect(notificationCredentialRecoveryRoute(target!)).toBe(
status === 'missing' ? '/pair-scan' : '/'
)
})
it('keeps ready hosts on the requested notification destination', () => {
const target = getNotificationNavigationTarget(
{ hostId: 'host-1', worktreeId: 'repo::/tmp/worktree' },
{ credentialStatusByHostId: new Map([['host-1', 'ready']]) }
)
expect(target?.sessionTarget).not.toBeNull()
expect(notificationCredentialRecoveryRoute(target!)).toBeNull()
})
})
it('preserves the originating pane in the workspace route', () => {
const paneKey = 'tab-b:11111111-1111-4111-8111-111111111111'
expect(
getNotificationNavigationTarget({ hostId: 'host', worktreeId: 'folder:/work', paneKey })
?.sessionTarget?.params
).toEqual({ hostId: 'host', worktreeId: 'folder:/work', paneKey })
})
it('scopes a tap to a server workspace, and keeps anything else on the desktop', () => {
const paramsFor = (executionHost: unknown) =>
getNotificationNavigationTarget({ hostId: 'host', worktreeId: 'repo::/srv', executionHost })
?.sessionTarget?.params
expect(paramsFor('runtime:env-1')).toEqual({
hostId: 'host',
worktreeId: 'repo::/srv',
executionHost: 'runtime:env-1'
})
for (const notAServer of [undefined, '', 'local', 'ssh:box', 'runtime:', 'env-1', 42]) {
expect(paramsFor(notAServer)).toEqual({ hostId: 'host', worktreeId: 'repo::/srv' })
}
})