From 7ccc1fdd273f0110d69be8f38bcda9d1b8ced6cf Mon Sep 17 00:00:00 2001 From: yangdx Date: Fri, 31 Oct 2025 06:09:46 +0800 Subject: [PATCH] Add frontend rebuild warning indicator to version display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Return bool from check_frontend_build() - Add ⚠️ symbol to outdated versions - Show tooltip with rebuild message - Add translations for warning text - Fix tailwind config filename typo --- lightrag/api/lightrag_server.py | 32 +++++++++++++++------- lightrag_webui/src/features/SiteHeader.tsx | 21 ++++++++++++-- lightrag_webui/src/locales/ar.json | 1 + lightrag_webui/src/locales/en.json | 1 + lightrag_webui/src/locales/fr.json | 1 + lightrag_webui/src/locales/zh.json | 1 + lightrag_webui/src/locales/zh_TW.json | 1 + 7 files changed, 45 insertions(+), 13 deletions(-) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 3269fbb5..fc1e0484 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -131,7 +131,11 @@ class LLMConfigCache: def check_frontend_build(): - """Check if frontend is built and optionally check if source is up-to-date""" + """Check if frontend is built and optionally check if source is up-to-date + + Returns: + bool: True if frontend is outdated, False if up-to-date or production environment + """ webui_dir = Path(__file__).parent / "webui" index_html = webui_dir / "index.html" @@ -166,7 +170,7 @@ def check_frontend_build(): logger.debug( "Production environment detected, skipping source freshness check" ) - return + return False # Development environment, perform source code timestamp check logger.debug("Development environment detected, checking source freshness") @@ -197,7 +201,7 @@ def check_frontend_build(): source_dir / "bun.lock", source_dir / "vite.config.ts", source_dir / "tsconfig.json", - source_dir / "tailwind.config.js", + source_dir / "tailraid.config.js", source_dir / "index.html", ] @@ -241,17 +245,25 @@ def check_frontend_build(): ASCIIColors.cyan(" cd ..") ASCIIColors.yellow("\nThe server will continue with the current build.") ASCIIColors.yellow("=" * 80 + "\n") + return True # Frontend is outdated else: logger.info("Frontend build is up-to-date") + return False # Frontend is up-to-date except Exception as e: # If check fails, log warning but don't affect startup logger.warning(f"Failed to check frontend source freshness: {e}") + return False # Assume up-to-date on error def create_app(args): - # Check frontend build first - check_frontend_build() + # Check frontend build first and get outdated status + is_frontend_outdated = check_frontend_build() + + # Create unified API version display with warning symbol if frontend is outdated + api_version_display = ( + f"{__api_version__}⚠️" if is_frontend_outdated else __api_version__ + ) # Setup logging logger.setLevel(args.log_level) @@ -801,7 +813,7 @@ def create_app(args): "auth_mode": "disabled", "message": "Authentication is disabled. Using guest access.", "core_version": core_version, - "api_version": __api_version__, + "api_version": api_version_display, "webui_title": webui_title, "webui_description": webui_description, } @@ -810,7 +822,7 @@ def create_app(args): "auth_configured": True, "auth_mode": "enabled", "core_version": core_version, - "api_version": __api_version__, + "api_version": api_version_display, "webui_title": webui_title, "webui_description": webui_description, } @@ -828,7 +840,7 @@ def create_app(args): "auth_mode": "disabled", "message": "Authentication is disabled. Using guest access.", "core_version": core_version, - "api_version": __api_version__, + "api_version": api_version_display, "webui_title": webui_title, "webui_description": webui_description, } @@ -845,7 +857,7 @@ def create_app(args): "token_type": "bearer", "auth_mode": "enabled", "core_version": core_version, - "api_version": __api_version__, + "api_version": api_version_display, "webui_title": webui_title, "webui_description": webui_description, } @@ -909,7 +921,7 @@ def create_app(args): "pipeline_busy": pipeline_status.get("busy", False), "keyed_locks": keyed_lock_info, "core_version": core_version, - "api_version": __api_version__, + "api_version": api_version_display, "webui_title": webui_title, "webui_description": webui_description, } diff --git a/lightrag_webui/src/features/SiteHeader.tsx b/lightrag_webui/src/features/SiteHeader.tsx index e0186b6a..dbea38bd 100644 --- a/lightrag_webui/src/features/SiteHeader.tsx +++ b/lightrag_webui/src/features/SiteHeader.tsx @@ -62,6 +62,12 @@ export default function SiteHeader() { ? `${coreVersion}/${apiVersion}` : null; + // Check if frontend needs rebuild (apiVersion ends with warning symbol) + const hasWarning = apiVersion?.endsWith('⚠️'); + const versionTooltip = hasWarning + ? t('header.frontendNeedsRebuild') + : versionDisplay ? `v${versionDisplay}` : ''; + const handleLogout = () => { navigationService.navigateToLogin(); } @@ -106,9 +112,18 @@ export default function SiteHeader() {