mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-05 06:08:59 +00:00
feat(adoption): one owner for config/layout identity and the adoption sequence
`src/config-adoption.ts` owns config/layout with revision and fingerprint; the host keeps `_serverCfg`/`_cfgRev`/`_layout`/`_layoutRev` as delegates. All seven authoritative adoptions go through `adoptAuthoritativeGated` (backdrop readiness → continuity → adopt → profile tail); the post-write paths (space/delete ×2, optimize_undo, import/apply) gain the gate and take revisions from the re-read bodies. `rollbackOptimistic` moves to the owner; plan-optimize, space copy and the vacuum writers stop assigning identity. Issue: #500 User-Visible: no
This commit is contained in:
@@ -35,25 +35,5 @@ export function optimisticAttempt<T>(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll back only the failed candidate represented by this attempt. A conflict
|
||||
* reload or a newer edit owns a different revision/content and must win.
|
||||
*/
|
||||
export function rollbackOptimistic<T>(
|
||||
host: {
|
||||
_serverCfg: T | null;
|
||||
_cfgRev: number;
|
||||
_cfgContentFingerprint: string;
|
||||
requestUpdate: () => unknown;
|
||||
},
|
||||
attempt: OptimisticAttempt<T>,
|
||||
fingerprint: (value: T) => string,
|
||||
): boolean {
|
||||
const current = host._serverCfg;
|
||||
if (!current || host._cfgRev !== attempt.revision
|
||||
|| fingerprint(current) !== attempt.attemptedFingerprint) return false;
|
||||
host._serverCfg = attempt.previous;
|
||||
host._cfgContentFingerprint = attempt.previousFingerprint;
|
||||
host.requestUpdate();
|
||||
return true;
|
||||
}
|
||||
// The rollback of an attempt lives with the identity owner:
|
||||
// `ConfigAdoption.rollbackOptimistic` (#500).
|
||||
|
||||
Reference in New Issue
Block a user