mirror of
https://github.com/stablyai/orca.git
synced 2026-11-14 09:57:48 +00:00
* fix(chat): isolate sends from terminal drafts * test(chat): expect replacement clear for resume commands * test(chat): refresh draft-clear RPC recordings
27 lines
863 B
TypeScript
27 lines
863 B
TypeScript
import { isLoneStructuredAgentSessionConversationCommand } from './agent-session/view/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 trailing text would read as their arguments. */
|
|
export function appendReturnedDraftText(
|
|
draft: string,
|
|
text: string,
|
|
options?: { preserveConversationCommands?: boolean }
|
|
): string {
|
|
const returned = text.trimEnd()
|
|
if (returned.trim() === '') {
|
|
return draft
|
|
}
|
|
const kept = draft.trimEnd()
|
|
if (
|
|
kept === '' ||
|
|
(!options?.preserveConversationCommands &&
|
|
isLoneStructuredAgentSessionConversationCommand(kept))
|
|
) {
|
|
return text
|
|
}
|
|
if (kept === returned || kept.endsWith(`\n\n${returned}`)) {
|
|
return draft
|
|
}
|
|
return `${kept}\n\n${text}`
|
|
}
|