Index: uspace/lib/termui/src/history.c
===================================================================
--- uspace/lib/termui/src/history.c	(revision 3e41cc4ae595fc88a3e5e146b78f8aaa2cc37f88)
+++ uspace/lib/termui/src/history.c	(revision 9fd74d5a6666abbee200b27b93e8d961bcd2bc7d)
@@ -126,6 +126,6 @@
 
 #define _history_check(history) do { \
-	assert(history->lines.head < history->lines.buf_len); \
-	assert(history->lines.tail < history->lines.buf_len); \
+	assert(history->lines.head < history->lines.buf_len || history->lines.head == 0); \
+	assert(history->lines.tail < history->lines.buf_len || history->lines.tail == 0); \
 	assert(history->cells.tail_top <= history->cells.head_offset); \
 	assert(history->cells.head_offset <= history->cells.head_top); \
@@ -298,4 +298,9 @@
 	if (lines->tail >= lines->buf_len)
 		lines->tail = 0;
+
+	if (viewport_inactive) {
+	    /* Ensure consistent state so asserts don't trigger inside _evict_oldest_line(). */
+	    history->viewport_top = lines->tail;
+	}
 
 	if (lines->tail == lines->head)
Index: uspace/lib/termui/src/history.h
===================================================================
--- uspace/lib/termui/src/history.h	(revision 3e41cc4ae595fc88a3e5e146b78f8aaa2cc37f88)
+++ uspace/lib/termui/src/history.h	(revision 9fd74d5a6666abbee200b27b93e8d961bcd2bc7d)
@@ -66,4 +66,9 @@
 };
 
+/* History consists of two circular buffers.
+ * The cell buffer is a linear array of character cells.
+ * The line buffer contains offsets into the cell buffer, and segments it into logical lines.
+ * Both of these buffers have a maximum size, so history is limited both by maximum number
+ * of characters, and maximum number of lines.  */
 struct history {
 	size_t viewport_top;
