mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
Show the chat title in the breadcrumbs instead of "Chat"
This commit is contained in:
parent
d761ca1992
commit
07f89a4268
3 changed files with 20 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
} from "@/components/ui/breadcrumb";
|
||||
import { searchSpacesApiService } from "@/lib/apis/search-spaces-api.service";
|
||||
import { authenticatedFetch, getBearerToken } from "@/lib/auth-utils";
|
||||
import { getThreadFull } from "@/lib/chat/thread-persistence";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
|
||||
interface BreadcrumbItemInterface {
|
||||
|
|
@ -34,6 +35,16 @@ export function DashboardBreadcrumb() {
|
|||
enabled: !!searchSpaceId,
|
||||
});
|
||||
|
||||
// Extract chat thread ID from pathname for chat pages
|
||||
const chatThreadId = segments[2] === "new-chat" && segments[3] ? segments[3] : null;
|
||||
|
||||
// Fetch thread details when on a chat page with a thread ID
|
||||
const { data: threadData } = useQuery({
|
||||
queryKey: ["threads", searchSpaceId, "detail", chatThreadId],
|
||||
queryFn: () => getThreadFull(Number(chatThreadId)),
|
||||
enabled: !!chatThreadId && !!searchSpaceId,
|
||||
});
|
||||
|
||||
// State to store document title for editor breadcrumb
|
||||
const [documentTitle, setDocumentTitle] = useState<string | null>(null);
|
||||
|
||||
|
|
@ -144,10 +155,11 @@ export function DashboardBreadcrumb() {
|
|||
}
|
||||
|
||||
// Handle new-chat sub-sections (thread IDs)
|
||||
// Don't show thread ID in breadcrumb - users identify chats by content, not by ID
|
||||
// Show the chat title if available, otherwise fall back to "Chat"
|
||||
if (section === "new-chat") {
|
||||
const chatLabel = threadData?.title || t("chat") || "Chat";
|
||||
breadcrumbs.push({
|
||||
label: t("chat") || "Chat",
|
||||
label: chatLabel,
|
||||
});
|
||||
return breadcrumbs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -524,6 +524,8 @@ export function LayoutDataProvider({
|
|||
queryClient.invalidateQueries({ queryKey: ["threads", searchSpaceId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["all-threads", searchSpaceId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["search-threads", searchSpaceId] });
|
||||
// Invalidate thread detail for breadcrumb update
|
||||
queryClient.invalidateQueries({ queryKey: ["threads", searchSpaceId, "detail", String(chatToRename.id)] });
|
||||
} catch (error) {
|
||||
console.error("Error renaming thread:", error);
|
||||
toast.error(tSidebar("error_renaming_chat") || "Failed to rename chat");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue