From 354e65acdfa29c6be87b6e7b70928c3506db5193 Mon Sep 17 00:00:00 2001 From: sravan Date: Fri, 14 Aug 2026 12:38:05 +0530 Subject: [PATCH] #14 follow-up: keep in-progress edit text as a draft when leaving a chat mid-edit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit persistCurrentDraft() no longer skips while editing — leaving a chat mid-edit abandons the edit (openConvo clears editTarget) but now keeps whatever's in the composer as that chat's draft, so your typing isn't lost. It returns as a normal draft (sending posts a new message, not an edit). The edit-cancel (X) path still restores the pre-edit draft, unchanged. Verified with puppeteer: edit "hi bob" -> "hi bob EDITED" -> switch chats -> back -> composer holds "hi bob EDITED" (PASS). Co-Authored-By: Claude Opus 4.8 --- server/public/home.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/public/home.html b/server/public/home.html index 86e206a..8fd12a6 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -3423,8 +3423,10 @@ function setDraft(kind,id,val){ try{ if(val&&val.trim()) localStorage.setItem(dr // #14: GUARANTEED save of the currently-open chat's draft — called the instant we leave it (switching chats // OR going back to the list). The per-keystroke 'input' save can be missed on mobile (predictive text / a // fast tap-away fires no final input event), which lost the whole draft on switch-and-return. Snapshotting -// the composer value at leave-time makes it reliable regardless. Skipped while editing (that's not a draft). -function persistCurrentDraft(){ try{ if(selected && !editTarget){ const inp=document.getElementById('msgInput'); if(inp) setDraft(selected.kind, selected.id, inp.value); } }catch(_){} } +// the composer value at leave-time makes it reliable regardless. This ALSO covers leaving mid-EDIT: the edit +// is abandoned (openConvo clears editTarget), and whatever's in the composer is kept as that chat's draft so +// your typing isn't lost — it just returns as a normal draft (sending it posts a new message, not an edit). +function persistCurrentDraft(){ try{ if(selected){ const inp=document.getElementById('msgInput'); if(inp) setDraft(selected.kind, selected.id, inp.value); } }catch(_){} } // Compositor-only open slide (workflow-verified). armOpenSlide() runs AFTER openConvo's synchronous // render: it pins the pane off-screen (chat-opening), lets a frame paint it, then adds .chat-anim on a // double-rAF so the compositor runs the 300ms transform with the main thread idle. All scrollTop/innerHTML