Shopify / cli-ui

CLI tooling framework with simple interactive widgets
MIT License
1.01k stars 50 forks source link

SpinGroup hangs when used inside Prompt.ask #500

Closed cFire closed 1 month ago

cFire commented 8 months ago

I recently updated the cli-ui gem for a project I have and I've noticed SpinGroups have stopped working when used inside of a CLI::UI::Prompt.ask block.

I'm not entirely sure which version exactly it stopped working. I'll try to do some additional testing and narrow it down if possible.

Old cli-ui version where this still worked: 1.5.1

New cli-ui version where this no longer works: 2.2.3

Minimal example to reproduce:

require 'cli/ui'

CLI::UI::StdoutRouter.enable

def my_spinner
  CLI::UI::SpinGroup.new do |sg|
    sg.add('pending') { |spinner|
      result = { 'message' => 'mock api result' }
      sleep(0.5)
      spinner.update_title(result['message'])
    }
  end
end

# Works
my_spinner

# Hangs forever
CLI::UI::Prompt.ask('What do you want to do?') do |handler|
  handler.option('Watch a spinner spin') { my_spinner }
end
cFire commented 8 months ago

Tested some of the intermediate versions, last working version was 2.1.0 and 2.2.1 is the first version where this bug happens.

fatkodima commented 3 months ago

@cFire Can you verify the linked PR fixes your issue?

cFire commented 3 months ago

@cFire Can you verify the linked PR fixes your issue?

Indeed it does! Thanks for working out the fix.