Activity bar wears the mode the engine applies
The comet above the composer sweeps in plan's hue while the session plans, from a second trail shaded onto the same rail. It reads the mode the engine reports, never the keypress: a mid-turn switch lands in the engine at once and each tool call is judged against it as it starts, so the color changes when what the turn can do changes. derived_activity_shades moves to styles/shades.rs beside the ramps it builds, which keeps styles.rs under 500 lines. CHANGELOG entries for this and the git checks -R fix.
This commit is contained in:
@@ -17,8 +17,17 @@ changes add to that section until it ships; `scripts/version-check.py` holds the
|
||||
matches the window's title first, then its app's name, and with no title it takes the frontmost
|
||||
window. A miss lists the windows it saw.
|
||||
|
||||
### Changed
|
||||
|
||||
- The activity bar above the composer sweeps in plan's color while the session plans. A switch
|
||||
mid-turn recolors it once luxe has made the switch, the moment the agent's next tool call is held
|
||||
to the new mode.
|
||||
|
||||
### Fixed
|
||||
|
||||
- The `git` tool's `checks` reads another repository's pull request when given `-R owner/name`.
|
||||
It used to drop the flag and answer with this checkout's pull request of the same number. It now
|
||||
refuses any argument it doesn't understand instead of skipping it.
|
||||
- On Windows, a pasted line break no longer sends the message. The console types a paste out one
|
||||
key at a time, so luxe gathers a burst of keys back into one paste.
|
||||
- On a scaled Windows display, `screenshot` captures the whole screen instead of its top-left
|
||||
|
||||
@@ -137,6 +137,54 @@ fn the_activity_row_keeps_the_mode_button_at_its_left() {
|
||||
assert!(line[..hint].chars().count() > usize::from(column), "{line}");
|
||||
}
|
||||
|
||||
/// The colors the activity row is drawn in to the right of the mode button, at a frame with the
|
||||
/// comet's head mid-bar.
|
||||
fn activity_colors(app: &mut App) -> Vec<ratatui::style::Color> {
|
||||
app.status.spinner_frame = 24;
|
||||
let mode = app.status.mode.clone();
|
||||
let (text, buffer) = screen(app, 80, 20);
|
||||
let (column, row) = mode_badge_at(&text, &mode).expect("the mode button during a turn");
|
||||
let bar = column + mode.chars().count() as u16 + 1;
|
||||
(bar..80).map(|x| buffer[(x, row)].fg).collect()
|
||||
}
|
||||
|
||||
/// The engine moving to `mode` while a turn runs, which reports the turn as still streaming.
|
||||
fn switched_mid_turn(app: &mut App, mode: &str) {
|
||||
app.update(Msg::Engine(Event::StateChanged(luxe_core::event::EngineState {
|
||||
model: luxe_core::event::ModelRef::new("openai", "test-model"),
|
||||
streaming: true,
|
||||
status: format!("mode: {mode}"),
|
||||
mode: mode.into(),
|
||||
thinking: luxe_core::provider::ThinkingLevel::Off,
|
||||
})));
|
||||
}
|
||||
|
||||
/// The activity bar's comet wears the mode the engine reports, switched mid-turn too: that is the
|
||||
/// mode each tool call is judged by as it starts, so it is what the turn can do from here on.
|
||||
///
|
||||
/// The break this catches: a comet in the accent whatever the mode, or one that recolors on the
|
||||
/// keypress before the engine has moved the mode the calls are judged by.
|
||||
#[test]
|
||||
fn the_activity_bar_wears_the_mode_the_engine_reports() {
|
||||
let (mut app, _rx) = mode_app();
|
||||
in_mode(&mut app, "build");
|
||||
app.status.state = crate::app::AppState::Streaming;
|
||||
app.status.on_turn_start();
|
||||
let build = app.theme_styles.activity_trail[0].fg.unwrap();
|
||||
let plan = app.theme_styles.activity_trail_plan[0].fg.unwrap();
|
||||
assert_ne!(build, plan, "the theme has to tell the two comets apart");
|
||||
let colors = activity_colors(&mut app);
|
||||
assert!(colors.contains(&build) && !colors.contains(&plan), "build's comet: {colors:?}");
|
||||
|
||||
app.update(Msg::Key(KeyEvent::new(KeyCode::BackTab, KeyModifiers::SHIFT)));
|
||||
let colors = activity_colors(&mut app);
|
||||
assert!(colors.contains(&build) && !colors.contains(&plan), "asked, not applied: {colors:?}");
|
||||
|
||||
switched_mid_turn(&mut app, "plan");
|
||||
let colors = activity_colors(&mut app);
|
||||
assert!(colors.contains(&plan) && !colors.contains(&build), "plan's comet: {colors:?}");
|
||||
}
|
||||
|
||||
/// Plan mode's color reaches the question the agent asks, and nothing further.
|
||||
#[test]
|
||||
fn plan_mode_tints_the_agent_s_question() {
|
||||
|
||||
@@ -31,6 +31,20 @@ pub(crate) fn accent(mode: &str, styles: &ThemeStyles) -> Style {
|
||||
}
|
||||
}
|
||||
|
||||
/// The comet the activity bar sweeps while a turn runs in `mode`.
|
||||
///
|
||||
/// It follows the mode the engine reports, never the key just pressed: each tool call is judged
|
||||
/// against that mode as it starts, so the color says what the turn can do from here on.
|
||||
pub(crate) fn activity_trail<'a>(
|
||||
mode: &str,
|
||||
styles: &'a ThemeStyles,
|
||||
) -> &'a [Style; crate::theme::styles::ACTIVITY_TRAIL_LEN] {
|
||||
match mode {
|
||||
luxe_core::mode::PLAN => &styles.activity_trail_plan,
|
||||
_ => &styles.activity_trail,
|
||||
}
|
||||
}
|
||||
|
||||
/// The theme, with the border accent swapped for the mode's color.
|
||||
///
|
||||
/// Borrowed in every mode but plan, so the surfaces that take it cost nothing until somebody plans.
|
||||
@@ -71,6 +85,7 @@ mod tests {
|
||||
assert!(matches!(icon("review"), Icon::ModeBuild));
|
||||
assert_eq!(accent("review", &theme), theme.border_accent);
|
||||
assert!(matches!(styles("review", &theme), Cow::Borrowed(_)));
|
||||
assert_eq!(activity_trail("review", &theme), &theme.activity_trail);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -11,8 +11,8 @@ use color::{blend_rgb, color_value_to_ratatui, plan_hue, rgb_color, rgb_token, t
|
||||
use luxe_core::theme::ColorValue;
|
||||
use ratatui::style::{Modifier, Style};
|
||||
use shades::{
|
||||
shade_at, shade_ramp, Fade, COMET_FADE, CURSOR_LINE_WASH, GAUGE_FADE, PICK_WASH, RAIL_FADE,
|
||||
STREAM_FADE,
|
||||
derived_activity_shades, shade_at, shade_ramp, Fade, CURSOR_LINE_WASH, GAUGE_FADE, PICK_WASH,
|
||||
RAIL_FADE, STREAM_FADE,
|
||||
};
|
||||
pub use shades::{
|
||||
Depth, GaugeShades, SlabShades, ACTIVITY_TRAIL_LEN, SLAB_DEPTHS, STREAM_TRAIL_LEN,
|
||||
@@ -42,6 +42,8 @@ pub struct ThemeStyles {
|
||||
pub text: Style,
|
||||
/// Shades the activity comet wears, its leading cell first, fading toward the rail behind it.
|
||||
pub activity_trail: [Style; ACTIVITY_TRAIL_LEN],
|
||||
/// The comet plan mode wears: the same fade, from plan's hue rather than the accent.
|
||||
pub activity_trail_plan: [Style; ACTIVITY_TRAIL_LEN],
|
||||
/// Shades a spent unit wears as the comet's glow falls off it, nearest the comet first.
|
||||
///
|
||||
/// The last is the canvas itself but for a whisper, so the rail dissolves with distance instead
|
||||
@@ -134,8 +136,7 @@ impl ThemeStyles {
|
||||
diff_add_emphasis,
|
||||
diff_del_emphasis,
|
||||
} = derived_bands(&tokens, tint_base);
|
||||
let (activity_trail, activity_rail) =
|
||||
derived_activity_shades(&tokens, accent, tint_base, light);
|
||||
let activity = derived_activity_shades(&tokens, accent, tint_base, light);
|
||||
|
||||
ThemeStyles {
|
||||
accent,
|
||||
@@ -151,8 +152,9 @@ impl ThemeStyles {
|
||||
muted: fg("muted"),
|
||||
dim: fg("dim"),
|
||||
text: fg("text"),
|
||||
activity_trail,
|
||||
activity_rail,
|
||||
activity_trail: activity.trail,
|
||||
activity_trail_plan: activity.trail_plan,
|
||||
activity_rail: activity.rail,
|
||||
paste_indicator,
|
||||
chip,
|
||||
thinking_text: fg("thinkingText"),
|
||||
@@ -427,27 +429,6 @@ fn derived_bands(tokens: &Tokens<'_>, tint_base: Option<(u8, u8, u8)>) -> Bands
|
||||
}
|
||||
}
|
||||
|
||||
/// The activity comet's trail and the rail it sweeps over.
|
||||
///
|
||||
/// The comet fades from the accent into the rail, so its tail dissolves into the chrome instead of
|
||||
/// stopping at an edge.
|
||||
fn derived_activity_shades(
|
||||
tokens: &Tokens<'_>,
|
||||
accent: Style,
|
||||
tint_base: Option<(u8, u8, u8)>,
|
||||
light: bool,
|
||||
) -> ([Style; ACTIVITY_TRAIL_LEN], [Style; ACTIVITY_TRAIL_LEN]) {
|
||||
let resolved = tokens.0;
|
||||
let rail = rgb_token(resolved, "borderMuted")
|
||||
.or_else(|| rgb_token(resolved, "dim"))
|
||||
.or(tint_base)
|
||||
.unwrap_or(if light { (255, 255, 255) } else { (0, 0, 0) });
|
||||
let activity_trail = shade_ramp(accent, rail, light, COMET_FADE);
|
||||
let canvas = tint_base.unwrap_or(if light { (255, 255, 255) } else { (0, 0, 0) });
|
||||
let activity_rail = shade_ramp(tokens.fg("borderMuted"), canvas, light, RAIL_FADE);
|
||||
(activity_trail, activity_rail)
|
||||
}
|
||||
|
||||
/// Fraction of the status hue mixed into the canvas for a tool-call band. Deliberately low so the
|
||||
/// tint reads as a wash, not a fill.
|
||||
const TOOL_STATUS_TINT: f32 = 0.16;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Shades — fades, the slab and gauge ramps, depths and washes, derived from a theme's tokens.
|
||||
|
||||
use super::color::{blend_rgb, rgb_color};
|
||||
use super::color::{blend_rgb, plan_hue, rgb_color, rgb_token};
|
||||
use ratatui::style::{Color as RatatuiColor, Modifier, Style};
|
||||
|
||||
/// Shades in the activity comet's ramp, its leading cell first.
|
||||
@@ -15,6 +15,39 @@ pub const ACTIVITY_TRAIL_LEN: usize = 10;
|
||||
/// the text you are actually reading is at full contrast.
|
||||
pub const STREAM_TRAIL_LEN: usize = 16;
|
||||
|
||||
/// The activity comet's trails and the rail they sweep over.
|
||||
pub(super) struct ActivityShades {
|
||||
/// Build's comet, and every mode's but plan's: from the accent
|
||||
pub(super) trail: [Style; ACTIVITY_TRAIL_LEN],
|
||||
/// Plan's comet: from plan's hue
|
||||
pub(super) trail_plan: [Style; ACTIVITY_TRAIL_LEN],
|
||||
pub(super) rail: [Style; ACTIVITY_TRAIL_LEN],
|
||||
}
|
||||
|
||||
/// The comets for build and plan, and the rail under them.
|
||||
///
|
||||
/// Each comet fades from its hue into the rail, so its tail dissolves into the chrome instead of
|
||||
/// stopping at an edge. Both land on the one rail, so switching mode recolors the comet alone.
|
||||
pub(super) fn derived_activity_shades(
|
||||
tokens: &super::Tokens<'_>,
|
||||
accent: Style,
|
||||
tint_base: Option<(u8, u8, u8)>,
|
||||
light: bool,
|
||||
) -> ActivityShades {
|
||||
let resolved = tokens.0;
|
||||
let rail = rgb_token(resolved, "borderMuted")
|
||||
.or_else(|| rgb_token(resolved, "dim"))
|
||||
.or(tint_base)
|
||||
.unwrap_or(if light { (255, 255, 255) } else { (0, 0, 0) });
|
||||
let canvas = tint_base.unwrap_or(if light { (255, 255, 255) } else { (0, 0, 0) });
|
||||
let comet = |hue| shade_ramp(hue, rail, light, COMET_FADE);
|
||||
ActivityShades {
|
||||
trail: comet(accent),
|
||||
trail_plan: comet(plan_hue(resolved)),
|
||||
rail: shade_ramp(tokens.fg("borderMuted"), canvas, light, RAIL_FADE),
|
||||
}
|
||||
}
|
||||
|
||||
/// How a ramp fades: its curve, what it keeps at the far end, and the lift on its near end.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub(super) struct Fade {
|
||||
|
||||
@@ -177,9 +177,9 @@ fn first_steps(app: &App, width: usize) -> Option<Line<'static>> {
|
||||
|
||||
/// One row of the sweeping activity bar, as spans that can share a line with text.
|
||||
///
|
||||
/// The comet sweeps in shades of the theme accent, and the rail it travels is lit by the comet
|
||||
/// rather than drawn at a fixed weight, so the indicator belongs to the chrome and the motion is the
|
||||
/// only thing that draws the eye.
|
||||
/// The comet sweeps in shades of the theme accent, or of plan's hue while the session plans, and the
|
||||
/// rail it travels is lit by the comet rather than drawn at a fixed weight, so the indicator belongs
|
||||
/// to the chrome and the motion is the only thing that draws the eye.
|
||||
fn activity_bar_spans(app: &App, width: usize) -> Vec<Span<'static>> {
|
||||
use crate::widgets::ActivityGlyphs;
|
||||
use luxe_core::config::ActivityBarStyle;
|
||||
@@ -197,7 +197,7 @@ fn activity_bar_spans(app: &App, width: usize) -> Vec<Span<'static>> {
|
||||
app.status.spinner_frame as u64,
|
||||
width,
|
||||
glyphs,
|
||||
&styles.activity_trail,
|
||||
crate::modes::activity_trail(&app.status.mode, styles),
|
||||
&styles.activity_rail,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user