Skip to content

Commit c80a067

Browse files
authored
Update ui.js (messages, memory, session history)
better build messages function. memory improvements. sessions now have their own message history or should at least.
1 parent 008acfd commit c80a067

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

ai/ui.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// ui.js (FIX: Prevent first-launch modal from re-appearing after new chat)
21
document.addEventListener("DOMContentLoaded", () => {
3-
// Buttons
42
const newSessionBtn = document.getElementById("new-session-btn");
53
const modelSelect = document.getElementById("model-select");
64
const donationOpenBtn = document.getElementById("donation-open-btn");
@@ -11,34 +9,29 @@ document.addEventListener("DOMContentLoaded", () => {
119
const settingsModal = document.getElementById("settings-modal");
1210
const settingsModalClose = document.getElementById("settings-modal-close");
1311

14-
// Theme selectors - one in sidebar, one in settings
1512
const themeSelect = document.getElementById("theme-select");
1613
const themeSelectSettings = document.getElementById("theme-select-settings");
1714

18-
// Personalization
1915
const openPersonalizationBtn = document.getElementById("open-personalization-btn");
2016
const openPersonalizationSettings = document.getElementById("open-personalization-settings");
2117
const personalizationModal = document.getElementById("personalization-modal");
2218
const personalizationClose = document.getElementById("personalization-close");
2319
const savePersonalizationBtn = document.getElementById("save-personalization");
2420
const cancelPersonalizationBtn = document.getElementById("cancel-personalization");
2521

26-
// Memory Manager
2722
const openMemoryManagerBtn = document.getElementById("open-memory-manager");
2823
const memoryModal = document.getElementById("memory-modal");
2924
const memoryModalClose = document.getElementById("memory-modal-close");
3025
const memoryList = document.getElementById("memory-list");
3126
const addMemoryBtn = document.getElementById("add-memory-btn");
3227
const clearAllMemoryBtn = document.getElementById("clear-all-memory-btn");
3328

34-
// Add Memory Modal
3529
const addMemoryModal = document.getElementById("add-memory-modal");
3630
const addMemoryModalClose = document.getElementById("add-memory-modal-close");
3731
const newMemoryText = document.getElementById("new-memory-text");
3832
const saveNewMemoryBtn = document.getElementById("save-new-memory-btn");
3933
const cancelNewMemoryBtn = document.getElementById("cancel-new-memory-btn");
4034

41-
// Destructive Buttons
4235
const clearChatSessionsBtn = document.getElementById("clear-chat-sessions-btn");
4336
const clearUserDataBtn = document.getElementById("clear-user-data-btn");
4437

@@ -203,10 +196,6 @@ document.addEventListener("DOMContentLoaded", () => {
203196
}
204197
});
205198

206-
// ===================================================
207-
// FIX: set firstLaunch to "1" when creating a new chat
208-
// so the first-launch modal won't appear again.
209-
// ===================================================
210199
newSessionBtn.addEventListener("click", () => {
211200
localStorage.setItem("firstLaunch", "1");
212201
const newSess = Storage.createSession("New Chat");
@@ -310,9 +299,6 @@ document.addEventListener("DOMContentLoaded", () => {
310299
Memory.addMemoryEntry(memoryText);
311300
}
312301

313-
// =====================
314-
// MEMORY MANAGER
315-
// =====================
316302
openMemoryManagerBtn.addEventListener("click", () => {
317303
memoryModal.classList.remove("hidden");
318304
loadMemoryEntries();
@@ -369,7 +355,6 @@ document.addEventListener("DOMContentLoaded", () => {
369355
btnContainer.style.display = "flex";
370356
btnContainer.style.gap = "6px";
371357

372-
// Edit
373358
const editBtn = document.createElement("button");
374359
editBtn.className = "btn btn-sm btn-secondary";
375360
editBtn.innerHTML = '<i class="fas fa-pen"></i>';
@@ -378,7 +363,7 @@ document.addEventListener("DOMContentLoaded", () => {
378363
editBtn.addEventListener("click", () => {
379364
const newText = prompt("Edit memory entry:", line);
380365
if (!newText || newText.trim() === line) {
381-
return; // cancelled or unchanged
366+
return;
382367
}
383368
const success = Memory.updateMemoryEntry(idx, newText);
384369
if (success) {
@@ -388,7 +373,6 @@ document.addEventListener("DOMContentLoaded", () => {
388373
});
389374
btnContainer.appendChild(editBtn);
390375

391-
// Delete
392376
const delBtn = document.createElement("button");
393377
delBtn.className = "btn btn-sm btn-danger";
394378
delBtn.innerHTML = '<i class="fas fa-trash"></i>';
@@ -416,9 +400,6 @@ document.addEventListener("DOMContentLoaded", () => {
416400
}
417401
}
418402

419-
// =====================
420-
// DESTRUCTIVE BUTTONS
421-
// =====================
422403
clearChatSessionsBtn.addEventListener("click", () => {
423404
if (!confirm("Are you sure you want to CLEAR ALL chat sessions?")) return;
424405
Storage.clearAllSessions();

0 commit comments

Comments
 (0)