mutiny-diff 0.1.22

TUI git diff viewer with worktree management
use crossterm::event::KeyEvent;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QuitCombo {
    CtrlC,
    CtrlD,
}

impl QuitCombo {
    pub fn label(self) -> &'static str {
        match self {
            Self::CtrlC => "Ctrl+C",
            Self::CtrlD => "Ctrl+D",
        }
    }
}
use crate::state::annotation_state::{Annotation, AnnotationCategory, AnnotationSeverity};

/// Central action enum — all state mutations flow through here.
#[derive(Debug, Clone)]
pub enum Action {
    // Lifecycle
    #[allow(dead_code)]
    Quit,
    ConfirmQuitSignal(QuitCombo),
    Tick,

    // Navigation
    NavigatorUp,
    NavigatorDown,
    NavigatorTop,
    NavigatorBottom,
    SelectFile(usize),

    // Diff view
    ScrollUp,
    ScrollDown,
    ScrollToTop,
    ScrollToBottom,
    ScrollPageUp,
    ScrollPageDown,
    ToggleViewMode,
    ToggleWhitespace,

    ExpandContext,

    // Hunk navigation
    JumpNextHunk,
    JumpPrevHunk,

    // Focus / Window management
    FocusDiffView,
    FocusPaneLeft,
    FocusPaneRight,
    CycleFocus,
    WindowPrefix,

    // File search (navigator)
    StartSearch,
    ConfirmSearch,
    CancelSearch,
    SearchChar(char),
    SearchBackspace,

    // Diff text search
    StartDiffSearch,
    EndDiffSearch,
    DiffSearchChar(char),
    DiffSearchBackspace,
    DiffSearchNext,
    DiffSearchPrev,

    // Global diff search (Ctrl+F)
    StartGlobalSearch,
    EndGlobalSearch,
    GlobalSearchChar(char),
    GlobalSearchBackspace,
    GlobalSearchNext,
    GlobalSearchPrev,

    // Git mutations
    StageFile,
    UnstageFile,
    RestoreFile,
    OpenCommitDialog,
    ConfirmCommit,
    CancelCommit,
    CommitChar(char),
    CommitBackspace,
    CommitNewline,

    // Restore confirm
    ConfirmRestore,
    CancelRestore,

    // Target change
    OpenTargetDialog,
    ConfirmTarget,
    CancelTarget,
    TargetChar(char),
    TargetBackspace,

    // Worktree
    ToggleWorktreeBrowser,
    WorktreeUp,
    WorktreeDown,
    WorktreeSelect,
    WorktreeRefresh,
    WorktreeFreeze,
    WorktreeBack,

    // Visual selection
    EnterVisualMode,
    ExitVisualMode,
    ExtendSelectionUp,
    ExtendSelectionDown,

    // Comment editor
    OpenCommentEditor,
    ConfirmComment,
    CancelComment,
    CommentChar(char),
    CommentBackspace,
    CommentNewline,

    // Category/severity picker
    SelectCategory(AnnotationCategory),
    SelectSeverity(AnnotationSeverity),
    CancelCategoryPicker,
    CategoryPickerDefault,

    // Annotations
    DeleteAnnotation,
    NextAnnotation,
    PrevAnnotation,
    OpenAnnotationMenu,
    AnnotationMenuUp,
    AnnotationMenuDown,
    AnnotationMenuEdit,
    AnnotationMenuDelete,
    CancelAnnotationMenu,

    // Prompt / clipboard
    CopyPromptToClipboard,
    TogglePromptPreview,

    // Quick-reaction scores
    SetLineScore(u8),
    RemoveLineScore,

    // Agent selector
    OpenAgentSelector,
    AgentSelectorUp,
    AgentSelectorDown,
    AgentSelectorFilter(char),
    AgentSelectorBackspace,
    AgentSelectorCycleModel,
    SelectAgent,
    CancelAgentSelector,

    // Agent outputs tab
    SwitchToAgentOutputs,
    AgentOutputsUp,
    AgentOutputsDown,
    AgentOutputsCopyPrompt,
    KillAgentProcess,
    AgentOutputsSwitchWorktree,

    // PTY focus mode
    PtyInput(KeyEvent),
    PtyPaste(String),
    PtyScrollUp,
    PtyScrollDown,

    // Generic text input
    TextPaste(String),

    // Review state
    ToggleFileReviewed,
    NextUnreviewed,

    // Refresh
    RefreshDiff,

    // Open in editor
    OpenInEditor,

    // HUD
    #[allow(dead_code)]
    ToggleHud,

    // Which-key help overlay
    ToggleWhichKey,

    // Settings modal
    OpenSettings,
    CloseSettings,
    SettingsUp,
    SettingsDown,
    SettingsLeft,
    SettingsRight,

    // Feedback summary
    ToggleFeedbackSummary,
    FeedbackSummaryUp,
    FeedbackSummaryDown,
    FeedbackSummaryCopyJson,
    FeedbackSummaryCopyPrompt,

    // Feedback export
    ExportFeedback,

    // Generic text input navigation
    TextCursorLeft,
    TextCursorRight,
    TextCursorHome,
    TextCursorEnd,
    TextDeleteWord,

    // Resize
    Resize,

    // Checklist
    ToggleChecklist, // Toggle checklist panel visibility
    ChecklistUp,     // Navigate checklist items
    ChecklistDown,
    ChecklistToggleItem, // Toggle current item checked/unchecked
    ChecklistAddNote,    // Open note editor for current item

    // Tree navigator
    ToggleTreeView,
    TreeToggleCollapse,
    TreeCollapseAll,
    TreeExpandAll,

    // Bookmarks
    ToggleBookmark,
    ToggleBookmarkList,
    NextBookmark,
    PrevBookmark,
    SetNamedBookmark(char),
    JumpToNamedBookmark(char),
    BookmarkListUp,
    BookmarkListDown,
    BookmarkListSelect,
    BookmarkListDelete,

    // Command bar (`:` vim-style)
    OpenCommandBar,
    CommandBarChar(char),
    CommandBarBackspace,
    CommandBarConfirm,
    CommandBarCancel,
    GoToLine(u32),

    // File picker (Ctrl+P)
    OpenFilePicker,
    FilePickerChar(char),
    FilePickerBackspace,
    FilePickerUp,
    FilePickerDown,
    FilePickerConfirm,
    FilePickerCancel,

    // Agentic review — text input modal
    OpenAgenticReview,
    AgenticReviewChar(char),
    AgenticReviewBackspace,
    AgenticReviewNewline,
    AgenticReviewConfirm,
    // Agentic review — side panel
    ToggleAgenticReviewPanel,

    // Agentic review — async events from orchestration runner
    AgenticReviewStreamToken(String),
    AgenticReviewChildProgress(usize, usize),
    AgenticReviewComplete(Vec<Annotation>),
    AgenticReviewError(String),
    AgenticReviewPanelUp,
    AgenticReviewPanelDown,
}