MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / undoEditHistory

Function undoEditHistory

packages/studio/src/utils/editHistory.ts:164–190  ·  view source on GitHub ↗
(
  state: EditHistoryState,
  currentHashes: Record<string, string>,
  now: number,
)

Source from the content-addressed store, hash-verified

162}
163
164export function undoEditHistory(
165 state: EditHistoryState,
166 currentHashes: Record<string, string>,
167 now: number,
168): EditHistoryTransitionResult {
169 const entry = state.undo[state.undo.length - 1];
170 if (!entry) return { ok: false, reason: "empty", state, filesToWrite: {} };
171
172 const check = canApplyEditHistoryEntry(entry, "undo", currentHashes);
173 if (!check.ok) {
174 return { ok: false, reason: check.reason, path: check.path, state, filesToWrite: {} };
175 }
176
177 return {
178 ok: true,
179 entry,
180 filesToWrite: Object.fromEntries(
181 Object.entries(entry.files).map(([path, snapshot]) => [path, snapshot.before]),
182 ),
183 state: {
184 version: 1,
185 updatedAt: now,
186 undo: state.undo.slice(0, -1),
187 redo: [...state.redo, entry],
188 },
189 };
190}
191
192export function redoEditHistory(
193 state: EditHistoryState,

Callers 2

undoFunction · 0.90

Calls 2

canApplyEditHistoryEntryFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected