Browse Source

Fix sidebar navigation and stale job cleanup (#8, #9)

This commit addresses two issues:

**Issue #9: Sidebar menu unclickable on text2img page**
- Increased sidebar z-index from 40 to 50
- Ensures sidebar is always clickable above all other UI elements
- Previous z-hierarchy had potential stacking context conflicts

Changes in webui/components/sidebar.tsx:
- Changed z-40 to z-50 (line 20)

New z-index hierarchy:
- Sidebar: z-50 (highest - always clickable)
- Model Status Bar: z-35
- Header: z-30
- PromptTextarea suggestions: z-30

**Issue #8: Stale "processing" jobs after server restart**
- Added cleanup logic in loadJobsFromDisk()
- Jobs in PROCESSING state are marked as FAILED on server startup
- Error message: "Server restarted while job was processing"
- Updated job status is persisted back to disk
- Console output confirms cleanup with log message

Changes in src/generation_queue.cpp:
- Added stale job detection after loading job from disk (lines 554-562)
- Marks PROCESSING jobs as FAILED with appropriate error message
- Sets endTime to current time
- Calls saveJobToFile() to persist updated status

Impact:
- Queue view now shows accurate job states after restart
- No more misleading "processing" indicators for dead jobs
- Users can see which jobs failed due to server restart

Fixes #8
Fixes #9
Fszontagh 3 months ago
parent
commit
eac0d80d5b
2 changed files with 11 additions and 1 deletions
  1. 10 0
      src/generation_queue.cpp
  2. 1 1
      webui/components/sidebar.tsx

+ 10 - 0
src/generation_queue.cpp

@@ -551,6 +551,16 @@ public:
                         job.errorMessage = jobJson["error_message"];
                     }
 
+                    // Clean up stale processing jobs from server restart
+                    if (job.status == GenerationStatus::PROCESSING) {
+                        job.status = GenerationStatus::FAILED;
+                        job.errorMessage = "Server restarted while job was processing";
+                        job.endTime = std::chrono::steady_clock::now();
+                        std::cout << "Marked stale job as failed: " << job.id << std::endl;
+                        // Persist updated status to disk
+                        saveJobToFile(job);
+                    }
+
                     // Add to active jobs
                     std::lock_guard<std::mutex> lock(jobsMutex);
                     activeJobs[job.id] = job;

+ 1 - 1
webui/components/sidebar.tsx

@@ -17,7 +17,7 @@ export function Sidebar() {
   const pathname = usePathname();
 
   return (
-    <aside className="fixed left-0 top-0 z-40 h-screen w-64 border-r border-border bg-card">
+    <aside className="fixed left-0 top-0 z-50 h-screen w-64 border-r border-border bg-card">
       <div className="flex h-full flex-col gap-2">
         {/* Logo */}
         <div className="flex h-16 items-center border-b border-border px-6">