[Feature Request] Persist Execution History and Output Metadata Across Restarts
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 155
Description
### Feature Idea
# Proposal
ComfyUI's current asset persistence does not persist generation history.
Even when using `--enable-assets` with `--database-url` pointing to persistent storage, generated files remain on disk after a restart, but their execution history and prompt/workflow associations are lost.
I propose extending the existing persistence system to store execution history and output metadata in SQLite, so that generation history can be restored after restarts or crashes.
# Problem
When ComfyUI is restarted:
* Output files still exist on disk.
* Model assets indexed by `--enable-assets` remain in the database.
* However, the History tab is empty.
* The frontend cannot restore the prompt/workflow associated with previous outputs.
This is also relevant to local users using NAS/network storage and users running ComfyUI as a persistent server, not only cloud or Docker deployments.
This behavior is also documented as a known limitation in #13061, where it was explained that the frontend asset list is populated from backend execution history, which is not persisted across server restarts.
# Technical Background
From my source-code investigation:
1. The `/history` endpoint obtains history from `self.prompt_queue.get_history()`.
2. `PromptExecutor` maintains execution results in memory, but I could not find code that persists this execution history to the SQLite database.
3. The existing `--enable-assets` database migrations create and maintain asset-related tables, but there does not appear to be a persistent table for execution history/prompt data.
4. The startup asset seeder can discover existing output files, but this alone cannot reconstruct their original execution history or prompt/workflow associations.
Therefore, scanning the output directory is not sufficient to restore the History UI.
# Expected Behavior
After restarting ComfyUI with the same persistent database and output directory:
* Previous executions should remain available in the History tab.
* Existing output files should remain associated with their execution records.
* Prompt/workflow information should be available for previous generations.
* Users should be able to restore previous workflows in the same way as before the restart.
The exact database schema and implementation details can be determined by the maintainers.
# Steps to Reproduce
1. Start ComfyUI with persistent storage:
```bash
python main.py \
--enable-assets \
--database-url "sqlite:///persistent/path/comfyui.db" \
--output-directory "/persistent/path/output"
```
2. Generate an image and confirm that it appears in the History tab.
3. Stop ComfyUI completely.
4. Start it again with the same arguments.
5. The output file still exists, but the previous execution history is no longer available in the UI.
## Why This Would Be Useful
Persisting execution history would make the existing SQLite asset persistence much more useful for:
* Local users with NAS/network storage
* Long-running ComfyUI servers
* Docker/container deployments
* Cloud environments where instances may restart
* Users who regularly reboot their machine
The key benefit is that generated files would retain their context: **what was generated, with which prompt/workflow, and when.**
# Related Issue
#13061 — `after restart, the output assets can not load automaticly`
Thank you for considering this feature.
### Existing Solutions
_No response_
### Other
_No response_
Contributor guide
Research direction
Start at the /history endpoint and self.prompt_queue.get_history(), then trace how PromptExecutor stores execution results and how the existing --enable-assets SQLite migrations and startup asset seeder work. Define persistence for execution history, prompt/workflow associations, and output metadata so the History tab and workflow restoration survive a restart, and verify it using the listed stop-and-restart reproduction steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100