mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
Some checks are pending
Build and Push Docker Images / tag_release (push) Waiting to run
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (backend, surfsense-backend) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (web, surfsense-web) (push) Blocked by required conditions
79 lines
2.8 KiB
TypeScript
79 lines
2.8 KiB
TypeScript
"use client";
|
|
|
|
import { useAtomValue } from "jotai";
|
|
import { usePathname } from "next/navigation";
|
|
import { currentThreadAtom } from "@/atoms/chat/current-thread.atom";
|
|
import { activeSearchSpaceIdAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
|
import { activeTabAtom, tabsAtom } from "@/atoms/tabs/tabs.atom";
|
|
import { ChatHeader } from "@/components/new-chat/chat-header";
|
|
import { ChatShareButton } from "@/components/new-chat/chat-share-button";
|
|
import { useIsMobile } from "@/hooks/use-mobile";
|
|
import type { ChatVisibility, ThreadRecord } from "@/lib/chat/thread-persistence";
|
|
import { RightPanelExpandButton } from "../right-panel/RightPanel";
|
|
|
|
interface HeaderProps {
|
|
mobileMenuTrigger?: React.ReactNode;
|
|
}
|
|
|
|
export function Header({ mobileMenuTrigger }: HeaderProps) {
|
|
const pathname = usePathname();
|
|
const searchSpaceId = useAtomValue(activeSearchSpaceIdAtom);
|
|
const isMobile = useIsMobile();
|
|
const activeTab = useAtomValue(activeTabAtom);
|
|
const tabs = useAtomValue(tabsAtom);
|
|
|
|
const isFreePage = pathname?.startsWith("/free") ?? false;
|
|
const isChatPage = pathname?.includes("/new-chat") ?? false;
|
|
const isDocumentTab = activeTab?.type === "document";
|
|
const hasTabBar = tabs.length > 1;
|
|
|
|
const currentThreadState = useAtomValue(currentThreadAtom);
|
|
|
|
const hasThread = isChatPage && !isDocumentTab && currentThreadState.id !== null;
|
|
|
|
// Free chat pages have their own header with model selector; only render mobile trigger
|
|
if (isFreePage) {
|
|
if (!mobileMenuTrigger) return null;
|
|
return (
|
|
<header className="sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 bg-main-panel/95 backdrop-blur supports-backdrop-filter:bg-main-panel/60 px-4">
|
|
{mobileMenuTrigger}
|
|
</header>
|
|
);
|
|
}
|
|
|
|
const threadForButton: ThreadRecord | null =
|
|
hasThread && currentThreadState.id !== null
|
|
? {
|
|
id: currentThreadState.id,
|
|
visibility: currentThreadState.visibility ?? "PRIVATE",
|
|
created_by_id: null,
|
|
search_space_id: 0,
|
|
title: "",
|
|
archived: false,
|
|
created_at: "",
|
|
updated_at: "",
|
|
}
|
|
: null;
|
|
|
|
const handleVisibilityChange = (_visibility: ChatVisibility) => {};
|
|
|
|
return (
|
|
<header className="sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 bg-main-panel/95 backdrop-blur supports-backdrop-filter:bg-main-panel/60 px-4">
|
|
{/* Left side - Mobile menu trigger + Model selector */}
|
|
<div className="flex flex-1 items-center gap-2 min-w-0">
|
|
{mobileMenuTrigger}
|
|
{isChatPage && !isDocumentTab && searchSpaceId && (
|
|
<ChatHeader searchSpaceId={Number(searchSpaceId)} className="md:h-9 md:px-4 md:text-sm" />
|
|
)}
|
|
</div>
|
|
|
|
{/* Right side - Actions */}
|
|
<div className="ml-auto flex items-center gap-2">
|
|
{hasThread && (
|
|
<ChatShareButton thread={threadForButton} onVisibilityChange={handleVisibilityChange} />
|
|
)}
|
|
{!isMobile && !hasTabBar && <RightPanelExpandButton />}
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|