langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
48.45k stars 6.92k forks source link

WebApps links don't point to the current workflow running. Recovering a job running is impossible once you close the browser tab. #9152

Open Emasoft opened 1 week ago

Emasoft commented 1 week ago

Self Checks

Dify version

0.9.1

Cloud or Self Hosted

Cloud

Steps to reproduce

✔️ Expected Behavior

The link should display the job currently running in the WebApp page, displaying the progress and the log, with the options to pause/stop/restart the job.

❌ Actual Behavior

The WebApps permalink provided don't point to the current workflow job running, but shows a new job start page. No configuration input is preserved. Recovering a job running is impossible once you close the browser tab. If you try to start a new job, it would answer with: Please wait for the response to the previous message to complete. But the user have no way to see the queue of jobs running, nor to stop/pause them or get the logs or the results. Money is spent without any option for the user to manage the running jobs or stopping them if they are consuming too much tokens.

dosubot[bot] commented 1 week ago

To address the issue of WebApps links not pointing to the current workflow running, you can use the handleBackupDraft and handleLoadBackupDraft functions from the useWorkflowRun hook. These functions help preserve and restore the workflow state, allowing job recovery after closing the browser tab.

Steps to Implement:

  1. Backup the Current Workflow State: Use handleBackupDraft to save the current state of the workflow, including nodes, edges, viewport, features, and environment variables.

    const { handleBackupDraft } = useWorkflowRun();
    handleBackupDraft();
  2. Load the Backup on Reopening: Use handleLoadBackupDraft to restore the workflow state from the backup when reopening the application.

    const { handleLoadBackupDraft } = useWorkflowRun();
    handleLoadBackupDraft();

These steps ensure that the workflow state is preserved and can be restored, allowing for job recovery after closing and reopening the browser tab [1][2].

To continue talking to Dosu, mention @dosu.