Restore Checkpoint Feature (#934)

This commit is contained in:
Louis Jimenez
2025-06-11 15:33:09 -04:00
committed by GitHub
parent f75c48323c
commit e0f4f428fc
19 changed files with 837 additions and 63 deletions

View File

@@ -20,6 +20,7 @@ export interface UseHistoryManagerReturn {
updates: Partial<Omit<HistoryItem, 'id'>> | HistoryItemUpdater,
) => void;
clearItems: () => void;
loadHistory: (newHistory: HistoryItem[]) => void;
}
/**
@@ -38,6 +39,10 @@ export function useHistory(): UseHistoryManagerReturn {
return baseTimestamp + messageIdCounterRef.current;
}, []);
const loadHistory = useCallback((newHistory: HistoryItem[]) => {
setHistory(newHistory);
}, []);
// Adds a new item to the history state with a unique ID.
const addItem = useCallback(
(itemData: Omit<HistoryItem, 'id'>, baseTimestamp: number): number => {
@@ -101,5 +106,6 @@ export function useHistory(): UseHistoryManagerReturn {
addItem,
updateItem,
clearItems,
loadHistory,
};
}