diff --git a/application/single_app/config.py b/application/single_app/config.py index 402bc9fb..21eeb639 100644 --- a/application/single_app/config.py +++ b/application/single_app/config.py @@ -88,7 +88,7 @@ EXECUTOR_TYPE = 'thread' EXECUTOR_MAX_WORKERS = 30 SESSION_TYPE = 'filesystem' -VERSION = "0.237.005" +VERSION = "0.237.006" SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production') diff --git a/application/single_app/static/js/chat/chat-sidebar-conversations.js b/application/single_app/static/js/chat/chat-sidebar-conversations.js index cb77ea50..d7908551 100644 --- a/application/single_app/static/js/chat/chat-sidebar-conversations.js +++ b/application/single_app/static/js/chat/chat-sidebar-conversations.js @@ -143,15 +143,23 @@ function createSidebarConversationItem(convo) { const originalTitleElement = headerRow ? headerRow.querySelector('.sidebar-conversation-title') : null; if (headerRow && dropdownElement && originalTitleElement) { + // Verify the dropdown is actually a child of headerRow before attempting manipulation + if (!headerRow.contains(dropdownElement)) { + console.error('Dropdown element is not a child of headerRow', { headerRow, dropdownElement }); + return convoItem; + } + const titleWrapper = document.createElement('div'); titleWrapper.classList.add('sidebar-conversation-header', 'd-flex', 'align-items-center', 'flex-grow-1', 'overflow-hidden', 'gap-2'); - // Insert the wrapper before the dropdown first - headerRow.insertBefore(titleWrapper, dropdownElement); + // Remove the original title from headerRow + originalTitleElement.remove(); - // Now move the title element into the wrapper + // Add styling to title originalTitleElement.classList.add('flex-grow-1', 'text-truncate'); originalTitleElement.style.minWidth = '0'; + + // Add title to wrapper titleWrapper.appendChild(originalTitleElement); const isGroupConversation = (convo.chat_type && convo.chat_type.startsWith('group')) || groupName; @@ -162,6 +170,9 @@ function createSidebarConversationItem(convo) { badge.title = groupName ? `Group conversation: ${groupName}` : 'Group conversation'; titleWrapper.appendChild(badge); } + + // Insert the wrapper before the dropdown + headerRow.insertBefore(titleWrapper, dropdownElement); } // Add double-click editing to title diff --git a/docs/explanation/release_notes.md b/docs/explanation/release_notes.md index 02aafcd1..3124ebb3 100644 --- a/docs/explanation/release_notes.md +++ b/docs/explanation/release_notes.md @@ -1,6 +1,17 @@ # Feature Release +### **(v0.237.006)** + +#### Bug Fixes + +* **Sidebar Conversations DOM Manipulation Fix** + * Fixed JavaScript error "Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node" that prevented sidebar conversations from loading. + * **Root Cause**: In `createSidebarConversationItem()`, the code was attempting DOM manipulation in the wrong order. When `originalTitleElement` was appended to `titleWrapper`, it was removed from `headerRow`, making the subsequent `insertBefore(titleWrapper, dropdownElement)` fail because `dropdownElement` was no longer a valid child reference in the expected DOM position. + * **Impact**: Users experienced a complete failure loading the sidebar conversation list, with the error appearing in browser console and preventing any conversations from displaying in the sidebar. This affected all users attempting to view their conversation history. + * **Solution**: Reordered DOM manipulation to remove `originalTitleElement` from DOM first, style it, add it to `titleWrapper`, then insert the complete `titleWrapper` before `dropdownElement`. Added validation to check if `dropdownElement` is a valid child before attempting insertion. + * (Ref: `chat-sidebar-conversations.js`, `createSidebarConversationItem()`, DOM manipulation order, line 150) + ### **(v0.237.005)** #### Bug Fixes