Skip to content

armgit / orca

Public Imported from GitHub
0

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.

1.0 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { pickResumeWorktree } from './resume-worktree'

const wt = (id: string, extra: { isActive?: boolean; lastOutputAt?: number } = {}) => ({
  id,
  ...extra
})

describe('pickResumeWorktree', () => {
  it('returns null for an empty list', () => {
    expect(pickResumeWorktree([])).toBeNull()
  })

  it('prefers the desktop-active worktree over list order and output time', () => {
    const list = [
      wt('a', { lastOutputAt: 999 }),
      wt('b', { isActive: true, lastOutputAt: 1 }),
      wt('c', { lastOutputAt: 500 })
    ]
    expect(pickResumeWorktree(list)?.id).toBe('b')
  })

  it('falls back to the most recent output when none is desktop-active', () => {
    const list = [wt('a', { lastOutputAt: 10 }), wt('b', { lastOutputAt: 99 }), wt('c')]
    expect(pickResumeWorktree(list)?.id).toBe('b')
  })

  it('falls back to the first when there is no output timing', () => {
    const list = [wt('a'), wt('b'), wt('c')]
    expect(pickResumeWorktree(list)?.id).toBe('a')
  })
})