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 type { Repo } from './repo-types'
import type { ManualRepoOrderEntry } from './ui-chrome-types'
import {
applyManualRepoOrder,
getManualRepoOrder,
normalizeManualRepoOrder
} from './manual-repo-order'
function repo(id: string, hostId: Repo['executionHostId']): Repo {
return {
id,
path: `/${hostId}/${id}`,
displayName: id,
badgeColor: '#000',
addedAt: 1,
executionHostId: hostId
}
}
const localAlpha = repo('alpha', 'local')
const localBravo = repo('bravo', 'local')
const remoteCharlie = repo('charlie', 'runtime:node-b')
const remoteDelta = repo('delta', 'runtime:node-b')
describe('manual repo order', () => {
it('returns the input array when no overlay exists', () => {
const repos = [localBravo, localAlpha]
expect(applyManualRepoOrder(repos, [])).toBe(repos)
})
it('returns the input array when the saved order moves nothing', () => {
const repos = [localAlpha, remoteCharlie, localBravo, remoteDelta]
expect(applyManualRepoOrder(repos, getManualRepoOrder(repos))).toBe(repos)
})
it('returns a new array when the saved order actually reorders', () => {
const repos = [localBravo, localAlpha]
const reordered = applyManualRepoOrder(repos, getManualRepoOrder([localAlpha, localBravo]))
expect(reordered).not.toBe(repos)
expect(reordered).toEqual([localAlpha, localBravo])
})
it('restores a host-qualified cross-host interleaving', () => {
const order = getManualRepoOrder([localAlpha, remoteCharlie, localBravo, remoteDelta])
expect(
applyManualRepoOrder([remoteCharlie, remoteDelta, localAlpha, localBravo], order)
).toEqual([localAlpha, remoteCharlie, localBravo, remoteDelta])
})
it('places a late host into its saved positions', () => {
const order = getManualRepoOrder([localAlpha, remoteCharlie, localBravo, remoteDelta])
const localOnly = applyManualRepoOrder([localBravo, localAlpha], order)
expect(applyManualRepoOrder([...localOnly, remoteDelta, remoteCharlie], order)).toEqual([
localAlpha,
remoteCharlie,
localBravo,
remoteDelta
])
})
it('distinguishes duplicate bare repo ids on different hosts', () => {
const local = repo('same-id', 'local')
const remote = repo('same-id', 'runtime:node-b')
const order = getManualRepoOrder([remote, local])
expect(applyManualRepoOrder([local, remote], order)).toEqual([remote, local])
})
it('appends unranked repos in their source order', () => {
const newOne = repo('new-one', 'local')
const newTwo = repo('new-two', 'runtime:node-b')
const order = getManualRepoOrder([remoteCharlie, localAlpha])
expect(applyManualRepoOrder([newTwo, localAlpha, newOne, remoteCharlie], order)).toEqual([
remoteCharlie,
localAlpha,
newTwo,
newOne
])
})
it('normalizes malformed, invalid-host, and duplicate entries', () => {
const value = [
null,
{ hostId: 'bogus', repoId: 'bad-host' },
{ hostId: 'local', repoId: '' },
{ hostId: 'runtime:node-b', repoId: 'same-id' },
{ hostId: 'runtime:node-b', repoId: 'same-id' },
{ hostId: 'local', repoId: 'same-id' }
] as unknown as ManualRepoOrderEntry[]
expect(normalizeManualRepoOrder(value)).toEqual([
{ hostId: 'runtime:node-b', repoId: 'same-id' },
{ hostId: 'local', repoId: 'same-id' }
])
})
})