mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
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.
This commit is contained in:
1 parent
52162d5c4a
commit
d99fcc268e
20 files changed
+732
-418
No files matched your search
@@ -4,12 +4,8 @@ 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 { EditSessionTitleDialog } from "@/components/session/EditSessionTitleDialog";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { ReactNode } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useMobile } from "@/hooks/useMobile";
|
||||
import { X } from "lucide-react";
|
||||
|
||||
interface HeaderProps {
|
||||
children: ReactNode;
|
||||
@@ -56,107 +52,6 @@ function HeaderTitle({ children, logo, className }: HeaderTitleProps) {
|
||||
);
|
||||
}
|
||||
|
||||
interface HeaderEditableTitleProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
subtitle?: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function HeaderEditableTitle({ value, onChange, subtitle, className }: HeaderEditableTitleProps) {
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [editTitle, setEditTitle] = useState(value);
|
||||
const isMobile = useMobile();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEditing) {
|
||||
setEditTitle(value);
|
||||
}
|
||||
}, [value, isEditing]);
|
||||
|
||||
const handleTitleClick = () => {
|
||||
setIsEditing(true);
|
||||
setEditTitle(value);
|
||||
};
|
||||
|
||||
const handleTitleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (editTitle.trim() && editTitle !== value) {
|
||||
onChange(editTitle.trim());
|
||||
}
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
setEditTitle(value);
|
||||
setIsEditing(false);
|
||||
} else if (e.key === 'Enter') {
|
||||
handleTitleSubmit(e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = (newTitle: string) => {
|
||||
if (newTitle.trim() && newTitle !== value) {
|
||||
onChange(newTitle.trim());
|
||||
}
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cn("min-w-0 flex-1", className)}>
|
||||
{isMobile && (
|
||||
<EditSessionTitleDialog
|
||||
isOpen={isEditing}
|
||||
currentTitle={value}
|
||||
onClose={() => setIsEditing(false)}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
)}
|
||||
{isEditing && !isMobile ? (
|
||||
<form onSubmit={handleTitleSubmit} className="flex items-center gap-1 min-w-0">
|
||||
<input
|
||||
type="text"
|
||||
value={editTitle}
|
||||
onChange={(e) => setEditTitle(e.target.value)}
|
||||
onBlur={(e) => {
|
||||
if (!e.relatedTarget?.closest('button')) {
|
||||
handleTitleSubmit(e);
|
||||
}
|
||||
}}
|
||||
onKeyDown={handleKeyDown}
|
||||
className="text-[16px] sm:text-base font-semibold bg-background border border-border rounded-l px-2 py-1 outline-none w-full truncate focus:border-primary sm:max-w-[250px] h-7"
|
||||
autoFocus
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 rounded-l-none border border-l-0 border-border hover:bg-accent flex-shrink-0 mt-0"
|
||||
onClick={() => setEditTitle("")}
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</Button>
|
||||
</form>
|
||||
) : (
|
||||
<div className="min-w-0">
|
||||
<h1
|
||||
className="text-xs sm:text-base font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent truncate cursor-pointer hover:opacity-80 transition-opacity"
|
||||
onClick={handleTitleClick}
|
||||
>
|
||||
{value}
|
||||
</h1>
|
||||
{subtitle && (
|
||||
<p className="text-[10px] sm:text-xs text-muted-foreground truncate">
|
||||
{typeof subtitle === 'string' ? subtitle : subtitle}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HeaderActions({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn("flex items-center gap-2", className)}>{children}</div>;
|
||||
}
|
||||
@@ -180,13 +75,11 @@ function HeaderSettingsButton() {
|
||||
export const Header = Object.assign(HeaderBase, {
|
||||
BackButton: HeaderBackButton,
|
||||
Title: HeaderTitle,
|
||||
EditableTitle: HeaderEditableTitle,
|
||||
Actions: HeaderActions,
|
||||
Settings: HeaderSettingsButton,
|
||||
}) as typeof HeaderBase & {
|
||||
BackButton: typeof HeaderBackButton;
|
||||
Title: typeof HeaderTitle;
|
||||
EditableTitle: typeof HeaderEditableTitle;
|
||||
Actions: typeof HeaderActions;
|
||||
Settings: typeof HeaderSettingsButton;
|
||||
};
|
||||
Reference in new issue
Block a user