From 1d86324da44b345389b5477175f883a040f86bf0 Mon Sep 17 00:00:00 2001 From: JTInventory Date: Wed, 1 Jul 2026 01:48:36 +0000 Subject: [PATCH 1/4] fix: settle codex secondmate sends before submit --- bin/fm-send.sh | 18 ++++++++--- tests/fm-send-popup-settle.test.sh | 49 ++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/bin/fm-send.sh b/bin/fm-send.sh index 489c07ca..15e3d585 100755 --- a/bin/fm-send.sh +++ b/bin/fm-send.sh @@ -12,8 +12,9 @@ # instead of silently leaving an unsubmitted instruction (incident afk-invx-i5). # The composer/submit logic is shared with the away-mode daemon via # bin/fm-tmux-lib.sh. Tune with FM_SEND_RETRIES (default 3) / FM_SEND_SLEEP (0.4). -# Slash commands, and codex `$...` skill invocations resolved through harness -# meta, get a longer pre-Enter settle so completion popups do not swallow Enter. +# Slash commands, codex `$...` skill invocations resolved through harness meta, +# and marked codex secondmate text get a longer pre-Enter settle so completion or +# input timing does not swallow Enter. # # From-firstmate marker: when the resolved target is a bare `fm-` whose meta # records kind=secondmate, the text is prefixed with the from-firstmate marker @@ -102,13 +103,22 @@ else # `$` case is scoped to codex on purpose: unlike `/`, a leading `$` commonly # starts ordinary text ("$5/month", "$HOME"), so a universal `$` rule would # needlessly slow plain text to claude/opencode/pi. The retried Enter in - # fm_tmux_submit_core still backs the settle up either way. + # fm_tmux_submit_core still backs the settle up either way. A marked ordinary + # message to a codex secondmate also uses the longer settle: live Codex panes + # have swallowed Enter on that path while leaving the already-typed request in + # the composer, and the marker is present only for bare kind=secondmate targets. case "$*" in /*) settle=1.2 ;; \$*) if [ "$TARGET_HARNESS" = codex ]; then settle=1.2; else settle=0.3; fi ;; - *) settle=0.3 ;; + *) + if [ -n "$MARK_PREFIX" ] && [ "$TARGET_HARNESS" = codex ]; then + settle=1.2 + else + settle=0.3 + fi + ;; esac retries=${FM_SEND_RETRIES:-3} sleep_s=${FM_SEND_SLEEP:-0.4} diff --git a/tests/fm-send-popup-settle.test.sh b/tests/fm-send-popup-settle.test.sh index fcf0d2b6..07ab49df 100755 --- a/tests/fm-send-popup-settle.test.sh +++ b/tests/fm-send-popup-settle.test.sh @@ -15,6 +15,7 @@ # $... explicit -> 0.3 (session:window target has no meta -> harness unknown # -> non-codex safe default) # plain text -> 0.3 (fast path) +# marked codex secondmate plain text -> 1.2 (long settle before submit) # # The popup-settle is the FIRST sleep recorded: fm_tmux_submit_core types the text, # then `sleep "$settle"`, then the Enter-retry loop (sleep 0.4 each) and finally @@ -67,16 +68,16 @@ SH printf '%s\n' "$fb" } -# first_settle