Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive Prompt Reminder for lanes waiting for input/confirm #302

Merged
merged 5 commits into from
Oct 22, 2021

Conversation

AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Oct 14, 2021

What

This introduces a monkey-patch on fastlane's interactive UI methods like the UI.input and UI.confirm which will remind you (via beep + badge and icon jumping in Dock, and optionally an opt-in spoken alert) that the Terminal is waiting for an answer from you if you didn't provide one after some time.

Why

This is particularly very useful if, like me, your often run a command like bundle exec fastlane new_beta_release then switch another app to work on something else, thinking that you can work on something else while the beta is building on CI… only to realize 10mn or even 30mn or more later that the CI never started, and that you've wasted all that waiting time for nothing, because you forgot that the lane was waiting for you to confirm the action first.

With this change, if you go do other things and forget that the prompt is waiting for you, you'll now be reminded about it ✨

Demo

(Turn sound on, as I narrate and have enabled the FASTLANE_PROMPT_REMINDER_MESSAGE option too)

interactive_prompt_reminder-720p.mov

Customization

This code uses Monkey-Patching 🐒 to redefine fastlane's UI.… interactive methods (UI.input, UI,confirm, etc) and wrap their original implementations around a helper method (UI.with_reminder) which handles the delay+alerting logic.

By default, those UI.… methods will be automatically patched to generate a system beep and make your Terminal icon jump after 30s then 3mn then 10mn. You can opt-out of the auto-patching using FASTLANE_PROMPT_REMINDER_DISABLE_AUTO_PATCH=1 env var.

When you don't opt-out of the auto-patching (the default), you can also refine the behavior of those reminders:

  • By default, it will only beep + make the Dock icon bounce, after 30s, 180s then 600s of you failing to reply the prompts
  • You can customize the delays using FASTLANE_PROMPT_REMINDER_DELAYS env var
  • You can also make the reminder speak a message – via the System's say command – using the FASTLANE_PROMPT_REMINDER_MESSAGE env var.
    • Set it to the value default, yes, true or 1 to use the default message, i.e "An interactive prompt is waiting for you in the Terminal!"
    • Set it to any other string to use that string as the message to be spoken
    • Unset it if you don't want the reminder to speak to you, but only beep + bounce dock icon (the default)

To test

0. Point your Pluginfile to this PR
  • Cut a test branch from your develop branch in your client repo (e.g. WPiOS)
  • Point your fastlane/Pluginfile to this branch, run bundle update fastlane-plugin-wpmreleasetoolkit to update the Gemfile.lock, and commit the changes (because we need a clean repo in order for the new_beta_release lane not to fail)
1. Test the default behavior
  • Run bundle exec fastlane new_beta_release in your terminal, then switch to another app and/or go drink a coffee (without waiting or replying to the prompt)
  • Confirm that after 30s while not replying to the prompt waiting for you in the terminal, you'll get a beep and the Terminal icon will jumping (once) in your Dock
  • Reply n to the prompt to cancel the new beta
  • git checkout back to your test branch (as new_beta_release would have switched to the release branch during its exececution)
2. Test a custom delay + default spoken message
  • Run FASTLANE_PROMPT_REMINDER_DELAYS=3,5 FASTLANE_PROMPT_REMINDER_MESSAGE=default bundle exec fastlane new_beta_release
  • Confirm that after 3 seconds, you will not only get the system beep + Dock icon badge and bounce, but also have your Mac speak out loud the "An interactive prompt is waiting for you in the Terminal!" message.
  • Confirm that after 5 more seconds, you'll get the beep + icon badge + spoken message once more
  • Reply n to the prompt, then git checkout back to your test branch
3. Test a custom spoken message
  • Run FASTLANE_PROMPT_REMINDER_DELAYS=3,5 FASTLANE_PROMPT_REMINDER_MESSAGE="Hello?" bundle exec fastlane new_beta_release
  • Confirm that after 3 seconds, you will not only get the system beep + Dock icon badge and bounce, but also have your Mac speak out loud the "An interactive prompt is waiting for you in the Terminal!" message.
  • Confirm that after 5 more seconds, you'll get the beep + icon badge + spoken message once more
  • Reply n to the prompt, then git checkout back to your test branch
4. Test opting out completely
  • Run FASTLANE_PROMPT_REMINDER_DISABLE_AUTO_PATCH=1 FASTLANE_PROMPT_REMINDER_DELAYS=3,5 FASTLANE_PROMPT_REMINDER_MESSAGE=default bundle exec fastlane new_beta_release
  • Confirm that you won't get any reminder at all, neither after 3, 5 or 30 seconds of waiting.
  • Reply n to the prompt, then git checkout back to your test branch

Mergeability

We maybe want to wait for us to do the 2.0.0 major release of the release-toolkit first before merging this and ship it as part of a 2.1.0, just because if we need to fix or revert things introduced by the breaking changes from #300 due to some bug, it would make more sense to keep the major release focused on the big change only. This is why I've kept this PR as Draft for now, and why I didn't add the CHANGELOG entry just yet.

That being said, if it's approved in time, and you feel it has its place in the upcoming 2.0.0, I don't have strong feelings about it being included sooner.

@AliSoftware AliSoftware self-assigned this Oct 14, 2021
@AliSoftware AliSoftware requested a review from a team October 14, 2021 18:51
@AliSoftware AliSoftware force-pushed the prompt-reminder branch 2 times, most recently from 5d6ac13 to 3919652 Compare October 14, 2021 19:53
@AliSoftware AliSoftware changed the title Interactive Prompt Reminder for lanes waiting for input/confirm – say "An interactive prompt is waiting for you in the Terminal!" Interactive Prompt Reminder for lanes waiting for input/confirm Oct 15, 2021
@AliSoftware AliSoftware marked this pull request as ready for review October 20, 2021 14:20
@AliSoftware
Copy link
Contributor Author

@wordpress-mobile/owl-team This is now ready for review.

(As a bonus, if we merge #299 soon, then that PR would make an easy candidate for a small new version to test the gem push by Buildkite CI 😛 )

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

When I first saw the PR and understood it involved monkey patching, my first reaction was "woo woo 🤚 monkey patching is dangerous! is the added 'risk' worth the reminders?" Then, I forgot about the prompt for 3 builds in a row and wished I had a spoken reminder there. 😅

I tested it and it worked as described in terms of the configuration behavior but my terminal (iTerm 2 Build 3.4.9beta1) did not beep nor bounce. I suspect this has to do with my notifications configurations in Big Sur, though 🤔

The icon did show the notification badge with a "1" when I went back and checked 👍

module FastlaneCore
# NOTE: FastlaneCore::UI delegates to the FastlaneCore::Shell implementation when output is the terminal
class Shell
DEFAULT_PROMPT_REMINDER_MESSAGE = 'An interactive prompt is waiting for you in the Terminal!'.freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: do you hear any difference when using the exclamation mark? I tried `say "potato"; say "potato!"; say "potato. potato!" and they all sounded the same 😄 🤷‍♂️

@AliSoftware
Copy link
Contributor Author

AliSoftware commented Oct 22, 2021

I tested it and it worked as described in terms of the configuration behavior but my terminal (iTerm 2 Build 3.4.9beta1) did not beep nor bounce. I suspect this has to do with my notifications configurations in Big Sur, though 🤔

Since the code calls $STDOUT.beep I think the beep sound isn't tied to BigSur's notifications settings (it's not like it was trying to post in the Notifications Center); I'd be betting on a setting in iTerm preferences instead which disables the beep?

h/t @mokagio

Co-authored-by: Gio Lodi <giovanni.lodi42@gmail.com>
@AliSoftware
Copy link
Contributor Author

@mokagio I found this article about iTerm vs Terminal beep/bell settings.

So I think the reason why you didn't have a beep in your iTerm is just because you probably have "Silence bell" option enabled in your iTerm preferences. 🙃

@AliSoftware
Copy link
Contributor Author

I've merged develop back into this PR after #299 landed, and now the CI checks are all green 🎉 prooving that our Buildkite pipeline works as expected 😃

@AliSoftware AliSoftware merged commit f853039 into develop Oct 22, 2021
@AliSoftware AliSoftware deleted the prompt-reminder branch October 22, 2021 13:01
@mokagio
Copy link
Contributor

mokagio commented Oct 25, 2021

you probably have "Silence bell" option enabled in your iTerm preferences. 🙃

Indeed:

Screen Shot 2021-10-25 at 12 09 32 pm

I store those settings in Dropbox. I must have set it years ago, forgot about it, and just assumed it's the default behavior for everyone 😅

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.

2 participants