From 8f31c44e972a7572b5e05cbb7d5d265bd383ed20 Mon Sep 17 00:00:00 2001 From: Oliver Baer <75138893+mrwind-up-bird@users.noreply.github.com> Date: Thu, 26 Feb 2026 15:18:46 +0100 Subject: [PATCH] fix(autofix): Missing error boundary for widget failures --- dashboard/widget/minirag-widget.js | 59 +++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/dashboard/widget/minirag-widget.js b/dashboard/widget/minirag-widget.js index ab4a578..f21787c 100644 --- a/dashboard/widget/minirag-widget.js +++ b/dashboard/widget/minirag-widget.js @@ -35,18 +35,35 @@ } connectedCallback() { - // Allow attribute overrides on the custom element itself - const botId = this.getAttribute('bot-id') || config.botId; - const apiUrl = this.getAttribute('api-url') || config.apiUrl; - const apiToken = this.getAttribute('api-token') || config.apiToken; - const title = this.getAttribute('title') || config.title; + try { + // Allow attribute overrides on the custom element itself + const botId = this.getAttribute('bot-id') || config.botId; + const apiUrl = this.getAttribute('api-url') || config.apiUrl; + const apiToken = this.getAttribute('api-token') || config.apiToken; + const title = this.getAttribute('title') || config.title; + + this._config = { botId, apiUrl, apiToken, title }; + } catch (error) { + console.error('MiniRAG Widget initialization error:', error); + this._renderError('Failed to initialize widget'); + return; + } - this._config = { botId, apiUrl, apiToken, title }; + this._loadStyles(); + } + _loadStyles() { + try { const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = cssUrl; this.shadowRoot.appendChild(link); + } catch (error) { + console.error('MiniRAG Widget CSS loading error:', error); + this._renderError('Failed to load widget styles'); + return; + } + this._container = document.createElement('div'); this.shadowRoot.appendChild(this._container); @@ -54,6 +71,20 @@ } _render() { + try { + this._renderContent(); + } catch (error) { + console.error('MiniRAG Widget render error:', error); + this._renderError('Widget failed to render'); + } + } + + _renderContent() { + const c = this._container; + if (!c) { + throw new Error('Container not found'); + } + const c = this._container; c.innerHTML = ''; @@ -172,6 +203,22 @@ `; bubble2.onclick = () => { this._open = false; this._render(); }; + _renderError(message) { + if (!this._container) { + this.shadowRoot.innerHTML = `