Wait for the keypress ourselves instead of asking gum to (#8082)
* Wait for the keypress ourselves instead of asking gum to gum 2.0 runs a spun command without the terminal attached, so the `gum spin -- read -n 1` that held the presentation terminal open returned at once. Every menu command that ended in a failure took its window down with it before the error could be read, which is how a failed update looked like a terminal that just quit. Read the key directly. gum's own terminal query replies are still sitting on the tty when the spinner stops, so drain those first or they answer the prompt on the user's behalf. The green dot reads better than the globe did, so the provisioning notice uses it too and drops its spinner along the way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Ask the terminal for itself before prompting on it The /dev/tty node is there whether or not a terminal is behind it, so the existence check passed on a headless run and left both reads failing with "No such device or address". Open it instead. Prompt on the terminal too, rather than stdout: a caller that redirects us was sending the prompt to a file while the read waited on the terminal, which looks like a hang with no instruction on screen. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1565919c87
commit
5d3299fb94
@@ -141,7 +141,8 @@ say() {
|
|||||||
notice() {
|
notice() {
|
||||||
clear_logo
|
clear_logo
|
||||||
echo
|
echo
|
||||||
gum spin --spinner "pulse" --title "$1" -- sleep "${2:-2}"
|
printf '%*s\033[32m● \033[0m%s\n' "$PADDING_LEFT" '' "$1"
|
||||||
|
sleep "${2:-2}"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-3
@@ -1,6 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Display a "Done!" message with a spinner and wait for user to press any key.
|
# omarchy:summary=Display a "Done!" message and wait for user to press any key.
|
||||||
|
|
||||||
echo
|
# The device node is there whether or not a terminal is behind it, so opening
|
||||||
gum spin --spinner "globe" --title "Done! Press any key to close..." -- bash -c 'read -n 1 -s'
|
# it is the only test that means anything.
|
||||||
|
: 2>/dev/null <>/dev/tty || exit 0
|
||||||
|
|
||||||
|
# gum 2.0 no longer lets a spun command read the terminal, so the wait has to
|
||||||
|
# happen here. Its own query replies are still queued on the tty; drop those or
|
||||||
|
# they answer the keypress for the user.
|
||||||
|
while read -rsn 1 -t 0.1 _ </dev/tty; do :; done
|
||||||
|
|
||||||
|
# Prompt on the terminal rather than stdout, or a caller that redirects us
|
||||||
|
# leaves the user waiting on a prompt they were never shown.
|
||||||
|
printf '\n\033[32m● \033[0mDone! Press any key to close...' >/dev/tty
|
||||||
|
read -rsn 1 </dev/tty
|
||||||
|
echo >/dev/tty
|
||||||
|
|||||||
Reference in New Issue
Block a user