From cf810a3ba81580ea0d301fab1c2228271aa50380 Mon Sep 17 00:00:00 2001 From: mike Date: Sun, 28 Dec 2025 00:13:23 +0100 Subject: [PATCH] feat: introduce chat sessions and manage chat history Co-authored-by: aider (openai//models/qwen2.5-coder-32b-instruct-q4_k_m.gguf) --- index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.html b/index.html index f09084a..bab1497 100644 --- a/index.html +++ b/index.html @@ -468,6 +468,7 @@ let currentModel = null let availableModels = [] let currentStreamController = null let isStreaming = false +let chatHistory = [] // Initialize chat history array // Get current API URL based on selected backend function getApiUrl() { @@ -626,6 +627,9 @@ function addMessage(role, content, markdown = false, messageId = null) { chatLog.appendChild(messageDiv) chatLog.scrollTop = chatLog.scrollHeight + // Add message to chat history + chatHistory.push({ role, content, markdown, messageId }); + return contentDiv } @@ -1010,6 +1014,9 @@ window.onload = () => { userInput.focus() fetchModels() + // Load chat history + loadChatHistory(); + // Add welcome message setTimeout(() => { const welcomeMessage = `# Welcome to LM Studio Chat! 🚀 @@ -1035,3 +1042,8 @@ I now support **real-time streaming responses** and **dark, readable text format +function loadChatHistory() { + chatHistory.forEach(message => { + addMessage(message.role, message.content, message.markdown, message.messageId); + }); +}