Changeset 0.22.8 (#150)
This commit is contained in:
@@ -205,7 +205,7 @@ async function loadChats() {
|
||||
}
|
||||
|
||||
async function selectChat(chatId) {
|
||||
clearStaged(); // Discard any staged attachments from previous chat
|
||||
clearStaged(); // Discard any staged files from previous chat
|
||||
App.currentChatId = chatId;
|
||||
try { sessionStorage.setItem('cs-active-chat', chatId); } catch (_) {}
|
||||
UI.renderChatList();
|
||||
@@ -246,8 +246,8 @@ async function selectChat(chatId) {
|
||||
// Load multi-model roster for @mention routing (v0.20.0)
|
||||
if (typeof ChannelModels !== 'undefined') ChannelModels.load(chatId);
|
||||
|
||||
// Load attachments for message rendering (non-blocking, best-effort)
|
||||
await loadChannelAttachments(chatId);
|
||||
// Load files for message rendering (non-blocking, best-effort)
|
||||
await loadChannelFiles(chatId);
|
||||
|
||||
UI.renderMessages(chat.messages);
|
||||
UI.showRegenerate(chat.messages.some(m => m.role === 'assistant'));
|
||||
@@ -378,7 +378,7 @@ function _cleanStaleChatModel(chatId) {
|
||||
}
|
||||
|
||||
async function newChat() {
|
||||
clearStaged(); // Discard any staged attachments
|
||||
clearStaged(); // Discard any staged files
|
||||
App.currentChatId = null;
|
||||
UI.renderChatList();
|
||||
UI.showEmptyState();
|
||||
@@ -501,15 +501,15 @@ function startRenameChat(chatId) {
|
||||
|
||||
async function sendMessage() {
|
||||
const text = ChatInput.getValue().trim();
|
||||
const hasAttachments = hasStagedAttachments();
|
||||
const hasFiles = hasStagedFiles();
|
||||
|
||||
// Need text or attachments, not generating, not blocked by uploads
|
||||
if ((!text && !hasAttachments) || App.isGenerating || isSendBlocked()) return;
|
||||
// Need text or files, not generating, not blocked by uploads
|
||||
if ((!text && !hasFiles) || App.isGenerating || isSendBlocked()) return;
|
||||
|
||||
ChatInput.setValue('');
|
||||
|
||||
// Snapshot attachment IDs before clearing staged state
|
||||
const attachmentIds = getStagedAttachmentIds();
|
||||
// Snapshot file IDs before clearing staged state
|
||||
const fileIds = getStagedFileIds();
|
||||
|
||||
const selectedId = UI.getModelValue();
|
||||
const modelInfo = App.findModel(selectedId);
|
||||
@@ -542,19 +542,19 @@ async function sendMessage() {
|
||||
if (!chat) return;
|
||||
|
||||
// Optimistic: show user message immediately
|
||||
const userContent = text || (hasAttachments ? `[${attachmentIds.length} file${attachmentIds.length > 1 ? 's' : ''} attached]` : '');
|
||||
const userContent = text || (hasFiles ? `[${fileIds.length} file${fileIds.length > 1 ? 's' : ''} attached]` : '');
|
||||
chat.messages.push({ role: 'user', content: userContent, timestamp: new Date().toISOString(), siblingCount: 1, siblingIndex: 0 });
|
||||
UI.renderMessages(chat.messages);
|
||||
|
||||
// Clear staged attachments (they're now part of this message)
|
||||
if (hasAttachments) consumeStaged();
|
||||
// Clear staged files (they're now part of this message)
|
||||
if (hasFiles) consumeStaged();
|
||||
|
||||
App.isGenerating = true;
|
||||
App.abortController = new AbortController();
|
||||
UI.setGenerating(true);
|
||||
|
||||
try {
|
||||
const resp = await API.streamCompletion(App.currentChatId, text, model, App.abortController.signal, modelInfo?.configId, personaId, attachmentIds,
|
||||
const resp = await API.streamCompletion(App.currentChatId, text, model, App.abortController.signal, modelInfo?.configId, personaId, fileIds,
|
||||
typeof ToolsToggle !== 'undefined' ? ToolsToggle.getDisabledTools() : []);
|
||||
await UI.streamResponse(resp, chat.messages, modelInfo?.name);
|
||||
|
||||
@@ -620,7 +620,7 @@ async function reloadActivePath() {
|
||||
siblingIndex: m.sibling_index || 0,
|
||||
}));
|
||||
chat.messageCount = chat.messages.length;
|
||||
await loadChannelAttachments(App.currentChatId);
|
||||
await loadChannelFiles(App.currentChatId);
|
||||
UI.renderMessages(chat.messages);
|
||||
updateContextWarning(); updateChatTokenCount();
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user