Skip to content

Wait for the keypress ourselves instead of asking gum to - #8082

Merged
dhh merged 2 commits into
quattrofrom
show-done-waits-without-gum
Aug 24, 2026
Merged

dhh merged 2 commits into
quattrofrom
show-done-waits-without-gum

Conversation

@dhh

@dhh dhh commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

gum 2.0 runs a spun command without the terminal attached, so the gum spin -- bash -c 'read -n 1 -s' that omarchy-show-done relied on returns immediately instead of waiting for a keypress.

Every command launched through omarchy-launch-floating-terminal-with-presentation ends in omarchy-show-done, so the pause at the end of those terminals is simply gone. When the command succeeds that is mostly invisible — something else usually prompts. When it fails, the window takes the error down with it, which is how a failed update looks like a terminal that just quits before anything can be read.

Measured in a foot window on gum 2.0.0:

result
read -n1 -s -t 6 blocks the full 6s
gum spin --spinner globe --title "Done!" -- bash -c 'read -n 1 -s' returns rc=0 in 0s

The script logging wrapper in omarchy-update is not involved — the spinner returns instantly with or without it.

The fix

Read the key directly instead of asking gum to. Three details this has to get right:

  • gum's own terminal query replies are still queued on the tty when the spinner stops, so those get drained first — otherwise they answer the prompt on the user's behalf and the window closes just the same.
  • The prompt is written to the terminal rather than stdout. A caller that redirects stdout would otherwise send the prompt to a log while the read waits on /dev/tty, leaving a terminal that looks hung with no instruction.
  • /dev/tty is opened rather than tested with -e. The device node exists whether or not a terminal is behind it, so a headless run (cron, systemd, ssh without -t) would pass an -e check and then fail both reads with "No such device or address".

The green dot reads better than the globe did, so omarchy-provision-owner's notice() picks it up too and drops its spinner along the way. Those were the only two gum spin sites in the repo.

Verification

  • In a pty, the patched omarchy-show-done holds until a keypress is injected, then returns rc=0. Before the fix the same harness returned in 0s.
  • Headless (setsid, no controlling terminal): exits 0, silently.
  • With stdout redirected: prompt lands on the terminal, 0 bytes in the redirect target, still waits.
  • test/cli: 116 ok, 0 failures.

🤖 Generated with Claude Code

dhh and others added 2 commits August 24, 2026 19:17
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) <[email protected]>
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) <[email protected]>
Copilot AI balanced review requested due to automatic review settings August 24, 2026 17:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dhh
dhh merged commit 5d3299f into quattro Aug 24, 2026
3 checks passed
@dhh
dhh deleted the show-done-waits-without-gum branch August 24, 2026 17:46
omarchybot pushed a commit that referenced this pull request Aug 24, 2026
…8082)

Backport of the keypress fix (PR #8082, merged to quattro as 5d3299f) onto the
v4-0-1 release branch.

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 /dev/tty node is there whether or not a terminal is
behind it, so open it rather than test for it -- the existence check passed on a
headless run and left both reads failing with "No such device or address" -- and
prompt on the terminal rather than stdout, so a caller that redirects us does
not leave the user waiting on a prompt they were never shown.

The green dot reads better than the globe did, so the provisioning notice uses
it too and drops its spinner along the way.

Clean cherry-pick: both files are byte-identical to quattro, so merging v4-0-1
into quattro resolves without a conflict. Exercised against the installed gum
2.0.0: headless it exits 0 at once, and on a pty it prints the prompt and
returns on one keypress. test/shell (186 files) and test/cli pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018DEMYa9UWtroz93DhMTtcV
@omarchybot omarchybot mentioned this pull request Aug 24, 2026
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
* 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) <[email protected]>

* 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) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@emirb emirb added this to the 4.5 milestone Oct 17, 2026
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.

3 participants