1dcf1fc2f3
Sessions with cursor near the top (e.g. a fresh tunnel/ssh session) have content at rows 1-2 and rows 3-40 blank in a 40-row terminal. The previous fix trimmed AFTER slice(-20), but slice(-20) of a 40-line snapshot grabs the last 20 rows — all blank. Trimming after slice then removed everything, leaving an empty <pre>. Fix: trim trailing blank lines from the full snapshot first, then slice the last N lines of what remains. This way a session with 2 content lines at the top is reduced to those 2 lines before slicing, and both appear in the preview. Fixes both buildTileHTML (grid tiles) and buildSidebarHTML (sidebar cards). Tests updated to cover the 40-row terminal scenario.