From 476f605a4a6b2e2dd5c6859b6a46717e680b2cf6 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Fri, 8 May 2026 08:47:42 +0200 Subject: [PATCH] Handle 3-way merge conflict in editor: show markers, update base_hash --- src/components/PageEditor.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/PageEditor.svelte b/src/components/PageEditor.svelte index 033128b..501c1d8 100644 --- a/src/components/PageEditor.svelte +++ b/src/components/PageEditor.svelte @@ -85,7 +85,16 @@ credentials: 'include', body: JSON.stringify({ content, base_hash: baseHash }), }); - if (r.status === 409) { errorMsg = await r.text(); return; } + if (r.status === 409) { + const data = await r.json(); + const detail = data.detail ?? {}; + errorMsg = typeof detail === 'string' ? detail : (detail.message ?? 'Conflitto'); + if (detail.content) { + content = detail.content; + baseHash = detail.base_hash ?? baseHash; + } + return; + } if (!r.ok) throw new Error(await r.text()); saveStatus = 'Costruendo…'; const rb = await fetch('/rebuild', { method: 'POST', credentials: 'include' });