#14 draft ROOT CAUSE: openConvo's cancelEdit() wiped the just-opened chat's draft
Reproduced with a real headless browser driving the live app: typing saved the draft and it survived switching chats, but RETURNING to the chat deleted it. Stack trace pinned it exactly: setDraft(REMOVE) <- _restoreDraftAfterEdit <- cancelEdit <- openConvo:3484 <- selectChat openConvo ran `clearReply(); cancelEdit(); hideAttach();` on every open. cancelEdit -> _restoreDraftAfterEdit -> setDraft(selected,'') — and since `selected` is already the chat being opened, it wiped THAT chat's draft (and blanked the composer) BEFORE the draft-restore a few lines later could read it. So the draft never survived reopening — this predated the recent rounds; my _restoreDraftAfterEdit change just made the wipe explicit. Fix: drop cancelEdit() from openConvo (edit state is already reset at the top via editTarget=null/_editSavedDraft='', and the shell was just rebuilt fresh). The edit-cancel button + saveEdit still call cancelEdit normally. Verified with puppeteer: type in chat A -> open B -> back to A -> "hello draft" restored (PASS), no setDraft REMOVE on return. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3481,7 +3481,11 @@ async function openConvo(kind,id){
|
|||||||
el.ondrop=(e)=>{ const f=e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files[0]; if(f){ e.preventDefault(); el.classList.remove('drag-over'); uploadFile(f); } };
|
el.ondrop=(e)=>{ const f=e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files[0]; if(f){ e.preventDefault(); el.classList.remove('drag-over'); uploadFile(f); } };
|
||||||
const back=document.getElementById('convoBack'); if(back) back.onclick=showWelcome;
|
const back=document.getElementById('convoBack'); if(back) back.onclick=showWelcome;
|
||||||
const form=document.getElementById('composer'); if(form) form.addEventListener('submit',(e)=>{ e.preventDefault(); sendMessage(); });
|
const form=document.getElementById('composer'); if(form) form.addEventListener('submit',(e)=>{ e.preventDefault(); sendMessage(); });
|
||||||
clearReply(); cancelEdit(); hideAttach();
|
// #14 ROOT CAUSE: do NOT call cancelEdit() here. It runs _restoreDraftAfterEdit → setDraft(selected,'') which
|
||||||
|
// WIPED the just-opened chat's draft (and blanked the composer) BEFORE the restore below could read it — the
|
||||||
|
// draft never survived reopening a chat. Edit state is already reset at the top (editTarget=null,
|
||||||
|
// _editSavedDraft=''), and the composer/edit bar are fresh from the shell rebuild, so nothing else is needed.
|
||||||
|
clearReply(); hideAttach();
|
||||||
const ab2=document.getElementById('attachBtn'); const apop=document.getElementById('attachPop');
|
const ab2=document.getElementById('attachBtn'); const apop=document.getElementById('attachPop');
|
||||||
if(ab2&&apop) ab2.onclick=(e)=>{ e.stopPropagation(); apop.style.display = apop.style.display==='none' ? 'flex' : 'none'; }; // show a composer-anchored menu instead of firing the generic mid-screen OS chooser straight away
|
if(ab2&&apop) ab2.onclick=(e)=>{ e.stopPropagation(); apop.style.display = apop.style.display==='none' ? 'flex' : 'none'; }; // show a composer-anchored menu instead of firing the generic mid-screen OS chooser straight away
|
||||||
if(apop) apop.querySelectorAll('.attach-opt').forEach(b=>b.onclick=(e)=>{ e.stopPropagation(); apop.style.display='none'; const src=b.dataset.src; const inp = src==='photo'?document.getElementById('fileInputImg') : src==='camera'?document.getElementById('fileInputCam') : document.getElementById('fileInput'); if(inp) inp.click(); }); // Photos → gallery, Camera → capture, Document → any file
|
if(apop) apop.querySelectorAll('.attach-opt').forEach(b=>b.onclick=(e)=>{ e.stopPropagation(); apop.style.display='none'; const src=b.dataset.src; const inp = src==='photo'?document.getElementById('fileInputImg') : src==='camera'?document.getElementById('fileInputCam') : document.getElementById('fileInput'); if(inp) inp.click(); }); // Photos → gallery, Camera → capture, Document → any file
|
||||||
|
|||||||
Reference in New Issue
Block a user