feat(issue-24): startup dialogs come from the agent adapter and are handled while waiting for the TUI

handle_startup_dialogs was a claude-only string ladder called only when
AGENT=claude, and wait_for_tui_ready does not treat a dialog screen as ready.
So agy, grok and codex sat on their directory-trust prompt for the full
readiness timeout, the session was recorded as tui-ready-timeout, and
onboarding injection was disabled (create_session.sh:313-314) - a human had to
accept each dialog by hand.

The signatures and accept keys move to the adapters as `startup_dialogs`
(pattern, keys, kind), published through the existing `facts` eval contract as
MAM_STARTUP_DIALOGS. claude's ladder moves over verbatim; agy takes Enter, grok
y, codex Enter, and codex's update notice takes 2 (Skip), which blocks a start
just as hard while changing nothing. kind is `trust` or `notice`:
--no-auto-trust leaves trust dialogs to a human and still answers notices,
since trusting a directory makes codex load its project-local config, hooks and
exec policy.

Re-sending is gated by time (MAM_DIALOG_RESEND_S, default 5s), not by frames.
#24's comment reports that `--source visible` keeps showing an accepted dialog
for a while, and _pane_capture hardcodes that source, so "still on screen" is
not evidence the keys were missed; acceptance is judged by the ready tokens
alone.

Two existing tests asserted the old shape and are updated, not weakened:
b19's "Escape branch stays" now looks for it in claude's adapter, and c1b's
"Enter once per iteration" becomes "never twice for one frame", which the
cooldown satisfies strictly more tightly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5 committed 2026-09-22 04:22:09 +00:00
1 parent 3bcaa39ab0
commit 5ba04a27ca
11 files changed
+344 -29

No files matched your search

+1
View File
@@ -63,6 +63,7 @@ def main():
print(f"MAM_STRONG_READY_TOKENS={q(adapter.strong_ready_tokens)}")
print(f"MAM_WEAK_READY_TOKENS={q(adapter.weak_ready_tokens)}")
print(f"MAM_MODAL_TOKENS={q(adapter.modal_tokens or '')}")
print(f"MAM_STARTUP_DIALOGS={q(json.dumps(adapter.startup_dialogs))}")
print(f"MAM_EXIT_KEY={q(adapter.exit_key)}")
print(f"MAM_DELEGATE_AGENT_KEY={q(adapter.delegate_agent_key)}")
@@ -23,6 +23,15 @@ class AgyAgentAdapter(BaseAgentAdapter):
def delegate_agent_key(self) -> str:
return 'antigravity-cli'
@property
def startup_dialogs(self) -> list:
# #24: "Do you trust the contents of this project?" with
# "> Yes, I trust this folder" preselected - Enter accepts.
return [
('Do you trust the contents of this project|Yes, I trust this folder',
['Enter'], 'trust'),
]
@property
def identity_cache_fields(self) -> tuple:
return ('conversation_id', 'conversation_db', 'conversation_brain_dir')
@@ -44,6 +44,19 @@ class ClaudeAgentAdapter(BaseAgentAdapter):
def modal_tokens(self) -> Optional[str]:
return 'Try the new fullscreen renderer\\?'
@property
def startup_dialogs(self) -> list:
# The ladder handle_startup_dialogs used to hardcode, unchanged.
return [
('Do you trust the files|Yes, I trust this folder|Quick safety check', ['Enter'], 'trust'),
# Fullscreen-renderer upsell, not the idle /tui tip: Enter would
# accept and restart the session without the permission flags.
('Yes, try it', ['Escape'], 'notice'),
('Yes, proceed', ['Down', 'Enter'], 'trust'),
('Resuming the full session', ['Enter'], 'notice'),
('Press Enter to continue', ['Enter'], 'notice'),
]
def artifact_path(self, uuid: str, ctx: DiscoveryContext) -> str:
return f"{ctx.claude_dir}/{ctx.ws_key}/{uuid}.jsonl"
@@ -24,6 +24,20 @@ class CodexAgentAdapter(BaseAgentAdapter):
def delegate_agent_key(self) -> str:
return 'codex-cli'
@property
def startup_dialogs(self) -> list:
# #24: the trust prompt lists "1. Yes, continue" preselected, so Enter
# accepts. Trust here also loads this project's local config, hooks and
# exec policy, which is why --no-auto-trust exists.
#
# The 0.155.1 update notice (observed 2026-09-22) blocks the session the
# same way; "2" is Skip, the choice that changes nothing.
return [
('Do you trust the contents of this directory|1\\. Yes, continue',
['Enter'], 'trust'),
('1\\. Update now|Skip until next version', ['2'], 'notice'),
]
@property
def identity_cache_fields(self) -> tuple:
return ('session_id',)
@@ -26,6 +26,13 @@ class GrokAgentAdapter(BaseAgentAdapter):
def delegate_agent_key(self) -> str:
return 'grok-build'
@property
def startup_dialogs(self) -> list:
# #24: "Do you trust the contents of this directory?" answered with y.
return [
('Do you trust the contents of this directory', ['y'], 'trust'),
]
@property
def identity_cache_fields(self) -> tuple:
return ('session_id', 'session_jsonl')
+15
View File
@@ -156,6 +156,21 @@ class BaseAgentAdapter:
def modal_tokens(self) -> Optional[str]:
return None
@property
def startup_dialogs(self) -> List[tuple]:
"""Blocking modals this CLI can show before its TUI is usable, most
specific first: (pattern, keys, kind).
`pattern` is an extended-regex signature matched against the pane tail,
`keys` are herdr send-keys arguments sent in order, and `kind` is
'trust' (a directory-trust prompt, gated by --auto-trust) or 'notice'
(anything else that blocks the start, always answered).
Issue #24: without this the start-up trust prompts of agy, grok and
codex burn the whole readiness timeout and onboarding is skipped.
"""
return []
@property
def strong_ready_tokens(self) -> str:
return self.ready_tokens