From d7f0df031595099d23632204a88757586cbd4309 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Tue, 27 Oct 2026 02:02:49 -0700 Subject: [PATCH] fix: refuse a move while an editor holds text that is not valid JSON That text never reaches the draft, and the move closes the editor holding it. The move now refuses before closing anything, as opening a session from a page drawer already does. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../src/lib/components/sessions/moveSessionToFork.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/sessions/moveSessionToFork.ts b/frontend/src/lib/components/sessions/moveSessionToFork.ts index 714cf5540c..60dda21745 100644 --- a/frontend/src/lib/components/sessions/moveSessionToFork.ts +++ b/frontend/src/lib/components/sessions/moveSessionToFork.ts @@ -5,7 +5,10 @@ import { UserDraftDbSyncer } from '$lib/userDraftDbSyncer.svelte' import { invalidateWorkspaceDrafts } from '$lib/workspaceDrafts.svelte' import { invalidateWorkspaceDiffCache } from '$lib/components/copilot/chat/global/diffSnapshot' import { logFeatureUsage } from '$lib/utils/featureUsage' -import { flushAllPendingEditorChanges } from '$lib/components/pendingEditorFlush' +import { + anyEditorUnparseable, + flushAllPendingEditorChanges +} from '$lib/components/pendingEditorFlush' import { flushEditorSaves } from './useUserDraftSync.svelte' import { materializeForkOutcome, @@ -44,6 +47,10 @@ 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() flushEditorSaves(workspace) await tick()