Fix orphaned branches after clearing all snapshots
The footer "Clear All Snapshots" button deleted records from the server but left stale in-memory state (lastCapturedIdMap, activeSnapshotId, etc.) intact. New captures then referenced deleted parents, creating isolated branches. Reset all branching state on both clear-all paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2917,6 +2917,7 @@ async function buildSidebar(el) {
|
|||||||
if (entry.workflowKey === currentKey) {
|
if (entry.workflowKey === currentKey) {
|
||||||
activeSnapshotId = null;
|
activeSnapshotId = null;
|
||||||
currentSnapshotId = null;
|
currentSnapshotId = null;
|
||||||
|
activeBranchSelections.clear();
|
||||||
}
|
}
|
||||||
if (viewingWorkflowKey === entry.workflowKey) {
|
if (viewingWorkflowKey === entry.workflowKey) {
|
||||||
viewingWorkflowKey = null;
|
viewingWorkflowKey = null;
|
||||||
@@ -2996,6 +2997,13 @@ async function buildSidebar(el) {
|
|||||||
if (!confirmed) return;
|
if (!confirmed) return;
|
||||||
try {
|
try {
|
||||||
const { lockedCount } = await db_deleteAllForWorkflow(effKey);
|
const { lockedCount } = await db_deleteAllForWorkflow(effKey);
|
||||||
|
// Clear stale in-memory state to prevent orphaned branches
|
||||||
|
lastCapturedIdMap.delete(effKey);
|
||||||
|
lastCapturedHashMap.delete(effKey);
|
||||||
|
lastGraphDataMap.delete(effKey);
|
||||||
|
activeSnapshotId = null;
|
||||||
|
currentSnapshotId = null;
|
||||||
|
activeBranchSelections.clear();
|
||||||
pickerDirty = true;
|
pickerDirty = true;
|
||||||
if (lockedCount > 0) {
|
if (lockedCount > 0) {
|
||||||
showToast(`Cleared snapshots (${lockedCount} locked kept)`, "info");
|
showToast(`Cleared snapshots (${lockedCount} locked kept)`, "info");
|
||||||
|
|||||||
Reference in New Issue
Block a user