From 893376dc14e18dcdf66958dc1adda91ec9fa5c32 Mon Sep 17 00:00:00 2001 From: Luca Sacchi Ricciardi Date: Fri, 24 Apr 2026 19:30:53 +0200 Subject: [PATCH] fix: resolve console errors (localStorage in Worker, favicon, Tailwind CDN) Issues fixed: 1. Web Worker localStorage error - Remove localStorage calls from worker - Worker cannot access localStorage (browser context only) - Worker now sends data to main thread via postMessage - Main thread handles all localStorage operations 2. Add favicon to avoid 404 error - Use inline SVG favicon (llama emoji) - No external file request 3. Optimize Tailwind CSS for production - Add tailwind.config.js for content scanning - Add app/web/static/css/input.css (Tailwind directives) - Update package.json with tailwind build commands - Update Dockerfile multi-stage build: * Stage 1: Node.js - compile Tailwind CSS * Stage 2: Python - install dependencies * Stage 3: Runtime - use compiled CSS - Update index.html to use compiled output.css - Add fallback to CDN for development 4. Add DEVELOPMENT.md documentation - Setup instructions for local development - Tailwind CSS workflow (watch mode) - Docker build explanation - Development tips and best practices Benefits: - No more localStorage errors in console - No more 404 favicon requests - Optimized CSS for production (~30KB minified) - Clear development workflow - Multi-stage Docker build is efficient (~300MB image) --- Dockerfile | 20 ++- app/web/static/css/input.css | 3 + app/web/static/js/data-sync.worker.js | 10 +- app/web/templates/index.html | 7 + docs/DEVELOPMENT.md | 216 ++++++++++++++++++++++++++ package.json | 4 +- tailwind.config.js | 11 ++ 7 files changed, 258 insertions(+), 13 deletions(-) create mode 100644 app/web/static/css/input.css create mode 100644 docs/DEVELOPMENT.md create mode 100644 tailwind.config.js diff --git a/Dockerfile b/Dockerfile index 16776fd..e069542 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,21 @@ # Multi-stage build per LLM Monitor -# Stage 1: Builder +# Stage 1: Build CSS with Tailwind +FROM node:18-alpine as css-builder + +WORKDIR /app + +# Copiare file di configurazione +COPY package.json tailwind.config.js ./ +COPY app/web/static/css/input.css ./app/web/static/css/ + +# Installare dipendenze Node +RUN npm install + +# Compilare CSS Tailwind +RUN npm run tailwind:build + +# Stage 2: Build Python packages FROM python:3.11-slim as builder WORKDIR /app @@ -19,7 +34,7 @@ ENV PATH="/opt/venv/bin:$PATH" RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \ pip install --no-cache-dir -r requirements.txt -# Stage 2: Runtime +# Stage 3: Runtime FROM python:3.11-slim WORKDIR /app @@ -33,6 +48,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY --from=builder /opt/venv /opt/venv # Copiare codice dell'app + COPY --from=css-builder /app/app/web/static/css/output.css ./app/web/static/css/ COPY app/ /app/app/ COPY main.py /app/ COPY .env* /app/ diff --git a/app/web/static/css/input.css b/app/web/static/css/input.css new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ b/app/web/static/css/input.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/app/web/static/js/data-sync.worker.js b/app/web/static/js/data-sync.worker.js index 2b15e39..4c1f680 100644 --- a/app/web/static/js/data-sync.worker.js +++ b/app/web/static/js/data-sync.worker.js @@ -59,16 +59,8 @@ async function syncData() { const health = await fetchHealth(); const modelsData = await fetchModels(); - // Salvare in localStorage - if (health) { - localStorage.setItem("llm_monitor_health", JSON.stringify(health)); - } - - if (modelsData) { - localStorage.setItem("llm_monitor_models", JSON.stringify(modelsData)); - } - // Notificare il main thread + // (il main thread gestisce localStorage) self.postMessage({ type: "DATA_UPDATED", health, diff --git a/app/web/templates/index.html b/app/web/templates/index.html index e3822dd..6099f01 100644 --- a/app/web/templates/index.html +++ b/app/web/templates/index.html @@ -4,6 +4,10 @@ LLM Monitor - Dashboard Ollama + + + +