do-next 0.0.0-2026.4.8

Pick your next Jira task & manage it from the terminal
use std::collections::HashMap;

use crate::jira::types::{Attachment, Comment, FieldOption, Issue, Transition};

#[derive(Debug)]
pub enum AppEvent {
    /// Keyboard or mouse event from the terminal.
    Input(crossterm::event::Event),
    /// A background fetch completed successfully.
    SourceLoaded(String, Vec<Issue>),
    /// A whole-source fetch failed (no subsources).
    SourceError(String, anyhow::Error),
    /// One subsource fetch failed; other subsources continue.
    SubsourceError(String, usize, anyhow::Error),
    /// A Jira action (transition, comment, assign, move) completed.
    ActionDone(ActionResult),
    /// Current user resolved (sent once on startup).
    CurrentUserResolved(String),
    /// Spinner animation frame — only sent while sources are loading.
    Tick,
    /// Filesystem path completions ready (from debounced async fetch).
    PathCompletions {
        generation: u64,
        completions: Vec<String>,
    },
    /// Git-based update warnings for team configs (sent once on startup).
    UpdateWarnings(Vec<String>),
}

#[derive(Debug)]
pub enum ActionResult {
    TransitionApplied {
        issue_key: String,
        new_status: String,
    },
    TransitionsLoaded {
        issue_key: String,
        transitions: Vec<Transition>,
    },
    CommentPosted {
        issue_key: String,
        new_comment: Comment,
    },
    AssignedToMe {
        issue_key: String,
    },
    MovedToProject {
        issue_key: String,
        project: String,
    },
    Hidden {
        issue_key: String,
    },
    FieldUpdated {
        issue_key: String,
        field_id: String,
        new_value: serde_json::Value,
    },
    FieldOptionsLoaded {
        issue_key: String,
        field_id: String,
        label: String,
        original_json: serde_json::Value,
        options: Vec<FieldOption>,
        description: Option<String>,
        multi: bool,
    },
    FieldNamesLoaded {
        names: HashMap<String, String>,
        /// Jira editmeta `schema.type` per `field_id` (e.g. `"date"`, `"datetime"`).
        schemas: HashMap<String, String>,
        /// True when this came from the global field registry (all fields loaded).
        all_fields: bool,
    },
    CommentEdited {
        issue_key: String,
        updated_comment: Comment,
    },
    CommentDeleted {
        issue_key: String,
        comment_id: String,
    },
    AttachmentCached {
        attachment_id: String,
        cache_path: std::path::PathBuf,
        open_after: bool,
    },
    AttachmentUploaded {
        issue_key: String,
        new_attachment: Attachment,
    },
    AttachmentDeleted {
        issue_key: String,
        attachment_id: String,
    },
    Error(anyhow::Error),
}