Persist active ring and change detection across reload and tab switch

- Seed lastCapturedIdMap, lastCapturedHashMap, and lastGraphDataMap
  from most recent snapshot on startup so the active ring appears
  immediately after page reload
- Seed lastCapturedIdMap on workflow tab switch so the ring appears
  when switching to a tab with existing snapshots

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 00:11:27 +01:00
parent 4bfc1912f2
commit 463e234cd1

View File

@@ -3864,8 +3864,16 @@ if (window.__COMFYUI_FRONTEND_VERSION__) {
// Clear branching state for the old workflow // Clear branching state for the old workflow
lastCapturedIdMap.delete(prevKey); lastCapturedIdMap.delete(prevKey);
activeBranchSelections.clear(); activeBranchSelections.clear();
// Track session workflow (new key, after switch) // Seed active ring for the new workflow tab
trackSessionWorkflow(getWorkflowKey()); const newKey = getWorkflowKey();
trackSessionWorkflow(newKey);
db_getAllForWorkflow(newKey).then(recs => {
if (recs.length > 0 && !lastCapturedIdMap.has(newKey)) {
const latest = recs.reduce((best, r) => r.timestamp > best.timestamp ? r : best);
lastCapturedIdMap.set(newKey, latest.id);
if (timelineRefresh) timelineRefresh().catch(() => {});
}
}).catch(() => {});
if (sidebarRefresh) { if (sidebarRefresh) {
sidebarRefresh(true).catch(() => {}); sidebarRefresh(true).catch(() => {});
} }
@@ -3890,6 +3898,23 @@ if (window.__COMFYUI_FRONTEND_VERSION__) {
// Build the timeline bar on the canvas // Build the timeline bar on the canvas
buildTimeline(); buildTimeline();
// Seed in-memory state so the active ring shows on reload
// and the first auto-capture gets correct change-type detection
try {
const wfKey = getWorkflowKey();
const records = await db_getAllForWorkflow(wfKey);
if (records.length > 0) {
const latest = records.reduce((best, r) => r.timestamp > best.timestamp ? r : best);
lastCapturedIdMap.set(wfKey, latest.id);
const graphData = getGraphData();
if (graphData) {
lastCapturedHashMap.set(wfKey, quickHash(JSON.stringify(graphData)));
lastGraphDataMap.set(wfKey, graphData);
}
if (timelineRefresh) timelineRefresh().catch(() => {});
}
} catch {}
// Track initial workflow for profiles // Track initial workflow for profiles
trackSessionWorkflow(getWorkflowKey()); trackSessionWorkflow(getWorkflowKey());