detail
Root cause: DOMContentLoaded restore gate used if(hasDraft() && savedHdr) - AND-gate requiring both draft AND header present or else-branch wipes both cai_gym_editing_id and cai_gym_hdr plus resets form. loadSessionIntoLog() writes draft (saveDraft()) and hdr/editing_id in separate try/catch blocks - if saveDraft() silently failed (empty catch, no trace), draft missing but hdr present would still trigger destructive fresh-start branch on refresh. Matches reported symptom exactly. Fix: changed gate to hasDraft()||savedHdr, header-restore now independently guarded by if(savedHdr). Also fixed saveDraft() empty catch to log+toast on failure instead of silent swallow. Verified: backed up original first (backups/20-builder/file/Builder_gym-logger_CURRENT.html), node --check passed on extracted JS before deploy, deployed via file_write_web.php, read back live and confirmed functional if(hasDraft() || savedHdr) present with old AND-gate no longer in executable code, file size 222117->223959 bytes. NOT verified: live on-device reproduction of the original bug being gone (needs USR369 to test on real device). KEEP checkbox server-save, minor session-info-lbl position, dead loaded-session-header div, and sync-offline root cause all remain open from original request.