import type { ZCodeProvider, ZCodeTaskMeta, ZCodeTaskChangeSummary, EditorInfo, GitRepositorySummary, RemoteTarget, UserInfo, } from "@zcode/shared"; import { useState } from "react"; import { TID_WORKSPACE_HEADER } from "@zcode/shared"; import type { ConversationDropTargetController } from "@/v4/composer/conversationDropTarget.js"; import { cn } from "@/components/lib/utils.js"; import { WorkspaceHeaderActionSection, type WorkspaceHeaderState, WorkspaceHeaderTitleSection, } from "@/WorkspaceHeaderSections.js"; import type { WorkspaceHeaderVariant } from "@/WorkspaceHeaderSections/shared.js"; export function WorkspaceHeader({ variant = "task", draftDropTargetController, readOnlyReason, workspaceAbsPath, remoteSessionId, workspaceIdentity, remoteTarget, localWorkspacePath, projectName, activeTaskTitle, activeTaskChangeSummary, hasUpdateReady, activeTaskId, user, activeTraceId, activeSessionId, activeTaskProvider, resolvedActiveTaskMeta, sessionLogPath, nativeSessionLogProvider, nativeSessionLogPath, nativeSessionLogExists, nativeSessionLogLoading, workspaceHeaderState, gitSummary, gitDirtyFileCount, isMacDesktop, isMacFullscreen, isWindowsDesktop, isDesktop, simplifyForNarrowRemote = false, isSidebarVisible, isTerminalOpen, isSidePaneOpen, onRefreshGit, onToggleTerminal, onToggleSidePane, toggleSidePaneShortcutLabel, onReloadSession, reloadSessionDisabled, reloadSessionPending, }: { variant?: WorkspaceHeaderVariant; draftDropTargetController?: ConversationDropTargetController | null; readOnlyReason?: string; workspaceAbsPath: string; remoteSessionId?: string; workspaceIdentity?: string; remoteTarget?: RemoteTarget; localWorkspacePath?: string; projectName: string; activeTaskTitle: string; activeTaskChangeSummary?: ZCodeTaskChangeSummary | null; hasUpdateReady: boolean; activeTaskId: string | null; user?: UserInfo | null; activeTraceId: string | null; activeSessionId: string | null; activeTaskProvider: ZCodeProvider | null; resolvedActiveTaskMeta?: ZCodeTaskMeta | null; sessionLogPath: string | null; nativeSessionLogProvider: ZCodeProvider | null; nativeSessionLogPath: string | null; nativeSessionLogExists: boolean; nativeSessionLogLoading: boolean; workspaceHeaderState: WorkspaceHeaderState; gitSummary: GitRepositorySummary; gitDirtyFileCount: number; isMacDesktop?: boolean; isMacFullscreen?: boolean; isWindowsDesktop?: boolean; reserveWindowControls?: boolean; windowsWindowControlsRightPaddingPx?: number; isDesktop?: boolean; simplifyForNarrowRemote?: boolean; isSidebarVisible: boolean; isTerminalOpen: boolean; isSidePaneOpen: boolean; onRefreshGit: () => void; onToggleTerminal: () => void; onToggleBrowser: () => void; onToggleSidePane: () => void; toggleSidePaneShortcutLabel?: string; onReloadSession: (options?: { resumeTaskId?: string | null; provider?: ZCodeProvider | null; }) => void | Promise; reloadSessionDisabled?: boolean; reloadSessionPending?: boolean; onCreateTask: () => void; onOpenWorkspace: () => void; allowOpenWorkspace?: boolean; }) { const [selectedEditor, setSelectedEditor] = useState(null); const shouldOffsetHeaderForWindowControls = !isSidebarVisible; // Linux 与 Windows 共用内联窗控,不再预留旧悬浮窗控的标题栏区域。 const usesInlineWindowControls = Boolean(isWindowsDesktop || (isDesktop && !isMacDesktop)); let headerWindowControlsPaddingClass: string | false = false; if (shouldOffsetHeaderForWindowControls) { if (isMacDesktop) { if (hasUpdateReady) { headerWindowControlsPaddingClass = isMacFullscreen ? "pl-48" : "pl-66"; } else { headerWindowControlsPaddingClass = isMacFullscreen ? "pl-38" : "pl-58"; } } else { headerWindowControlsPaddingClass = hasUpdateReady ? "pl-44" : "pl-38"; } } return (
{variant === "draft" && draftDropTargetController?.active ? (
) : null}
{variant === "task" ? ( ) : (
); }