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.

2.1 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { HIDEABLE_HEADER_BUTTONS, HIDEABLE_MENU_ITEMS, isHidden } from './ui-visibility'

describe('isHidden', () => {
  it('hides a hideable id that is listed', () => {
    expect(isHidden('duplicate', ['duplicate'])).toBe(true)
    expect(isHidden('mic', ['mic', 'comments'])).toBe(true)
  })
  it('ignores the retired live-link ids a settings.json from an older build still carries', () => {
    expect(isHidden('live-link', ['live-link', 'share-link'])).toBe(false)
    expect(isHidden('share-link', ['live-link', 'share-link'])).toBe(false)
  })
  it('shows everything when nothing is listed', () => {
    for (const { id } of [...HIDEABLE_MENU_ITEMS, ...HIDEABLE_HEADER_BUTTONS])
      expect(isHidden(id, [])).toBe(false)
  })
  it('never hides an id outside the hideable inventory, however the list got there', () => {
    for (const id of ['delete', 'restart-agent', 'search', 'close', 'branch'])
      expect(isHidden(id, [id])).toBe(false)
  })
  it('reads a hand-edited non-array value as nothing hidden', () => {
    for (const bad of [5, 'context-meter', null, undefined, { 'context-meter': true }])
      expect(isHidden('context-meter', bad as unknown as string[])).toBe(false)
  })
  it('ignores unknown ids in the list', () => {
    expect(isHidden('duplicate', ['nonsense', 'duplicate'])).toBe(true)
    expect(isHidden('nonsense', ['nonsense'])).toBe(false)
  })
})

describe('hideable inventories', () => {
  it('list the agreed ids and nothing destructive', () => {
    expect(HIDEABLE_MENU_ITEMS.map((r) => r.id)).toEqual([
      'group', 'remove-from-group', 'colors', 'icon', 'duplicate', 'snap-zone', 'collapse',
      'markdown-view', 'refresh-terminal', 'vanilla-restart'
    ])
    expect(HIDEABLE_HEADER_BUTTONS.map((r) => r.id)).toEqual([
      'context-meter', 'remote-control', 'maximize', 'refresh', 'mic', 'ai-name', 'comments', 'hide-fanout', 'tidy-fanout', 'md-hint'
    ])
  })
  it('gives every entry a user-facing label', () => {
    for (const { label } of [...HIDEABLE_MENU_ITEMS, ...HIDEABLE_HEADER_BUTTONS])
      expect(label.length).toBeGreaterThan(0)
  })
})