MCPcopy
hub / github.com/composio-community/open-claude-cowork / renderChatHistory

Function renderChatHistory

renderer/renderer.js:277–310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

275
276// Render chat history sidebar
277function renderChatHistory() {
278 chatHistoryList.innerHTML = '';
279
280 if (allChats.length === 0) {
281 chatHistoryList.innerHTML = '<div class="chat-history-empty">No chats yet</div>';
282 return;
283 }
284
285 // Sort by updated time (most recent first)
286 const sortedChats = [...allChats].sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0));
287
288 sortedChats.forEach(chat => {
289 const item = document.createElement('div');
290 item.className = 'chat-history-item' + (chat.id === currentChatId ? ' active' : '');
291 item.innerHTML = `
292 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
293 <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
294 </svg>
295 <span class="chat-title">${escapeHtml(chat.title || 'New chat')}</span>
296 <button class="delete-chat-btn" onclick="deleteChat('${chat.id}', event)" title="Delete">
297 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
298 <line x1="18" y1="6" x2="6" y2="18"></line>
299 <line x1="6" y1="6" x2="18" y2="18"></line>
300 </svg>
301 </button>
302 `;
303 item.onclick = (e) => {
304 if (!e.target.closest('.delete-chat-btn')) {
305 switchToChat(chat.id);
306 }
307 };
308 chatHistoryList.appendChild(item);
309 });
310}
311
312// Switch to a different chat
313function switchToChat(chatId) {

Callers 4

initFunction · 0.85
saveStateFunction · 0.85
loadChatFunction · 0.85
renderer.jsFile · 0.85

Calls 2

escapeHtmlFunction · 0.85
switchToChatFunction · 0.85

Tested by

no test coverage detected