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.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import type { DiffComment } from './diff-comment-types'
/** Mutation-only snapshot; never persisted with workspace metadata. */
export type DiffCommentBaseMutation = {
diffCommentsBase?: DiffComment[]
}
// Why: a writer's list can predate another device's edits, so apply only what it changed since its base.
export function mergeDiffCommentMutation(
base: readonly DiffComment[],
current: readonly DiffComment[],
requested: readonly DiffComment[]
): DiffComment[] {
const baseById = new Map(base.map((comment) => [comment.id, comment]))
const requestedById = new Map(requested.map((comment) => [comment.id, comment]))
const retained = current.flatMap((comment) => {
const before = baseById.get(comment.id)
if (!before) {
return [comment]
}
const after = requestedById.get(comment.id)
if (!after) {
return []
}
return [JSON.stringify(before) === JSON.stringify(after) ? comment : after]
})
const currentIds = new Set(current.map((comment) => comment.id))
const added = requested.filter(
(comment) => !baseById.has(comment.id) && !currentIds.has(comment.id)
)
return [...retained, ...added]
}