jbilcke-hf / clapper

Clapper.app, a video synthesizer and sequencer designed for the age of AI cinema
https://clapper.app
GNU General Public License v3.0
2.06k stars 192 forks source link

Display error and warnings messages as toasts #67

Open jbilcke-hf opened 2 months ago

jbilcke-hf commented 2 months ago

Context

We need to display error messages to the user

it's a blocker for users but not for developers, who can always look at the browser console (for client-side errors) and the NextJS console (for server-side error)

I propose to wrap calls to the various APIs using the task manager

it is able to handle both visible and invisible tasks, short or long-running

Solution

What needs to be done is to:

  1. wrap resolveSegment and resolveEntity into invisible background tasks (search for useTasks() in the code base)
  2. when there is an exception, display a toast to show the error (useTasks might have to be modified a bit)
  3. show separately warnings (recoverable or optional paths, in orange) from errors (critical failures, in red)
jbilcke-hf commented 2 months ago

I have implemented a first version for the segment resolution task, but it is lacking some color I think (it's still monochrome in case of error, instead of being red/orange)

devniel commented 2 months ago

Hi, I found the same when generating videos: if an error is thrown while building the video, the dialog is stuck and no way to close it, so is a blocker for users; I found the solution by wrapping the main call with try/catch and using task.fail(), but it keeps showing the toast with the success message.

Please, could you tell where is the segment resolution task fix ? thanks!

jbilcke-hf commented 2 months ago

in the "resolveSegment" function which is on the client side, there are now two tasks:

entityTask (to track the progress and status of entity generation) and resolutionTask (to track the progress and status of generation)

https://github.com/jbilcke-hf/clapper/blob/main/packages/app/src/services/resolver/useResolver.ts

jbilcke-hf commented 2 months ago

Note that there is a special visibility field which is used to control the visibility of a task (since we might have a lot of short tasks eg. storyboards)

but in case of error I think we want to always display the error toast (this is normally already implemented)

the idea for this visibility field is to give us the flexibility and freedom to display a toast or not, depending on the importance of a task, have some blocking tasks (eg. MP4 export) and even have some tasks fully running in the background

there is also a button in the bottom toolbar, to display a list of pending tasks, but I haven't worked a lot on this