Changeset 0.21.6 (#92)
This commit is contained in:
@@ -211,13 +211,25 @@ async function startApp() {
|
||||
UI.renderChatList();
|
||||
UI.updateModelSelector();
|
||||
|
||||
// Restore last-active chat from sessionStorage (QOL: state restore on refresh)
|
||||
try {
|
||||
const savedChat = sessionStorage.getItem('cs-active-chat');
|
||||
if (savedChat && App.chats.some(c => c.id === savedChat)) {
|
||||
selectChat(savedChat);
|
||||
}
|
||||
} catch (_) {}
|
||||
// Check for workspaces on startup — register editor surface early (v0.21.6)
|
||||
// This ensures the Editor button + Files tab appear without needing to browse first.
|
||||
if (typeof EditorMode !== 'undefined') {
|
||||
try { await EditorMode.checkStartup(); } catch (_) {}
|
||||
}
|
||||
|
||||
// Initialize hash router (v0.21.6) — replaces sessionStorage chat restore.
|
||||
// Reads current URL hash and routes to the right surface/chat/workspace.
|
||||
if (typeof Router !== 'undefined') {
|
||||
Router.init();
|
||||
} else {
|
||||
// Fallback: restore last-active chat from sessionStorage
|
||||
try {
|
||||
const savedChat = sessionStorage.getItem('cs-active-chat');
|
||||
if (savedChat && App.chats.some(c => c.id === savedChat)) {
|
||||
selectChat(savedChat);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
UI.updateUser();
|
||||
UI.showAdminButton(API.isAdmin);
|
||||
@@ -443,6 +455,37 @@ function initListeners() {
|
||||
_initPanelSwipe(); // from panels.js — mobile swipe navigation
|
||||
_initPanelResponsive(); // from panels.js — auto-collapse dual on resize
|
||||
_initPanelOverlay(); // from panels.js — mobile tap-to-close overlay
|
||||
_initSidebarTabs(); // v0.21.6: Chats/Files tab switching
|
||||
}
|
||||
|
||||
function _initSidebarTabs() {
|
||||
const tabBar = document.getElementById('sidebarTabs');
|
||||
if (!tabBar) return;
|
||||
|
||||
tabBar.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('.sidebar-tab');
|
||||
if (!btn) return;
|
||||
const tabName = btn.dataset.tab;
|
||||
|
||||
// Update active tab
|
||||
tabBar.querySelectorAll('.sidebar-tab').forEach(t => t.classList.toggle('active', t === btn));
|
||||
|
||||
// Show/hide panels
|
||||
document.querySelectorAll('.sidebar-tab-panel').forEach(p => {
|
||||
p.style.display = p.dataset.tabPanel === tabName ? '' : 'none';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Show or hide the Files tab. Called by EditorMode on register/unregister. */
|
||||
function showSidebarFilesTab(show) {
|
||||
const tab = document.getElementById('sidebarFilesTab');
|
||||
if (tab) tab.style.display = show ? '' : 'none';
|
||||
// If hiding and Files was active, switch back to Chats
|
||||
if (!show && tab?.classList.contains('active')) {
|
||||
const chatsTab = document.querySelector('.sidebar-tab[data-tab="chats"]');
|
||||
if (chatsTab) chatsTab.click();
|
||||
}
|
||||
}
|
||||
|
||||
function _initGlobalKeyboard() {
|
||||
|
||||
Reference in New Issue
Block a user