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>
27 lines
733 B
TypeScript
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);
|
|
}
|