mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-16 14:57:15 +00:00
fix(web): complete pluginized agent onboarding flows
This commit is contained in:
@@ -13,6 +13,7 @@ import logging
|
||||
import uuid
|
||||
import hmac
|
||||
import hashlib
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import httpx
|
||||
@@ -29,6 +30,7 @@ _AUTH_TIMEOUT_SECONDS = 10.0
|
||||
|
||||
# Cache the widget template content
|
||||
_widget_template_cache: str | None = None
|
||||
_widget_template_cache_mtime_ns: int | None = None
|
||||
_logo_bytes_cache: bytes | None = None
|
||||
|
||||
|
||||
@@ -37,12 +39,14 @@ def _is_valid_uuid(s: str) -> bool:
|
||||
|
||||
|
||||
def _get_widget_template() -> str:
|
||||
"""Load and cache the widget JS template."""
|
||||
global _widget_template_cache
|
||||
if _widget_template_cache is None:
|
||||
template_path = paths.get_resource_path('templates/embed/widget.js')
|
||||
"""Load the widget template and refresh the cache when the file changes."""
|
||||
global _widget_template_cache, _widget_template_cache_mtime_ns
|
||||
template_path = paths.get_resource_path('templates/embed/widget.js')
|
||||
template_mtime_ns = os.stat(template_path).st_mtime_ns
|
||||
if _widget_template_cache is None or _widget_template_cache_mtime_ns != template_mtime_ns:
|
||||
with open(template_path, 'r', encoding='utf-8') as f:
|
||||
_widget_template_cache = f.read()
|
||||
_widget_template_cache_mtime_ns = template_mtime_ns
|
||||
return _widget_template_cache
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
var scriptTestNotice = scriptEl
|
||||
? scriptEl.getAttribute("data-test-notice")
|
||||
: null;
|
||||
var scriptAutoOpen = scriptEl
|
||||
? scriptEl.getAttribute("data-auto-open") === "true"
|
||||
: false;
|
||||
|
||||
// ========== i18n ==========
|
||||
var I18N = {
|
||||
@@ -1252,6 +1255,9 @@
|
||||
}
|
||||
root.remove();
|
||||
};
|
||||
root.langbotOpen = function () {
|
||||
if (!state.isOpen) togglePanel();
|
||||
};
|
||||
document.body.appendChild(root);
|
||||
|
||||
var shadow = root.attachShadow({ mode: "open" });
|
||||
@@ -1406,6 +1412,8 @@
|
||||
panel.appendChild(inputArea);
|
||||
|
||||
shadow.appendChild(panel);
|
||||
|
||||
if (scriptAutoOpen) root.langbotOpen();
|
||||
}
|
||||
|
||||
// ========== Initialize ==========
|
||||
|
||||
Reference in New Issue
Block a user