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 { isLoneStructuredAgentSessionConversationCommand } from './structured-agent-session-composer'
/** Append returned text without replacing typed drafts or duplicating an existing suffix.
* Replace lone /compact or /clear commands: they were unsent and cannot accept trailing text. */
export function appendReturnedDraftText(draft: string, text: string): string {
const returned = text.trimEnd()
if (returned.trim() === '') {
return draft
}
const kept = draft.trimEnd()
if (kept === '' || isLoneStructuredAgentSessionConversationCommand(kept)) {
return text
}
if (kept === returned || kept.endsWith(`\n\n${returned}`)) {
return draft
}
return `${kept}\n\n${text}`
}