feat: show active session name in browser tab title
Updates document.title dynamically to show the current session label (e.g. 'main — PinchChat'). Integrates with the existing notification system so unread badges still work correctly (e.g. '(3) main — PinchChat'). Resets to plain 'PinchChat' when no session is selected.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect, useCallback, useRef, lazy, Suspense } from 'react';
|
||||
import { useGateway } from './hooks/useGateway';
|
||||
import { useNotifications } from './hooks/useNotifications';
|
||||
import { useNotifications, setBaseTitle } from './hooks/useNotifications';
|
||||
import { Header } from './components/Header';
|
||||
import { Sidebar } from './components/Sidebar';
|
||||
import { LoginScreen } from './components/LoginScreen';
|
||||
@@ -33,6 +33,13 @@ export default function App() {
|
||||
}
|
||||
}, [messages, notify]);
|
||||
|
||||
// Update document title with active session label
|
||||
useEffect(() => {
|
||||
const session = sessions.find(s => s.key === activeSession);
|
||||
setBaseTitle(session?.label || session?.key);
|
||||
return () => setBaseTitle(undefined);
|
||||
}, [activeSession, sessions]);
|
||||
|
||||
// Close sidebar on Escape key, open shortcuts on ?
|
||||
const handleKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && sidebarOpen) {
|
||||
|
||||
Reference in New Issue
Block a user