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

Output in spinner function gets removed instead of spinner #180

Closed
toonvd opened this issue Jan 2, 2025 · 1 comment
Closed

Output in spinner function gets removed instead of spinner #180

toonvd opened this issue Jan 2, 2025 · 1 comment

Comments

@toonvd
Copy link

toonvd commented Jan 2, 2025

Laravel Prompts Version

0.3.2

Laravel Version

Laravel zero 11.0.3

PHP Version

8.3.15

Operating System & Version

Ubuntu 22.04

Terminal Application

iTerm

Description

Prompt output is cut off, this is likely because off wrong cursor position calculation.
Screenshot 2025-01-02 at 01 16 48

Steps To Reproduce

Noticed this in Laravel Zero when trying to wrap the handle call in the execute function:

            return (int) spin(
                message: 'Loading...',
                callback: fn() => $this->laravel->call([$this, $method])
            );

This is basically promptception since a table prompt was nested within a spinner prompt. PrevFrame was possibly overriden by the Table output

@jessarcher
Copy link
Member

Hi @toonvd,

The spinner doesn't support having console output from the callback function, and I can't think of a way to make this possible at the moment.

The spinner forks a separate process to run the callback so it can continue animating the spinner while the callback is running. As a result, the parent process isn't aware of anything the callback outputs.

Even if it could be made aware, it would be quite complex to render two different outputs. The parent process would probably need to intercept the rendering of the child process so it can erase the spinner, render the child's output, and then resume the spinner below again.

If possible, I'd suggest having the callback return the data required for the table when it's done and output the table after the spinner has completed.

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

No branches or pull requests

2 participants