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

Allow spinners to be marked as "done" and persist in the UI. #89

Closed
danmatthews opened this issue Sep 27, 2023 · 3 comments
Closed

Allow spinners to be marked as "done" and persist in the UI. #89

danmatthews opened this issue Sep 27, 2023 · 3 comments
Assignees

Comments

@danmatthews
Copy link

When running a task with multiple spinners that are over with particularly quickly, only one spinner instance is shown, but the message: argument changes:

CleanShot 2023-09-27 at 11 11 10

This is great, but if multiple tasks run quickly, the spinner simply appears to keep the text from the first instance that was around long enough to render the message:

CleanShot 2023-09-27 at 11 12 41

Of course, you can add info calls to intersperse them:

CleanShot 2023-09-27 at 11 14 32

But the spinner disappears and just leaves the info messages in one big "dump".

Suggestion: Persistent / Completed spinner.

When a spinner completes it's callback, the spinner persists in the UI, but with a checkmark next to it, or, if it failed, a red cross?

This way, you get: predictable output for tasks and can see previous completions.

I would suggest a persist argument to the class:

spin(
  callback: fn () => $this->doSomething(),
  message: 'Calling the API',
  persist: true,
);

Please excuse the bad photoshop next...

CleanShot 2023-09-27 at 11 28 45@2x

Something like this?

Would love to know your thoughts.

@danmatthews
Copy link
Author

Just another quick addition to this:

The ability to change the message yourself when the task is complete would be super handy too, for example, we use spin in our deployment script, which has a few stages.

CleanShot 2023-09-27 at 17 02 07@2x

It would be great if we could change this to something custom like "Assets Packaged!" etc.

@mortenscheel
Copy link

If you're open to taking this a step further, I would recommend taking a look at the Listr package for NodeJS for inspiration. It has a nice and clean api for creating multi-step tasks. All tasks can provide callbacks that determine if they should be disabled or skipped at runtime. All callbacks receive a shared Context object, which they can read from and add to, which allows them to adapt to information provided by previous steps, or pass information on to future tasks. A task can even be a nested list of sub-tasks.

@driesvints
Copy link
Member

Hi all. I think for this one that the discussion is best continued in a PR. Feel free to send one in which we can have a look at, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants