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.

940 B
Raw Blame
// Decode child views once at client admission so equality and readers never consume raw wire rows.

import type { AgentSessionBackgroundTaskState } from './agent-session-wire'
import { backgroundTaskStatesEqual } from './agent-session-background-task-state-equality'
import { decodeAgentChildWorkViews } from './agent-status-child-work-view-wire'

/** Preserve identity on repeated rosters so memoized readers skip unchanged frames. */
export function admitAgentSessionBackgroundTaskState(
  next: AgentSessionBackgroundTaskState | null | undefined,
  previous?: AgentSessionBackgroundTaskState | null
): AgentSessionBackgroundTaskState | null | undefined {
  if (!next) {
    return next
  }
  const { children: raw, ...rest } = next
  const children = decodeAgentChildWorkViews(raw)
  const decoded = { ...rest, ...(children ? { children } : {}) }
  return previous && backgroundTaskStatesEqual(decoded, previous) ? previous : decoded
}