Files
Agent-System/web/src/lib/durableBodySnippet.ts
T
weichenandCursor 5db2d9a3b1 fix(e2e): persist the winning A1 body snippet for post-restart
UI-13b already made A1 the durable document, but phase-state still expected the UI-06 marker. Record successful saves as the latest snippet, ignore conflict drafts, and write that final value at UI-15-pre without relaxing the restore assertion.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 23:28:17 +00:00

27 lines
733 B
TypeScript

export type DurableBodyEvent =
| { kind: 'persisted'; snippet: string }
| { kind: 'conflict_draft'; snippet: string };
export function requireDurableSnippet(snippet: string): string {
const next = snippet.trim();
if (!next) {
throw new Error('empty_durable_body_snippet');
}
return next;
}
/**
* Latest server-durable body snippet for post-restart.
* A later successful save replaces the previous snippet.
* A conflict-failed editor draft never becomes the expected body.
*/
export function nextDurableBodySnippet(
current: string | undefined,
event: DurableBodyEvent,
): string | undefined {
if (event.kind === 'conflict_draft') {
return current;
}
return requireDurableSnippet(event.snippet);
}