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.

944 B
Raw Blame
/** What an explicit terminal close removes. A pane close never stands in for its tab. */
export type TerminalSurfaceCloseTarget =
  | { kind: 'tab'; tabId: string }
  | { kind: 'pane'; tabId: string; leafId: string }

export type TerminalPaneCloseTarget = Extract<TerminalSurfaceCloseTarget, { kind: 'pane' }>

function isNonEmptyString(value: unknown): value is string {
  return typeof value === 'string' && value.length > 0
}

export function parseTerminalSurfaceCloseTarget(value: unknown): TerminalSurfaceCloseTarget | null {
  if (typeof value !== 'object' || value === null || !('kind' in value) || !('tabId' in value)) {
    return null
  }
  const { kind, tabId } = value
  if (!isNonEmptyString(tabId)) {
    return null
  }
  if (kind === 'tab') {
    return { kind, tabId }
  }
  if (kind !== 'pane' || !('leafId' in value) || !isNonEmptyString(value.leafId)) {
    return null
  }
  return { kind, tabId, leafId: value.leafId }
}