`bud run` stdout/stderr improvements
Jotting down a quick list of bugs and improvements to make to bud run's terminal logging. @012e brought us a big step forward in terms of DX with #131, but there's a few loose ends left to cleanup:
-
[ ] Frontend reloads always show 0ms. This one is tricky to time because the start is in the app server, the end is in the bud dev server. The way frontend reloads work is they just send a signal to the frontend as an event source message to re-import it's page component. Should still be possible with @012e prompter state machine, we'll probably just need to make it concurrency safe and pass it through more places
-
[ ] Frontend errors don't show an error message in terminal or browser until refreshing the page. I think this is a regression, but I'm not sure. Eventually I'd like to show error messages in the same way that CRA or Next.js have these error message dialogs, but for now, I think it's fine to just print the error out in terminal and browser.
-
[ ] Rename internal prompter. Right now the prompter doesn't read from stdin and is more like a state machine that tracks what state the runner is in and updates the terminal accordingly. I'm sure there are packages that have something like this (maybe docker?), we should find a better name.
-
[ ] Simplify internal prompter API. It doesn't need track stdout and stderr separately, it can implement an
io.Writerthat stores any output into a buffer, then check if that buffer has been written to in order to determine whether we can replace the current line or not. -
[ ] Provide a way to disable the prompter during tests. I find myself occasionally commenting out
clearLineandmoveCursorUpto prevent logs from being lost.