From 42bd39e093460634a7e48eb27305f2a0833045ce Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Mon, 7 Sep 2026 21:27:50 +0200 Subject: [PATCH] fix(sessions): keep every released value, and refresh a tab whose editor was replaced MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A cell can be let go of more than once inside one save — released with an edit, reopened, released again as a freshly loaded baseline — and keeping only the last snapshot let that baseline erase the edit the record exists to preserve. All of them are kept for the length of the window now, and any one differing from what was written leaves the draft alone. A save also reported only which tab it came from, so a tab left and reopened on the same item during the write was taken for the editor that had settled its own baseline. The editor standing there loaded before the save landed and has not; it says whether it is still the mounted one, and the tab is refreshed when it is not. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KcyBRxE8j3ujCYkum9KrC4 --- .../components/sessions/PreviewTabHost.svelte | 20 ++++++++++---- .../sessions/ResourceEditorView.svelte | 22 +++++++++++++--- .../sessions/ScheduleEditorView.svelte | 20 +++++++++++--- .../sessions/VariableEditorView.svelte | 20 +++++++++++--- frontend/src/lib/userDraft.svelte.ts | 26 ++++++++++++------- .../(root)/(logged)/sessions/+page.svelte | 7 +++-- 6 files changed, 89 insertions(+), 26 deletions(-) diff --git a/frontend/src/lib/components/sessions/PreviewTabHost.svelte b/frontend/src/lib/components/sessions/PreviewTabHost.svelte index 282815a165..50f4320331 100644 --- a/frontend/src/lib/components/sessions/PreviewTabHost.svelte +++ b/frontend/src/lib/components/sessions/PreviewTabHost.svelte @@ -76,6 +76,8 @@ to?: string fromSessionId: string | undefined fromTabId: string + /** Whether the editor that reported is still the one mounted on this tab. */ + fromLive?: boolean }) => void } = $props() @@ -227,14 +229,21 @@ ) const reportSaved = $derived( slot.kind === 'entity' - ? (kind: EntityEditorKind, newPath: string, fromPath: string, fromWs: string) => + ? ( + kind: EntityEditorKind, + newPath: string, + fromPath: string, + fromWs: string, + fromLive: boolean + ) => onEntityWritten({ kind, path: fromPath, workspace: fromWs, to: newPath, fromSessionId: session?.id, - fromTabId: tab.id + fromTabId: tab.id, + fromLive }) : undefined ) @@ -428,7 +437,8 @@ {workspaceId} onBack={backToList} onRemoved={(from, ws) => reportRemoved?.('trigger_schedule', from, ws)} - onSavedTo={(to, from, ws) => reportSaved?.('trigger_schedule', to, from, ws)} + onSavedTo={(to, from, ws, live) => + reportSaved?.('trigger_schedule', to, from, ws, live)} onViewRuns={viewRuns} /> {/await} @@ -441,7 +451,7 @@ {workspaceId} onBack={backToList} onRemoved={(from, ws) => reportRemoved?.('resource', from, ws)} - onSavedTo={(to, from, ws) => reportSaved?.('resource', to, from, ws)} + onSavedTo={(to, from, ws, live) => reportSaved?.('resource', to, from, ws, live)} /> {/await} {:else if slot.entityKind === 'variable'} @@ -453,7 +463,7 @@ {workspaceId} onBack={backToList} onRemoved={(from, ws) => reportRemoved?.('variable', from, ws)} - onSavedTo={(to, from, ws) => reportSaved?.('variable', to, from, ws)} + onSavedTo={(to, from, ws, live) => reportSaved?.('variable', to, from, ws, live)} /> {/await} {/if} diff --git a/frontend/src/lib/components/sessions/ResourceEditorView.svelte b/frontend/src/lib/components/sessions/ResourceEditorView.svelte index 11eff09e80..82a4229679 100644 --- a/frontend/src/lib/components/sessions/ResourceEditorView.svelte +++ b/frontend/src/lib/components/sessions/ResourceEditorView.svelte @@ -1,6 +1,6 @@