diff --git a/comfyui_integration.py b/comfyui_integration.py index cd4e429..d7276a3 100644 --- a/comfyui_integration.py +++ b/comfyui_integration.py @@ -181,9 +181,9 @@ def build_prompt_from_appearance(character: dict, context: str = "") -> str: result = result.replace(de, en) return result - # Build prompt + # Build prompt — use established Danbooru tags for NoobAI-XL parts = [ - f"upper body, {style_prefix}{gender_tag}", + f"cowboy shot, {style_prefix}{gender_tag.strip()}", f"{age} years old", ] if build: @@ -206,7 +206,7 @@ def build_prompt_from_appearance(character: dict, context: str = "") -> str: parts.append(context) prompt = ", ".join(parts) - prompt += ", looking at viewer, detailed face, high quality, masterpiece, best quality, simple background" + prompt += ", looking at viewer, detailed face, masterpiece, best quality, very aesthetic, absurdres" return prompt diff --git a/main.py b/main.py index 35c9f47..8bd9ed6 100644 --- a/main.py +++ b/main.py @@ -282,7 +282,7 @@ templates = Jinja2Templates(directory=str(BASE_DIR / "templates")) app.mount("/static", StaticFiles(directory=str(BASE_DIR / "static")), name="static") def set_session_cookie(response, sid: str): - response.set_cookie(SESSION_COOKIE_NAME, sid, max_age=SESSION_DURATION, httponly=False, samesite="lax") + response.set_cookie(SESSION_COOKIE_NAME, sid, max_age=SESSION_DURATION, httponly=False, samesite="lax", path="/") @app.get("/", response_class=HTMLResponse) async def index(request: Request, session_id: str = Cookie(None, alias=SESSION_COOKIE_NAME)): diff --git a/static/avatars/mara.png b/static/avatars/mara.png index c7d0651..bac2a38 100644 Binary files a/static/avatars/mara.png and b/static/avatars/mara.png differ diff --git a/templates/chat.html b/templates/chat.html index 1f622d2..d96ca1a 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -258,28 +258,24 @@ } } - // Load history on reconnect (fixes the "conversation is somewhere else" bug) + // Load history on reconnect — preserves existing messages async function loadHistory() { try { const resp = await fetch(`/api/history/${encodeURIComponent(charFilename)}`); const data = await resp.json(); if (data.history && data.history.length > 0) { - // Only reload if we have more messages than currently shown - const currentMsgs = chat.querySelectorAll('.msg').length; - if (data.history.length > currentMsgs || currentMsgs === 0) { - chat.innerHTML = ''; - if ("{{ character.greeting }}") { - const g = document.createElement('div'); - g.className = 'msg msg-greeting'; - g.textContent = "{{ character.greeting }}"; - chat.appendChild(g); - } - data.history.forEach(h => { + // Count current messages (exclude greeting) + const currentMsgs = chat.querySelectorAll('.msg-user, .msg-bot').length; + // Only append messages we don't already have + if (data.history.length > currentMsgs) { + // Keep existing DOM, only append missing messages + for (let i = currentMsgs; i < data.history.length; i++) { + const h = data.history[i]; const div = document.createElement('div'); div.className = `msg ${h.role === 'user' ? 'msg-user' : 'msg-bot'}`; div.textContent = h.content; chat.appendChild(div); - }); + } chat.scrollTop = chat.scrollHeight; } } @@ -288,8 +284,7 @@ } } - // Load history on page load (fixes reconnect issue) - // Only if we don't already have history from server-side rendering + // Load history on page load ONLY if server didn't render any {% if not history %} loadHistory(); {% endif %}