@avocadostudio-ai/orchestrator-core 0.12.1 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http/history-actions.js +24 -4
- package/package.json +3 -3
|
@@ -16,6 +16,26 @@
|
|
|
16
16
|
* file.
|
|
17
17
|
*/
|
|
18
18
|
import { scopedSessionKey, historyUndo, historyRedo, getHistoryMap, getPage, setPage, removePage, pushUndo, pushCappedHistory, bumpVersion, pushVersionEntry, getVersionLog, versions, versionLog, schedulePersistState } from "../state/session-state.js";
|
|
19
|
+
/**
|
|
20
|
+
* Write a restored snapshot into the draft, stamped as changed *now*.
|
|
21
|
+
*
|
|
22
|
+
* `updatedAt` is not decoration here. The live preview store treats it as the
|
|
23
|
+
* page's version (`versionOf` in `live-preview-store-core.ts`) and ignores any
|
|
24
|
+
* server render whose version is not strictly newer than what it already shows
|
|
25
|
+
* — a guard against a slow refresh clobbering newer optimistic state. A
|
|
26
|
+
* snapshot carries the timestamp it was taken at, so restoring one wrote a
|
|
27
|
+
* page that looked *older* than the screen, and every history operation was
|
|
28
|
+
* discarded by that guard: the draft changed, the orchestrator answered
|
|
29
|
+
* `applied`, and the preview went on showing the state the user had just
|
|
30
|
+
* undone. From the user's seat the Undo button does nothing.
|
|
31
|
+
*
|
|
32
|
+
* Every other mutation path already does this — `ops-engine` stamps
|
|
33
|
+
* `updatedAt` on each op it applies. Undo, redo, restore and discard are
|
|
34
|
+
* mutations too; they were the only writers that did not.
|
|
35
|
+
*/
|
|
36
|
+
function restoreSnapshot(session, snapshot) {
|
|
37
|
+
setPage(session, { ...structuredClone(snapshot), updatedAt: new Date().toISOString() });
|
|
38
|
+
}
|
|
19
39
|
const badRequest = (error) => ({ code: 400, body: { error } });
|
|
20
40
|
/** Whether undo and redo have anything to offer for this slug. */
|
|
21
41
|
export function historyStatus(query) {
|
|
@@ -70,7 +90,7 @@ export function historyUndoAction(body, log) {
|
|
|
70
90
|
schedulePersistState(log);
|
|
71
91
|
return { code: 200, body: { status: "applied", previewVersion, navigateToSlug: "/", canUndo: list.length > 0, canRedo: true } };
|
|
72
92
|
}
|
|
73
|
-
|
|
93
|
+
restoreSnapshot(session, prev);
|
|
74
94
|
const previewVersion = bumpVersion(session);
|
|
75
95
|
pushVersionEntry(session, { version: previewVersion, slug, summary: "Undo", opTypes: [], opCount: 0, source: "undo", snapshot: structuredClone(prev) });
|
|
76
96
|
schedulePersistState(log);
|
|
@@ -107,7 +127,7 @@ export function historyRedoAction(body, log) {
|
|
|
107
127
|
schedulePersistState(log);
|
|
108
128
|
return { code: 200, body: { status: "applied", previewVersion, navigateToSlug: "/", canUndo: true, canRedo: list.length > 0 } };
|
|
109
129
|
}
|
|
110
|
-
|
|
130
|
+
restoreSnapshot(session, next);
|
|
111
131
|
const previewVersion = bumpVersion(session);
|
|
112
132
|
pushVersionEntry(session, { version: previewVersion, slug, summary: "Redo", opTypes: [], opCount: 0, source: "redo", snapshot: structuredClone(next) });
|
|
113
133
|
schedulePersistState(log);
|
|
@@ -142,7 +162,7 @@ export function historyRestoreAction(body, log) {
|
|
|
142
162
|
if (target.snapshot === null)
|
|
143
163
|
removePage(session, target.slug);
|
|
144
164
|
else
|
|
145
|
-
|
|
165
|
+
restoreSnapshot(session, target.snapshot);
|
|
146
166
|
const previewVersion = bumpVersion(session);
|
|
147
167
|
pushVersionEntry(session, {
|
|
148
168
|
version: previewVersion,
|
|
@@ -251,7 +271,7 @@ export function historyDiscardAction(body, log) {
|
|
|
251
271
|
if (snapshot === null)
|
|
252
272
|
removePage(session, slug);
|
|
253
273
|
else
|
|
254
|
-
|
|
274
|
+
restoreSnapshot(session, snapshot);
|
|
255
275
|
previewVersion = bumpVersion(session);
|
|
256
276
|
const count = alsoDiscarded.length + 1;
|
|
257
277
|
pushVersionEntry(session, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avocadostudio-ai/orchestrator-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"openai": "^4.87.1",
|
|
23
23
|
"sharp": "^0.35.4",
|
|
24
24
|
"zod": "^4.3.6",
|
|
25
|
-
"@avocadostudio-ai/migration-sdk": "^0.
|
|
26
|
-
"@avocadostudio-ai/shared": "^0.
|
|
25
|
+
"@avocadostudio-ai/migration-sdk": "^0.13.1",
|
|
26
|
+
"@avocadostudio-ai/shared": "^0.13.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@anthropic-ai/claude-agent-sdk": "^0.3.220",
|