Persist step/stage state and improve error visibility#112
Merged
nicpottier merged 5 commits intomainfrom Feb 24, 2026
Merged
Conversation
Replace fragile in-memory state tracking with step_runs table as single source of truth. Persist full step lifecycle (running/done/error/skipped) with error messages. Derive stage state purely from steps, add per-step error display in UI, show queued stages on book add, and clean up interrupted steps on server restart. Key changes: - New step_runs table (schema v8) with status/error/message - All step events written to DB in real-time - Stage state: running > queued > error > done > idle (pure derivation) - Per-step error messages displayed in StageRunCard - Active run range included in queued stages (fixes "no icon on book add") - Improved frontend-backend state sync via SSE and query prioritization - 12 new tests for step/stage completion logic
Separate explicit queue items (re-runs behind another job) from the active run range. Completed stages within the active range now correctly show "done" instead of staying "queued" after their steps finish.
- Clean up stale .lock dir, -journal, -wal, -shm files on startup before opening any book DB (node-sqlite3-wasm can't recover once it hits a stale lock) - Close DB handles on open failure to prevent leaked locks - Add busy_timeout pragma for concurrent request contention - Gracefully degrade on "database is locked" in book list/detail - Red retry button on errored stages, enable extract retry on error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces fragile multi-source state tracking (in-memory
StageRunJob, in-memoryrunningSteps, DBstep_completions) with a unifiedstep_runstable as the single source of truth. Errors now persist across page refreshes and server restarts, per-step error messages display in the UI, and queued stages correctly show when a book is added.Key Changes
step_runstable (schema v8): Tracks full step lifecycle with status (running/done/error/skipped), timestamps, and error messagesstep-start,step-progress,step-complete,step-skip,step-errorevent to DBrunning > queued > error > done > idle, computed from step states + in-memory run queuegetQueuedStages()now includes the active run's stage range so not-yet-started stages show as queuedstep_runswithstatus='running'asstatus='error'to handle mid-run crashesTests
All 623 tests passing, including 13 new tests for step/stage completion logic, queued stages during active runs, and error state preservation.
Files Changed