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 { WorkspaceSessionState } from './workspace-session-state-types'
/** Preserve base-only drafts because no other channel can recover them. */
export function keepUnsavedDrafts(next: WorkspaceSessionState, base: WorkspaceSessionState): void {
for (const [key, baseFiles] of Object.entries(base.openFilesByWorktree ?? {})) {
const files = next.openFilesByWorktree?.[key] ?? []
const drafts = new Map(
baseFiles.filter((file) => file.dirtyDraftContent !== undefined).map((f) => [f.filePath, f])
)
if (files === baseFiles || drafts.size === 0) {
continue
}
// A host entry with its own draft wins; a clean one yields to the base's draft for that path.
const held = new Set(files.map((file) => file.filePath))
const merged = [
...files.map(
(file) => (file.dirtyDraftContent === undefined && drafts.get(file.filePath)) || file
),
...[...drafts.values()].filter((file) => !held.has(file.filePath))
]
next.openFilesByWorktree = { ...next.openFilesByWorktree, [key]: merged }
}
}