Skip to content

Commit adaeab9

Browse files
authored
Merge pull request anomalyco#886 from affaan-m/feat/ecc2-split-pane
feat(ecc2): add split-pane dashboard resizing
2 parents 4105a2f + 8981dd6 commit adaeab9

4 files changed

Lines changed: 312 additions & 59 deletions

File tree

‎ecc2/src/config/mod.rs‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ use anyhow::Result;
22
use serde::{Deserialize, Serialize};
33
use std::path::PathBuf;
44

5+
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
6+
#[serde(rename_all = "snake_case")]
7+
pub enum PaneLayout {
8+
#[default]
9+
Horizontal,
10+
Vertical,
11+
Grid,
12+
}
13+
514
#[derive(Debug, Clone, Serialize, Deserialize)]
615
#[serde(default)]
716
pub struct Config {
@@ -15,6 +24,7 @@ pub struct Config {
1524
pub cost_budget_usd: f64,
1625
pub token_budget: u64,
1726
pub theme: Theme,
27+
pub pane_layout: PaneLayout,
1828
}
1929

2030
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -37,6 +47,7 @@ impl Default for Config {
3747
cost_budget_usd: 10.0,
3848
token_budget: 500_000,
3949
theme: Theme::Dark,
50+
pane_layout: PaneLayout::Horizontal,
4051
}
4152
}
4253
}
@@ -60,7 +71,7 @@ impl Config {
6071

6172
#[cfg(test)]
6273
mod tests {
63-
use super::Config;
74+
use super::{Config, PaneLayout};
6475

6576
#[test]
6677
fn default_includes_positive_budget_thresholds() {
@@ -88,5 +99,18 @@ theme = "Dark"
8899

89100
assert_eq!(config.cost_budget_usd, defaults.cost_budget_usd);
90101
assert_eq!(config.token_budget, defaults.token_budget);
102+
assert_eq!(config.pane_layout, defaults.pane_layout);
103+
}
104+
105+
#[test]
106+
fn default_pane_layout_is_horizontal() {
107+
assert_eq!(Config::default().pane_layout, PaneLayout::Horizontal);
108+
}
109+
110+
#[test]
111+
fn pane_layout_deserializes_from_toml() {
112+
let config: Config = toml::from_str(r#"pane_layout = "grid""#).unwrap();
113+
114+
assert_eq!(config.pane_layout, PaneLayout::Grid);
91115
}
92116
}

‎ecc2/src/session/manager.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl fmt::Display for SessionStatus {
357357
#[cfg(test)]
358358
mod tests {
359359
use super::*;
360-
use crate::config::{Config, Theme};
360+
use crate::config::{Config, PaneLayout, Theme};
361361
use crate::session::{Session, SessionMetrics, SessionState};
362362
use anyhow::{Context, Result};
363363
use chrono::{Duration, Utc};
@@ -403,6 +403,7 @@ mod tests {
403403
cost_budget_usd: 10.0,
404404
token_budget: 500_000,
405405
theme: Theme::Dark,
406+
pane_layout: PaneLayout::Horizontal,
406407
}
407408
}
408409

‎ecc2/src/tui/app.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ pub async fn run(db: StateStore, cfg: Config) -> Result<()> {
3232
(_, KeyCode::Char('q')) => break,
3333
(_, KeyCode::Tab) => dashboard.next_pane(),
3434
(KeyModifiers::SHIFT, KeyCode::BackTab) => dashboard.prev_pane(),
35+
(_, KeyCode::Char('+')) | (_, KeyCode::Char('=')) => {
36+
dashboard.increase_pane_size()
37+
}
38+
(_, KeyCode::Char('-')) => dashboard.decrease_pane_size(),
3539
(_, KeyCode::Char('j')) | (_, KeyCode::Down) => dashboard.scroll_down(),
3640
(_, KeyCode::Char('k')) | (_, KeyCode::Up) => dashboard.scroll_up(),
3741
(_, KeyCode::Char('n')) => dashboard.new_session(),

0 commit comments

Comments
 (0)