Skip to content

Commit 90dc320

Browse files
committed
feat(tui): name shared coherence palette
1 parent be66325 commit 90dc320

3 files changed

Lines changed: 50 additions & 12 deletions

File tree

crates/deadreckon/src/main.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12980,9 +12980,9 @@ fn render_plan_attach(
1298012980
.title(title)
1298112981
.borders(Borders::ALL)
1298212982
.border_style(if is_selected {
12983-
Style::default().fg(Color::Cyan)
12983+
Style::default().fg(ui::TUI_PALETTE.border_focused)
1298412984
} else {
12985-
Style::default()
12985+
Style::default().fg(ui::TUI_PALETTE.border_idle)
1298612986
}),
1298712987
)
1298812988
.wrap(Wrap { trim: true }),
@@ -15550,10 +15550,11 @@ fn render_acceptance(
1555015550

1555115551
fn acceptance_color(status: AcceptanceUiStatus) -> Color {
1555215552
match status {
15553-
AcceptanceUiStatus::DefaultGate | AcceptanceUiStatus::Configured => Color::Yellow,
15554-
AcceptanceUiStatus::Running => Color::Cyan,
15555-
AcceptanceUiStatus::Passed => Color::Green,
15556-
AcceptanceUiStatus::Failed => Color::Red,
15553+
AcceptanceUiStatus::DefaultGate => ui::TUI_PALETTE.acceptance_default,
15554+
AcceptanceUiStatus::Configured => ui::TUI_PALETTE.acceptance_configured,
15555+
AcceptanceUiStatus::Running => ui::TUI_PALETTE.acceptance_running,
15556+
AcceptanceUiStatus::Passed => ui::TUI_PALETTE.acceptance_passed,
15557+
AcceptanceUiStatus::Failed => ui::TUI_PALETTE.acceptance_failed,
1555715558
}
1555815559
}
1555915560

@@ -16149,19 +16150,19 @@ fn turn_timer(
1614916150

1615016151
fn meter_color(ratio: f64, state: &deadreckon_core::PipelineState) -> Color {
1615116152
if state.pause_reason.as_deref() == Some("spend cap reached") {
16152-
Color::Magenta
16153+
ui::TUI_PALETTE.spend_pause_cap
1615316154
} else {
1615416155
threshold_color(ratio)
1615516156
}
1615616157
}
1615716158

1615816159
fn threshold_color(ratio: f64) -> Color {
1615916160
if ratio >= 0.8 {
16160-
Color::Red
16161+
ui::TUI_PALETTE.spend_high
1616116162
} else if ratio >= 0.6 {
16162-
Color::Yellow
16163+
ui::TUI_PALETTE.spend_mid
1616316164
} else {
16164-
Color::Green
16165+
ui::TUI_PALETTE.spend_low
1616516166
}
1616616167
}
1616716168

crates/deadreckon/src/ui.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::io::{self, IsTerminal, Write as _};
22
use std::sync::atomic::{AtomicBool, Ordering};
33

4+
use ratatui::style::Color;
5+
46
static PLAIN_OUTPUT: AtomicBool = AtomicBool::new(false);
57

68
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -24,6 +26,41 @@ pub(crate) enum Tone {
2426
Hint,
2527
}
2628

29+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
30+
pub(crate) struct TuiPalette {
31+
pub(crate) border_focused: Color,
32+
pub(crate) border_idle: Color,
33+
pub(crate) status_running: Color,
34+
pub(crate) status_completed: Color,
35+
pub(crate) status_failed: Color,
36+
pub(crate) acceptance_default: Color,
37+
pub(crate) acceptance_configured: Color,
38+
pub(crate) acceptance_running: Color,
39+
pub(crate) acceptance_passed: Color,
40+
pub(crate) acceptance_failed: Color,
41+
pub(crate) spend_low: Color,
42+
pub(crate) spend_mid: Color,
43+
pub(crate) spend_high: Color,
44+
pub(crate) spend_pause_cap: Color,
45+
}
46+
47+
pub(crate) const TUI_PALETTE: TuiPalette = TuiPalette {
48+
border_focused: Color::Cyan,
49+
border_idle: Color::Reset,
50+
status_running: Color::Cyan,
51+
status_completed: Color::Green,
52+
status_failed: Color::Red,
53+
acceptance_default: Color::DarkGray,
54+
acceptance_configured: Color::Yellow,
55+
acceptance_running: Color::Cyan,
56+
acceptance_passed: Color::Green,
57+
acceptance_failed: Color::Red,
58+
spend_low: Color::Green,
59+
spend_mid: Color::Yellow,
60+
spend_high: Color::Red,
61+
spend_pause_cap: Color::Magenta,
62+
};
63+
2764
pub(crate) fn set_plain_output(plain: bool) {
2865
PLAIN_OUTPUT.store(plain, Ordering::Relaxed);
2966
}

docs/AS-BUILT-ARCHITECTURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,9 +1666,9 @@ The alpha CLI names intent before force. Kill paths use `--escalate`; destinatio
16661666

16671667
`attach <id>` prints `attaching to run|chain|plan <prefix>` to stderr before opening a TUI. `kill <run-id>`, `chain kill`, and `kill <plan-id>` route through one banner shape; plan kill keeps the plan-only process count.
16681668

1669-
### 26.7 TUI Parity
1669+
### 26.7 TUI Palette And Parity
16701670

1671-
The chain attach poll cadence matches the run TUI at 200 ms. Applied chain steps render ``, so applied and running no longer share ``. The spend gauge keeps the green, yellow, red, and cap-paused magenta thresholds; above 60 percent, the title exposes the budget percentage so the label remains readable at narrow widths.
1671+
`ui::TUI_PALETTE` names the shared TUI color slots for focused borders, acceptance states, run states, and spend thresholds. The chain attach poll cadence matches the run TUI at 200 ms. Applied chain steps render ``, so applied and running no longer share ``. The spend gauge keeps the green, yellow, red, and cap-paused magenta thresholds; above 60 percent, the title exposes the budget percentage so the label remains readable at narrow widths.
16721672

16731673
### 26.8 Provider And Failure Vocabulary
16741674

0 commit comments

Comments
 (0)