Files
opencode-manager/frontend/src/components/ui/header.tsx
T
Chris Scott d99fcc268e feat(frontend): open session details from the header
Pressing the session title opens a details sheet with server, project, branch and directory and inline rename. Linked-server sessions show a server icon and their branch, child sessions show a parent session pill, a banner marks paused live updates while the stream reconnects, and the header context indicator is removed now that usage lives on the model pill.
2026-10-23 20:18:27 -04:00

86 lines
2.5 KiB
TypeScript

import { Settings } from "lucide-react";
import { Button } from "@/components/ui/button";
import { BackButton } from "@/components/ui/back-button";
import { PageHeader } from "@/components/ui/page-header";
import { useSettingsDialog } from "@/hooks/useSettingsDialog";
import { useTheme } from "@/hooks/useTheme";
import { cn } from "@/lib/utils";
import type { ReactNode } from "react";
interface HeaderProps {
children: ReactNode;
className?: string;
}
function HeaderBase({ children, className, ...props }: HeaderProps) {
return (
<PageHeader className={cn("flex-shrink-0", className)} {...props}>
<div className="flex items-center justify-between px-2 sm:px-4 py-1.5 sm:py-2">
{children}
</div>
</PageHeader>
);
}
function HeaderBackButton({ to, className }: { to?: string; className?: string }) {
return to ? <BackButton to={to} className={className} /> : null;
}
interface HeaderTitleProps {
children: ReactNode;
logo?: boolean;
className?: string;
}
function HeaderTitle({ children, logo, className }: HeaderTitleProps) {
const theme = useTheme();
return (
<div className={cn("flex min-w-0 items-center gap-2", className)}>
{logo && typeof children === "string" && children === "OpenCode" ? (
<img
src={theme === 'light' ? "/opencode-wordmark-light.svg" : "/opencode-wordmark-dark.svg"}
alt="OpenCode Manager"
className="ml-2 h-6 w-auto sm:ml-0 sm:h-8"
/>
) : (
<h1 className="text-xl font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent truncate">
{children}
</h1>
)}
</div>
);
}
function HeaderActions({ children, className }: { children: ReactNode; className?: string }) {
return <div className={cn("flex items-center gap-2", className)}>{children}</div>;
}
function HeaderSettingsButton() {
const { open } = useSettingsDialog();
return (
<Button
variant="ghost"
size="icon"
onClick={open}
aria-label="Settings"
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
>
<Settings className="w-4 h-4" />
</Button>
);
}
export const Header = Object.assign(HeaderBase, {
BackButton: HeaderBackButton,
Title: HeaderTitle,
Actions: HeaderActions,
Settings: HeaderSettingsButton,
}) as typeof HeaderBase & {
BackButton: typeof HeaderBackButton;
Title: typeof HeaderTitle;
Actions: typeof HeaderActions;
Settings: typeof HeaderSettingsButton;
};