Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

1.5 KB
Raw Blame
import { afterEach, describe, expect, it } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import {
  BUILTIN_AGENT_IDS,
  setCustomAgentBaseResolver,
  type AgentId,
  type BuiltinAgentId
} from '@shared/agents/config'
import { AgentIcon } from './agentIcons'

const renderIcon = (agentId: AgentId, size = 18): string =>
  renderToStaticMarkup(<AgentIcon agentId={agentId} size={size} />)

afterEach(() => setCustomAgentBaseResolver(null))

describe('AgentIcon custom-agent inheritance', () => {
  it('renders the exact base harness icon for inheriting custom agents', () => {
    const bases: BuiltinAgentId[] = [...BUILTIN_AGENT_IDS]
    setCustomAgentBaseResolver((id) => {
      const base = id.startsWith('custom:') ? id.slice('custom:'.length) : ''
      return bases.includes(base as BuiltinAgentId) ? (base as BuiltinAgentId) : undefined
    })

    for (const base of bases) {
      expect(renderIcon(`custom:${base}`), base).toBe(renderIcon(base))
    }
  })

  it('keeps the terminal fallback for baseless custom agents', () => {
    setCustomAgentBaseResolver(() => undefined)

    const custom = renderIcon('custom:plain')
    expect(custom).not.toBe(renderIcon('claude'))
    expect(custom).not.toBe(renderIcon('grok'))
    expect(custom).toContain('<svg')
  })

  it('preserves the requested size after resolving the base icon', () => {
    setCustomAgentBaseResolver((id) => (id === 'custom:claude' ? 'claude' : undefined))
    expect(renderIcon('custom:claude', 23)).toBe(renderIcon('claude', 23))
  })
})