import React from 'react'; import { ActionMenu, ActionMenuDivider, ActionMenuItem, ActionMenuSectionLabel, } from './ActionMenu'; import { useTheme } from './ThemeProvider'; import { THEME_MODES } from './themeModes'; import { ReviewAgentsIcon } from './ReviewAgentsIcon'; import { MenuVersionSection } from './MenuVersionSection'; import type { UpdateInfo } from '../hooks/useUpdateCheck'; import type { Origin } from '@plannotator/core/agents'; interface PlanHeaderMenuProps { appVersion: string; updateInfo?: UpdateInfo | null; origin?: Origin | null; isWSL?: boolean; onOpenSettings: () => void; onOpenExport: () => void; onCopyAgentInstructions: () => void; onDownloadAnnotations: () => void; onPrint: () => void; onCopyShareLink: () => void; onOpenImport: () => void; onSaveToObsidian: () => void; onSaveToBear: () => void; onSaveToOctarine: () => void; sharingEnabled: boolean; isApiMode: boolean; agentInstructionsEnabled: boolean; obsidianConfigured: boolean; bearConfigured: boolean; octarineConfigured: boolean; compactTouchLayout?: boolean; compactSessionActions?: CompactPlanAction[]; compactDocumentActions?: CompactPlanAction[]; } export interface CompactPlanAction { id: 'exit' | 'feedback' | 'approve' | 'copy' | 'done' | 'edit' | 'tools' | 'annotate' | 'refresh' | 'annotations' | 'ai' | 'review' | 'note' | 'discard-finish' | 'bundle-previous' | 'bundle-next'; label: string; subtitle?: string; onSelect: () => void; disabled?: boolean; } export const PlanHeaderMenu: React.FC = ({ appVersion, updateInfo, origin, isWSL = false, onOpenSettings, onOpenExport, onCopyAgentInstructions, onDownloadAnnotations, onPrint, onCopyShareLink, onOpenImport, onSaveToObsidian, onSaveToBear, onSaveToOctarine, sharingEnabled, isApiMode, agentInstructionsEnabled, obsidianConfigured, bearConfigured, octarineConfigured, compactTouchLayout = false, compactSessionActions = [], compactDocumentActions = [], }) => { const { theme, setTheme } = useTheme(); const showUpdateDot = !!updateInfo?.updateAvailable && !updateInfo.dismissed; const anyNotesAppConfigured = isApiMode && (obsidianConfigured || bearConfigured || octarineConfigured); return ( ( )} > {({ closeMenu }) => ( <> {compactTouchLayout && compactSessionActions.length > 0 && ( <> )} {compactTouchLayout && compactDocumentActions.length > 0 && ( <> )}
Theme
{THEME_MODES.map(({ id, label, Icon }) => ( ))}
{ closeMenu(); onOpenSettings(); }} icon={} label="Settings" /> { closeMenu(); onOpenExport(); }} icon={} label="Export" /> {agentInstructionsEnabled && ( { closeMenu(); onCopyAgentInstructions(); }} icon={} label="Agent Instructions" subtitle="Copy agent instructions for external annotations" /> )} { closeMenu(); onDownloadAnnotations(); }} icon={} label="Download Annotations" /> { closeMenu(); onPrint(); }} icon={} label="Print / Save as PDF" subtitle="Choose 'Save as PDF' in the print dialog" /> {sharingEnabled && ( { closeMenu(); onCopyShareLink(); }} icon={} label="Copy Share Link" /> )} {sharingEnabled && ( { closeMenu(); onOpenImport(); }} icon={} label="Import Review" /> )} {anyNotesAppConfigured && ( <> {obsidianConfigured && ( { closeMenu(); onSaveToObsidian(); }} icon={} label="Save to Obsidian" /> )} {bearConfigured && ( { closeMenu(); onSaveToBear(); }} icon={} label="Save to Bear" /> )} {octarineConfigured && ( { closeMenu(); onSaveToOctarine(); }} icon={} label="Save to Octarine" /> )} )} )}
); }; const CompactActionSection = ({ label, actions, closeMenu, }: { label: string; actions: CompactPlanAction[]; closeMenu: () => void; }) => (
{label}
{actions.map((action) => ( { closeMenu(); action.onSelect(); }} disabled={action.disabled} icon={} label={action.label} subtitle={action.subtitle} /> ))}
); const CompactPlanActionIcon = ({ kind }: { kind: CompactPlanAction['id'] }) => { if (kind === 'review') { return ( ); } if (kind === 'annotations') { return ( ); } if (kind === 'ai') { return ( ); } if (kind === 'approve' || kind === 'done') { return ( ); } if (kind === 'feedback') { return ( ); } if (kind === 'copy') { return ( ); } if (kind === 'edit' || kind === 'annotate') { return ( ); } if (kind === 'tools') { // Eye, matching the desktop header's show/hide-tools toggle. return ( ); } return ( ); }; const MenuIcon = () => ( ); const CloseIcon = () => ( ); const SettingsIcon = () => ( ); const ExportIcon = () => ( ); const DownloadIcon = () => ( ); const PrintIcon = () => ( ); const LinkIcon = () => ( ); const ImportIcon = () => ( ); const NoteIcon = () => ( );