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 {
hostPlatformSchema,
hostRepoCatalogSchema,
hostSshTargetSummariesSchema,
hostViewSettingsSchema
} from './host-screen-reply-schema'
describe('host screen reply schemas', () => {
it('requires the repo list and drops a row no map could key', () => {
expect(hostRepoCatalogSchema.safeParse({}).success).toBe(false)
const parsed = hostRepoCatalogSchema.parse({
repos: [{ id: 'r1', displayName: 'orca' }, { id: 'r2' }, { displayName: 'ghost' }]
})
expect(parsed.map((repo) => repo.id)).toEqual(['r1'])
})
it('salvages badgeColor onto the generated swatch main fell back to', () => {
expect(
hostRepoCatalogSchema.parse({ repos: [{ id: 'r', displayName: 'o', badgeColor: 3 }] })[0]
?.badgeColor
).toBeUndefined()
})
it('keeps a known repo icon arm and degrades an unknown one to absent', () => {
const known = hostRepoCatalogSchema.parse({
repos: [{ id: 'r', displayName: 'o', repoIcon: { type: 'emoji', emoji: 'x' } }]
})
expect(known[0]?.repoIcon).toEqual({ type: 'emoji', emoji: 'x' })
const unknown = hostRepoCatalogSchema.parse({
repos: [{ id: 'r', displayName: 'o', repoIcon: { type: 'svg', markup: '<svg/>' } }]
})
// Unknown icon arms retain the row and use MobileRepoIcon’s Folder default.
expect(unknown[0]?.id).toBe('r')
expect(unknown[0]?.repoIcon).toBeUndefined()
})
it('keeps an image icon whose source this build has never heard of', () => {
const [repo] = hostRepoCatalogSchema.parse({
repos: [
{
id: 'r',
displayName: 'o',
repoIcon: {
type: 'image',
src: 'https://example.invalid/a.png',
source: 'gitlab',
label: 'acme/orca'
}
}
]
})
// MobileRepoIcon ignores source; constraining it would drop images from newer hosts for a member the renderer never reads.
expect(repo?.repoIcon).toEqual({
type: 'image',
src: 'https://example.invalid/a.png',
source: 'gitlab',
label: 'acme/orca'
})
})
it('passes a host-id spelling through for getRepoExecutionHostId to judge', () => {
const [repo] = hostRepoCatalogSchema.parse({
repos: [{ id: 'r', displayName: 'o', executionHostId: 'cloud:zone-a', connectionId: null }]
})
expect(repo?.executionHostId).toBe('cloud:zone-a')
expect(repo?.connectionId).toBeNull()
})
it('degrades an unreadable ssh target list to the empty one that falls back to host ids', () => {
expect(hostSshTargetSummariesSchema.parse({})).toEqual([])
expect(hostSshTargetSummariesSchema.parse({ targets: 'none' })).toEqual([])
expect(
hostSshTargetSummariesSchema.parse({
targets: [{ id: 't', label: 'T' }, { id: 'u' }, { label: 'V' }]
})
).toEqual([{ id: 't', label: 'T' }])
})
it('keeps SSH lifecycle fields raw and drops a malformed one without losing the target', () => {
expect(
hostSshTargetSummariesSchema.parse({
targets: [
{ id: 't', label: 'T', connected: false, connectionStatus: 'hibernating' },
{ id: 'u', label: 'U', connected: 'no', connectionStatus: 7 }
]
})
).toEqual([
{ id: 't', label: 'T', connected: false, connectionStatus: 'hibernating' },
{ id: 'u', label: 'U' }
])
})
it('answers the empty target list for a reply that is no object at all', () => {
// Label writes precede platform writes; malformed targets must degrade to [] rather than skip both.
for (const payload of [null, undefined, 'nope', 42, []]) {
expect(hostSshTargetSummariesSchema.parse(payload)).toEqual([])
}
})
it('reads only a platform Node could have reported', () => {
expect(hostPlatformSchema.parse({ platform: 'win32' })).toBe('win32')
expect(hostPlatformSchema.parse({ platform: 'plan9' })).toBeNull()
expect(hostPlatformSchema.parse({ platform: '' })).toBeNull()
expect(hostPlatformSchema.parse({})).toBeNull()
for (const payload of [null, undefined, 'nope', 42]) {
expect(hostPlatformSchema.parse(payload)).toBeNull()
}
})
it('requires the ui member main read with a bare property access', () => {
expect(hostViewSettingsSchema.safeParse({}).success).toBe(false)
expect(hostViewSettingsSchema.safeParse(null).success).toBe(false)
expect(hostViewSettingsSchema.parse({ ui: {} })).toEqual({})
})
it('degrades an unknown grouping or sort arm to absent so the local mode is kept', () => {
const parsed = hostViewSettingsSchema.parse({
ui: { groupBy: 'agent', sortBy: 'stars', hideSleepingWorkspaces: 'yes' }
})
expect(parsed.groupBy).toBeUndefined()
expect(parsed.sortBy).toBeUndefined()
expect(parsed.hideSleepingWorkspaces).toBeUndefined()
})
it('keeps the known view arms and the lists the screen adopts', () => {
const parsed = hostViewSettingsSchema.parse({
ui: {
groupBy: 'workspace-status',
sortBy: 'recent',
filterRepoIds: ['r1'],
collapsedGroups: [],
workspaceStatuses: [{ id: 'active', label: 'Active' }]
}
})
expect(parsed.groupBy).toBe('workspace-status')
expect(parsed.sortBy).toBe('recent')
expect(parsed.filterRepoIds).toEqual(['r1'])
expect(parsed.workspaceStatuses).toEqual([{ id: 'active', label: 'Active' }])
})
it('reads every Workspace options value the desktop mirrors to its phone', () => {
const ui = {
hideAutomationGeneratedWorkspaces: true,
hideCliCreatedWorkspaces: false,
hideDetachedHeadWorkspaces: true,
hideWorkspacesFromOtherDevices: true,
projectOrderBy: 'recent',
worktreeCardProperties: ['status', 'a-property-from-a-newer-desktop'],
agentActivityDisplayMode: 'full'
}
expect(hostViewSettingsSchema.parse({ ui })).toEqual(ui)
})
it('reads a desktop that predates them as absent, which keeps the local value', () => {
const parsed = hostViewSettingsSchema.parse({
ui: { groupBy: 'repo', projectOrderBy: 'alphabetical', agentActivityDisplayMode: 7 }
})
expect(parsed).toEqual({ groupBy: 'repo' })
})
it('salvages a non-array status catalog rather than handing a string to the group lookups', () => {
expect(
hostViewSettingsSchema.parse({ ui: { workspaceStatuses: 'active' } }).workspaceStatuses
).toBeUndefined()
})
})
describe('repo icon payloads', () => {
it('preserves the lucide icon name the row renders', () => {
const [row] = hostRepoCatalogSchema.parse({
repos: [{ id: 'r', displayName: 'r', repoIcon: { type: 'lucide', name: 'Terminal' } }]
})
expect(row?.repoIcon).toEqual({ type: 'lucide', name: 'Terminal' })
})
})