From 489d3b76772d1323bbdaa552bdb36be1ba937475 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Tue, 27 Oct 2026 02:05:55 -0700 Subject: [PATCH] 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) --- .../src/lib/components/sessions/moveSessionToFork.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/sessions/moveSessionToFork.ts b/frontend/src/lib/components/sessions/moveSessionToFork.ts index 60dda21745..0967769770 100644 --- a/frontend/src/lib/components/sessions/moveSessionToFork.ts +++ b/frontend/src/lib/components/sessions/moveSessionToFork.ts @@ -47,11 +47,12 @@ export type MoveSessionResult = */ export async function flushPendingSaves(workspace: string): Promise { 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)