Debounce password prompt and auto-cancel on falling edge#261
Merged
Conversation
The canonical+!echo heuristic is identical to ghostty's, but ghostel
checks on every redraw (sub-100ms) and reacts with a modal `read-passwd'
minibuffer — so short-lived flips that ghostty's 200ms termios poller
silently misses become user-visible popups in ghostel. Two defenses:
1. Debounce the rising edge. `ghostel-password-prompt-debounce'
(default 0.2s) schedules a confirm timer; the source chain only
runs if the heuristic still reports password mode at the deadline.
Sub-debounce flickers leave no trace beyond a brief mode-line
indicator flash, matching ghostty's transient lock-icon UX.
2. Auto-cancel on falling edge. When the heuristic flips off while
our `read-passwd' is up, `abort-recursive-edit' closes it — useful
when the user kills the foreground program (e.g. C-c C-c sending
Ctrl+C to sudo) and expects the prompt to disappear with it.
Three gates ensure we only abort our own minibuffer:
- Active flag: source chain is in flight.
- Depth: `minibuffer-depth' equals the value captured before our
prompt opened, plus one (our minibuffer is innermost).
- Minibuffer identity: `(window-buffer (active-minibuffer-window))'
matches the buffer captured by `minibuffer-with-setup-hook' when
our `read-passwd' was entered. The setup hook only captures when
`minibuffer-selected-window' points at our buffer, so an unrelated
minibuffer opened concurrently (cross-buffer M-x race) can't
poison the capture. Identity is robust to focus switching —
`minibuffer-selected-window' alone returns nil once the user
moves focus out of the minibuffer.
Refs #244.
7480ee9 to
c5c191e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ghostel-password-prompt-debounce, default 0.2s): re-check the canonical+!echo heuristic at the deadline before openingread-passwd, so sub-200ms flips don't pop a modal prompt — matching ghostty's natural ~200 ms termios poll cadence.read-passwdon falling edge: when the heuristic flips off while our prompt is up (e.g. user kills the foreground program withC-c C-c),abort-recursive-editcloses the minibuffer.minibuffer-with-setup-hook(so cross-bufferM-xraces and focus-switching don't clobber unrelated minibuffers).Refs #244.
Test plan
make -j4 all— 343 tests pass (341 expected + 2 unrelated skips), lint clean.sudo -s→read-passwdopens after 200 ms → switch to ghostel window →C-c C-ckills sudo →read-passwdauto-closes.auth-source-style flows.