Skip to content

Show lstk aws spinner only for long-running operations#238

Merged
peter-smith-phd merged 3 commits into
mainfrom
drg-829-aws-spinner-duration
May 11, 2026
Merged

Show lstk aws spinner only for long-running operations#238
peter-smith-phd merged 3 commits into
mainfrom
drg-829-aws-spinner-duration

Conversation

@peter-smith-phd
Copy link
Copy Markdown
Contributor

@peter-smith-phd peter-smith-phd commented May 10, 2026

The lstk aws spinner was rendering for every invocation, which looks odd for the common case where the command completes in well under a second. The spinner now waits 4 s before rendering its first frame, so it only appears for operations that are actually slow (e.g. lazy service init). The label is also clarified from "Loading..." to "Loading service..." so the wait is self-explanatory.

Fixed DRG-829

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@carole-lavillonniere
Copy link
Copy Markdown
Collaborator

@gtsiolis can we get your opinion on this change?

Copy link
Copy Markdown
Member

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Thanks, @peter-smith-phd! Left some comments below. Once we revert the copy and update the delay duration, we can merge this unless there are any engineering concerns from @carole-lavillonniere.

Comment thread cmd/aws.go Outdated
stdout, stderr := io.Writer(os.Stdout), io.Writer(os.Stderr)
if terminal.IsTerminal(os.Stderr) {
s := terminal.NewSpinner(os.Stderr, "Loading...")
s := terminal.NewSpinner(os.Stderr, "Service loading...", 4*time.Second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

issue: On the copy change, I'd revert Service loading... back to Loading.....

  • The first one is more ambiguous and confusing. For example, which service is loading? lstk, docker, localstack, something else?
  • The verb-based pattern would actually be informative (Creating bucket…, Listing buckets... etc) but isn't possible without overengineering because aws command is a pure proxy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was intentionally trying to be more specific, and less vague. The problem is that when I see Loading..., I immediately ask myself "What is loading?". When I use the aws command, I don't expect anything to be loading. I don't expect lstk to be loading, nor do I expect docker or localstack because both of them have been loaded already. It was actually quite confusing to see the Loading... message at all, because I wasn't expecting anything to be loading.

By adding Service loading... we're specifically explaining that the delay is (most likely) due to the emulated service loading. Use of aws is usually very quick and responsive, because that's how AWS designed the APIs. The fact that we're using lazy service loading is what makes it sometimes slow. As an expert user of aws, that extra Service word was important to help me understand why.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fair point. Could you rename it to Loading service... so it becomes a verb-based label?

Comment thread cmd/aws.go Outdated
stdout, stderr := io.Writer(os.Stdout), io.Writer(os.Stderr)
if terminal.IsTerminal(os.Stderr) {
s := terminal.NewSpinner(os.Stderr, "Loading...")
s := terminal.NewSpinner(os.Stderr, "Service loading...", 4*time.Second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thought: Adding a delay before showing a spinner is a common pattern in many UI design systems. In contrast, most CLI and TUI design guidelines or frameworks either recommend printing something as fast as possible to the user or don't expose any delay option at all, with one or two exceptions that also default to zero delay. The deferred spinner sounds ok to add here given the AWS CLI itself does not surface any loading feedback.

Comment thread cmd/aws.go Outdated
stdout, stderr := io.Writer(os.Stdout), io.Writer(os.Stderr)
if terminal.IsTerminal(os.Stderr) {
s := terminal.NewSpinner(os.Stderr, "Loading...")
s := terminal.NewSpinner(os.Stderr, "Service loading...", 4*time.Second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: In CLI design being responsive is more important than being fast[1]. The 4 second window seems unreasonably high. A slow invocation is indistinguishable from a hung CLI. If we're going to add a delay parameter I'd...

  1. Add a smaller delay like 1 second, so the spinner doesn't appear on every AWS command invocation but the silent window is short enough to stay responsive.
  2. Add a minimum visible duration of ~500 ms once the spinner starts, so commands that finish just past the 1 second threshold don't flash a single frame.
  3. Skip [2] if slow AWS invocations always overshoot 1 scond by a meaningful margin which is true from what I've seen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did think about 3 seconds initially, but when I did some practical experiments it felt like 4 seconds was the time at which I start to think "this is taking a while". Normally, the aws command doesn't show any spinners, nor would customers expect aws commands to take more than a few seconds.

I feel that 1 second is far too short, as the user will see the spinner even on "normal" AWS calls - that is, when there is no lazy-loading actually happening.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Following up from #238 (comment), we can also keep the 4 seconds for now and adjust later.

Comment thread cmd/aws.go Outdated
stdout, stderr := io.Writer(os.Stdout), io.Writer(os.Stderr)
if terminal.IsTerminal(os.Stderr) {
s := terminal.NewSpinner(os.Stderr, "Loading...")
s := terminal.NewSpinner(os.Stderr, "Service loading...", 4*time.Second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: Just to confirm, this adds the delay only for aws commands, right?

Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere May 11, 2026

Choose a reason for hiding this comment

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

The delay is only added to the non-TTY (aka non-TUI/non-bubbletea) spinner which is only used for the aws command at the moment. However it would be applied to any other future use case.
Taking this back. The delay can be configured so whether the spinner should appear after a delay or not can be decided on a command basis 👏

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this needs to be configurable for each command. The proposed message Service loading... and the delay of 4 seconds only makes sense in the context of aws. For other commands there would be different messages and different delays.

Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere left a comment

Choose a reason for hiding this comment

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

Good to go from a code perspective once @gtsiolis is happy, well done @peter-smith-phd

@peter-smith-phd peter-smith-phd requested a review from gtsiolis May 11, 2026 19:59
Copy link
Copy Markdown
Member

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Looks shippable. :shipit:

Updated PR description to use the new copy.

Thanks for contributing, @peter-smith-phd! 🏀

@peter-smith-phd peter-smith-phd merged commit 75d456b into main May 11, 2026
12 checks passed
@peter-smith-phd peter-smith-phd deleted the drg-829-aws-spinner-duration branch May 11, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants