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) <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-10-27 01:39:47 -07:00
co-authored by Claude Opus 5.5
parent 36fbbe3ebe
commit d84a8f4551
@@ -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.