title management

This commit is contained in:
2026-02-14 21:31:09 -08:00
parent 684d441763
commit 3076f4f1a4
2 changed files with 28 additions and 0 deletions

View File

@@ -487,6 +487,24 @@ export default function App() {
return "New search";
}, [draftKind, selectedChat, selectedChatSummary, selectedItem, selectedSearch, selectedSearchSummary]);
const pageTitle = useMemo(() => {
if (draftKind || !selectedItem) return "Sybil";
if (selectedItem.kind === "chat") {
if (selectedChat) return `${getChatTitle(selectedChat, selectedChat.messages)} — Sybil`;
if (selectedChatSummary) return `${getChatTitle(selectedChatSummary)} — Sybil`;
return "Sybil";
}
const searchQuery = selectedSearch?.query?.trim() || selectedSearchSummary?.query?.trim();
if (searchQuery) return `${searchQuery} — Sybil`;
if (selectedSearch) return `${getSearchTitle(selectedSearch)} — Sybil`;
if (selectedSearchSummary) return `${getSearchTitle(selectedSearchSummary)} — Sybil`;
return "Sybil";
}, [draftKind, selectedChat, selectedChatSummary, selectedItem, selectedSearch, selectedSearchSummary]);
useEffect(() => {
document.title = pageTitle;
}, [pageTitle]);
const handleCreateChat = () => {
setError(null);
setContextMenu(null);

View File

@@ -53,6 +53,16 @@ export default function SearchRoutePage() {
return () => window.removeEventListener("popstate", onPopState);
}, []);
useEffect(() => {
document.title = routeQuery ? `${routeQuery} — Sybil` : "Sybil";
}, [routeQuery]);
useEffect(() => {
return () => {
document.title = "Sybil";
};
}, []);
useEffect(() => {
return () => {
streamAbortRef.current?.abort();