fix: deleting a pipeline clears it from open sessions so autosave cannot restore it

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Diego Imbert
2026-10-01 14:27:26 +02:00
co-authored by Claude Opus 5.5
parent 77d58bd7d7
commit e96f6bcfae
2 changed files with 18 additions and 1 deletions
@@ -48,6 +48,11 @@
deleting = true
try {
const { removed, failures } = await deletePipeline(ws, folder, plan, hardDelete)
// Loaded on demand: the home list should not pull in the session runtime.
const { forgetDeletedPipeline } = await import(
'$lib/components/sessions/sessionRuntime.svelte'
)
forgetDeletedPipeline(ws, folder)
if (failures.length) {
sendUserToast(`Pipeline f/${folder} was only partly removed`, true, [], failures.join('\n'))
} else {
@@ -3,7 +3,7 @@ import { get } from 'svelte/store'
import { base } from '$lib/base'
import { AIChatManager, AIMode } from '$lib/components/copilot/chat/AIChatManager.svelte'
import { PipelineEditorState } from '$lib/components/assets/AssetGraph/pipelineEditorState.svelte'
import { pipelineLocalMirrorKey } from '$lib/pipelinePaths'
import { PIPELINE_DRAFT_KIND, pipelineBundlePath, pipelineLocalMirrorKey } from '$lib/pipelinePaths'
import type { DeployResult } from '$lib/utils_workspace_deploy'
import { initFlow } from '$lib/components/flows/flowStore.svelte'
import {
@@ -1162,6 +1162,18 @@ export function listRuntimes(): SessionRuntime[] {
return Array.from(runtimes.values())
}
/** A pipeline deleted outside the session: every live session on its workspace
* drops what it holds of it. Its in-memory drafts would otherwise keep showing the
* pipeline in the preview, and autosave would write the deleted draft back. */
export function forgetDeletedPipeline(workspace: string, folder: string): void {
const key = normalizePipelineFolder(folder)
for (const runtime of runtimes.values()) {
if (runtime.manager.operatingWorkspace !== workspace) continue
runtime.forgetPipelineDrafts(key)
void runtime.manager.removeModifiedItem(PIPELINE_DRAFT_KIND, pipelineBundlePath(key))
}
}
export function getRuntime(sessionId: string): SessionRuntime | undefined {
return runtimes.get(sessionId)
}