From d84a8f455163d8d5496ea6f6b99c8e6ea964f183 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Tue, 27 Oct 2026 01:39:47 -0700 Subject: [PATCH] fix: drain draft editors before closing them for a move Closing an editor drops an edit it has not yet handed to its draft save, so a keystroke typed just before the move could be lost. The editors are now flushed while still mounted, and closed right after with no await in between. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../src/lib/components/sessions/SessionWrapper.svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/sessions/SessionWrapper.svelte b/frontend/src/lib/components/sessions/SessionWrapper.svelte index 6419487186..a30223d8bc 100644 --- a/frontend/src/lib/components/sessions/SessionWrapper.svelte +++ b/frontend/src/lib/components/sessions/SessionWrapper.svelte @@ -540,13 +540,20 @@ return } moving = true - if (runtime) runtime.manager.moving = true const releaseAutoResume = runtime?.manager.holdAutoResume() // Bracketed like a turn, so another tab on this session cannot send while its drafts // move, then re-reads the session (its new workspace, the model note) once it ends. const chatId = runtime?.manager.historyManager.getCurrentChatId() if (chatId) localRunStarted(session.id, chatId) try { + // Closing the draft editors drops what they have not handed to their save yet, so they + // are drained while still mounted, then closed with no await in between. + const unsaved = await flushPendingSaves(req.parent) + if (unsaved) { + moveRequest = { ...req, open: true, error: unsaved } + return + } + if (runtime) runtime.manager.moving = true // A turn that ran while the dialog was open (a job's auto-resume, another tab) may have // added drafts the list does not show, and the conflicts listed may have been discarded // since. Now that no turn can start, both are re-read.