Changeset 0.21.6 (#92)
This commit is contained in:
@@ -193,6 +193,7 @@ async function loadChats() {
|
||||
model: c.model || '',
|
||||
messageCount: c.message_count || 0,
|
||||
projectId: c.project_id || null,
|
||||
workspace_id: c.workspace_id || null,
|
||||
messages: [],
|
||||
updatedAt: c.updated_at,
|
||||
settings: c.settings || {},
|
||||
@@ -257,6 +258,14 @@ async function selectChat(chatId) {
|
||||
// Refresh KB toggle state for the new channel
|
||||
if (typeof KnowledgeUI !== 'undefined') KnowledgeUI.onChatChanged();
|
||||
updateChatTokenCount();
|
||||
|
||||
// Notify surfaces and extensions about channel switch (v0.21.6)
|
||||
Events.emit('chat.switched', { chatId, projectId: chat.projectId || null }, { localOnly: true });
|
||||
|
||||
// Sync URL hash (v0.21.6)
|
||||
if (typeof Router !== 'undefined' && Router._initialized) {
|
||||
Router.update('chat', { chatId });
|
||||
}
|
||||
}
|
||||
|
||||
// ── Chat Header Token Count ──────────────────
|
||||
@@ -386,6 +395,12 @@ async function newChat() {
|
||||
if (ov) ov.style.display = 'none';
|
||||
}
|
||||
if (typeof KnowledgeUI !== 'undefined') KnowledgeUI.onChatChanged();
|
||||
// Notify surfaces — no channel selected (v0.21.6)
|
||||
Events.emit('chat.switched', { chatId: null, projectId: null }, { localOnly: true });
|
||||
// Sync URL hash
|
||||
if (typeof Router !== 'undefined' && Router._initialized) {
|
||||
Router.update('chat');
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteChat(chatId) {
|
||||
@@ -511,7 +526,7 @@ async function sendMessage() {
|
||||
try {
|
||||
const title = text.slice(0, 50) + (text.length > 50 ? '...' : '');
|
||||
const resp = await API.createChannel(title, model, App.settings.systemPrompt, 'direct');
|
||||
const chat = { id: resp.id, title: resp.title, type: 'direct', model, messages: [], messageCount: 0, projectId: resp.project_id || null, updatedAt: resp.updated_at, settings: resp.settings || {} };
|
||||
const chat = { id: resp.id, title: resp.title, type: 'direct', model, messages: [], messageCount: 0, projectId: resp.project_id || null, workspace_id: resp.workspace_id || null, updatedAt: resp.updated_at, settings: resp.settings || {} };
|
||||
// Auto-assign to active project (v0.19.1)
|
||||
if (App.activeProjectId && !chat.projectId) {
|
||||
try {
|
||||
@@ -522,6 +537,12 @@ async function sendMessage() {
|
||||
App.chats.unshift(chat);
|
||||
App.currentChatId = chat.id;
|
||||
UI.renderChatList();
|
||||
// Notify surfaces about new chat creation (v0.21.6)
|
||||
Events.emit('chat.created', { chatId: chat.id, projectId: chat.projectId || null }, { localOnly: true });
|
||||
// Sync URL hash
|
||||
if (typeof Router !== 'undefined' && Router._initialized) {
|
||||
Router.update('chat', { chatId: chat.id });
|
||||
}
|
||||
} catch (e) { UI.toast('Failed to create chat: ' + e.message, 'error'); return; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user