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.

851 B
Raw Blame
import type { AgentStatus } from '../agent-title-core'
import type { ProgramActivityChange } from '../agent-status-osc'

/** An activity change to apply before the title at `beforeTitle` (`titles.length`: after them all). */
export type PlacedProgramActivity = { beforeTitle: number; activity: AgentStatus | null }

/** Interleave explicit activity with titles in chunk order; titles preceding a later Clear must use the activity that existed then. */
export function placeProgramActivityAmongTitles(
  titleEnds: readonly number[],
  activity: readonly ProgramActivityChange[]
): PlacedProgramActivity[] {
  let titleIndex = 0
  return activity.map((change) => {
    while (titleIndex < titleEnds.length && titleEnds[titleIndex] <= change.offset) {
      titleIndex += 1
    }
    return { beforeTitle: titleIndex, activity: change.activity }
  })
}