From a32ac0c44a69acae31ace8b8e0dc71840fd6e838 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 3 Dec 2026 19:24:01 -0600 Subject: [PATCH 1/2] cli(test[load]): Isolate spinner snapshot colors why: NO_COLOR takes precedence over ColorMode.ALWAYS, so the styled spinner golden depends on the environment inherited by pytest. what: - Clear NO_COLOR while rendering the in-memory spinner snapshot --- tests/test_vt_snapshots.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_vt_snapshots.py b/tests/test_vt_snapshots.py index e70550ac84..96db565b66 100644 --- a/tests/test_vt_snapshots.py +++ b/tests/test_vt_snapshots.py @@ -93,6 +93,7 @@ def test_cli_spinner_panel_and_success_vt_snapshots( """``Spinner`` ``?2026`` frames and ``CURSOR_UP_1`` cleanup render cleanly.""" from libvt.testing import vt_screen + monkeypatch.delenv("NO_COLOR", raising=False) monkeypatch.setattr( shutil, "get_terminal_size", From eb16d90e6482a0b35bc63943a51790f3c09ece13 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 20:30:14 -0600 Subject: [PATCH 2/2] cli(test[load]): Cover narrow-terminal recovery why: The failure prompt wraps at 48 columns. The detach choice should leave the partially built window available for inspection. what: - Wait for the full logical prompt through libvt's PTY session - Snapshot detach and check the window on the real tmux server --- tests/__snapshots__/test_vt_snapshots.ambr | 40 ++++++++++++++++++++++ tests/test_vt_snapshots.py | 27 ++++++++++----- 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/tests/__snapshots__/test_vt_snapshots.ambr b/tests/__snapshots__/test_vt_snapshots.ambr index 4757f5a00e..0d10c6d8bc 100644 --- a/tests/__snapshots__/test_vt_snapshots.ambr +++ b/tests/__snapshots__/test_vt_snapshots.ambr @@ -1,4 +1,44 @@ # serializer version: 1 +# name: test_cli_load_failure_recovery_prompt_pty[48-narrow-detach][load_error_detached_narrow] + size=48x10 cursor=(3,0,vis=True) alt=False modes=[] + ┌────────────────────────────────────────────────┐ + │[Error] Database port 5432 unreachable │ + │Error loading workspace. (k)ill, (a)ttach, (d)et│W + │ach? - (k, a, d) [k]: d │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + └────────────────────────────────────────────────┘ + styles: + r0[0..7]: fg=red + r1[0..24]: fg=red + r2[7..16]: fg=blue + r2[17..20]: fg=cyan +# --- +# name: test_cli_load_failure_recovery_prompt_pty[48-narrow-detach][load_error_prompt_narrow] + size=48x10 cursor=(2,22,vis=True) alt=False modes=[] + ┌────────────────────────────────────────────────┐ + │[Error] Database port 5432 unreachable │ + │Error loading workspace. (k)ill, (a)ttach, (d)et│W + │ach? - (k, a, d) [k]: │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + └────────────────────────────────────────────────┘ + styles: + r0[0..7]: fg=red + r1[0..24]: fg=red + r2[7..16]: fg=blue + r2[17..20]: fg=cyan +# --- # name: test_cli_load_failure_recovery_prompt_pty[48-narrow][load_error_killed_narrow] size=48x10 cursor=(4,0,vis=True) alt=False modes=[] ┌────────────────────────────────────────────────┐ diff --git a/tests/test_vt_snapshots.py b/tests/test_vt_snapshots.py index 96db565b66..fbdf1731b0 100644 --- a/tests/test_vt_snapshots.py +++ b/tests/test_vt_snapshots.py @@ -281,10 +281,11 @@ async def _exercise() -> None: @pytest.mark.parametrize( - ("cols", "width_label"), + ("cols", "width_label", "choice"), [ - (76, "normal"), - (48, "narrow"), + pytest.param(76, "normal", "k", id="76-normal"), + pytest.param(48, "narrow", "k", id="48-narrow"), + pytest.param(48, "narrow", "d", id="48-narrow-detach"), ], ) def test_cli_load_failure_recovery_prompt_pty( @@ -294,8 +295,9 @@ def test_cli_load_failure_recovery_prompt_pty( vt_snapshot: SnapshotAssertion, cols: int, width_label: str, + choice: t.Literal["k", "d"], ) -> None: - """Failed ``tmuxp load`` stops spinner, prompts cleanly, and kills on ``k``.""" + """Failed ``tmuxp load`` clears progress before kill or detach.""" from libvt.testing import vt_screen assert server.socket_name is not None @@ -370,7 +372,7 @@ async def _exercise() -> None: err_gate_file.write_text("fail", encoding="utf-8") prompt_snap = await pty.wait_for( - lambda snap: "[k]:" in snap.text, + "Error loading workspace. (k)ill, (a)ttach, (d)etach? - (k, a, d) [k]:", timeout=8.0, ) assert server.has_session(session_name) is True @@ -384,18 +386,25 @@ async def _exercise() -> None: name=f"load_error_prompt_{width_label}" ) - pty.send(b"k\r") + pty.send(f"{choice}\r".encode()) final_snap = await pty.wait_for(lambda _: pty.eof, timeout=8.0) rc = await pty.process.wait() assert rc == 0 - assert "Session killed." in final_snap.text + if choice == "k": + assert "Session killed." in final_snap.text assert "Loaded" not in final_snap.text assert "detached state" not in final_snap.text assert final_snap.cursor.visible is True assert pty.terminal.synchronized is False + outcome = "killed" if choice == "k" else "detached" assert vt_screen(final_snap, scrubbers=_SPINNER_SCRUB) == vt_snapshot( - name=f"load_error_killed_{width_label}" + name=f"load_error_{outcome}_{width_label}" ) asyncio.run(_exercise()) - assert server.has_session(session_name) is False + if choice == "k": + assert server.has_session(session_name) is False + else: + built = server.sessions.get(session_name=session_name, default=None) + assert built is not None + assert [window.window_name for window in built.windows] == ["api"]