refactor: massive codebase restructuring — naming, splitting, DRY
Crate renames: - zesdex-entities::seaorm → domain (misleading name, no SeaORM used) - zesdex-dto → merged into zesdex-entities (100% re-exports) - zesdex-libs → zesdex-infra (vague name) Module renames: - app/harness → guard (misleading: safety gatekeeper, not test harness) - runtime/commands → action_dispatch (name clashed with controller/command) - resources → prompts (embedded prompt text, not general resources) - tool/seqthink → sequential_think (unreadable abbreviation) - msglog/query → insert (module only inserts, never queries) Dead code removal: - app/mode/help.rs (orphaned — not declared in mod.rs) - app/mode/loading.rs (orphaned — not declared in mod.rs) File splitting (71 new files, avg ~115 lines/file): - app/runtime/actions/: 1→8 files (was 2030 lines) - view/overlays/: 1→16 files (was 1167 lines) - tool/lsp/: 1→8 per-tool files (was 909 lines) - main.rs: 1→5 files (session, daemon, attach, event_loop) - workflow/engine + hive_mind: 2→10 files - subagent/engine + auto: 2→9 files - lsp/provisioner: 1→5 files - review/: 1→6 files - guard/: 1→2 files (extracted patterns) - state/misc: 1→3 files (input, scroll) - mcp/: 1→3 files (transport, adapter) - stream/json_repair extracted from turn.rs DRY: - Pattern constants (STUB_PATTERNS etc) in guard/patterns shared with subagent - 3 near-identical background spawners → 1 generic + thin wrappers - Shared spawn_subagent_with_drain() extracted - Shared create_session() in main - write_osc52 deduplicated Bug fixes: - archive_message(): sess.db → db (wrong variable name) - execute_one_tool(): wrong parameter name - check_credential_read() function was missing (restored from test expectations)
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
//! Overlay rendering: each overlay variant gets its own module with a
|
||||
//! `pub fn render(frame, area, block, state)` entry point, dispatched by
|
||||
//! the top-level `render_overlay` function in this module.
|
||||
|
||||
pub mod bash;
|
||||
pub mod clear_confirm;
|
||||
pub mod editor;
|
||||
pub mod effort;
|
||||
pub mod help;
|
||||
pub mod key_input;
|
||||
pub mod learning;
|
||||
pub mod loading;
|
||||
pub mod mcp;
|
||||
pub mod model_selector;
|
||||
pub mod quit_confirm;
|
||||
pub mod rewind;
|
||||
pub mod settings;
|
||||
pub mod todo;
|
||||
pub mod usage;
|
||||
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::Style;
|
||||
use ratatui::widgets::{Block, Borders, Clear};
|
||||
use ratatui::Frame;
|
||||
use super::theme::Theme;
|
||||
|
||||
/// Compute a centered rectangle within `area` at the given percentage width
|
||||
/// and height. The result is always at least 40 cols wide and 10 rows tall.
|
||||
pub fn centered_rect(area: Rect, percent_x: u16, percent_y: u16) -> Rect {
|
||||
let x_pad = (area.width.saturating_sub(area.width * percent_x / 100)) / 2;
|
||||
let y_pad = (area.height.saturating_sub(area.height * percent_y / 100)) / 2;
|
||||
|
||||
Rect {
|
||||
x: area.x.saturating_add(x_pad),
|
||||
y: area.y.saturating_add(y_pad),
|
||||
width: area.width.saturating_sub(x_pad * 2).max(40),
|
||||
height: area.height.saturating_sub(y_pad * 2).max(10),
|
||||
}
|
||||
}
|
||||
|
||||
/// Render the active modal overlay as a centered panel.
|
||||
///
|
||||
/// Each overlay gets a surface-colored panel with:
|
||||
/// - A top accent border strip (colored per variant)
|
||||
/// - A title line with icon
|
||||
/// - Content area with proper spacing
|
||||
pub fn render_overlay(
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
overlay: crate::app::state::types::Overlay,
|
||||
state: &crate::app::state::rest::AppStateRest,
|
||||
) {
|
||||
let overlay_area = centered_rect(area, 75, 70);
|
||||
|
||||
// Clear the area behind the overlay (semi-transparent effect)
|
||||
frame.render_widget(Clear, overlay_area);
|
||||
|
||||
let block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_style(Style::default().fg(Theme::BORDER))
|
||||
.style(Style::default().bg(Theme::BG));
|
||||
|
||||
match overlay {
|
||||
crate::app::state::types::Overlay::None => {}
|
||||
|
||||
crate::app::state::types::Overlay::Help => {
|
||||
help::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Settings => {
|
||||
settings::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Bash => {
|
||||
bash::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::QuitConfirm => {
|
||||
quit_confirm::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::KeyInput => {
|
||||
key_input::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Editor => {
|
||||
editor::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Effort => {
|
||||
effort::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Mcp => {
|
||||
mcp::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Todo => {
|
||||
todo::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Rewind => {
|
||||
rewind::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Learning => {
|
||||
learning::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Usage => {
|
||||
usage::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::Loading => {
|
||||
loading::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::ModelSelector => {
|
||||
model_selector::render(frame, overlay_area, block, state);
|
||||
}
|
||||
|
||||
crate::app::state::types::Overlay::ClearConfirm => {
|
||||
clear_confirm::render(frame, overlay_area, block, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user