Compare commits

..

3 Commits

Author SHA1 Message Date
mike
5c2276ef1e chore: update 1 file(s) 2025-12-28 00:21:02 +01:00
mike
cf810a3ba8 feat: introduce chat sessions and manage chat history
Co-authored-by: aider (openai//models/qwen2.5-coder-32b-instruct-q4_k_m.gguf) <aider@aider.chat>
2025-12-28 00:13:23 +01:00
mike
32abb9ffe7 fix: reduce DOM update frequency and make code selectable
Co-authored-by: aider (openai//models/qwen2.5-coder-32b-instruct-q4_k_m.gguf) <aider@aider.chat>
2025-12-28 00:03:58 +01:00

View File

@@ -44,6 +44,7 @@
border-radius: 3px;
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
font-size: 0.9em;
user-select: text;
}
.markdown-content pre {
@@ -54,6 +55,7 @@
overflow-x: auto;
margin: 1em 0;
border: 1px solid #30363d;
user-select: text;
}
.markdown-content pre code {
@@ -466,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() {
@@ -624,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
}
@@ -809,7 +815,7 @@ async function handleStreamingResponse(userMessage) {
// Debounce DOM updates to reduce stutter
let updateScheduled = false
let lastUpdate = Date.now()
const MIN_UPDATE_INTERVAL = 50 // ms, update at most every 50ms
const MIN_UPDATE_INTERVAL = 100 // ms, update at most every 100ms
function scheduleUpdate() {
if (updateScheduled) return
@@ -955,6 +961,11 @@ async function handleNonStreamingResponse(userMessage) {
userInput.focus()
}
}
function loadChatHistory() {
chatHistory.forEach(message => {
addMessage(message.role, message.content, message.markdown, message.messageId);
});
}
// Stop current stream
function stopStream() {
@@ -1008,6 +1019,9 @@ window.onload = () => {
userInput.focus()
fetchModels()
// Load chat history
loadChatHistory();
// Add welcome message
setTimeout(() => {
const welcomeMessage = `# Welcome to LM Studio Chat! 🚀