Three defences against cursor-position desync in the two-line progress bar:
A) _post_with_retry now accepts an on_warn callback. The heartbeat flush
closures pass _render_warn, which acquires _render_lock before printing,
writes \n to leave the progress lines, and resets display["lines"]=0 so
the next render starts fresh. Previously a brief server hiccup would print
a raw \n outside the lock, shifting the cursor and orphaning both progress
lines to scrollback.
B) SIGWINCH handler: resets display["lines"]=0 on terminal resize so cursor
tracking recovers on the next heartbeat cycle.
C) Pre-scroll the initial single→two-line transition: prepend \n\x1b[1A so
line2's row is guaranteed to exist below line1 even if the cursor is on
the terminal's bottom row when two-line mode first activates.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>