From e96f6bcfaec886b56a9f8b6a00036bf128f95ddd Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Thu, 1 Oct 2026 14:27:26 +0200 Subject: [PATCH] fix: deleting a pipeline clears it from open sessions so autosave cannot restore it Co-Authored-By: Claude Opus 5.5 (1M context) --- .../lib/components/common/table/PipelineRow.svelte | 5 +++++ .../components/sessions/sessionRuntime.svelte.ts | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/common/table/PipelineRow.svelte b/frontend/src/lib/components/common/table/PipelineRow.svelte index f196356683..509297442b 100644 --- a/frontend/src/lib/components/common/table/PipelineRow.svelte +++ b/frontend/src/lib/components/common/table/PipelineRow.svelte @@ -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 { diff --git a/frontend/src/lib/components/sessions/sessionRuntime.svelte.ts b/frontend/src/lib/components/sessions/sessionRuntime.svelte.ts index 1aa7b7ef78..580dce62c4 100644 --- a/frontend/src/lib/components/sessions/sessionRuntime.svelte.ts +++ b/frontend/src/lib/components/sessions/sessionRuntime.svelte.ts @@ -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) }