//! ProjectBoxData: plain struct (NOT an Entity) holding project state.
//!
//! Rendered as ProjectBoxFullElement (custom Element) from Workspace::render().
//! No Entity boundary = no dispatch tree node = no ancestor dirty cascade.

use gpui::*;

use crate::state::{AgentStatus, Project, ProjectTab};

/// Plain data struct for a project box. NOT an Entity — no view overhead.
/// Workspace owns these directly and creates custom Elements from them.
pub struct ProjectBoxData {
    pub status: AgentStatus,
    pub active_tab: ProjectTab,
    pub accent_index: usize,
    pub agent_pane: Option<Entity<crate::components::agent_pane::AgentPane>>,
    pub terminal_view: Option<Entity<crate::terminal::renderer::TerminalView>>,
    pub shared_blink: Option<crate::components::blink_state::SharedBlink>,
    pub id_project: SharedString,
    pub id_content: SharedString,
    pub cached_name: SharedString,
    pub cached_cwd: SharedString,
}

impl ProjectBoxData {
    pub fn new(project: &Project) -> Self {
        let id = &project.id;
        Self {
            status: project.agent.status,
            active_tab: project.active_tab,
            accent_index: project.accent_index,
            agent_pane: None,
            terminal_view: None,
            shared_blink: None,
            id_project: SharedString::from(format!("project-{id}")),
            id_content: SharedString::from(format!("content-{id}")),
            cached_name: SharedString::from(project.name.clone()),
            cached_cwd: SharedString::from(project.cwd.clone()),
        }
    }
}
