magi-code 0.96.1

Repository-aware CLI coding agent for terminal work
Documentation
use super::*;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct PromptViewport {
    pub(crate) visible_rows: u16,
    pub(crate) wrap_width: u16,
}

impl PromptViewport {
    pub(super) fn safe(self) -> Self {
        Self {
            visible_rows: self.visible_rows.max(1),
            wrap_width: self.wrap_width.max(1),
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct TranscriptViewport {
    pub(crate) visible_rows: u16,
    pub(crate) wrap_width: u16,
}

impl TranscriptViewport {
    pub(super) fn safe(self) -> Self {
        Self {
            visible_rows: self.visible_rows.max(1),
            wrap_width: self.wrap_width.max(1),
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct ActivityTreeViewport {
    pub(crate) visible_rows: u16,
}

impl ActivityTreeViewport {
    pub(super) fn safe(self) -> Self {
        Self {
            visible_rows: self.visible_rows.max(1),
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct DetailViewport {
    pub(crate) visible_rows: u16,
    pub(crate) wrap_width: u16,
}

impl DetailViewport {
    pub(super) fn safe(self) -> Self {
        Self {
            visible_rows: self.visible_rows,
            wrap_width: self.wrap_width.max(1),
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct SystemPromptViewport {
    pub(crate) visible_rows: u16,
    pub(crate) wrap_width: u16,
}

impl SystemPromptViewport {
    pub(super) fn safe(self) -> Self {
        Self {
            visible_rows: self.visible_rows.max(1),
            wrap_width: self.wrap_width.max(1),
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct PickerViewport {
    pub(crate) visible_rows: u16,
}

impl PickerViewport {
    pub(super) fn safe(self) -> Self {
        Self {
            visible_rows: self.visible_rows.max(1),
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct SessionPickerViewport {
    pub(crate) list_rows: u16,
    pub(crate) preview_rows: u16,
    pub(crate) preview_width: u16,
    pub(crate) preview_visible: bool,
}

impl SessionPickerViewport {
    pub(super) fn safe(self) -> Self {
        Self {
            list_rows: self.list_rows.max(1),
            preview_rows: self.preview_rows.max(1),
            preview_width: self.preview_width.max(1),
            preview_visible: self.preview_visible,
        }
    }
}

pub(super) const DEFAULT_PROMPT_VIEWPORT: PromptViewport = PromptViewport {
    visible_rows: 1,
    wrap_width: 80,
};

pub(super) const DEFAULT_TRANSCRIPT_VIEWPORT: TranscriptViewport = TranscriptViewport {
    visible_rows: 1,
    wrap_width: 80,
};

pub(super) const DEFAULT_ACTIVITY_TREE_VIEWPORT: ActivityTreeViewport =
    ActivityTreeViewport { visible_rows: 1 };

pub(super) const DEFAULT_DETAIL_VIEWPORT: DetailViewport = DetailViewport {
    visible_rows: 1,
    wrap_width: 80,
};

pub(super) const DEFAULT_SYSTEM_PROMPT_VIEWPORT: SystemPromptViewport = SystemPromptViewport {
    visible_rows: 10,
    wrap_width: 80,
};

pub(crate) const DEFAULT_PICKER_VISIBLE_ROWS: u16 = 10;

#[derive(Debug, Clone, Copy, Default)]
pub(crate) struct KeyViewports {
    pub(crate) prompt: Option<PromptViewport>,
    pub(crate) transcript: Option<TranscriptViewport>,
    pub(crate) activity_tree: Option<ActivityTreeViewport>,
    pub(crate) detail: Option<DetailViewport>,
    pub(crate) summary: Option<Rect>,
    pub(crate) system_prompt: Option<SystemPromptViewport>,
    pub(crate) rewind_modal: Option<SystemPromptViewport>,
    pub(crate) usage_modal: Option<SystemPromptViewport>,
    pub(crate) connect_provider: Option<PickerViewport>,
    pub(crate) connect_provider_modal_visible: bool,
    pub(crate) connect_provider_custom_field_visible: bool,
    pub(crate) connect_provider_oauth_controls_visible: bool,
    pub(crate) connect_provider_oauth_fallback_visible: bool,
    pub(crate) logout_picker: Option<PickerViewport>,
    pub(crate) logout_confirmation_action_row: Option<Rect>,
    pub(crate) model_picker: Option<PickerViewport>,
    pub(crate) sessions_modal: Option<SessionPickerViewport>,
    pub(crate) subagent_viewer: Option<SystemPromptViewport>,
    pub(crate) subagent_prompt: Option<PromptViewport>,
    pub(crate) skills_modal: Option<PickerViewport>,
    pub(crate) skills_scope_visible: bool,
    pub(crate) mcp_modal: Option<PickerViewport>,
    pub(crate) tools_modal: Option<PickerViewport>,
    pub(crate) tools_scope_visible: bool,
    pub(crate) subagents_modal: Option<PickerViewport>,
    pub(crate) subagents_scope_visible: bool,
    pub(crate) theme_picker: Option<PickerViewport>,
    pub(crate) theme_query_visible: bool,
}