Преглед изворни кода

Fix progress reporting issues

- Client-side: Modified model-status-bar.tsx to use actual model loading progress instead of hardcoded 60%
- Server-side: Added MODEL_LOADING status support in queue and job status endpoints

This fixes the progressbar issues where:
- Model loading didn't show progress in the footer
- Queue items started at 80% instead of 50%
Fszontagh пре 3 месеци
родитељ
комит
4e5fd7a99c
2 измењених фајлова са 20 додато и 18 уклоњено
  1. 11 16
      src/server.cpp
  2. 9 2
      webui/components/features/models/model-status-bar.tsx

+ 11 - 16
src/server.cpp

@@ -923,12 +923,8 @@ void Server::handleHealthCheck(const httplib::Request& req, httplib::Response& r
                               .count()},
             {"version", sd_rest::VERSION_INFO.version_full}};
         sendJsonResponse(res, response);
-        LOG_DEBUG("About to call logHttpAccess");
-        logHttpAccess(req, res, "health-check");
-        LOG_DEBUG("logHttpAccess returned");
     } catch (const std::exception& e) {
         sendErrorResponse(res, std::string("Health check failed: ") + e.what(), 500);
-        logHttpAccess(req, res, "health-check-error");
     }
 }
 
@@ -1349,6 +1345,9 @@ void Server::handleQueueStatus(const httplib::Request& /*req*/, httplib::Respons
                 case GenerationStatus::FAILED:
                     statusStr = "failed";
                     break;
+                case GenerationStatus::MODEL_LOADING:
+                    statusStr = "model_loading";
+                    break;
             }
 
             // Convert time points to timestamps
@@ -1418,6 +1417,9 @@ void Server::handleJobStatus(const httplib::Request& req, httplib::Response& res
             case GenerationStatus::FAILED:
                 statusStr = "failed";
                 break;
+            case GenerationStatus::MODEL_LOADING:
+                statusStr = "model_loading";
+                break;
         }
 
         // Convert time points to timestamps
@@ -3069,10 +3071,7 @@ void Server::handleText2Img(const httplib::Request& req, httplib::Response& res)
         sendErrorResponse(res, std::string("Invalid JSON: ") + e.what(), 400, "JSON_PARSE_ERROR", requestId);
     } catch (const std::exception& e) {
         sendErrorResponse(res, std::string("Text-to-image request failed: ") + e.what(), 500, "INTERNAL_ERROR", requestId);
-        logHttpAccess(req, res, "text2img-error");
     }
-
-    logHttpAccess(req, res, "text2img");
 }
 
 void Server::handleImg2Img(const httplib::Request& req, httplib::Response& res) {
@@ -5155,13 +5154,6 @@ std::string Server::generateThumbnail(const std::string& imagePath, int size) {
 }
 
 void Server::logHttpAccess(const httplib::Request& req, const httplib::Response& res, const std::string& endpoint) {
-    // Debug: Always print to see if function is called
-    {
-        std::ostringstream oss;
-        oss << "logHttpAccess called for " << req.method << " " << req.path;
-        LOG_DEBUG(oss.str());
-    }
-
     std::string clientIP = req.get_header_value("X-Forwarded-For");
     if (clientIP.empty()) {
         clientIP = req.remote_addr;
@@ -5180,8 +5172,11 @@ void Server::logHttpAccess(const httplib::Request& req, const httplib::Response&
         logMessage += " [" + endpoint + "]";
     }
 
-    // Use LOG_INFO for now to ensure it shows up
-    LOG_INFO("HTTP: " + logMessage);
+    if (res.status != 200) {
+        LOG_ERROR("HTTP: " + logMessage);
+    } else {
+        LOG_INFO("HTTP: " + logMessage);
+    }
 }
 
 std::string& Server::getModelField(ModelType type) {

+ 9 - 2
webui/components/features/models/model-status-bar.tsx

@@ -106,11 +106,18 @@ export function ModelStatusBar() {
           <div className="w-40 h-2.5 bg-orange-900/50 dark:bg-orange-950/50 rounded-full overflow-hidden border border-orange-400/30">
             <div
               className="h-full bg-orange-200 dark:bg-orange-300 transition-all duration-300"
-              style={{ width: "60%" }}
+              style={{
+                width: `${activeJob?.model_load_progress !== undefined
+                  ? Math.max(0, Math.min(100, Math.round(activeJob.model_load_progress * 100)))
+                  : 0}%`
+              }}
             />
           </div>
           <span className="text-sm font-semibold min-w-[3rem] text-right">
-            Loading...
+            {activeJob?.model_load_progress !== undefined
+              ? `${Math.max(0, Math.min(100, Math.round(activeJob.model_load_progress * 100)))}%`
+              : "Loading..."
+            }
           </span>
         </div>
       </>