8000 fix(base): refuse to push at a pending Codex approval dialog by simon-inkie · Pull Request #17 · simon-inkie/inkie-deck · GitHub
[go: up one dir, main page]

Skip to content

fix(base): refuse to push at a pending Codex approval dialog - #17

Merged
simon-inkie merged 2 commits into
mainfrom
chore/port-codex-dialog-gate
Sep 4, 2026
Merged

simon-inkie merged 2 commits into
mainfrom
chore/port-codex-dialog-gate

Conversation

@simon-inkie
Copy link
Copy Markdown
Owner

Summary

Ports an internal fleet fix: Codex prints "Press enter to confirm or esc to cancel" under every one of its native approval dialogs. A pane wedged on an unanswered dialog is running nothing and waiting on a human, and inbox-push's deliver path is send-keys text then Enter, where Enter is the dialog's confirm key. An unattended keystroke reaching a permission decision, not just a bad log line.

bin/pane-idle gains pane_has_codex_approval_dialog(), tail-anchored against the exact footer (so it can't be fooled by transcript prose quoting it, or an already-answered dialog scrolled out of view), with three validation hardenings on its window-size override (zero, integer-overflow, and an oversized-window clamp). inbox-push gains two Codex-only guards: refuse to send at all if a dialog is showing (skip:dialog-pending), and if one appears during the send window, report pushed-unverified rather than a false queued, with the guard placed so it can never let a retry Enter reach a pending dialog.

Note on this repo specifically

This tree already has PR #14 (the esc-to-cancel lead-of-clause narrowing), which the internal source doesn't have yet. That flips the premise: here, a Codex dialog pane reads idle, not busy, and idle is precisely the verdict that licenses the deliver path — so this isn't a false-queued bug on this tree the way it is internally, it's a bare keystroke-safety gap. Rationale, one test's expected verdict, and a new structural line-order test (guard must precede the busy branch in the source, which a verdict test alone can't prove) were rewritten for this tree rather than copied wholesale.

Also flagged, out of scope for this PR: stuck-pane-sweep.sh's default_patterns here doesn't include the Codex dialog footer literal (internal's does), so the deterministic stuck tier won't escalate a wedged Codex pane on this tree. Worth its own follow-up.

Test plan

  • node scripts/leak-gate.mjs, licence-gate.mjs, lib-version-gate.mjs all clean
  • pane-idle.test.sh 30 → 47, inbox-push.test.sh 80 → 89, both green
  • Measured against the pre-change scripts, not assumed: the pre-send gate and the guard's placement go red there
  • Unaffected suites still green: inbox (69), activity-sweep (84), stuck-pane-sweep (82)

Codex prints "Press enter to confirm or esc to cancel" under every one of its
native approval dialogs. A pane wedged on an UNANSWERED dialog is running
nothing and waiting on a human, so check_idle answers IDLE for it, and IDLE is
the verdict that licenses inbox-push's deliver path. Deliver is send-keys text
then Enter, and Enter is the dialog's CONFIRM key: the text is swallowed by a
modal that is not a text field, and the keypress answers a permission prompt
the runtime deliberately stopped to ask a human about, unattended and in the
yes direction. That is an unattended keystroke reaching a permission decision,
not a bad log line.

bin/pane-idle gains pane_has_codex_approval_dialog, which asks the question
check_idle structurally cannot. Busy/idle is two-way and the world is
three-way, and the third state is the one where pressing a key is unsafe.

TAIL-ANCHORED to the last 20 lines, for the same reason the stuck sweep
matches its own literals inside a TAIL_LINES window: a dialog that has ALREADY
been answered, and transcript prose that merely QUOTES the footer, both sit
higher in the viewport. A whole-pane substring test answers "dialog pending"
for every one of those, and since the response is to not deliver, that is a
silent delivery outage aimed squarely at whoever is working on the dialog
problem. The window override is validated three ways, all of which fail
towards LOOKING at a dialog rather than towards missing one: a zero window
(all-digits validation accepts "0", tail -n 0 emits nothing, and a real
on-screen dialog reads as absent), a value past the shell's integer range
(where the validation's own arithmetic errors, silenced by its own redirect,
so neither the fallback nor the clamp fires), and an absurdly large window
(which defeats the tail-anchoring by pulling in the quoting prose).

PANE_IDLE_LIB_VERSION 2 -> 3, with the manifest row the version gate requires
in the same commit, and inbox-push raises its own pin to -ge 3. That pin
carries more weight than the v2 one: an undefined pane_has_codex_approval_
dialog returns non-zero, which reads as "no dialog here", so against a v2
library the guard would answer all clear every time and the Enter would go out
anyway. The library's other callers do not use it and keep their existing
assertions, because pins are per-caller.

Two guards in inbox-push, both Codex-only. A dialog visible at the gate skips
as skip:dialog-pending without typing anything. A dialog that appears during
the send window ends the run at pushed-unverified without reaching any retry
Enter. The second sits ABOVE the check_idle branch rather than inside it,
deliberately: a guard whose job is to withhold a keystroke must not depend on
a busy classification it exists to distrust, and the marker that reads this
footer has already moved once in this file's history.

The pre-send refusal already happened here, but by accident, as skip:staged:
the dialog's selected option carries the composer glyph, so find_composer_line
read it and called the pane staged. That is one glyph doing double duty, not a
guard. It knows nothing about dialogs and evaporates the moment the selection
is rendered differently, so the refusal is now deliberate and the reason
honest.

Tests: pane-idle 30 -> 47 cases, inbox-push 80 -> 89, both green, and the
other three shell suites unchanged and green. Measured against the pre-change
scripts rather than assumed. The pre-send gate and the guard's placement go
red there; the post-send guard's own case does not, because the staged-text
accident above already produced the same verdict, and the suite says so out
loud rather than letting it look like proof. The window-validation cases go
red against a naive all-digits check.

Ported from the internal fleet tooling this package was extracted from, and
hand-adapted rather than applied: the esc-to-cancel anchoring that landed here
first changes what the collision looks like on this side, so the detector's
rationale, the placement argument and two test expectations are written for
this tree rather than copied.

Co-authored-by: Simon <simon@inkie.ink>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@simon-inkie
Copy link
Copy Markdown
Owner Author

Model-Diverse Peer Review: PR #17 (inkie-deck, commit 146c7df)

Verdict: FULL APPROVAL


1. Audit of Keystroke-Safety Gate (pane-idle + inbox-push)

  • Detection Boundary (packages/base/bin/pane-idle):

    • check_codex_approval_dialog reliably detects pending Codex approval prompts in the pane capture tail.
    • Bounded window (CODEX_DIALOG_TAIL_LINES, default 20, ceiling 200) prevents older quoted dialog strings in chat transcripts from triggering false positives.
    • check_idle classifies an approval-dialog pane as idle so sweeps recognize the pane is waiting for input rather than executing commands.
  • Refusal to Push (packages/base/bin/inbox-push):

    • Intercepts pending approval dialogs and immediately aborts push attempts (skip:dialog-pending, exit code 2).
    • This closes the critical safety risk where delivery keystrokes (such as text or unhandled Enters) could inadvertently confirm destructive actions or garble the dialog prompt.
    • Post-send verification halts follow-up Enter re-sends if an approval dialog appears immediately post-delivery.

2. Test Verification

  • Executed packages/base/test/pane-idle.test.sh: 47 passed / 47 tests.
  • Executed packages/base/test/inbox-push.test.sh: 89 passed / 89 tests.
  • Total: 136 passed / 136 tests. All edge cases (tail line bounds, window clamping, non-numeric values, post-send dialog appearances) covered.

pane_has_codex_approval_dialog matched the footer literal anywhere inside
the last N lines of the capture. A window is a distance, and distance is
the wrong test for "is this the bottom of the pane": a transcript that
quotes the footer a few lines above a ready composer sits entirely inside
the default 20-line window, so the detector answered "dialog pending" for
a pane that was idle, reachable and waiting at a composer. inbox-push acts
on that answer by refusing delivery (skip:dialog-pending), so the false
positive is a silent delivery outage, aimed once again at whoever is
discussing dialogs -- the same shape the tail window was added to close,
surviving it because the window only moved the quote further down the pane.

The property that separates a live dialog from a quotation is not proximity
to the bottom, it IS the bottom: Codex draws the dialog where the composer
would be, so the footer is the last rendered content and nothing follows it.
A quotation always has something below it, the composer at minimum.

The detector now takes the tail window, strips trailing blank rows, and
requires the last remaining line to END WITH the literal once trimmed.
Strictly narrower than the test it replaces (a last line ending with the
literal contains it, so the old test matched every pane this one does), so
the change can only move verdicts from dialog-pending to no-dialog, never
the reverse: it cannot introduce a new pane at which a caller presses Enter.

The window-size validation (zero handling, overflow clamp, 200-line
ceiling) is retained verbatim. What the window bounds is now narrower --
how far up the trailing-blank strip reaches rather than how much prose is
in scope -- but the bug classes it closes are independent of that.

Tests: a new negative fixture with the footer quoted four lines above a
ready composer, plus a construction pin that one line of anything below the
footer is enough. Both were verified red against the previous function body
sourced from the parent commit. The pre-existing quoted-footer case keeps
its 24 lines of filler and stays as its own case: with the quote outside the
window it could never have failed while the detector was a window test.
The window boundary fixtures now pad with blank rows rather than content,
because content below the footer is no longer a dial
B1CB
og at any distance;
they grade identically against the old body, so no existing pin is weakened.

Lib version stays at 3: the function surface is unchanged.

Found by independent code review.
@simon-inkie
Copy link
Copy Markdown
Owner Author

Model-Diverse Re-Review Confirmation: PR #17 (inkie-deck, commit 0fe23e8)

Verdict: FULL APPROVAL


Audit of Bottom-Anchoring Fix (packages/base/bin/pane-idle)

  • Last Non-Blank Line Property Verified:

    • pane_has_codex_approval_dialog now finds the last non-blank line in the tail window (trimmed) and tests case "$last" in *"$footer").
    • Trailing blank rows from terminal viewports are stripped, but any rendered content below the footer (such as an idle composer prompt > ...) forces $last to that lower line, preventing false-positive matches on near-tail transcript quotes.
    • Suffix containment (*"$footer") safely accommodates leading indentation without fragility.
  • Test Suite Verification:

    • New negative tests CODEX_QUOTED_NEAR (quote 4 lines up above a ready composer) and content-below-footer pass cleanly.
    • pane-idle.test.sh: 49 passed / 49 tests.
    • inbox-push.test.sh: 89 passed / 89 tests.

@simon-inkie
simon-inkie merged commit 308a462 into main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0