-
+
-
Send a message to start this conversation.
-
-
-
+
+
Send a message to start this conversation.
+
+
-
Enter to send · Shift+Enter for a new line · Sessions are saved in this browser
@@ -735,7 +766,13 @@ function persistActiveChatSession() {
}
saveChatSessionsStore();
renderChatSessionList();
- renderChatMainTitle();
+}
+
+function clearChatPrompt() {
+ const promptEl = $("chat-prompt");
+ if (!promptEl) return;
+ promptEl.value = "";
+ promptEl.style.height = "auto";
}
function createNewChatSession() {
@@ -751,21 +788,23 @@ function createNewChatSession() {
chatSessions.unshift(session);
activeChatSessionId = session.id;
chatHistory = [];
+ clearChatPrompt();
saveChatSessionsStore();
renderChatSessionList();
renderChatHistory();
- renderChatMainTitle();
renderChatAuthHint();
const promptEl = $("chat-prompt");
if (promptEl) promptEl.focus();
}
function selectChatSession(sessionId) {
- if (chatBusy || sessionId === activeChatSessionId) return;
+ if (chatBusy) return;
const session = chatSessions.find(item => item.id === sessionId);
if (!session) return;
+ if (sessionId === activeChatSessionId) return;
activeChatSessionId = session.id;
chatHistory = (session.messages || []).slice();
+ clearChatPrompt();
if (session.model) {
selectedChatModel = session.model;
localStorage.setItem("meshnet_chat_model", selectedChatModel);
@@ -775,7 +814,6 @@ function selectChatSession(sessionId) {
localStorage.setItem(CHAT_ACTIVE_SESSION_KEY, activeChatSessionId);
renderChatSessionList();
renderChatHistory();
- renderChatMainTitle();
renderChatAuthHint();
}
@@ -792,6 +830,7 @@ function deleteChatSession(sessionId, event) {
if (chatSessions.length) {
activeChatSessionId = chatSessions[0].id;
chatHistory = (chatSessions[0].messages || []).slice();
+ clearChatPrompt();
if (chatSessions[0].model) {
selectedChatModel = chatSessions[0].model;
localStorage.setItem("meshnet_chat_model", selectedChatModel);
@@ -805,7 +844,6 @@ function deleteChatSession(sessionId, event) {
saveChatSessionsStore();
renderChatSessionList();
renderChatHistory();
- renderChatMainTitle();
renderChatModels();
}
@@ -827,37 +865,31 @@ function initChatSessions() {
if (active.model) selectedChatModel = active.model;
}
renderChatSessionList();
- renderChatMainTitle();
renderChatHistory();
}
-function renderChatMainTitle() {
- const el = $("chat-main-title");
- if (!el) return;
- const session = getActiveChatSession();
- el.textContent = session ? chatSessionTitle(session) : "New chat";
-}
-
function renderChatSessionList() {
const list = $("chat-session-list");
if (!list) return;
if (!chatSessions.length) {
- list.classList.add("empty");
- list.innerHTML = "no chats yet";
+ list.className = "chat-session-list empty-state";
+ list.innerHTML = "No chats yet";
return;
}
- list.classList.remove("empty");
+ list.className = "chat-session-list";
list.innerHTML = chatSessions.map(session => {
const active = session.id === activeChatSessionId ? " active" : "";
const title = esc(chatSessionTitle(session));
- const model = esc(short(session.model || "no model", 18));
const when = esc(formatSessionTime(session.updatedAt || session.createdAt));
const id = JSON.stringify(session.id);
- return `