This commit is contained in:
2026-10-20 14:25:01 +08:00
parent 5679b156ca
commit 03b1e7163e
23 changed files with 425 additions and 54 deletions
@@ -64,7 +64,9 @@ export function useDispatchCommandRecovery(scope: () => string) {
try { const sent = await send(snapshot(command)); validateCommandResult(sent, command); command.result = sent }
catch (error) {
// A later rejection cannot erase an earlier unknown write result.
if (!previouslyAttempted && isDefiniteDispatchRejection(error)) command.rejected = true
if (!previouslyAttempted && isDefiniteDispatchRejection(error)) {
pending.value = null
}
persist(); throw error
}
}
@@ -75,8 +77,11 @@ export function useDispatchCommandRecovery(scope: () => string) {
} finally { busy.value = false }
}
function discardRejected() {
if (busy.value || !pending.value?.rejected) return
if (busy.value || pending.value?.rejected !== true) return
pending.value = null; persist()
}
// Older browser records explicitly marked a first-attempt rejection as terminal.
// Only that recorded proof permits cleanup; unknown attempts and proven results remain.
discardRejected()
return { pending, busy, begin, execute, discardRejected }
}