Skip to content

The agent that grows with you

test(e2e): TUI clarify cell tolerates the API-only first-contact note; exit failures dump threads + tmux server signals

teknium113bf2ebaaa35
diff --git a/tests/e2e/core/tui_pty/_helpers.py b/tests/e2e/core/tui_pty/_helpers.py
index 4a4fcfbc24c..3da67f108aa 100644
--- a/tests/e2e/core/tui_pty/_helpers.py
+++ b/tests/e2e/core/tui_pty/_helpers.py
@@ -263,6 +263,7 @@ class TmuxTui:
self.tmux("pipe-pane", "-t", "p", f"cat >> {shlex.quote(str(self.transcript_path))}")
self.pane_pid = int(self.tmux("display", "-p", "-t", "p", "#{pane_pid}").strip())
self.pane_tty = self.tmux("display", "-p", "-t", "p", "#{pane_tty}").strip()
+ self.server_pid = int(self.tmux("display", "-p", "#{pid}").strip() or 0)
self.seen: set[int] = set()
# -- tmux ------------------------------------------------------------------------------------
@@ -459,6 +460,7 @@ class TmuxTui:
f"elapsed since /exit: {time.monotonic() - t0:.1f}s\n"
f"tmux: rc={q.returncode} out={q.stdout.strip()!r} err={q.stderr.strip()!r}\n"
f"pane pid {self.pane_pid}: {proc}\n"
+ f"tmux server {self.server_pid}: {_status_fields(self.server_pid)}\n"
f"--- frame before /exit ---\n{before}\n"
f"--- last {tail} lines of the PTY transcript ---\n{self.transcript_tail(tail)}")
@@ -538,7 +540,37 @@ def _proc_state(pid: int) -> str:
state = Path(f"/proc/{pid}/stat").read_text(encoding="utf-8").rsplit(")", 1)[1].split()[0]
except OSError:
return "gone (reaped)"
- return f"state {state} ({'zombie, not reaped yet' if state == 'Z' else 'still running'}): {cmdline(pid)}"
+ return (f"state {state} ({'zombie, not reaped yet' if state == 'Z' else 'still running'}): {cmdline(pid)}\n"
+ f" {_status_fields(pid)}\n threads: {_threads(pid)}")
+
+
+def _status_fields(pid: int, keys: tuple[str, ...] = ("State", "PPid", "Threads", "SigPnd", "ShdPnd", "SigBlk",
+ "SigIgn", "SigCgt")) -> str:
+ """Selected ``/proc/<pid>/status`` lines: why a process is not reaped (a zombie leader whose
+ other threads are still exiting, or a parent with SIGCHLD blocked/pending)."""
+ try:
+ lines = Path(f"/proc/{pid}/status").read_text(encoding="utf-8").splitlines()
+ except OSError as exc:
+ return f"(no status: {exc})"
+ return " ".join(line.replace("\t", "") for line in lines if line.split(":", 1)[0] in keys)
+
+
+def _threads(pid: int) -> str:
+ """``tid:comm:state:wchan`` for every thread of ``pid``."""
+ out = []
+ try:
+ tids = sorted(os.listdir(f"/proc/{pid}/task"), key=int)
+ except OSError as exc:
+ return f"(no tasks: {exc})"
+ for tid in tids:
+ base = f"/proc/{pid}/task/{tid}"
+ try:
+ stat = Path(f"{base}/stat").read_text(encoding="utf-8")
+ wchan = Path(f"{base}/wchan").read_text(encoding="utf-8") or "-"
+ except OSError:
+ continue
+ out.append(f"{tid}:{stat[stat.index('(') + 1:stat.rindex(')')]}:{stat.rsplit(')', 1)[1].split()[0]}:{wchan}")
+ return " ".join(out)
def _alive(pid: int) -> bool:
diff --git a/tests/e2e/core/tui_pty/test_modals_resize.py b/tests/e2e/core/tui_pty/test_modals_resize.py
index f4a09008d1a..eb9276402de 100644
--- a/tests/e2e/core/tui_pty/test_modals_resize.py
+++ b/tests/e2e/core/tui_pty/test_modals_resize.py
@@ -62,6 +62,13 @@ def _tool_results(llm: FakeLLMServer) -> list[str]:
return out
+def _typed(content) -> object:
+ """What the user typed into a wire user message: the install's first message carries the
+ API-only first-contact onboarding note (``\\n\\n[System note: ...]``, never persisted), which is
+ per-turn context riding the user turn, not a second user turn."""
+ return content.split("\n\n[System note: ", 1)[0] if isinstance(content, str) else content
+
+
def _visible_once(tui: TmuxTui, needles: list[str]) -> str:
text = "\n".join(tui.rows())
bad = {n: text.count(n) for n in needles if text.count(n) != 1}
@@ -111,7 +118,7 @@ def _scenario(root, victim) -> object:
# The answer is the tool's result, never a persisted user message (the TUI echoes it as a
# bubble by design; state.db and the next wire request must not grow a user turn).
users = [c for _s, r, c in tui.messages() if r == "user"]
- wire_users = [m.get("content") for m in (llm.main_requests()[-1].get("messages") or [])
+ wire_users = [_typed(m.get("content")) for m in (llm.main_requests()[-1].get("messages") or [])
if m.get("role") == "user"]
cells.add("clarify_answer_not_a_user_turn",
"" if users == ["pick a colour mq1"] and wire_users == ["pick a colour mq1"]