Add durable AI cancellation and undoable output application

This commit is contained in:
2026-11-08 01:03:05 +08:00
parent d07bc2ef91
commit 6243602402
13 changed files with 255 additions and 47 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ import type { LedgerSnapshot } from './ledger.ts';
/** The footprint follows ownership; geometry does not decide which canvas owns an object. */
export function operationCanvases(intent: OperationIntent, document: Document): readonly Id[] {
if(intent.operationType==='asset.upload')return[];
if(intent.operationType==='asset.upload'||intent.operationType==='run.cancel')return[];
if (intent.canvasIds?.length) return intent.canvasIds;
const ids = new Set<Id>();
for (const change of intent.changes) {
@@ -30,7 +30,7 @@ export function operationCanvases(intent: OperationIntent, document: Document):
export function replayPending(base: Document, ledger: LedgerSnapshot, registry: Registry): Document {
let document = base;
for (const record of [...ledger.operations.values()].sort((a, b) => a.intent.sequence - b.intent.sequence)) {
if (record.phase === 'resolved' || record.intent.operationType!=='document.change') continue;
if (record.phase === 'resolved' || !['document.change','run.apply'].includes(record.intent.operationType)) continue;
for (const change of record.intent.changes) {
if (satisfied(document, change)) continue;
document = applyChanges(document, [change]);