fix: check for invalid JSON after the editors have parsed what was flushed

The JSON editors parse a flushed buffer in an effect, so the check reads
the registry after a tick, as RunForm and the page drawer already do. The
message says the editor is in the preview.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-10-27 02:05:55 -07:00
co-authored by Claude Opus 5.5
parent d7f0df0315
commit 489d3b7677
@@ -47,11 +47,12 @@ export type MoveSessionResult =
*/
export async function flushPendingSaves(workspace: string): Promise<string | undefined> {
flushAllPendingEditorChanges()
// Text that does not parse never reaches the draft, and the move closes the editor holding it.
if (anyEditorUnparseable()) {
return 'An editor has changes that are not valid JSON. Fix them before moving.'
}
await tick()
// Text that does not parse never reaches the draft, and the move closes the editor holding it.
// After the tick: the JSON editors parse what was just flushed in an effect.
if (anyEditorUnparseable()) {
return 'An editor in the preview has changes that are not valid JSON. Fix them before moving.'
}
flushEditorSaves(workspace)
await tick()
const unsaved = await UserDraftDbSyncer.flushWorkspace(workspace)