fix(v4): nothing of a session left on screen after logout

From the fresh review of the stick's increment 1 (With fixes):
- Critical: after logout Zuse's last screen, her prompt included, could be
  drawn back on a headless machine. The logout clear (ESC[2J) blanked the
  pixels only: Alt+TAB, still read while headless, redrew the terminal
  from its saved text; and if she had Alt+TABbed to the graphics view
  before the pull, the clear did nothing and her session stayed on screen
  (and the console did not draw at her next login). Now vt100_reset()
  forgets everything the terminal has shown -- the on-screen text, the
  scrollback and their boot snapshots -- makes it visible again and fills
  the screen; and Alt+TAB does nothing while the screen is off (v3's never
  is, so v3 is unchanged).
- Important: an EMERGENCY_CONSOLE_ENABLED build no longer clears the screen
  when Zuse's drive is pulled: its console goes on running.

Red: alttab_after_logout 183308 (4515 lit), alttab_before_pull 183529
(4539 lit; the console not redrawn), emergency_pull 183759 (0 lit).
Green: 184115, 184328, 184552; regression 184805-185956 (screens,
keyboard, hotplug, emergency, v3 typed by keyboard) all pass.
Accepted: 190111, 190312, 190710, POST 538/538, dict_hash
0xfec8c47cfc6f437f; test-32, 39 modules, 0 failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-26 19:14:22 -04:00
co-authored by Claude Opus 5.5
parent cab0ffb487
commit a78cc56c31
36 changed files with 11376 additions and 4 deletions
+58
View File
@@ -30,6 +30,10 @@ the stick's, plan 2026-10-26-stick-1-screen-and-keyboard.md):
usb_kbd the only keyboard a USB one (--make "QEMU_EXTRA='-machine
i8042=off -device usb-kbd,bus=xhci0.0,port=3'"): it types
no_framebuffer no display (-vga none): serial alone, 7 ok
alttab_after_logout after logout, Alt+TAB twice: the screen stays black
alttab_before_pull Alt+TAB, then the drive pulled: black; re-attach draws the console
emergency_pull EMERGENCY_CONSOLE_ENABLED=1: Zuse added and pulled, the screen
still shows the running console, and it types
virtio_kbd aarch64/riscv64: QEMU's virtio keyboard types 7 ok
Needs only Python 3. One QEMU at a time (.claude/CLAUDE.md).
@@ -49,6 +53,7 @@ ap.add_argument("--no-zuse", action="store_true")
a = ap.parse_args()
NO_ZUSE_MODES = {"headless", "hotplug", "midpull", "waitpull", "typeahead", "emergency",
"alttab_after_logout", "alttab_before_pull", "emergency_pull",
"screen_dark_until_login", "screen_console_after_login", "screen_dark_after_logout",
"kbd_typeahead"}
label = a.label or f"{a.mode}-{a.arch}"
@@ -176,6 +181,11 @@ def key_line(line):
time.sleep(0.1)
def alt_tab():
qcmd("send-key", keys=[{"type": "qcode", "data": "alt"}, {"type": "qcode", "data": "tab"}])
time.sleep(1)
SHOTS = 0
@@ -348,6 +358,54 @@ elif m in ("no_framebuffer", "virtio_kbd"):
key_line("3 4 + .")
check("7 ok", wait_for(PROMPT, 60, n) and re.search(r"7\s+ok", text()) is not None)
elif m in ("alttab_after_logout", "alttab_before_pull"):
add_zuse(1)
check("[zuse@Hera] ok> after attach", wait_for(PROMPT, 120))
n = count(PROMPT)
key_line("3 4 + .")
check("7 ok typed", wait_for(PROMPT, 60, n))
if m == "alttab_before_pull":
alt_tab() # to the graphics view, her session on screen
del_zuse(1)
check("session ended on detach", wait_for(r"Zuse: session ended -- reattach to re-authenticate", 60))
time.sleep(5)
if m == "alttab_after_logout":
alt_tab()
alt_tab()
time.sleep(3)
_, _, lit, _ = screen()
check(f"the screen is black after logout ({lit} lit)", lit == 0)
if m == "alttab_before_pull":
p = count(PROMPT)
add_zuse(2)
check("[zuse@Hera] ok> again", wait_for(PROMPT, 120, p))
time.sleep(3)
_, _, lit1, px1 = screen()
check(f"the console is drawn again ({lit1} lit)", lit1 >= 500)
n = count(PROMPT)
key_line("1 2 + .")
check("3 ok typed", wait_for(PROMPT, 60, n))
time.sleep(3)
_, _, _, px2 = screen()
check("the screen changed with what was typed", px2 != px1)
elif m == "emergency_pull":
check("ok> with no drive", wait_for(ANYPROMPT, 60))
add_zuse(1)
check("Zuse: identity confirmed", wait_for(r"Zuse: identity confirmed from attached thumbdrive", 120))
time.sleep(3)
del_zuse(1)
check("session ended on detach", wait_for(r"Zuse: session ended -- reattach to re-authenticate", 60))
time.sleep(5)
_, _, lit1, px1 = screen()
check(f"the screen still shows the console ({lit1} lit)", lit1 >= 500)
n = count(ANYPROMPT)
key_line("3 4 + .")
check("7 ok typed after the pull", wait_for(ANYPROMPT, 60, n) and re.search(r"7\s+ok", text()) is not None)
time.sleep(3)
_, _, _, px2 = screen()
check("the screen changed with what was typed", px2 != px1)
else:
check(f"known mode {m}", False)