luxe 0.1.5: a provider picker, model ids, and a guided review that says less
The dock's provider row opens a list of providers, and the model picker opens on the provider in use, with tab to widen it; signing in opens it on the provider just signed in to. Models go by their id unless config names them, and the model row wears its maker's mark. The guided review's guide prompt is shorter, the pull request brief shows the start of the description with the rest behind p, its commits drop the Luxe-review and Luxe-revision lines, and the weakened-gates signal is gone. luxe update reruns the installer it was installed with, in place of luxe-cli-update. The preview's FILE tab reads files the session changed outside the project, and only those. Smaller fixes: bash headers are highlighted, the preview loses a blank row, the launcher divider sits inside its frame, and the phone app's top bar is clear of iOS's blur. rustls-webpki 0.103.16 and webpki-roots 1.0.10 fix RUSTSEC-2026-0381 and RUSTSEC-2026-0382, and vite 8.3.4 fixes GHSA-587h-7wmj-h5pm, GHSA-698v-4r3x-3vcv and GHSA-r825-w8mm-5pxw.
This commit is contained in:
@@ -8,7 +8,7 @@ repository.workspace = true
|
||||
homepage.workspace = true
|
||||
|
||||
[dependencies]
|
||||
luxe-core = { path = "../luxe-core", version = "0.1.4" }
|
||||
luxe-core = { path = "../luxe-core", version = "0.1.5" }
|
||||
# `unstable-rendered-line-info` enables Paragraph::line_count, used for precise wrapping-aware
|
||||
# mouse hit-testing over word-wrapped surfaces (guide/dock/conversation clicks). It adds no crate;
|
||||
# the API is marked unstable upstream but is stable within our pinned minor (re-check on upgrade).
|
||||
|
||||
@@ -168,8 +168,9 @@ impl App {
|
||||
/// models it reached, any advice that only makes sense now) becomes the picker's opening line,
|
||||
/// and the transcript keeps the whole of it for a reader who scrolls back.
|
||||
///
|
||||
/// The picker opens at the top with nothing chosen: which model to run is the reader's call,
|
||||
/// and a cursor already resting on one reads as luxe recommending it.
|
||||
/// The picker opens on the provider just signed in to, at the top with nothing chosen: which
|
||||
/// model to run is the reader's call, and a cursor already resting on one reads as luxe
|
||||
/// recommending it. `tab` widens it to every provider.
|
||||
fn finish_login(&mut self, outcome: luxe_core::auth::LoginOutcome) {
|
||||
self.close_auth_wizard();
|
||||
self.refresh_configuration();
|
||||
@@ -178,7 +179,7 @@ impl App {
|
||||
self.push_convo(ConvoBlock::System(login_report(&outcome)));
|
||||
let current = Some(self.status.model.as_str()).filter(|model| !model.is_empty());
|
||||
let note = login_note(&outcome, current);
|
||||
self.open_model_picker_at_top(note);
|
||||
self.open_model_picker_after_login(note, &outcome.provider_id);
|
||||
}
|
||||
|
||||
/// Re-read what is configured, so the Configuration summary reflects a login that just landed.
|
||||
|
||||
@@ -12,14 +12,16 @@
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||
|
||||
use crate::app::{App, Msg};
|
||||
use crate::app::{App, DescriptionStep, Msg};
|
||||
|
||||
/// The review's own overlay that takes typing, when one is open.
|
||||
///
|
||||
/// In the order they take it: a search outranks the source reference field, which outranks the
|
||||
/// picker it was opened from. The help sheet takes no typing, only Esc.
|
||||
/// In the order they take it: the pull request's description, read over everything, outranks a
|
||||
/// search, which outranks the source reference field, which outranks the picker it was opened
|
||||
/// from. The help sheet takes no typing, only Esc.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum LocalOverlay {
|
||||
Description,
|
||||
Search,
|
||||
SourceReference,
|
||||
SourcePicker,
|
||||
@@ -29,7 +31,9 @@ enum LocalOverlay {
|
||||
|
||||
impl LocalOverlay {
|
||||
fn of(workspace: &crate::guided_review::GuidedReviewWorkspace) -> Self {
|
||||
if workspace.search.is_some() {
|
||||
if workspace.description_scroll.is_some() {
|
||||
LocalOverlay::Description
|
||||
} else if workspace.search.is_some() {
|
||||
LocalOverlay::Search
|
||||
} else if workspace.source_reference_open() {
|
||||
LocalOverlay::SourceReference
|
||||
@@ -77,7 +81,9 @@ pub fn claim(app: &mut App, key: &KeyEvent) -> Option<Msg> {
|
||||
|
||||
/// Esc closes what is drawn on top — the help sheet first — and with nothing open leaves the review.
|
||||
fn escape(workspace: &crate::guided_review::GuidedReviewWorkspace) -> Msg {
|
||||
if workspace.help_visible {
|
||||
if workspace.description_scroll.is_some() {
|
||||
Msg::GuidedReviewDescription(DescriptionStep::Toggle)
|
||||
} else if workspace.help_visible {
|
||||
Msg::GuidedReviewToggleHelp
|
||||
} else if workspace.source_reference_open() {
|
||||
Msg::GuidedReviewCancelSourceReference
|
||||
@@ -95,6 +101,9 @@ fn escape(workspace: &crate::guided_review::GuidedReviewWorkspace) -> Msg {
|
||||
/// A space in the source reference field is text too, though a reference is one token: typed, it
|
||||
/// is refused at submit with a reason, where passed through it stepped the walk behind the field.
|
||||
fn overlay_key(overlay: LocalOverlay, picker_open: bool, key: &KeyEvent) -> Option<Msg> {
|
||||
if overlay == LocalOverlay::Description {
|
||||
return Some(description_key(key));
|
||||
}
|
||||
let plain = !key.modifiers.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT);
|
||||
let msg = match (overlay, key.code) {
|
||||
(LocalOverlay::Search, KeyCode::Enter | KeyCode::Down) => Msg::GuidedReviewSearchNext,
|
||||
@@ -127,6 +136,26 @@ fn overlay_key(overlay: LocalOverlay, picker_open: bool, key: &KeyEvent) -> Opti
|
||||
Some(msg)
|
||||
}
|
||||
|
||||
/// Rows a page key moves the description. Short of a screen, so the last lines of one page are
|
||||
/// still in view at the top of the next.
|
||||
const DESCRIPTION_PAGE_ROWS: i32 = 10;
|
||||
|
||||
/// A key while the description is open: it scrolls, `p` shuts it, and everything else is
|
||||
/// swallowed so nothing moves in the review behind it.
|
||||
fn description_key(key: &KeyEvent) -> Msg {
|
||||
let step = match key.code {
|
||||
KeyCode::Down | KeyCode::Char('j') => DescriptionStep::Scroll(1),
|
||||
KeyCode::Up | KeyCode::Char('k') => DescriptionStep::Scroll(-1),
|
||||
KeyCode::PageDown | KeyCode::Char(' ') => DescriptionStep::Scroll(DESCRIPTION_PAGE_ROWS),
|
||||
KeyCode::PageUp => DescriptionStep::Scroll(-DESCRIPTION_PAGE_ROWS),
|
||||
KeyCode::Home => DescriptionStep::Scroll(i32::MIN),
|
||||
KeyCode::End => DescriptionStep::Scroll(i32::MAX),
|
||||
KeyCode::Char('p' | 'q') => DescriptionStep::Toggle,
|
||||
_ => return Msg::Tick,
|
||||
};
|
||||
Msg::GuidedReviewDescription(step)
|
||||
}
|
||||
|
||||
/// The walkthrough's own keys, and a swallowed tick for anything else.
|
||||
fn surface_key(
|
||||
workspace: &crate::guided_review::GuidedReviewWorkspace,
|
||||
@@ -148,6 +177,7 @@ fn surface_key(
|
||||
KeyCode::Char('z') => Msg::GuidedReviewToggleNarration,
|
||||
KeyCode::Char('d') => Msg::GuidedReviewToggleNoiseDetails,
|
||||
KeyCode::Char('s') => Msg::GuidedReviewToggleSourcePicker,
|
||||
KeyCode::Char('p') if !picking => Msg::GuidedReviewDescription(DescriptionStep::Toggle),
|
||||
KeyCode::Char('r') if failed => Msg::GuidedReviewRetry,
|
||||
// ↑/↓ scroll what is being read and never anything else, whichever pane has focus
|
||||
KeyCode::Down if ctrl => Msg::GuidedReviewFileNext,
|
||||
|
||||
@@ -53,6 +53,17 @@ pub(super) fn reduce(app: &mut App, msg: Msg) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Lays the frame out again for a new terminal size.
|
||||
fn resize(app: &mut App, width: u16, height: u16) {
|
||||
app.workspace_layout = crate::workspace_layout::resolve_workspace_layout(width).layout;
|
||||
app.guided_review_workspace.set_terminal_size(width, height);
|
||||
// A font-size change arrives as a resize and nothing else, and it moves the only number an
|
||||
// image is scaled against, so ask the terminal again rather than trusting what it said at
|
||||
// startup.
|
||||
app.images.set_cell_size(crate::graphics::CellSize::detect());
|
||||
app.with_review(|workspace, review| workspace.clamp_column_offset(&review.files));
|
||||
}
|
||||
|
||||
fn reduce_inner(app: &mut App, msg: Msg) {
|
||||
match msg {
|
||||
Msg::OpenChanges(_)
|
||||
@@ -125,15 +136,7 @@ fn reduce_inner(app: &mut App, msg: Msg) {
|
||||
app.apply_wizard_outcome(outcome);
|
||||
}
|
||||
}
|
||||
Msg::TerminalResized { width, height } => {
|
||||
app.workspace_layout = crate::workspace_layout::resolve_workspace_layout(width).layout;
|
||||
app.guided_review_workspace.set_terminal_size(width, height);
|
||||
// A font-size change arrives as a resize and nothing else, and it moves the only
|
||||
// number an image is scaled against — so ask the terminal again rather than trusting
|
||||
// what it said at startup.
|
||||
app.images.set_cell_size(crate::graphics::CellSize::detect());
|
||||
app.with_review(|workspace, review| workspace.clamp_column_offset(&review.files));
|
||||
}
|
||||
Msg::TerminalResized { width, height } => resize(app, width, height),
|
||||
Msg::ExitGuidedReview => super::navigation::exit_guided_review(app),
|
||||
Msg::GuidedReviewSelectDiffRow(_)
|
||||
| Msg::GuidedReviewSelectFile(_)
|
||||
@@ -167,6 +170,7 @@ fn reduce_inner(app: &mut App, msg: Msg) {
|
||||
| Msg::GuidedReviewToggleSplit
|
||||
| Msg::GuidedReviewToggleWordWrap
|
||||
| Msg::GuidedReviewToggleHelp
|
||||
| Msg::GuidedReviewDescription(_)
|
||||
| Msg::GuidedReviewToggleSourcePicker
|
||||
| Msg::GuidedReviewSourcePickerNext
|
||||
| Msg::GuidedReviewSourcePickerPrevious
|
||||
@@ -205,7 +209,7 @@ fn reduce_inner(app: &mut App, msg: Msg) {
|
||||
app.panes.save();
|
||||
}
|
||||
Msg::FinishPaneResize => app.panes.save(),
|
||||
Msg::OpenModelPicker => app.open_model_picker(),
|
||||
Msg::OpenModelPicker(start) => app.open_model_picker_at(start),
|
||||
Msg::CopyText(text) => app.record_copy(text),
|
||||
Msg::OpenImageExternally(key) => app.open_image_externally(&key),
|
||||
Msg::OpenImageViewer(key) => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! the feedback session; that is `review`'s. [`reduce`] takes the cursor's messages and hands the
|
||||
//! rest down one table at a time, so each stays short.
|
||||
|
||||
use crate::app::{App, Msg};
|
||||
use crate::app::{App, DescriptionStep, Msg};
|
||||
use crate::guided_review::GuidedReviewWorkspace;
|
||||
use luxe_core::guided_review::{GuidedReview, ReviewFinding};
|
||||
|
||||
@@ -98,6 +98,7 @@ pub(super) fn reduce(app: &mut App, msg: Msg) {
|
||||
|
||||
/// Search and the view toggles; the rest goes on to [`choose`].
|
||||
fn display(app: &mut App, msg: Msg) {
|
||||
let has_description = review_has_description(app);
|
||||
let workspace = &mut app.guided_review_workspace;
|
||||
match msg {
|
||||
Msg::GuidedReviewBeginSearch => workspace.begin_search(),
|
||||
@@ -125,10 +126,25 @@ fn display(app: &mut App, msg: Msg) {
|
||||
}),
|
||||
Msg::GuidedReviewToggleWordWrap => workspace.toggle_word_wrap(),
|
||||
Msg::GuidedReviewToggleHelp => workspace.toggle_help(),
|
||||
// Only a pull request has a description to read; anywhere else the key does nothing
|
||||
Msg::GuidedReviewDescription(DescriptionStep::Toggle) if has_description => {
|
||||
workspace.toggle_description();
|
||||
}
|
||||
Msg::GuidedReviewDescription(DescriptionStep::Toggle) => {}
|
||||
Msg::GuidedReviewDescription(DescriptionStep::Scroll(rows)) => {
|
||||
workspace.scroll_description(rows);
|
||||
}
|
||||
other => choose(app, other),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the review on screen is a pull request's with a description to open.
|
||||
fn review_has_description(app: &App) -> bool {
|
||||
let pull_request =
|
||||
app.guided_review.as_ref().and_then(|review| review.context.pull_request.as_ref());
|
||||
pull_request.is_some_and(|pr| !pr.body.trim().is_empty())
|
||||
}
|
||||
|
||||
/// The source picker and the findings window.
|
||||
fn choose(app: &mut App, msg: Msg) {
|
||||
let last_turn_available = app.review.last_turn.is_some();
|
||||
|
||||
@@ -51,6 +51,10 @@ pub enum Msg {
|
||||
GuidedReviewConfirmCommit,
|
||||
GuidedReviewCancelCommit,
|
||||
GuidedReviewToggleHelp,
|
||||
/// Opens, shuts or scrolls the pull request's whole description.
|
||||
///
|
||||
/// Args: what to do with it.
|
||||
GuidedReviewDescription(DescriptionStep),
|
||||
GuidedReviewRetry,
|
||||
|
||||
// === Review: choosing a source ===
|
||||
@@ -210,7 +214,8 @@ pub enum Msg {
|
||||
CopySelection,
|
||||
/// Moves the hover highlight to the target under the pointer (`None` when over empty space).
|
||||
HoverTarget(Option<crate::mouse::MouseTarget>),
|
||||
OpenModelPicker,
|
||||
/// Opens the model picker. Args: the step it opens on.
|
||||
OpenModelPicker(crate::model_picker::PickerStart),
|
||||
CopyText(String),
|
||||
/// Hands an image to the desktop's own viewer, for a terminal that cannot draw it inline.
|
||||
OpenImageExternally(crate::graphics::ImageKey),
|
||||
@@ -329,3 +334,12 @@ pub enum Msg {
|
||||
/// Args: `(catalog)`.
|
||||
ModelCatalogRefreshed(Vec<crate::model_picker::ModelEntry>),
|
||||
}
|
||||
|
||||
/// What a key or the wheel does to the pull request's description reader.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum DescriptionStep {
|
||||
/// Opens it at the top, or shuts it
|
||||
Toggle,
|
||||
/// Scrolls it, down when positive. Args: the rows.
|
||||
Scroll(i32),
|
||||
}
|
||||
|
||||
@@ -31,25 +31,34 @@ impl App {
|
||||
/// between — and a list of models that cannot authenticate is worse than no list, because
|
||||
/// picking one looks like progress and fails on the first turn.
|
||||
pub fn open_model_picker(&mut self) {
|
||||
self.open_model_picker_with(Vec::new());
|
||||
self.open_model_picker_at(crate::model_picker::PickerStart::Models);
|
||||
}
|
||||
|
||||
/// The same, opening with something to say first. Args: `(note)`.
|
||||
pub(crate) fn open_model_picker_with(&mut self, note: Vec<String>) {
|
||||
/// The same, on the step `start` names: the provider in use's models, or the providers.
|
||||
pub fn open_model_picker_at(&mut self, start: crate::model_picker::PickerStart) {
|
||||
let active = self.active_model_info.as_ref().map(|info| info.r#ref.clone());
|
||||
self.open_model_picker_on(note, active);
|
||||
self.open_model_picker_on(Vec::new(), active, |picker| picker.starting_on(start));
|
||||
}
|
||||
|
||||
/// The same, with the cursor on the first row rather than the model in use. Args: `(note)`.
|
||||
pub(crate) fn open_model_picker_at_top(&mut self, note: Vec<String>) {
|
||||
self.open_model_picker_on(note, None);
|
||||
/// The same, on the models of `provider`, which a login just reached, with the cursor on the
|
||||
/// first and something to say first. Args: `(note, provider)`.
|
||||
///
|
||||
/// Not the provider in use: a login can land on another, and its models are the ones the
|
||||
/// reader signed in for.
|
||||
pub(crate) fn open_model_picker_after_login(&mut self, note: Vec<String>, provider: &str) {
|
||||
let active = self.active_model_info.as_ref().map(|info| info.r#ref.clone());
|
||||
self.open_model_picker_on(note, active, |picker| picker.about_provider(provider));
|
||||
}
|
||||
|
||||
/// Opens the picker with the cursor on `start`, or the top. Args: `(note, start)`.
|
||||
/// Opens the picker with `active` marked, moved to its first step by `step`.
|
||||
/// Args: `(note, active, step)`.
|
||||
fn open_model_picker_on(
|
||||
&mut self,
|
||||
note: Vec<String>,
|
||||
start: Option<luxe_core::provider::ModelRef>,
|
||||
active: Option<luxe_core::provider::ModelRef>,
|
||||
step: impl FnOnce(
|
||||
crate::model_picker::ModelPickerState,
|
||||
) -> crate::model_picker::ModelPickerState,
|
||||
) {
|
||||
if let Some(sources) = &self.model_sources {
|
||||
self.model_catalog = (sources.build)().catalog;
|
||||
@@ -58,10 +67,9 @@ impl App {
|
||||
self.explain_no_models();
|
||||
return;
|
||||
}
|
||||
self.overlays.model_picker = Some(
|
||||
crate::model_picker::ModelPickerState::open(self.model_catalog.clone(), start)
|
||||
.with_note(note),
|
||||
);
|
||||
let picker =
|
||||
crate::model_picker::ModelPickerState::open(self.model_catalog.clone(), active);
|
||||
self.overlays.model_picker = Some(step(picker).with_note(note));
|
||||
// Drawn from what is on disk, then corrected by whatever a local server says when it
|
||||
// answers. The picker is already on screen either way: a list that updates a moment late
|
||||
// beats a frame that waits on a socket.
|
||||
|
||||
@@ -353,17 +353,19 @@ fn shift_tab_on_the_start_screen_switches_the_mode() {
|
||||
assert!(text.contains("shift+tab build mode"), "and back again:\n{text}");
|
||||
}
|
||||
|
||||
/// The composer's title is the mode switch on the start screen too, since it is the same composer.
|
||||
/// The mode button above the composer is the mode switch on the start screen too, since it is the
|
||||
/// same composer.
|
||||
#[test]
|
||||
fn the_start_screen_composer_title_switches_the_mode() {
|
||||
fn the_start_screen_mode_button_switches_the_mode() {
|
||||
let (tx, mut rx) = mpsc::channel(100);
|
||||
let mut app = App::new(tx, KeyMap::defaults(), Default::default());
|
||||
app.enter_dashboard(crate::dashboard::DashboardState::new(Vec::new()));
|
||||
in_mode(&mut app, "build");
|
||||
let (text, _) = screen(&mut app, 100, 30);
|
||||
let row = text.lines().position(|line| line.contains("build ─")).expect("a titled composer");
|
||||
let line = text.lines().nth(row).expect("the row");
|
||||
let column = line[..line.find("build").expect("the title")].chars().count() as u16;
|
||||
assert!(!text.contains("build ─"), "the frame still carries the mode:\n{text}");
|
||||
let row = text.lines().position(|line| line.contains('╭')).expect("the composer") - 1;
|
||||
let line = text.lines().nth(row).expect("the row above it");
|
||||
let column = line[..line.find("build").expect("the button")].chars().count() as u16;
|
||||
let click = crossterm::event::MouseEvent {
|
||||
kind: crossterm::event::MouseEventKind::Down(crossterm::event::MouseButton::Left),
|
||||
column,
|
||||
@@ -376,6 +378,30 @@ fn the_start_screen_composer_title_switches_the_mode() {
|
||||
assert_eq!(app.current_view, ViewMode::Dashboard);
|
||||
}
|
||||
|
||||
/// The divider under the launcher's input runs between the frame's plain sides, the way the rule
|
||||
/// over the key hints does, rather than teeing into them in a color the rule doesn't share.
|
||||
#[test]
|
||||
fn the_launcher_divider_does_not_tee_into_the_frame() {
|
||||
let (tx, _rx) = mpsc::channel(100);
|
||||
let mut app = App::new(tx, KeyMap::defaults(), Default::default());
|
||||
app.enter_dashboard(crate::dashboard::DashboardState::new(Vec::new()));
|
||||
let (text, buffer) = screen(&mut app, 100, 30);
|
||||
let top = text.lines().position(|line| line.contains('╭')).expect("the composer");
|
||||
let left = text.lines().nth(top).and_then(|line| line.chars().position(|c| c == '╭'));
|
||||
let left = left.expect("the frame's corner");
|
||||
// The first row under the input that is a rule, whatever its sides are drawn with
|
||||
let rows: Vec<Vec<char>> = text.lines().map(|line| line.chars().collect()).collect();
|
||||
let divider = (top + 1..rows.len()).find(|y| rows[*y][left + 1] == '─').expect("a divider");
|
||||
let line = &rows[divider];
|
||||
let right = line.iter().rposition(|cell| *cell != ' ').expect("a side");
|
||||
assert_eq!((line[left], line[right]), ('│', '│'), "{line:?}");
|
||||
assert!(line[left + 1..right].iter().all(|cell| *cell == '─'), "{line:?}");
|
||||
let y = divider as u16;
|
||||
let rule = buffer[(left as u16 + 1, y)].fg;
|
||||
assert_eq!(rule, app.theme_styles.border_muted.fg.expect("a muted rule"));
|
||||
assert_ne!(buffer[(left as u16, y)].fg, rule, "the sides keep the frame's color");
|
||||
}
|
||||
|
||||
/// A command the start screen cannot host gets a session first, then runs in it.
|
||||
#[test]
|
||||
fn a_command_found_on_the_start_screen_runs_in_a_new_session() {
|
||||
|
||||
@@ -87,39 +87,56 @@ fn shift_tab_switches_mode_from_the_composer_only() {
|
||||
assert!(rx.try_recv().is_err(), "shift+tab in the `/` menu switched the mode");
|
||||
}
|
||||
|
||||
/// The composer's title names the mode, in its own color, and clicking it switches.
|
||||
/// Where the mode button is, as `(column, row)` of its name: the row right above the composer's
|
||||
/// top edge, at its left end.
|
||||
pub(super) fn mode_badge_at(text: &str, mode: &str) -> Option<(u16, u16)> {
|
||||
let lines: Vec<&str> = text.lines().collect();
|
||||
let top = lines.iter().rposition(|line| line.contains('╭'))?;
|
||||
let corner = lines[top].chars().position(|c| c == '╭')?;
|
||||
let above = lines.get(top.checked_sub(1)?)?;
|
||||
let at = above.find(mode)?;
|
||||
let column = above[..at].chars().count();
|
||||
// The icon and a pad come first, and nothing else may: the button leads the row
|
||||
(column > corner && column <= corner + 4).then_some((column as u16, top as u16 - 1))
|
||||
}
|
||||
|
||||
/// The mode is named on the row above the composer, at its left end, in its own color, and
|
||||
/// clicking it switches. The frame no longer carries it.
|
||||
#[test]
|
||||
fn the_composer_title_names_the_mode_and_is_a_button() {
|
||||
fn the_mode_button_leads_the_row_above_the_composer() {
|
||||
let (mut app, mut rx) = mode_app();
|
||||
in_mode(&mut app, "build");
|
||||
let (text, _) = screen(&mut app, 80, 20);
|
||||
assert!(text.contains("build"), "the default mode is named too:\n{text}");
|
||||
assert!(mode_badge_at(&text, "build").is_some(), "the default mode is named too:\n{text}");
|
||||
|
||||
in_mode(&mut app, "plan");
|
||||
let (text, buffer) = screen(&mut app, 80, 20);
|
||||
let row = text.lines().position(|line| line.contains("plan ─")).expect("a titled composer");
|
||||
let column = text.lines().nth(row).unwrap().find("plan").unwrap();
|
||||
let column = text.lines().nth(row).unwrap()[..column].chars().count() as u16;
|
||||
assert!(!text.contains("plan ─"), "the frame still carries the mode:\n{text}");
|
||||
let (column, row) = mode_badge_at(&text, "plan").expect("the mode button");
|
||||
assert_eq!(
|
||||
buffer[(column, row as u16)].fg,
|
||||
buffer[(column, row)].fg,
|
||||
app.theme_styles.mode_plan.fg.unwrap(),
|
||||
"the title wears the plan color"
|
||||
"the button wears the plan color"
|
||||
);
|
||||
|
||||
let click = crossterm::event::MouseEvent {
|
||||
kind: crossterm::event::MouseEventKind::Down(crossterm::event::MouseButton::Left),
|
||||
column,
|
||||
row: row as u16,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
};
|
||||
if let crate::main_loop::RouteAction::Msg(message) =
|
||||
crate::main_loop::route_mouse(&mut app, &click)
|
||||
{
|
||||
app.update(*message);
|
||||
}
|
||||
click_at(&mut app, column, row);
|
||||
assert!(matches!(rx.try_recv(), Ok(Action::SetMode(mode)) if mode == "build"));
|
||||
}
|
||||
|
||||
/// A running turn's activity bar and time sit to the right of the mode button, which stays put.
|
||||
#[test]
|
||||
fn the_activity_row_keeps_the_mode_button_at_its_left() {
|
||||
let (mut app, _rx) = mode_app();
|
||||
in_mode(&mut app, "plan");
|
||||
app.status.state = crate::app::AppState::Streaming;
|
||||
app.status.on_turn_start();
|
||||
let (text, _) = screen(&mut app, 80, 20);
|
||||
let (column, row) = mode_badge_at(&text, "plan").expect("the button during a turn");
|
||||
let line = text.lines().nth(usize::from(row)).unwrap();
|
||||
let hint = line.find("to interrupt").expect("the activity is on the same row");
|
||||
assert!(line[..hint].chars().count() > usize::from(column), "{line}");
|
||||
}
|
||||
|
||||
/// Plan mode's color reaches the question the agent asks, and nothing further.
|
||||
#[test]
|
||||
fn plan_mode_tints_the_agent_s_question() {
|
||||
@@ -247,7 +264,7 @@ fn the_dock_names_the_mode_and_switches_it() {
|
||||
assert_eq!(buffer[(value, row)].fg, app.theme_styles.text.fg.unwrap());
|
||||
}
|
||||
|
||||
/// A narrower terminal shows the bar instead, which leaves the mode to the composer: its title and
|
||||
/// A narrower terminal shows the bar instead, which leaves the mode to the composer: its button and
|
||||
/// color say it beside the bar already, and a third copy is noise.
|
||||
#[test]
|
||||
fn the_bar_leaves_the_mode_to_the_composer() {
|
||||
@@ -258,7 +275,7 @@ fn the_bar_leaves_the_mode_to_the_composer() {
|
||||
let (text, buffer) = screen(&mut app, 110, 30);
|
||||
let bar = text.lines().last().unwrap();
|
||||
assert!(!bar.contains("plan"), "the bar names the mode: {bar}");
|
||||
let (column, row) = find_on_screen(&text, "plan ─").expect("the composer's title");
|
||||
let (column, row) = mode_badge_at(&text, "plan").expect("the composer's mode button");
|
||||
assert_eq!(buffer[(column, row)].fg, app.theme_styles.mode_plan.fg.unwrap());
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,9 @@ fn command_palette_filters_and_dispatches() {
|
||||
assert!(app.editor.current_input().is_empty(), "palette text must not leak to the editor");
|
||||
}
|
||||
|
||||
/// A finished login opens the picker at its top row and leaves the session's model alone: which
|
||||
/// model to run is the reader's call, and luxe has no favorite to land them on.
|
||||
/// A finished login opens the picker on the provider it signed in to, at its top row, and leaves
|
||||
/// the session's model alone: which model to run is the reader's call, and luxe has no favorite to
|
||||
/// land them on.
|
||||
#[tokio::test]
|
||||
async fn a_finished_login_opens_the_picker_at_the_top_and_chooses_nothing() {
|
||||
use crate::model_picker::{ModelEntry, ModelMenu};
|
||||
@@ -159,6 +160,9 @@ async fn a_finished_login_opens_the_picker_at_the_top_and_chooses_nothing() {
|
||||
assert_eq!(app.status.model, "", "the login picks no model for the reader");
|
||||
assert_eq!(picker(&app).cursor(), 0, "the picker starts at its top");
|
||||
assert!(picker(&app).note().iter().any(|line| line.contains("Choose a model to finish")));
|
||||
assert_eq!(picker(&app).match_count(), 2, "the models of the provider just signed in to");
|
||||
let top = picker(&app).selected_entry().map(ModelEntry::qualified_id);
|
||||
assert_eq!(top.as_deref(), Some("openai/gpt-5.4"));
|
||||
|
||||
// A second provider while one is in use: still the top, and Esc keeps what is running
|
||||
let mut app = app_with(catalog.clone());
|
||||
|
||||
@@ -151,6 +151,9 @@ impl DashboardState {
|
||||
|
||||
/// Once the composer is drawn: cut its bottom edge into the divider over the list, or, with the
|
||||
/// list folded, say on that edge how to open it.
|
||||
///
|
||||
/// The divider runs between plain sides, as the rule over the key hints does: a `├` `┤` pair
|
||||
/// in the accent met a muted rule mid-edge, and read as a frame that changed color halfway.
|
||||
pub fn finish(&self, f: &mut Frame, composer: Rect, theme: &ThemeStyles, border: Style) {
|
||||
if composer.width < 2 || composer.height == 0 {
|
||||
return;
|
||||
@@ -162,8 +165,8 @@ impl DashboardState {
|
||||
let y = composer.bottom() - 1;
|
||||
let buffer = f.buffer_mut();
|
||||
if self.list_shown() {
|
||||
buffer[(composer.x, y)].set_symbol("├").set_style(border);
|
||||
buffer[(composer.right() - 1, y)].set_symbol("┤").set_style(border);
|
||||
buffer[(composer.x, y)].set_symbol("│").set_style(border);
|
||||
buffer[(composer.right() - 1, y)].set_symbol("│").set_style(border);
|
||||
for x in composer.x + 1..composer.right() - 1 {
|
||||
buffer[(x, y)].set_symbol("─").set_style(theme.border_muted);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,32 @@
|
||||
//! Fixture models — the catalog a seeded app picks from, without a provider behind it.
|
||||
|
||||
/// The fixture's active model: reasons, tops out at High — the shape of an extended-thinking Claude.
|
||||
/// A few models for the picker the Configuration surface hands a finished login to.
|
||||
/// A few models for the picker the Configuration surface hands a finished login to, labeled by
|
||||
/// id as the catalog labels anything config does not name.
|
||||
pub(super) fn configurable_models() -> Vec<crate::model_picker::ModelEntry> {
|
||||
[
|
||||
("openai", "gpt-5.6", "GPT-5.6"),
|
||||
("openai", "gpt-5.6-mini", "GPT-5.6 mini"),
|
||||
("anthropic", "claude-sonnet-5", "Claude Sonnet 5"),
|
||||
("lmstudio", "qwen3-coder-30b", "Qwen3 Coder 30B"),
|
||||
("openai", "gpt-5.6"),
|
||||
("openai", "gpt-5.6-mini"),
|
||||
("anthropic", "claude-sonnet-5"),
|
||||
("lmstudio", "qwen3-coder-30b"),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(provider, id, label)| crate::model_picker::ModelEntry {
|
||||
.map(|(provider, id)| crate::model_picker::ModelEntry {
|
||||
info: luxe_core::provider::ModelInfo {
|
||||
r#ref: luxe_core::provider::ModelRef::new(provider, id),
|
||||
display_name: Some(label.into()),
|
||||
context_window: 200_000,
|
||||
..Default::default()
|
||||
},
|
||||
label: label.into(),
|
||||
label: id.into(),
|
||||
configured: true,
|
||||
unverified: false,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The fixture's active model: reasons, tops out at High, the shape of an extended-thinking Claude.
|
||||
pub(super) fn fixture_model() -> luxe_core::provider::ModelInfo {
|
||||
luxe_core::provider::ModelInfo {
|
||||
r#ref: luxe_core::provider::ModelRef::new("lmstudio", "qwen3.8-27b"),
|
||||
display_name: Some("Qwen3.8 27B".into()),
|
||||
reasoning: true,
|
||||
context_window: 262_144,
|
||||
thinking_level_map: std::collections::HashMap::from([
|
||||
|
||||
@@ -172,18 +172,19 @@ icons! {
|
||||
Model => ["\u{f06a9}", "●", "%"],
|
||||
/// Model reasoning
|
||||
Thinking => ["\u{f0335}", "●", "~"],
|
||||
/// Who serves the model, when it has no mark of its own (`md-cloud_outline`)
|
||||
Provider => ["\u{f0163}", "○", "@"],
|
||||
/// Google, serving Gemini (`md-google`)
|
||||
/// Who serves the model, when it has no mark of its own (`md-cloud`), filled like the rest
|
||||
Provider => ["\u{f015f}", "○", "@"],
|
||||
/// Google, as a provider and as the maker of Gemini (`md-google`)
|
||||
ProviderGoogle => ["\u{f02ad}", "○", "@"],
|
||||
/// Microsoft Azure, serving Foundry (`md-microsoft_azure`)
|
||||
ProviderAzure => ["\u{f0805}", "○", "@"],
|
||||
/// Amazon Bedrock (`md-aws`)
|
||||
ProviderAws => ["\u{f0e0f}", "○", "@"],
|
||||
/// OpenAI (`cod-openai`), one of the [`RECENT_BRANDS`]
|
||||
/// OpenAI, as a provider and as the maker of GPT (`cod-openai`), one of the [`RECENT_BRANDS`]
|
||||
ProviderOpenAi => ["\u{ec81}", "○", "@"],
|
||||
/// Anthropic (`cod-claude`), one of the [`RECENT_BRANDS`]
|
||||
ProviderAnthropic => ["\u{ec82}", "○", "@"],
|
||||
/// Claude, Anthropic's models (`cod-claude`), one of the [`RECENT_BRANDS`]. Nerd Fonts has no
|
||||
/// mark for Anthropic itself, so the provider wears the plain one
|
||||
ModelClaude => ["\u{ec82}", "●", "%"],
|
||||
/// GitHub Copilot (`cod-copilot`), one of the [`RECENT_BRANDS`]
|
||||
ProviderCopilot => ["\u{ec1e}", "○", "@"],
|
||||
// === Dashboard menu ===
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn resolve_vocabulary(preference: GlyphStyle) {
|
||||
/// 3.5, Copilot's after 3.0. They stay out of the nerd-tier probe, so an older font keeps every
|
||||
/// other icon, and are drawn only when [`brands`] says a font on the machine has them.
|
||||
pub const RECENT_BRANDS: &[Icon] =
|
||||
&[Icon::ProviderOpenAi, Icon::ProviderAnthropic, Icon::ProviderCopilot];
|
||||
&[Icon::ProviderOpenAi, Icon::ModelClaude, Icon::ProviderCopilot];
|
||||
|
||||
/// Whether the [`RECENT_BRANDS`] may be drawn. Off by default for the same reason as [`BRAILLE`]:
|
||||
/// a test or a site asset draws the same on any machine.
|
||||
|
||||
@@ -79,6 +79,10 @@ pub(crate) struct GuidedReviewWorkspace {
|
||||
pub(crate) feedback_scroll: u16,
|
||||
/// Rows the reading pane can scroll, as last drawn
|
||||
pub(crate) feedback_room: std::cell::Cell<u16>,
|
||||
/// Rows the pull request's description is scrolled down, while it is open; `None` when shut
|
||||
pub(crate) description_scroll: Option<u16>,
|
||||
/// Rows the description can scroll, as last drawn
|
||||
pub(crate) description_room: std::cell::Cell<u16>,
|
||||
/// Whether the narration band (section prose + this change's sentence) is shown above the diff;
|
||||
/// on by default, since the prose is the point, and `z` folds it for one who wants every row.
|
||||
pub(crate) narration_visible: bool,
|
||||
@@ -189,6 +193,8 @@ impl Default for GuidedReviewWorkspace {
|
||||
drawn: std::cell::Cell::new(preview_guard::Drawn::ALL),
|
||||
feedback_scroll: 0,
|
||||
feedback_room: std::cell::Cell::new(0),
|
||||
description_scroll: None,
|
||||
description_room: std::cell::Cell::new(0),
|
||||
narration_visible: true,
|
||||
fold: Fold::default(),
|
||||
noise_details_visible: false,
|
||||
@@ -278,6 +284,23 @@ impl GuidedReviewWorkspace {
|
||||
self.help_visible = !self.help_visible;
|
||||
}
|
||||
|
||||
/// Opens the pull request's whole description at its top, or shuts it.
|
||||
pub(crate) fn toggle_description(&mut self) {
|
||||
self.description_scroll = match self.description_scroll {
|
||||
Some(_) => None,
|
||||
None => Some(0),
|
||||
};
|
||||
}
|
||||
|
||||
/// Scrolls the open description by `rows`, down when positive, within what it was last drawn
|
||||
/// with, so scrolling past the end and back does not cost presses that move nothing.
|
||||
pub(crate) fn scroll_description(&mut self, rows: i32) {
|
||||
let Some(scroll) = self.description_scroll else { return };
|
||||
let room = i32::from(self.description_room.get());
|
||||
let at = i32::from(scroll).saturating_add(rows).clamp(0, room);
|
||||
self.description_scroll = Some(u16::try_from(at).unwrap_or(0));
|
||||
}
|
||||
|
||||
/// Opens the commit preview so the messages are read before history is written.
|
||||
pub(crate) fn open_commit_preview(&mut self) {
|
||||
self.commit_preview = Some(CommitPreview { squash: false, running: false });
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! What a click or a wheel notch means — the target under the pointer resolved to an action.
|
||||
|
||||
use super::{RouteAction, ScrollAction};
|
||||
use crate::app::{App, Msg};
|
||||
use crate::app::{App, Msg, ViewMode};
|
||||
use crate::mouse::MouseTarget;
|
||||
use crossterm::event::KeyEvent;
|
||||
|
||||
@@ -159,8 +159,8 @@ pub(super) fn clicked_target(app: &mut App, target: MouseTarget) -> RouteAction
|
||||
MouseTarget::PeekSelection(action) if app.changes.is_some() => {
|
||||
RouteAction::msg(Msg::PeekSelectionAction(action))
|
||||
}
|
||||
MouseTarget::DockModelRow if app.current_view != crate::app::ViewMode::GuidedReview => {
|
||||
RouteAction::msg(Msg::OpenModelPicker)
|
||||
MouseTarget::DockModelRow(step) if app.current_view != ViewMode::GuidedReview => {
|
||||
RouteAction::msg(Msg::OpenModelPicker(step))
|
||||
}
|
||||
// A click on a message opens whatever it is holding back — a card's output, a collapsed run
|
||||
// of calls, a previewed paste, a reasoning block — and does nothing at all on plain prose,
|
||||
@@ -290,6 +290,13 @@ fn review_footer_message(action: crate::mouse::ReviewFooterAction) -> Msg {
|
||||
/// view's primary surface when the cursor is over unregistered space.
|
||||
pub(super) fn wheel(app: &App, col: u16, row: u16, up: bool) -> RouteAction {
|
||||
use crate::mouse::ScrollRegionId;
|
||||
// The open description is what is being read, wherever the pointer happens to be
|
||||
if app.current_view == crate::app::ViewMode::GuidedReview
|
||||
&& app.guided_review_workspace.description_scroll.is_some()
|
||||
{
|
||||
let step = crate::app::DescriptionStep::Scroll(if up { -3 } else { 3 });
|
||||
return RouteAction::msg(Msg::GuidedReviewDescription(step));
|
||||
}
|
||||
match app.hit.borrow().scroll_at(col, row) {
|
||||
Some(ScrollRegionId::Conversation) => conversation_wheel(app, up),
|
||||
Some(ScrollRegionId::ReviewDiff) => RouteAction::msg(if up {
|
||||
|
||||
@@ -1,29 +1,23 @@
|
||||
//! Model picker — the searchable overlay behind `/model` and the palette's "Change model".
|
||||
//! Model picker — the searchable overlay behind `/model`, the palette's "Change model" and the
|
||||
//! dock's provider and model rows.
|
||||
//!
|
||||
//! Pure state + rendering. The CLI assembles the [`ModelEntry`] catalog (configured models from
|
||||
//! `models.json`, enriched/extended by a cached models.dev catalog); this module only filters,
|
||||
//! renders, and returns the chosen [`ModelInfo`]. Selecting one sends `Action::SetModel`.
|
||||
//!
|
||||
//! Two steps, so choosing who serves a model and choosing the model are separate questions. The
|
||||
//! model step lists the models of the provider in use, and `tab` widens it to every provider. The
|
||||
//! provider step (`←`, or the dock's provider row) lists providers: choosing one that serves the
|
||||
//! model in use switches to it there, and any other opens the model step on its models.
|
||||
|
||||
use crate::glyphs::Icon;
|
||||
use crate::picker::PickerNav;
|
||||
use crate::theme::styles::ThemeStyles;
|
||||
use crate::widgets::truncate_end as truncate;
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||
use luxe_core::provider::{ModelInfo, ModelRef};
|
||||
use ratatui::{
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, Clear, List, ListItem, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
mod meta;
|
||||
use meta::meta_suffix;
|
||||
|
||||
/// Panel label, shared by the rendered title and the modal-width computation.
|
||||
const TITLE: &str = "Select model";
|
||||
mod providers;
|
||||
mod render;
|
||||
use providers::ProviderStep;
|
||||
|
||||
/// The model catalog + active model the TUI runner installs at startup.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -77,7 +71,7 @@ impl ModelSources {
|
||||
pub struct ModelEntry {
|
||||
/// Full model info sent to the engine on selection.
|
||||
pub info: ModelInfo,
|
||||
/// Display name (models.dev name when known, else the model id).
|
||||
/// What the row calls it: the name the user gave it in config, else the model id.
|
||||
pub label: String,
|
||||
/// Whether this model is declared in the user's config (vs. a models.dev browse extra).
|
||||
pub configured: bool,
|
||||
@@ -95,6 +89,15 @@ impl ModelEntry {
|
||||
}
|
||||
}
|
||||
|
||||
/// Which step the model picker opens on.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PickerStart {
|
||||
/// The providers, for the dock's provider row
|
||||
Providers,
|
||||
/// The models of the provider in use, for everything else
|
||||
Models,
|
||||
}
|
||||
|
||||
/// Outcome of a model-picker keypress.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum ModelPickerOutcome {
|
||||
@@ -109,24 +112,73 @@ pub enum ModelPickerOutcome {
|
||||
/// Pure state machine for the model picker overlay.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ModelPickerState {
|
||||
/// Every model in the catalog, whoever serves it
|
||||
all: Vec<ModelEntry>,
|
||||
/// The models on show: `all`, or the scoped provider's share of it
|
||||
items: Vec<ModelEntry>,
|
||||
nav: PickerNav,
|
||||
active: Option<ModelRef>,
|
||||
note: Vec<String>,
|
||||
/// The provider the model step is about, when it serves anything
|
||||
scope: Option<String>,
|
||||
/// Whether `tab` widened the model step past [`Self::scope`] to every provider
|
||||
widened: bool,
|
||||
/// The provider step, while it is the one showing
|
||||
providers: Option<ProviderStep>,
|
||||
/// Whether the model step was reached from the provider step, which `esc` returns to
|
||||
from_providers: bool,
|
||||
}
|
||||
|
||||
impl ModelPickerState {
|
||||
/// Open the picker over a catalog, marking `active` as the current model.
|
||||
///
|
||||
/// Opens on every model; [`Self::starting_on`] narrows it to the provider in use, or opens on
|
||||
/// the providers.
|
||||
pub fn open(items: Vec<ModelEntry>, active: Option<ModelRef>) -> Self {
|
||||
let mut nav = PickerNav::new(items.len());
|
||||
let nav = PickerNav::new(items.len());
|
||||
let (all, note) = (items.clone(), Vec::new());
|
||||
let mut picker = Self {
|
||||
all,
|
||||
items,
|
||||
nav,
|
||||
active,
|
||||
note,
|
||||
scope: None,
|
||||
widened: false,
|
||||
providers: None,
|
||||
from_providers: false,
|
||||
};
|
||||
// Start on the active model when it's in the list, so the current choice is preselected.
|
||||
// Nothing is filtered yet, so an item's index is also its row.
|
||||
let active = picker.active.as_ref();
|
||||
if let Some(row) =
|
||||
active.as_ref().and_then(|it| items.iter().position(|entry| &entry.info.r#ref == it))
|
||||
active.and_then(|it| picker.items.iter().position(|entry| &entry.info.r#ref == it))
|
||||
{
|
||||
nav.select(row);
|
||||
picker.nav.select(row);
|
||||
}
|
||||
Self { items, nav, active, note: Vec::new() }
|
||||
picker
|
||||
}
|
||||
|
||||
/// Moves to the step `start` names: the provider in use's models, or the providers.
|
||||
pub fn starting_on(mut self, start: PickerStart) -> Self {
|
||||
let provider = self.active.as_ref().map(|active| active.provider.clone());
|
||||
match start {
|
||||
PickerStart::Models => self.show(provider, false),
|
||||
PickerStart::Providers => self.show_providers(),
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Moves to `provider`'s models with the cursor on the first, for a login that just reached
|
||||
/// them.
|
||||
///
|
||||
/// Those are the models the reader signed in for, whichever model is in use. The top row,
|
||||
/// because a cursor resting on one reads as luxe recommending it. A local server's models
|
||||
/// arrive when it answers, so until then the list is everything and [`Self::refresh`] narrows it.
|
||||
pub fn about_provider(mut self, provider: &str) -> Self {
|
||||
self.show(Some(provider.to_owned()), false);
|
||||
self.nav.select(0);
|
||||
self
|
||||
}
|
||||
|
||||
/// Opens with something to say first — what a login landed, and which model it left you on.
|
||||
@@ -155,45 +207,147 @@ impl ModelPickerState {
|
||||
|
||||
/// Handle a key event. Returns the outcome (select/close/consumed).
|
||||
pub fn on_key(&mut self, key: &KeyEvent) -> ModelPickerOutcome {
|
||||
let on_models = self.providers.is_none();
|
||||
let ctrl = key.modifiers.contains(KeyModifiers::CONTROL);
|
||||
match key.code {
|
||||
KeyCode::Esc => ModelPickerOutcome::Close,
|
||||
KeyCode::Enter => match self.selected_entry() {
|
||||
Some(entry) => ModelPickerOutcome::Select(Box::new(entry.info.clone())),
|
||||
None => ModelPickerOutcome::Consumed,
|
||||
},
|
||||
KeyCode::Up => {
|
||||
self.move_up();
|
||||
ModelPickerOutcome::Consumed
|
||||
}
|
||||
KeyCode::Down => {
|
||||
self.move_down();
|
||||
ModelPickerOutcome::Consumed
|
||||
}
|
||||
KeyCode::Char('p') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
self.move_up();
|
||||
ModelPickerOutcome::Consumed
|
||||
}
|
||||
KeyCode::Char('n') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
self.move_down();
|
||||
ModelPickerOutcome::Consumed
|
||||
}
|
||||
KeyCode::Esc => return self.escape(),
|
||||
KeyCode::Enter => return self.enter(),
|
||||
KeyCode::Right if !on_models => return self.enter(),
|
||||
KeyCode::Tab if on_models => self.widen(),
|
||||
KeyCode::Left if on_models => self.show_providers(),
|
||||
KeyCode::Up => self.nav_mut().move_up(),
|
||||
KeyCode::Char('p') if ctrl => self.nav_mut().move_up(),
|
||||
KeyCode::Down => self.nav_mut().move_down(),
|
||||
KeyCode::Char('n') if ctrl => self.nav_mut().move_down(),
|
||||
// Everything else is swallowed: the picker is modal, so a stray key must not reach the
|
||||
// composer behind it
|
||||
_ => {
|
||||
self.nav.edit_query(key, || searchable(&self.items));
|
||||
// Everything else is swallowed: the picker is modal, so a stray key must not
|
||||
// reach the composer behind it.
|
||||
ModelPickerOutcome::Consumed
|
||||
let rows = self.searchable_rows();
|
||||
self.nav_mut().edit_query(key, || rows);
|
||||
}
|
||||
}
|
||||
ModelPickerOutcome::Consumed
|
||||
}
|
||||
|
||||
/// `esc`: back to the providers when they led here, else close.
|
||||
fn escape(&mut self) -> ModelPickerOutcome {
|
||||
if self.providers.is_some() || !self.from_providers {
|
||||
return ModelPickerOutcome::Close;
|
||||
}
|
||||
self.show_providers();
|
||||
ModelPickerOutcome::Consumed
|
||||
}
|
||||
|
||||
/// `enter`: switch to the model under the cursor, or choose the provider under it.
|
||||
fn enter(&mut self) -> ModelPickerOutcome {
|
||||
if self.providers.is_some() {
|
||||
return self.choose_provider();
|
||||
}
|
||||
match self.selected_entry() {
|
||||
Some(entry) => ModelPickerOutcome::Select(Box::new(entry.info.clone())),
|
||||
None => ModelPickerOutcome::Consumed,
|
||||
}
|
||||
}
|
||||
|
||||
/// Chooses the provider under the cursor.
|
||||
///
|
||||
/// Another provider serving the model in use switches to it there and closes, since the model
|
||||
/// was never the question. The provider in use, or one without that model, opens on its
|
||||
/// models for the reader to choose from.
|
||||
fn choose_provider(&mut self) -> ModelPickerOutcome {
|
||||
let chosen = self.providers.as_ref().and_then(ProviderStep::selected);
|
||||
let Some(provider) = chosen.map(|row| row.id.clone()) else {
|
||||
return ModelPickerOutcome::Consumed;
|
||||
};
|
||||
if let Some(same) = self.same_model_from(&provider) {
|
||||
return ModelPickerOutcome::Select(Box::new(same.info.clone()));
|
||||
}
|
||||
self.providers = None;
|
||||
self.from_providers = true;
|
||||
self.show(Some(provider), false);
|
||||
ModelPickerOutcome::Consumed
|
||||
}
|
||||
|
||||
/// The model in use as `provider` serves it, when that is a different provider and it does.
|
||||
fn same_model_from(&self, provider: &str) -> Option<&ModelEntry> {
|
||||
let active = self.active.as_ref().filter(|active| active.provider != provider)?;
|
||||
self.all.iter().find(|entry| entry.info.r#ref == ModelRef::new(provider, &active.id))
|
||||
}
|
||||
|
||||
/// `tab`: every provider's models, or back to the one the step is about.
|
||||
fn widen(&mut self) {
|
||||
let widened = !self.widened;
|
||||
self.show(self.scope.clone(), widened);
|
||||
}
|
||||
|
||||
/// Opens the provider step, on the provider the model step is about.
|
||||
fn show_providers(&mut self) {
|
||||
let current =
|
||||
self.scope.clone().or_else(|| self.active.as_ref().map(|it| it.provider.clone()));
|
||||
self.providers = Some(ProviderStep::new(&self.all, current.as_deref()));
|
||||
}
|
||||
|
||||
/// Shows the model step about `scope`, widened or not, keeping the query and the cursor's model
|
||||
/// where they still apply.
|
||||
///
|
||||
/// The scope is kept even while it serves nothing, which is everything on show until a
|
||||
/// refresh brings its models.
|
||||
fn show(&mut self, scope: Option<String>, widened: bool) {
|
||||
self.scope = scope;
|
||||
self.widened = widened;
|
||||
let items = match self.scoped_provider() {
|
||||
Some(provider) => self
|
||||
.all
|
||||
.iter()
|
||||
.filter(|entry| entry.info.r#ref.provider == provider)
|
||||
.cloned()
|
||||
.collect(),
|
||||
None => self.all.clone(),
|
||||
};
|
||||
self.replace_items(items);
|
||||
}
|
||||
|
||||
/// The provider the model list is narrowed to right now, if it is.
|
||||
fn scoped_provider(&self) -> Option<&str> {
|
||||
self.served_scope().filter(|_| !self.widened)
|
||||
}
|
||||
|
||||
/// The provider the model step is about, while it serves anything.
|
||||
fn served_scope(&self) -> Option<&str> {
|
||||
let scope = self.scope.as_deref()?;
|
||||
self.all.iter().any(|entry| entry.info.r#ref.provider == scope).then_some(scope)
|
||||
}
|
||||
|
||||
/// The navigation of the step showing.
|
||||
fn nav(&self) -> &PickerNav {
|
||||
self.providers.as_ref().map_or(&self.nav, |step| &step.nav)
|
||||
}
|
||||
|
||||
/// The navigation of the step showing, to move.
|
||||
fn nav_mut(&mut self) -> &mut PickerNav {
|
||||
match self.providers.as_mut() {
|
||||
Some(step) => &mut step.nav,
|
||||
None => &mut self.nav,
|
||||
}
|
||||
}
|
||||
|
||||
/// What a reader can type at the rows of the step showing.
|
||||
fn searchable_rows(&self) -> Vec<String> {
|
||||
match &self.providers {
|
||||
Some(step) => step.searchable(),
|
||||
None => searchable(&self.items),
|
||||
}
|
||||
}
|
||||
|
||||
/// Moves the selection to `filtered_index` (a mouse click on that row); clamped to range.
|
||||
pub fn select(&mut self, filtered_index: usize) {
|
||||
self.nav.select(filtered_index);
|
||||
self.nav_mut().select(filtered_index);
|
||||
}
|
||||
|
||||
/// Filters by pasted text, the way typing it would.
|
||||
pub fn paste(&mut self, text: &str) {
|
||||
self.nav.paste_query(text, &searchable(&self.items));
|
||||
let rows = self.searchable_rows();
|
||||
self.nav_mut().paste_query(text, &rows);
|
||||
}
|
||||
|
||||
/// Swap in a freshly-built catalog without disturbing the reader.
|
||||
@@ -202,270 +356,57 @@ impl ModelPickerState {
|
||||
/// had chosen, so the row is re-found by id and the query survives. A model that has gone
|
||||
/// away takes the cursor to the top, which is the only honest answer left.
|
||||
pub fn refresh(&mut self, items: Vec<ModelEntry>) {
|
||||
self.all = items;
|
||||
self.show(self.scope.clone(), self.widened);
|
||||
if let Some(step) = &self.providers {
|
||||
let current = step.selected().map(|row| row.id.clone());
|
||||
self.providers = Some(ProviderStep::new(&self.all, current.as_deref()));
|
||||
}
|
||||
}
|
||||
|
||||
/// Replaces the models on show, keeping the query and the model under the cursor.
|
||||
fn replace_items(&mut self, items: Vec<ModelEntry>) {
|
||||
let chosen = self.selected_entry().map(ModelEntry::qualified_id);
|
||||
let query = self.nav.query().to_string();
|
||||
self.items = items;
|
||||
self.nav = PickerNav::new(self.items.len());
|
||||
self.nav.set_query(&query, &searchable(&self.items));
|
||||
if let Some(chosen) = chosen {
|
||||
if let Some(row) = self
|
||||
.nav
|
||||
.filtered_indices()
|
||||
.iter()
|
||||
.position(|index| self.items[*index].qualified_id() == chosen)
|
||||
{
|
||||
self.nav.select(row);
|
||||
}
|
||||
let row = chosen.and_then(|chosen| {
|
||||
let filtered = self.nav.filtered_indices();
|
||||
filtered.iter().position(|index| self.items[*index].qualified_id() == chosen)
|
||||
});
|
||||
if let Some(row) = row {
|
||||
self.nav.select(row);
|
||||
}
|
||||
}
|
||||
|
||||
/// The currently highlighted entry, if any row matches.
|
||||
/// The highlighted model, if any row of the model step matches.
|
||||
pub fn selected_entry(&self) -> Option<&ModelEntry> {
|
||||
self.items.get(self.nav.selected_item_index()?)
|
||||
}
|
||||
|
||||
/// Whether the provider step is the one showing.
|
||||
pub fn choosing_provider(&self) -> bool {
|
||||
self.providers.is_some()
|
||||
}
|
||||
|
||||
/// The cursor's row among the visible matches.
|
||||
pub(crate) fn cursor(&self) -> usize {
|
||||
self.nav.selected()
|
||||
self.nav().selected()
|
||||
}
|
||||
|
||||
/// Number of visible matches.
|
||||
pub fn match_count(&self) -> usize {
|
||||
self.nav.match_count()
|
||||
self.nav().match_count()
|
||||
}
|
||||
|
||||
/// The current search query.
|
||||
pub fn query(&self) -> &str {
|
||||
self.nav.query()
|
||||
}
|
||||
|
||||
fn move_up(&mut self) {
|
||||
self.nav.move_up();
|
||||
}
|
||||
|
||||
fn move_down(&mut self) {
|
||||
self.nav.move_down();
|
||||
}
|
||||
|
||||
/// Terminal-cell width for the picker modal: fit the widest model row (cursor + active
|
||||
/// marker + label + qualified id + metadata), the footer, and the border title, then add
|
||||
/// borders + one right-pad cell. Computed over ALL items so the width is query-stable.
|
||||
///
|
||||
/// The row's own frame is part of the fit rather than a constant beside it: a modal sized to
|
||||
/// the words alone clips the closing cap off its widest row the moment the frame changes.
|
||||
fn content_modal_width(&self, available: u16) -> u16 {
|
||||
let row_width = self
|
||||
.items
|
||||
.iter()
|
||||
.map(|entry| {
|
||||
crate::widgets::SELECTION_FRAME
|
||||
+ 2
|
||||
+ 2
|
||||
+ UnicodeWidthStr::width(entry.label.as_str())
|
||||
+ 2
|
||||
+ UnicodeWidthStr::width(entry.qualified_id().as_str())
|
||||
+ UnicodeWidthStr::width(meta_suffix(entry).as_str())
|
||||
})
|
||||
.max()
|
||||
.unwrap_or(0);
|
||||
let total = self.items.len();
|
||||
let footer_width = UnicodeWidthStr::width(
|
||||
format!(" {total}/{total} · enter switch · ↑/↓ choose · esc close ").as_str(),
|
||||
);
|
||||
let title_width = crate::widgets::panel_title_width(Icon::Model.glyph(), TITLE);
|
||||
// The lead space each note line is drawn with comes out of the same three cells the
|
||||
// borders take below, so the text's own width is the whole of what it asks for.
|
||||
let note_width =
|
||||
self.note.iter().map(|line| UnicodeWidthStr::width(line.as_str())).max().unwrap_or(0);
|
||||
let natural = row_width.max(footer_width).max(title_width).max(note_width) as u16;
|
||||
let max_width = available.saturating_sub(4).max(30);
|
||||
natural.saturating_add(3).clamp(30, max_width)
|
||||
}
|
||||
|
||||
/// Rows the picker wants in `area`: its list, its chrome, and a floor so it never reads as a
|
||||
/// scrap of a list.
|
||||
pub(crate) fn desired_height(&self, area: Rect) -> u16 {
|
||||
// Borders, the search field and its rule, the rows, the footer
|
||||
let desired = self.nav.filtered_indices().len().min(14) as u16
|
||||
+ 4
|
||||
+ crate::widgets::FOOTER_ROWS
|
||||
+ self.note_rows();
|
||||
desired.max(10 + self.note_rows()).min(area.height.saturating_sub(2))
|
||||
}
|
||||
|
||||
/// Renders the picker as a centered modal over the conversation.
|
||||
pub fn view(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
theme: &ThemeStyles,
|
||||
hit: &std::cell::RefCell<crate::mouse::HitRegions>,
|
||||
) {
|
||||
if area.width < 30 || area.height < 8 {
|
||||
return;
|
||||
}
|
||||
// Fit the widest model row (stable across queries) + one right-pad cell, rather than a
|
||||
// fixed-width box with trailing dead space.
|
||||
let width = self.content_modal_width(area.width);
|
||||
let height = self.desired_height(area);
|
||||
self.view_in(frame, crate::widgets::centered_rect(width, height, area), theme, hit);
|
||||
}
|
||||
|
||||
/// Renders the picker's panel at exactly `panel`, for a surface that has already placed it.
|
||||
///
|
||||
/// The Configuration surface hands a finished login straight to this, in the region the wizard
|
||||
/// was just in — "now pick a model" is the last step of setting one up, not a new screen.
|
||||
pub(crate) fn view_in(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
panel: Rect,
|
||||
theme: &ThemeStyles,
|
||||
hit: &std::cell::RefCell<crate::mouse::HitRegions>,
|
||||
) {
|
||||
frame.render_widget(Clear, panel);
|
||||
|
||||
let block = crate::widgets::titled_panel(Icon::Model.glyph(), TITLE, theme);
|
||||
let inner = block.inner(panel);
|
||||
frame.render_widget(block, panel);
|
||||
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
Constraint::Length(self.note_rows()),
|
||||
Constraint::Length(2),
|
||||
Constraint::Min(2),
|
||||
Constraint::Length(crate::widgets::FOOTER_ROWS),
|
||||
])
|
||||
.split(inner);
|
||||
|
||||
if !self.note.is_empty() {
|
||||
let room = usize::from(chunks[0].width).saturating_sub(1);
|
||||
let lines: Vec<Line> = self
|
||||
.note
|
||||
.iter()
|
||||
.map(|line| {
|
||||
Line::from(Span::styled(format!(" {}", truncate(line, room)), theme.muted))
|
||||
})
|
||||
.collect();
|
||||
frame.render_widget(Paragraph::new(lines), chunks[0]);
|
||||
}
|
||||
|
||||
let search = Paragraph::new(Line::from(vec![
|
||||
Span::styled(" Search: ", theme.accent.add_modifier(Modifier::BOLD)),
|
||||
Span::styled(self.query().to_string(), theme.text),
|
||||
]))
|
||||
.block(Block::default().borders(Borders::BOTTOM).border_style(theme.border_muted));
|
||||
frame.render_widget(search, chunks[1]);
|
||||
let cursor_x = chunks[1]
|
||||
.x
|
||||
.saturating_add(9)
|
||||
.saturating_add(UnicodeWidthStr::width(self.query()) as u16)
|
||||
.min(chunks[1].right().saturating_sub(1));
|
||||
frame.set_cursor_position((cursor_x, chunks[1].y));
|
||||
|
||||
if self.nav.filtered_indices().is_empty() {
|
||||
frame
|
||||
.render_widget(Paragraph::new(" No matching models").style(theme.muted), chunks[2]);
|
||||
} else {
|
||||
self.render_rows(frame, chunks[2], theme, hit);
|
||||
}
|
||||
|
||||
let count = format!(
|
||||
"{}/{}",
|
||||
self.nav.selected().saturating_add(1).min(self.nav.filtered_indices().len()),
|
||||
self.nav.filtered_indices().len()
|
||||
);
|
||||
crate::widgets::render_footer(
|
||||
frame,
|
||||
chunks[3],
|
||||
"enter switch · ↑/↓ choose · esc close",
|
||||
Some(&count),
|
||||
theme,
|
||||
);
|
||||
}
|
||||
|
||||
fn render_rows(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
theme: &ThemeStyles,
|
||||
hit: &std::cell::RefCell<crate::mouse::HitRegions>,
|
||||
) {
|
||||
let capacity = area.height as usize;
|
||||
let start = self
|
||||
.nav
|
||||
.selected()
|
||||
.saturating_add(1)
|
||||
.saturating_sub(capacity)
|
||||
.min(self.nav.filtered_indices().len().saturating_sub(capacity));
|
||||
let total = self.nav.filtered_indices().len();
|
||||
let end = start.saturating_add(capacity).min(total);
|
||||
let width = crate::widgets::list_rows_width(area.width, total, area.height);
|
||||
let available = width.saturating_sub(2 + crate::widgets::SELECTION_FRAME as u16) as usize;
|
||||
{
|
||||
let mut regions = hit.borrow_mut();
|
||||
for offset in 0..end.saturating_sub(start) {
|
||||
let row_y = area.y.saturating_add(offset as u16);
|
||||
regions.push(
|
||||
Rect::new(area.x, row_y, width, 1),
|
||||
crate::mouse::MouseTarget::ModelRow(start + offset),
|
||||
);
|
||||
}
|
||||
let list = crate::mouse::OverlayList::Models;
|
||||
crate::widgets::list_scrollbar(frame, &mut regions, area, list, (start, total), theme);
|
||||
}
|
||||
|
||||
let items: Vec<ListItem> = self.nav.filtered_indices()[start..end]
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(offset, index)| {
|
||||
let entry = &self.items[*index];
|
||||
let selected = start + offset == self.nav.selected();
|
||||
let is_active = self.active.as_ref() == Some(&entry.info.r#ref);
|
||||
let background = if selected { theme.selected_bg } else { Style::default() };
|
||||
|
||||
let cursor = crate::glyphs::Mark::Cursor.gutter(selected);
|
||||
let marker = if is_active { "● " } else { " " };
|
||||
let meta_text = meta_suffix(entry);
|
||||
|
||||
let label = truncate(&entry.label, available.saturating_sub(marker.len() + 3));
|
||||
// The id, then what it is, in whatever the label leaves: a row that ran past the
|
||||
// frame was cut by it mid-word, and took the selection's closing cap with it
|
||||
let room = available
|
||||
.saturating_sub(UnicodeWidthStr::width(marker))
|
||||
.saturating_sub(UnicodeWidthStr::width(label.as_str()));
|
||||
let id = truncate(&format!(" {}", entry.qualified_id()), room);
|
||||
let meta_text =
|
||||
truncate(&meta_text, room.saturating_sub(UnicodeWidthStr::width(id.as_str())));
|
||||
let mut spans = vec![
|
||||
Span::styled(cursor, theme.accent_on(selected)),
|
||||
Span::styled(
|
||||
marker,
|
||||
if is_active {
|
||||
theme.success.patch(background)
|
||||
} else {
|
||||
theme.muted.patch(background)
|
||||
},
|
||||
),
|
||||
Span::styled(label, theme.label_on(selected)),
|
||||
Span::styled(id, theme.muted.patch(background)),
|
||||
];
|
||||
if !meta_text.is_empty() {
|
||||
spans.push(Span::styled(meta_text, theme.secondary_on(selected)));
|
||||
}
|
||||
ListItem::new(crate::widgets::selection_row(
|
||||
spans,
|
||||
usize::from(width),
|
||||
selected,
|
||||
theme,
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
frame.render_widget(List::new(items), Rect { width, ..area });
|
||||
self.nav().query()
|
||||
}
|
||||
}
|
||||
|
||||
/// What a reader can type at a model row: its provider-qualified id and its display label.
|
||||
/// What a reader can type at a model row: its provider-qualified id and its label.
|
||||
fn searchable(items: &[ModelEntry]) -> Vec<String> {
|
||||
items.iter().map(|entry| format!("{} {}", entry.qualified_id(), entry.label)).collect()
|
||||
}
|
||||
|
||||
54
crates/luxe-tui/src/model_picker/providers.rs
Normal file
54
crates/luxe-tui/src/model_picker/providers.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
//! Provider step — the list of providers the model picker opens on from the dock's provider row.
|
||||
//!
|
||||
//! Choosing a provider keeps the model in use when that provider serves it too, and otherwise moves
|
||||
//! on to that provider's models. [`super::ModelPickerState`] makes that call; this holds the list
|
||||
//! and its cursor.
|
||||
|
||||
use super::ModelEntry;
|
||||
use crate::picker::PickerNav;
|
||||
|
||||
/// One provider row: its id and how many of the catalog's models it serves.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(super) struct ProviderRow {
|
||||
pub(super) id: String,
|
||||
pub(super) models: usize,
|
||||
}
|
||||
|
||||
/// The provider list and its cursor.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(super) struct ProviderStep {
|
||||
pub(super) rows: Vec<ProviderRow>,
|
||||
pub(super) nav: PickerNav,
|
||||
}
|
||||
|
||||
impl ProviderStep {
|
||||
/// Every provider serving one of `models`, with the cursor on `current` when it is among them.
|
||||
pub(super) fn new(models: &[ModelEntry], current: Option<&str>) -> Self {
|
||||
let rows = provider_rows(models);
|
||||
let mut nav = PickerNav::new(rows.len());
|
||||
if let Some(row) = current.and_then(|id| rows.iter().position(|row| row.id == id)) {
|
||||
nav.select(row);
|
||||
}
|
||||
Self { rows, nav }
|
||||
}
|
||||
|
||||
/// The provider under the cursor, if any row matches the query.
|
||||
pub(super) fn selected(&self) -> Option<&ProviderRow> {
|
||||
self.rows.get(self.nav.selected_item_index()?)
|
||||
}
|
||||
|
||||
/// What a reader can type at a provider row: its id.
|
||||
pub(super) fn searchable(&self) -> Vec<String> {
|
||||
self.rows.iter().map(|row| row.id.clone()).collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// One row per provider, by id. The catalog lists providers in a hash set's order, which means
|
||||
/// nothing, so a reader finds one where the alphabet says it is.
|
||||
fn provider_rows(models: &[ModelEntry]) -> Vec<ProviderRow> {
|
||||
let mut counts = std::collections::BTreeMap::<&str, usize>::new();
|
||||
for entry in models {
|
||||
*counts.entry(entry.info.r#ref.provider.as_str()).or_default() += 1;
|
||||
}
|
||||
counts.into_iter().map(|(id, models)| ProviderRow { id: id.to_owned(), models }).collect()
|
||||
}
|
||||
364
crates/luxe-tui/src/model_picker/render.rs
Normal file
364
crates/luxe-tui/src/model_picker/render.rs
Normal file
@@ -0,0 +1,364 @@
|
||||
//! Model picker drawing — the panel, its search line, the rows of whichever step is showing, and
|
||||
//! the footer that says what `tab` and `←` do from here.
|
||||
|
||||
use super::meta::meta_suffix;
|
||||
use super::providers::ProviderRow;
|
||||
use super::{ModelEntry, ModelPickerState};
|
||||
use crate::glyphs::{icon_label, Icon};
|
||||
use crate::theme::styles::ThemeStyles;
|
||||
use crate::widgets::truncate_end as truncate;
|
||||
use ratatui::{
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, Clear, List, ListItem, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
/// Panel label for the model step, and the start of its title when scoped to a provider.
|
||||
const MODEL_TITLE: &str = "Select model";
|
||||
|
||||
/// Panel label for the provider step.
|
||||
const PROVIDER_TITLE: &str = "Select provider";
|
||||
|
||||
impl ModelPickerState {
|
||||
/// The panel's glyph and title: the step showing, and which provider a scoped list is from.
|
||||
fn title(&self) -> (&'static str, String) {
|
||||
if self.providers.is_some() {
|
||||
return (Icon::Provider.glyph(), PROVIDER_TITLE.to_owned());
|
||||
}
|
||||
match self.scoped_provider() {
|
||||
Some(provider) => (Icon::Model.glyph(), format!("{MODEL_TITLE} \u{b7} {provider}")),
|
||||
None => (Icon::Model.glyph(), MODEL_TITLE.to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
/// The keys along the bottom edge, for the step showing.
|
||||
fn hint(&self) -> String {
|
||||
if self.providers.is_some() {
|
||||
return "enter choose \u{b7} \u{2191}/\u{2193} move \u{b7} esc close".to_owned();
|
||||
}
|
||||
let widen = match (self.served_scope(), self.widened) {
|
||||
(Some(provider), true) => format!("tab only {provider} \u{b7} "),
|
||||
(Some(_), false) => "tab every provider \u{b7} ".to_owned(),
|
||||
(None, _) => String::new(),
|
||||
};
|
||||
let esc = if self.from_providers { "esc back" } else { "esc close" };
|
||||
format!("enter switch \u{b7} {widen}\u{2190} providers \u{b7} {esc}")
|
||||
}
|
||||
|
||||
/// What a model row says after its label: who serves it while the list mixes providers, and
|
||||
/// its id when a configured name stands in for it.
|
||||
fn subtitle(&self, entry: &ModelEntry) -> String {
|
||||
let id = &entry.info.r#ref.id;
|
||||
let named = entry.label != *id;
|
||||
match (self.scoped_provider().is_none(), named) {
|
||||
(true, true) => format!(" {}", entry.qualified_id()),
|
||||
(true, false) => format!(" {}", entry.info.r#ref.provider),
|
||||
(false, true) => format!(" {id}"),
|
||||
(false, false) => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Terminal-cell width for the picker modal: fit the widest row of either step, the footer,
|
||||
/// the title and the note, then add borders and one right-pad cell. Measured over every row so
|
||||
/// the width holds still while a query narrows the list or the reader changes step.
|
||||
///
|
||||
/// The row's own frame is part of the fit rather than a constant beside it: a modal sized to
|
||||
/// the words alone clips the closing cap off its widest row the moment the frame changes.
|
||||
pub(super) fn content_modal_width(&self, available: u16) -> u16 {
|
||||
let chrome = crate::widgets::SELECTION_FRAME + 2 + 2;
|
||||
let model_rows = self.all.iter().map(|entry| {
|
||||
let words = entry.label.width() + entry.qualified_id().width() + 2;
|
||||
chrome + words + meta_suffix(entry).width()
|
||||
});
|
||||
let provider_rows = self.provider_step_rows().into_iter().map(|row| chrome + row.width());
|
||||
let row_width = model_rows.chain(provider_rows).max().unwrap_or(0);
|
||||
let total = self.all.len();
|
||||
let footer_width = format!(" {total}/{total} \u{b7} {} ", self.hint()).width();
|
||||
let (glyph, title) = self.title();
|
||||
let title_width = crate::widgets::panel_title_width(glyph, &title);
|
||||
// The lead space each note line is drawn with comes out of the same three cells the
|
||||
// borders take below, so the text's own width is the whole of what it asks for.
|
||||
let note_width = self.note.iter().map(|line| line.width()).max().unwrap_or(0);
|
||||
let natural = row_width.max(footer_width).max(title_width).max(note_width) as u16;
|
||||
let max_width = available.saturating_sub(4).max(30);
|
||||
natural.saturating_add(3).clamp(30, max_width)
|
||||
}
|
||||
|
||||
/// Every provider row as drawn, for measuring; the step need not be showing.
|
||||
fn provider_step_rows(&self) -> Vec<String> {
|
||||
let step = super::providers::ProviderStep::new(&self.all, None);
|
||||
step.rows.iter().map(provider_text).collect()
|
||||
}
|
||||
|
||||
/// Rows the picker wants in `area`: its list, its chrome, and a floor so it never reads as a
|
||||
/// scrap of a list.
|
||||
pub(crate) fn desired_height(&self, area: Rect) -> u16 {
|
||||
// Borders, the search field and its rule, the rows, the footer
|
||||
let desired =
|
||||
self.match_count().min(14) as u16 + 4 + crate::widgets::FOOTER_ROWS + self.note_rows();
|
||||
desired.max(10 + self.note_rows()).min(area.height.saturating_sub(2))
|
||||
}
|
||||
|
||||
/// Renders the picker as a centered modal over the conversation.
|
||||
pub fn view(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
theme: &ThemeStyles,
|
||||
hit: &std::cell::RefCell<crate::mouse::HitRegions>,
|
||||
) {
|
||||
if area.width < 30 || area.height < 8 {
|
||||
return;
|
||||
}
|
||||
// Fit the widest row (stable across queries) + one right-pad cell, rather than a
|
||||
// fixed-width box with trailing dead space.
|
||||
let width = self.content_modal_width(area.width);
|
||||
let height = self.desired_height(area);
|
||||
self.view_in(frame, crate::widgets::centered_rect(width, height, area), theme, hit);
|
||||
}
|
||||
|
||||
/// Renders the picker's panel at exactly `panel`, for a surface that has already placed it.
|
||||
///
|
||||
/// The Configuration surface hands a finished login straight to this, in the region the wizard
|
||||
/// was just in: "now pick a model" is the last step of setting one up, not a new screen.
|
||||
pub(crate) fn view_in(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
panel: Rect,
|
||||
theme: &ThemeStyles,
|
||||
hit: &std::cell::RefCell<crate::mouse::HitRegions>,
|
||||
) {
|
||||
frame.render_widget(Clear, panel);
|
||||
let (glyph, title) = self.title();
|
||||
let block = crate::widgets::titled_panel(glyph, &title, theme);
|
||||
let chunks = self.sections(block.inner(panel));
|
||||
frame.render_widget(block, panel);
|
||||
self.render_note(frame, chunks[0], theme);
|
||||
self.render_search(frame, chunks[1], theme);
|
||||
self.render_list(frame, chunks[2], theme, hit);
|
||||
let count = self.position_label();
|
||||
crate::widgets::render_footer(frame, chunks[3], &self.hint(), Some(&count), theme);
|
||||
}
|
||||
|
||||
/// The panel's inside, top to bottom: the note, the search line, the list and the footer.
|
||||
fn sections(&self, inner: Rect) -> std::rc::Rc<[Rect]> {
|
||||
Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
Constraint::Length(self.note_rows()),
|
||||
Constraint::Length(2),
|
||||
Constraint::Min(2),
|
||||
Constraint::Length(crate::widgets::FOOTER_ROWS),
|
||||
])
|
||||
.split(inner)
|
||||
}
|
||||
|
||||
/// `3/12`: the cursor's row among the matches, for the footer.
|
||||
fn position_label(&self) -> String {
|
||||
let total = self.match_count();
|
||||
format!("{}/{total}", self.cursor().saturating_add(1).min(total))
|
||||
}
|
||||
|
||||
/// What a login landed, above the list, when there is something to say.
|
||||
fn render_note(&self, frame: &mut Frame, area: Rect, theme: &ThemeStyles) {
|
||||
if self.note.is_empty() {
|
||||
return;
|
||||
}
|
||||
let room = usize::from(area.width).saturating_sub(1);
|
||||
let lines: Vec<Line> = self
|
||||
.note
|
||||
.iter()
|
||||
.map(|line| Line::from(Span::styled(format!(" {}", truncate(line, room)), theme.muted)))
|
||||
.collect();
|
||||
frame.render_widget(Paragraph::new(lines), area);
|
||||
}
|
||||
|
||||
/// The search line, with the terminal's cursor at the end of the query.
|
||||
fn render_search(&self, frame: &mut Frame, area: Rect, theme: &ThemeStyles) {
|
||||
let search = Paragraph::new(Line::from(vec![
|
||||
Span::styled(" Search: ", theme.accent.add_modifier(Modifier::BOLD)),
|
||||
Span::styled(self.query().to_string(), theme.text),
|
||||
]))
|
||||
.block(Block::default().borders(Borders::BOTTOM).border_style(theme.border_muted));
|
||||
frame.render_widget(search, area);
|
||||
let cursor_x = area
|
||||
.x
|
||||
.saturating_add(9)
|
||||
.saturating_add(self.query().width() as u16)
|
||||
.min(area.right().saturating_sub(1));
|
||||
frame.set_cursor_position((cursor_x, area.y));
|
||||
}
|
||||
|
||||
/// The rows of the step showing, or a line saying nothing matches.
|
||||
fn render_list(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
theme: &ThemeStyles,
|
||||
hit: &std::cell::RefCell<crate::mouse::HitRegions>,
|
||||
) {
|
||||
if self.match_count() == 0 {
|
||||
return self.render_empty(frame, area, theme);
|
||||
}
|
||||
let window = self.window(area.height as usize);
|
||||
let width = crate::widgets::list_rows_width(area.width, self.match_count(), area.height);
|
||||
self.register_rows(area, width, window, theme, frame, hit);
|
||||
let available = width.saturating_sub(2 + crate::widgets::SELECTION_FRAME as u16) as usize;
|
||||
let items: Vec<ListItem> = (window.0..window.1)
|
||||
.map(|row| {
|
||||
let selected = row == self.cursor();
|
||||
let spans = self.row_spans(row, selected, available, theme);
|
||||
let line = crate::widgets::selection_row(spans, width.into(), selected, theme);
|
||||
ListItem::new(line)
|
||||
})
|
||||
.collect();
|
||||
frame.render_widget(List::new(items), Rect { width, ..area });
|
||||
}
|
||||
|
||||
/// The line in place of the list when the query matches nothing.
|
||||
fn render_empty(&self, frame: &mut Frame, area: Rect, theme: &ThemeStyles) {
|
||||
let empty = if self.providers.is_some() { "providers" } else { "models" };
|
||||
let message = Paragraph::new(format!(" No matching {empty}")).style(theme.muted);
|
||||
frame.render_widget(message, area);
|
||||
}
|
||||
|
||||
/// Row `row` of the step showing, as spans.
|
||||
fn row_spans(
|
||||
&self,
|
||||
row: usize,
|
||||
selected: bool,
|
||||
available: usize,
|
||||
theme: &ThemeStyles,
|
||||
) -> Vec<Span<'static>> {
|
||||
match &self.providers {
|
||||
Some(step) => self.provider_spans(step, row, selected, available, theme),
|
||||
None => self.model_spans(row, selected, available, theme),
|
||||
}
|
||||
}
|
||||
|
||||
/// The `(first, end)` rows of the filtered list that fit `capacity`, around the cursor.
|
||||
fn window(&self, capacity: usize) -> (usize, usize) {
|
||||
let total = self.match_count();
|
||||
let start =
|
||||
(self.cursor() + 1).saturating_sub(capacity).min(total.saturating_sub(capacity));
|
||||
(start, (start + capacity).min(total))
|
||||
}
|
||||
|
||||
/// Publishes a click target per visible row, and the scrollbar beside them.
|
||||
fn register_rows(
|
||||
&self,
|
||||
area: Rect,
|
||||
width: u16,
|
||||
(start, end): (usize, usize),
|
||||
theme: &ThemeStyles,
|
||||
frame: &mut Frame,
|
||||
hit: &std::cell::RefCell<crate::mouse::HitRegions>,
|
||||
) {
|
||||
let mut regions = hit.borrow_mut();
|
||||
for row in start..end {
|
||||
let row_rect = Rect::new(area.x, area.y.saturating_add((row - start) as u16), width, 1);
|
||||
regions.push(row_rect, crate::mouse::MouseTarget::ModelRow(row));
|
||||
}
|
||||
let (list, position) = (crate::mouse::OverlayList::Models, (start, self.match_count()));
|
||||
crate::widgets::list_scrollbar(frame, &mut regions, area, list, position, theme);
|
||||
}
|
||||
|
||||
/// One model row: cursor, the in-use dot, label, who serves it or its id, and what it is.
|
||||
fn model_spans(
|
||||
&self,
|
||||
row: usize,
|
||||
selected: bool,
|
||||
available: usize,
|
||||
theme: &ThemeStyles,
|
||||
) -> Vec<Span<'static>> {
|
||||
let Some(entry) = self.nav.item_index_at(row).and_then(|index| self.items.get(index))
|
||||
else {
|
||||
return Vec::new();
|
||||
};
|
||||
let is_active = self.active.as_ref() == Some(&entry.info.r#ref);
|
||||
let label = truncate(&entry.label, available.saturating_sub(MARKER_WIDTH + 3));
|
||||
// The subtitle, then what it is, in whatever the label leaves: a row that ran past the
|
||||
// frame was cut by it mid-word, and took the selection's closing cap with it
|
||||
let room = available.saturating_sub(MARKER_WIDTH).saturating_sub(label.width());
|
||||
let subtitle = truncate(&self.subtitle(entry), room);
|
||||
let meta = truncate(&meta_suffix(entry), room.saturating_sub(subtitle.width()));
|
||||
let mut spans = lead_spans(selected, is_active, theme);
|
||||
spans.push(Span::styled(label, theme.label_on(selected)));
|
||||
spans.push(Span::styled(subtitle, theme.muted.patch(row_background(selected, theme))));
|
||||
if !meta.is_empty() {
|
||||
spans.push(Span::styled(meta, theme.secondary_on(selected)));
|
||||
}
|
||||
spans
|
||||
}
|
||||
|
||||
/// One provider row: cursor, the in-use dot, its mark and id, and how many models it serves.
|
||||
fn provider_spans(
|
||||
&self,
|
||||
step: &super::providers::ProviderStep,
|
||||
row: usize,
|
||||
selected: bool,
|
||||
available: usize,
|
||||
theme: &ThemeStyles,
|
||||
) -> Vec<Span<'static>> {
|
||||
let Some(provider) = step.nav.item_index_at(row).and_then(|index| step.rows.get(index))
|
||||
else {
|
||||
return Vec::new();
|
||||
};
|
||||
let is_active = self.active.as_ref().is_some_and(|active| active.provider == provider.id);
|
||||
let name = icon_label(crate::widgets::provider_icon(&provider.id).glyph(), &provider.id);
|
||||
let name = truncate(&name, available.saturating_sub(MARKER_WIDTH));
|
||||
let count = truncate(&model_count(provider), available.saturating_sub(name.width() + 2));
|
||||
let mut spans = lead_spans(selected, is_active, theme);
|
||||
spans.push(Span::styled(name, theme.label_on(selected)));
|
||||
spans.push(Span::styled(count, theme.muted.patch(row_background(selected, theme))));
|
||||
spans
|
||||
}
|
||||
}
|
||||
|
||||
/// Cells the in-use dot takes, with its gap, whether or not it is drawn.
|
||||
const MARKER_WIDTH: usize = 2;
|
||||
|
||||
/// What every row starts with: the cursor's gutter, then the in-use dot or its blank.
|
||||
fn lead_spans(selected: bool, is_active: bool, theme: &ThemeStyles) -> Vec<Span<'static>> {
|
||||
let marker = if is_active { "\u{25cf} " } else { " " };
|
||||
let marker_style = active_style(is_active, theme).patch(row_background(selected, theme));
|
||||
vec![
|
||||
Span::styled(crate::glyphs::Mark::Cursor.gutter(selected), theme.accent_on(selected)),
|
||||
Span::styled(marker, marker_style),
|
||||
]
|
||||
}
|
||||
|
||||
/// The cursor row's background, for spans that would otherwise leave a gap in it.
|
||||
fn row_background(selected: bool, theme: &ThemeStyles) -> Style {
|
||||
if selected {
|
||||
theme.selected_bg
|
||||
} else {
|
||||
Style::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// The in-use dot's ink: success on the row in use, muted (and blank) elsewhere.
|
||||
fn active_style(is_active: bool, theme: &ThemeStyles) -> Style {
|
||||
if is_active {
|
||||
theme.success
|
||||
} else {
|
||||
theme.muted
|
||||
}
|
||||
}
|
||||
|
||||
/// ` 12 models`, after a provider's name.
|
||||
fn model_count(provider: &ProviderRow) -> String {
|
||||
match provider.models {
|
||||
1 => " 1 model".to_owned(),
|
||||
count => format!(" {count} models"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A provider row's words as drawn, for measuring the panel.
|
||||
fn provider_text(provider: &ProviderRow) -> String {
|
||||
let name = icon_label(crate::widgets::provider_icon(&provider.id).glyph(), &provider.id);
|
||||
format!(" {name}{}", model_count(provider))
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
use super::meta::meta_suffix;
|
||||
use super::*;
|
||||
use ratatui::layout::Rect;
|
||||
|
||||
fn entry(provider: &str, id: &str, configured: bool) -> ModelEntry {
|
||||
ModelEntry {
|
||||
@@ -111,6 +113,153 @@ fn a_refreshed_catalog_keeps_the_query_and_the_row_under_the_cursor() {
|
||||
);
|
||||
}
|
||||
|
||||
/// The catalog as served by two providers that both offer `claude-sonnet-4-6`.
|
||||
fn shared_catalog() -> Vec<ModelEntry> {
|
||||
let mut models = catalog();
|
||||
models.push(entry("github-copilot", "claude-sonnet-4-6", false));
|
||||
models
|
||||
}
|
||||
|
||||
/// The picker on Anthropic's `claude-sonnet-4-6`, opened on `start`.
|
||||
fn on_sonnet(start: PickerStart) -> ModelPickerState {
|
||||
let active = Some(ModelRef::new("anthropic", "claude-sonnet-4-6"));
|
||||
ModelPickerState::open(shared_catalog(), active).starting_on(start)
|
||||
}
|
||||
|
||||
fn press(picker: &mut ModelPickerState, codes: &[KeyCode]) -> ModelPickerOutcome {
|
||||
codes.iter().map(|code| picker.on_key(&key(*code))).last().expect("a key")
|
||||
}
|
||||
|
||||
/// The model step is about the provider in use, and `tab` widens it to every provider and back,
|
||||
/// keeping the cursor on the model it was on.
|
||||
#[test]
|
||||
fn the_model_step_shows_the_provider_in_use_until_tab_widens_it() {
|
||||
let mut picker = on_sonnet(PickerStart::Models);
|
||||
assert_eq!(picker.match_count(), 2, "anthropic's two");
|
||||
let chosen = || Some("anthropic/claude-sonnet-4-6".to_owned());
|
||||
assert_eq!(picker.selected_entry().map(ModelEntry::qualified_id), chosen());
|
||||
press(&mut picker, &[KeyCode::Tab]);
|
||||
assert_eq!(picker.match_count(), 5, "every provider's");
|
||||
assert_eq!(picker.selected_entry().map(ModelEntry::qualified_id), chosen());
|
||||
press(&mut picker, &[KeyCode::Tab]);
|
||||
assert_eq!(picker.match_count(), 2, "and back");
|
||||
|
||||
// With no model in use there is no provider to be about
|
||||
let unset = ModelPickerState::open(catalog(), None).starting_on(PickerStart::Models);
|
||||
assert_eq!(unset.match_count(), 4);
|
||||
}
|
||||
|
||||
/// A login opens on the provider it signed in to, at the top with nothing chosen, even when the
|
||||
/// model in use is another provider's. `tab` still reaches everything else.
|
||||
#[test]
|
||||
fn a_login_opens_on_the_provider_it_signed_in_to() {
|
||||
let active = Some(ModelRef::new("anthropic", "claude-sonnet-4-6"));
|
||||
let mut picker = ModelPickerState::open(shared_catalog(), active).about_provider("openai");
|
||||
assert_eq!(picker.match_count(), 1, "openai's own");
|
||||
let shown = picker.selected_entry().map(ModelEntry::qualified_id);
|
||||
assert_eq!(shown.as_deref(), Some("openai/gpt-5-codex"));
|
||||
assert_eq!(picker.cursor(), 0);
|
||||
press(&mut picker, &[KeyCode::Tab]);
|
||||
assert_eq!(picker.match_count(), 5, "and tab widens it");
|
||||
}
|
||||
|
||||
/// A local server's models land a moment after the picker opens, so a provider that serves nothing
|
||||
/// yet shows every model until they arrive, then narrows to them.
|
||||
#[test]
|
||||
fn a_provider_whose_models_arrive_late_is_scoped_when_they_do() {
|
||||
let mut picker = ModelPickerState::open(catalog(), None).about_provider("ollama");
|
||||
assert_eq!(picker.match_count(), 4, "nothing of ollama's yet, so everything");
|
||||
let mut arrived = catalog();
|
||||
arrived.push(entry("ollama", "qwen3-coder", false));
|
||||
picker.refresh(arrived);
|
||||
assert_eq!(picker.match_count(), 1, "narrowed once they land");
|
||||
}
|
||||
|
||||
/// The provider step lists each provider once, by name, with the cursor on the one in use.
|
||||
#[test]
|
||||
fn the_provider_step_lists_each_provider_once() {
|
||||
let picker = on_sonnet(PickerStart::Providers);
|
||||
assert!(picker.choosing_provider());
|
||||
assert_eq!(picker.match_count(), 4, "anthropic, github-copilot, lmstudio, openai");
|
||||
assert_eq!(picker.cursor(), 0, "on anthropic, the one in use");
|
||||
let screen = drawn(&picker, Rect::new(0, 0, 120, 30));
|
||||
assert!(screen.contains("Select provider"), "{screen}");
|
||||
assert!(screen.contains("anthropic 2 models"), "{screen}");
|
||||
assert!(screen.contains("lmstudio 1 model "), "{screen}");
|
||||
}
|
||||
|
||||
/// Another provider serving the model in use switches to it there at once: the model was never
|
||||
/// the question, so nothing asks it again.
|
||||
#[test]
|
||||
fn a_provider_serving_the_same_model_switches_to_it_there() {
|
||||
let mut picker = on_sonnet(PickerStart::Providers);
|
||||
match press(&mut picker, &[KeyCode::Down, KeyCode::Enter]) {
|
||||
ModelPickerOutcome::Select(info) => {
|
||||
assert_eq!(info.r#ref, ModelRef::new("github-copilot", "claude-sonnet-4-6"));
|
||||
}
|
||||
other => panic!("expected the same model from copilot, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A provider without the model in use opens on its own models, and `esc` goes back to the
|
||||
/// providers it came from before it closes anything.
|
||||
#[test]
|
||||
fn a_provider_without_the_model_opens_on_its_models() {
|
||||
let mut picker = on_sonnet(PickerStart::Providers);
|
||||
let outcome =
|
||||
press(&mut picker, &[KeyCode::Down, KeyCode::Down, KeyCode::Down, KeyCode::Enter]);
|
||||
assert_eq!(outcome, ModelPickerOutcome::Consumed);
|
||||
assert!(!picker.choosing_provider());
|
||||
let shown = picker.selected_entry().map(ModelEntry::qualified_id);
|
||||
assert_eq!(shown.as_deref(), Some("openai/gpt-5-codex"), "openai's, and only those");
|
||||
assert_eq!(picker.match_count(), 1);
|
||||
|
||||
assert_eq!(press(&mut picker, &[KeyCode::Esc]), ModelPickerOutcome::Consumed);
|
||||
assert!(picker.choosing_provider(), "back to the providers");
|
||||
assert_eq!(press(&mut picker, &[KeyCode::Esc]), ModelPickerOutcome::Close);
|
||||
}
|
||||
|
||||
/// Choosing the provider already in use is asking to see its models, not a switch to nothing new.
|
||||
#[test]
|
||||
fn the_provider_in_use_opens_on_its_models() {
|
||||
let mut picker = on_sonnet(PickerStart::Providers);
|
||||
assert_eq!(press(&mut picker, &[KeyCode::Enter]), ModelPickerOutcome::Consumed);
|
||||
assert!(!picker.choosing_provider());
|
||||
assert_eq!(picker.match_count(), 2);
|
||||
}
|
||||
|
||||
/// `←` reaches the providers from a model step opened anywhere; `esc` there closes, since
|
||||
/// nothing led to it.
|
||||
#[test]
|
||||
fn left_reaches_the_providers_from_the_model_step() {
|
||||
let mut picker = on_sonnet(PickerStart::Models);
|
||||
press(&mut picker, &[KeyCode::Left]);
|
||||
assert!(picker.choosing_provider());
|
||||
assert_eq!(picker.cursor(), 0, "on the provider the models were from");
|
||||
assert_eq!(press(&mut picker, &[KeyCode::Esc]), ModelPickerOutcome::Close);
|
||||
}
|
||||
|
||||
/// A row names its provider only while the list mixes them, and its id only when a configured
|
||||
/// name stands in for it: a model is never written out twice.
|
||||
#[test]
|
||||
fn a_row_says_only_what_its_label_does_not() {
|
||||
let mut picker = on_sonnet(PickerStart::Models);
|
||||
let area = Rect::new(0, 0, 120, 30);
|
||||
let scoped = drawn(&picker, area);
|
||||
assert!(scoped.contains("Select model · anthropic"), "{scoped}");
|
||||
assert!(!scoped.contains("anthropic/"), "{scoped}");
|
||||
assert!(scoped.contains("tab every provider"), "{scoped}");
|
||||
press(&mut picker, &[KeyCode::Tab]);
|
||||
let every = drawn(&picker, area);
|
||||
assert!(every.contains("gpt-5-codex openai"), "{every}");
|
||||
assert!(every.contains("tab only anthropic"), "{every}");
|
||||
|
||||
let named =
|
||||
ModelEntry { label: "sonnet".into(), ..entry("anthropic", "claude-sonnet-4-6", true) };
|
||||
let picker = ModelPickerState::open(vec![named], None);
|
||||
assert!(drawn(&picker, area).contains("sonnet anthropic/claude-sonnet-4-6"));
|
||||
}
|
||||
|
||||
/// The opening line is measured, not guessed at: a panel sized without it clips its own
|
||||
/// hint row out through the bottom border, and one sized to the rows alone truncates it.
|
||||
#[test]
|
||||
@@ -164,7 +313,8 @@ fn a_row_too_long_for_the_frame_is_shortened_inside_it() {
|
||||
assert_eq!(rows.len(), 2, "{screen}");
|
||||
for row in &rows {
|
||||
let inside = row.trim_end().strip_suffix('│').expect("the frame's edge");
|
||||
assert!(inside.trim_end_matches(['▌', ' ']).ends_with('…'), "{screen}");
|
||||
// The label is what gives way; a provider short enough to fit after it still shows
|
||||
assert!(inside.contains("fit-in-s…"), "{screen}");
|
||||
}
|
||||
assert!(rows[0].trim_end().ends_with("▌│"), "the cursor's row keeps its cap: {screen}");
|
||||
}
|
||||
|
||||
@@ -197,8 +197,9 @@ pub enum MouseTarget {
|
||||
PeekSelection(PeekSelectionAction),
|
||||
/// A row of an open context menu, by index.
|
||||
ContextMenuItem(usize),
|
||||
/// The Context Dock footer's model-name row (opens the model picker).
|
||||
DockModelRow,
|
||||
/// The Context Dock's provider or model row, which opens the model picker on the providers or
|
||||
/// the models. Args: the step it opens on.
|
||||
DockModelRow(crate::model_picker::PickerStart),
|
||||
/// The statusline's changes module (opens the Changes pane).
|
||||
StatuslineChanges,
|
||||
/// The Context Dock footer's mode row, which switches to the next mode
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//! Activity — the row above the composer: the turn's activity bar, a copy toast, or a hint.
|
||||
//! Activity — the row above the composer: the mode button, then the turn's activity bar, a copy
|
||||
//! toast, or a hint.
|
||||
|
||||
use crate::app::App;
|
||||
use ratatui::{
|
||||
@@ -29,7 +30,11 @@ const ACTIVITY_BAR_WIDTH: usize = 24;
|
||||
/// design — one line here and one in the dock, never a modal, never an auto-opened review — because
|
||||
/// the reviewable unit is the increment and the only way that stays small is if the count is always
|
||||
/// in view.
|
||||
///
|
||||
/// The mode button always leads the row, so everything else here starts to its right.
|
||||
pub(super) fn render_composer_activity(f: &mut Frame, area: Rect, app: &App) {
|
||||
let badge = super::input::render_mode_badge(f, area, app);
|
||||
let area = Rect { x: area.x + badge, width: area.width - badge, ..area };
|
||||
if crate::statusline::activity_parts(app).is_none() {
|
||||
if let Some(line) =
|
||||
unreviewed_invitation(app).or_else(|| first_steps(app, usize::from(area.width)))
|
||||
|
||||
@@ -92,10 +92,10 @@ pub(super) fn header(block: &ConvoBlock, styles: &ThemeStyles) -> Line<'static>
|
||||
#[test]
|
||||
fn a_tool_card_reads_in_three_voices() {
|
||||
let styles = theme();
|
||||
let line = header(&tool_item("bash", luxe_core::ToolActivityState::Succeeded), &styles);
|
||||
let line = header(&tool_item("test", luxe_core::ToolActivityState::Succeeded), &styles);
|
||||
|
||||
let name = &line.spans[0];
|
||||
assert_eq!(name.content.as_ref(), format!("{} bash", tool_glyph("bash")));
|
||||
assert_eq!(name.content.as_ref(), format!("{} test", tool_glyph("test")));
|
||||
assert!(name.style.add_modifier.contains(Modifier::BOLD), "the tool name is bold");
|
||||
assert_eq!(name.style.fg, styles.success.fg, "a landed call takes its outcome color");
|
||||
|
||||
@@ -233,7 +233,7 @@ fn a_header_does_not_restate_the_body_under_it() {
|
||||
|
||||
// A one-line command has no body, so the header is the only place it can be.
|
||||
let one = card("bash", serde_json::json!({"command": "make build"}));
|
||||
assert_eq!(header(&one, &styles).spans[1].content.as_ref(), " make build");
|
||||
assert!(header(&one, &styles).to_string().ends_with(" make build 5ms"));
|
||||
|
||||
// And a `write`'s subject is the path while its body is the file: different things.
|
||||
let written = card("write", serde_json::json!({"path": "a.rs", "content": "fn main() {}"}));
|
||||
@@ -253,6 +253,42 @@ fn a_header_does_not_restate_the_body_under_it() {
|
||||
);
|
||||
}
|
||||
|
||||
/// A command the header carries is highlighted as shell, the way a card body draws one: a call with
|
||||
/// no `description` and one line has no body, so without this its command was the only one left
|
||||
/// plain. A described call's subject is prose, and stays body text.
|
||||
#[test]
|
||||
fn a_command_on_the_header_is_highlighted() {
|
||||
let styles = theme();
|
||||
let card = |arguments: serde_json::Value| {
|
||||
let mut activity = luxe_core::ToolActivity::running(
|
||||
"s",
|
||||
"c",
|
||||
"bash",
|
||||
luxe_core::describe_call("bash", &arguments, "/project"),
|
||||
1,
|
||||
);
|
||||
activity.card_body = luxe_core::tool_card_body("bash", &arguments, "/project");
|
||||
ConvoBlock::Tool(Box::new(crate::app::ToolItem {
|
||||
activity,
|
||||
expanded: false,
|
||||
details_toggled: false,
|
||||
waited_on_user_ms: 0,
|
||||
}))
|
||||
};
|
||||
let command = "cargo test --workspace 'a b'";
|
||||
let row = header(&card(serde_json::json!({"command": command})), &styles);
|
||||
let expected = crate::highlight::highlight_code(command, Some("sh"), &styles).remove(0);
|
||||
assert_eq!(row.spans[1].content.as_ref(), " ", "the gap stands apart from the command");
|
||||
assert_eq!(&row.spans[2..], expected.spans.as_slice(), "drawn as the highlighter draws it");
|
||||
let inks: std::collections::HashSet<_> = expected.spans.iter().map(|s| s.style.fg).collect();
|
||||
assert!(inks.len() > 1, "more than one color, or this proves nothing: {expected:?}");
|
||||
|
||||
let described = serde_json::json!({"description": "Run the suite", "command": command});
|
||||
let row = header(&card(described), &styles);
|
||||
assert_eq!(row.spans[1].content.as_ref(), " Run the suite");
|
||||
assert_eq!(row.spans[1].style.fg, styles.text.fg, "a description is prose");
|
||||
}
|
||||
|
||||
/// A call in flight reports how long it has been going, which is when that answers something.
|
||||
///
|
||||
/// The projector only times a call once it has *finished*, so a card used to show no figure at
|
||||
@@ -287,7 +323,7 @@ fn a_call_waiting_on_you_does_not_spin() {
|
||||
fn a_call_in_flight_reports_how_long_it_has_been_going() {
|
||||
let styles = theme();
|
||||
let card = |state| {
|
||||
let mut activity = luxe_core::ToolActivity::running("s", "c", "bash", "make test", 1);
|
||||
let mut activity = luxe_core::ToolActivity::running("s", "c", "test", "make test", 1);
|
||||
activity.state = state;
|
||||
activity.elapsed_ms =
|
||||
matches!(state, luxe_core::ToolActivityState::Succeeded).then_some(2_500);
|
||||
@@ -347,11 +383,13 @@ fn a_card_does_not_report_the_readers_own_deliberation() {
|
||||
};
|
||||
|
||||
// Thirty of those thirty-one seconds were a permission prompt on screen.
|
||||
// The clock is the header's last span; a command subject is several before it
|
||||
let clock = |line: &Line<'static>| line.spans.last().map(|span| span.content.to_string());
|
||||
let gated = header(&card("bash", 30_000), &styles);
|
||||
assert_eq!(gated.spans[2].content.as_ref(), " 1s");
|
||||
assert_eq!(clock(&gated).as_deref(), Some(" 1s"));
|
||||
// Nothing waited on, nothing to subtract.
|
||||
let plain = header(&card("bash", 0), &styles);
|
||||
assert_eq!(plain.spans[2].content.as_ref(), " 31s");
|
||||
assert_eq!(clock(&plain).as_deref(), Some(" 31s"));
|
||||
|
||||
// A `question` is that case taken to its limit: the whole call is a person thinking, so
|
||||
// there is no tool time to report at all.
|
||||
|
||||
@@ -45,6 +45,7 @@ pub(super) fn tool_lines(
|
||||
icon,
|
||||
tool: &activity.name,
|
||||
subject: header_subject(activity),
|
||||
command: subject_is_command(activity),
|
||||
elapsed_ms: header_duration(item, ctx.running_ms),
|
||||
summary,
|
||||
queued,
|
||||
@@ -122,6 +123,8 @@ struct ToolHeader<'a> {
|
||||
tool: &'a str,
|
||||
/// The command, the path, the pattern — what the call was about.
|
||||
subject: &'a str,
|
||||
/// Whether the subject is a shell command, and so drawn highlighted as one
|
||||
command: bool,
|
||||
/// How long the call took, once it has taken it.
|
||||
elapsed_ms: Option<u64>,
|
||||
/// An outcome worth a slot, for the tools whose result says more than a green wash.
|
||||
@@ -142,7 +145,7 @@ fn tool_header_line(header: ToolHeader<'_>, style: Style, styles: &ThemeStyles)
|
||||
let mut spans = vec![Span::styled(icon_label(header.icon, header.tool), name_style)];
|
||||
let subject = safe_tool_text(header.subject);
|
||||
if !subject.trim().is_empty() {
|
||||
spans.push(Span::styled(format!("{SUBJECT_GAP}{subject}"), styles.text));
|
||||
spans.extend(subject_spans(&subject, header.command, styles));
|
||||
}
|
||||
if let Some(batch) = header.queued {
|
||||
spans.push(Span::styled(format!(" {}/{}", batch.index, batch.total), styles.muted));
|
||||
@@ -157,6 +160,30 @@ fn tool_header_line(header: ToolHeader<'_>, style: Style, styles: &ThemeStyles)
|
||||
Line::from(spans)
|
||||
}
|
||||
|
||||
/// The subject, after the gap that holds it off the tool's name.
|
||||
///
|
||||
/// A command is highlighted as shell, as a card body draws one. Most `bash` calls are one line with
|
||||
/// no description, so their header is the only place the command shows, and plain it was the one
|
||||
/// command in the transcript a reader had to parse unaided.
|
||||
fn subject_spans(subject: &str, command: bool, styles: &ThemeStyles) -> Vec<Span<'static>> {
|
||||
let highlighted = command
|
||||
.then(|| crate::highlight::highlight_code(subject, Some("sh"), styles))
|
||||
.and_then(|lines| lines.into_iter().next())
|
||||
.filter(|line| !line.spans.is_empty());
|
||||
match highlighted {
|
||||
Some(line) => {
|
||||
std::iter::once(Span::styled(SUBJECT_GAP, styles.text)).chain(line.spans).collect()
|
||||
}
|
||||
None => vec![Span::styled(format!("{SUBJECT_GAP}{subject}"), styles.text)],
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a card's header subject is the command it ran: a `bash` call with no body, which is one
|
||||
/// with no description (that would be the subject instead) and only one line.
|
||||
fn subject_is_command(activity: &luxe_core::ToolActivity) -> bool {
|
||||
activity.name == "bash" && activity.card_body.is_none()
|
||||
}
|
||||
|
||||
/// What the header says the call was about, or nothing when the body below it already says it.
|
||||
///
|
||||
/// A header subject is a *preview*, for a card that shows nothing else. Where the body is the same
|
||||
|
||||
@@ -65,11 +65,12 @@ pub(super) fn footer_lines(
|
||||
}
|
||||
|
||||
/// The telemetry rows a click lands on, for a block starting at line `start`. The provider and the
|
||||
/// model are one choice in the picker, so both rows open it.
|
||||
/// model rows are separate targets, so each lights up alone and opens its own step of the picker.
|
||||
fn clickable_rows(start: usize) -> Vec<(usize, crate::mouse::MouseTarget)> {
|
||||
use crate::model_picker::PickerStart;
|
||||
vec![
|
||||
(start + PROVIDER_ROW, crate::mouse::MouseTarget::DockModelRow),
|
||||
(start + MODEL_ROW, crate::mouse::MouseTarget::DockModelRow),
|
||||
(start + PROVIDER_ROW, crate::mouse::MouseTarget::DockModelRow(PickerStart::Providers)),
|
||||
(start + MODEL_ROW, crate::mouse::MouseTarget::DockModelRow(PickerStart::Models)),
|
||||
(start + MODE_ROW, crate::mouse::MouseTarget::DockModeRow),
|
||||
]
|
||||
}
|
||||
@@ -199,25 +200,11 @@ pub(super) fn telemetry_lines(app: &App) -> Vec<Line<'static>> {
|
||||
fn model_telemetry(app: &App, row: usize, column: usize) -> Vec<Line<'static>> {
|
||||
let styles = &app.theme_styles;
|
||||
let status = &app.status;
|
||||
let mut lines: Vec<Line<'static>> = Vec::new();
|
||||
|
||||
lines.push(section_heading_line(Section::Model, app));
|
||||
lines.push(provider_row(app, row, column));
|
||||
let room = telemetry_value_width(row, column).saturating_sub(icon_cells(Icon::Model.glyph()));
|
||||
// Nothing chooses a model for the reader, so this row says which it is either way — and stays
|
||||
// the affordance that opens the picker, which is the whole reason a reader with none needs it.
|
||||
let (name, ink) = match status.model.is_empty() {
|
||||
true => ("no model".to_string(), styles.warning),
|
||||
false => (truncate_cells(&status.model, room), styles.text),
|
||||
};
|
||||
lines.push(telemetry_affordance(
|
||||
"model",
|
||||
icon_label(Icon::Model.glyph(), &name),
|
||||
ink,
|
||||
column,
|
||||
app,
|
||||
&crate::mouse::MouseTarget::DockModelRow,
|
||||
));
|
||||
let mut lines = vec![
|
||||
section_heading_line(Section::Model, app),
|
||||
provider_row(app, row, column),
|
||||
model_row(app, row, column),
|
||||
];
|
||||
lines.push(telemetry_row(
|
||||
"thinking",
|
||||
icon_label(Icon::Thinking.glyph(), thinking_label(&status.thinking)),
|
||||
@@ -254,6 +241,33 @@ fn model_telemetry(app: &App, row: usize, column: usize) -> Vec<Line<'static>> {
|
||||
lines
|
||||
}
|
||||
|
||||
/// The model, wearing its maker's mark.
|
||||
///
|
||||
/// Nothing chooses a model for the reader, so this row says which it is either way, and stays the
|
||||
/// affordance that opens the picker, which is the whole reason a reader with none needs it.
|
||||
fn model_row(app: &App, row: usize, column: usize) -> Line<'static> {
|
||||
let styles = &app.theme_styles;
|
||||
let model = app.status.model.as_str();
|
||||
let icon = crate::widgets::model_icon(model_id(app)).glyph();
|
||||
let room = telemetry_value_width(row, column).saturating_sub(icon_cells(icon));
|
||||
let (name, ink) = match model.is_empty() {
|
||||
true => ("no model".to_string(), styles.warning),
|
||||
false => (truncate_cells(model, room), styles.text),
|
||||
};
|
||||
let target = crate::mouse::MouseTarget::DockModelRow(crate::model_picker::PickerStart::Models);
|
||||
telemetry_affordance("model", icon_label(icon, &name), ink, column, app, &target)
|
||||
}
|
||||
|
||||
/// The id of the model the dock names, which picks its mark even where config gave it a name of
|
||||
/// its own. Taken from the active model while it is the one reported, else the name shown.
|
||||
pub(super) fn model_id(app: &App) -> &str {
|
||||
let status = &app.status;
|
||||
app.active_model_info
|
||||
.as_ref()
|
||||
.filter(|info| info.r#ref.provider == status.provider && info.display() == status.model)
|
||||
.map_or(status.model.as_str(), |info| info.r#ref.id.as_str())
|
||||
}
|
||||
|
||||
/// Who serves the model, wearing that provider's mark. Always drawn, so the rows under it keep
|
||||
/// their place: before the engine names a provider it says `none`, dimmed.
|
||||
fn provider_row(app: &App, row: usize, column: usize) -> Line<'static> {
|
||||
@@ -265,14 +279,9 @@ fn provider_row(app: &App, row: usize, column: usize) -> Line<'static> {
|
||||
true => ("none".to_string(), styles.dim),
|
||||
false => (truncate_cells(provider, room), styles.text),
|
||||
};
|
||||
telemetry_affordance(
|
||||
"provider",
|
||||
icon_label(icon, &name),
|
||||
ink,
|
||||
column,
|
||||
app,
|
||||
&crate::mouse::MouseTarget::DockModelRow,
|
||||
)
|
||||
let target =
|
||||
crate::mouse::MouseTarget::DockModelRow(crate::model_picker::PickerStart::Providers);
|
||||
telemetry_affordance("provider", icon_label(icon, &name), ink, column, app, &target)
|
||||
}
|
||||
|
||||
/// The SESSION block, once a turn has something to measure or someone has joined: the window,
|
||||
|
||||
@@ -354,6 +354,25 @@ fn the_label_column_seats_every_label() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The model's mark comes from its id, so a model named in config still wears its maker's mark.
|
||||
/// Once another model is reported, the stale one's id no longer speaks for it.
|
||||
#[test]
|
||||
fn a_named_model_is_marked_by_its_id() {
|
||||
let mut app = app();
|
||||
app.active_model_info = Some(luxe_core::provider::ModelInfo {
|
||||
r#ref: luxe_core::provider::ModelRef::new("anthropic", "claude-opus-5-5"),
|
||||
display_name: Some("opus".into()),
|
||||
..Default::default()
|
||||
});
|
||||
app.status.model = "opus".into();
|
||||
app.status.provider = "anthropic".into();
|
||||
assert_eq!(super::telemetry::model_id(&app), "claude-opus-5-5");
|
||||
|
||||
app.status.model = "gpt-5".into();
|
||||
app.status.provider = "openai".into();
|
||||
assert_eq!(super::telemetry::model_id(&app), "gpt-5");
|
||||
}
|
||||
|
||||
/// The provider is a row of its own, label left and value right like every other row, directly
|
||||
/// above the model it serves, and wears its own mark.
|
||||
#[test]
|
||||
|
||||
@@ -84,6 +84,7 @@ pub(super) fn build_chat_regions(app: &App, size: Rect) -> ChatRegions {
|
||||
// Everything between the top of the conversation column and the composer — the room a modal
|
||||
// that grows up from the prompt has to grow into.
|
||||
let above_composer = chat_column.height.saturating_sub(input_height);
|
||||
let activity_rows = activity_strip_height(app, diff_column);
|
||||
let modal_rows = if dock_presentation == DockPresentation::Replacement {
|
||||
0
|
||||
} else {
|
||||
@@ -91,20 +92,19 @@ pub(super) fn build_chat_regions(app: &App, size: Rect) -> ChatRegions {
|
||||
app,
|
||||
input::composer_area(chat_column, size).width,
|
||||
above_composer,
|
||||
ACTIVITY_STRIP_HEIGHT + tray_height,
|
||||
activity_rows + tray_height,
|
||||
)
|
||||
};
|
||||
// Top to bottom the conversation column reads chronologically: what was said, what the agent is
|
||||
// doing now, what the user has lined up next, and the prompt they are typing into. The activity
|
||||
// strip is always reserved — a blank row and the indicator's own — so a turn starting or
|
||||
// ending never shifts the composer out from under the cursor, and the prompt keeps its
|
||||
// breathing room from the transcript when nothing is running.
|
||||
// strip is always reserved, so a turn starting or ending never shifts the composer out from
|
||||
// under the cursor.
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
Constraint::Min(1),
|
||||
Constraint::Length(modal_rows),
|
||||
Constraint::Length(ACTIVITY_STRIP_HEIGHT),
|
||||
Constraint::Length(activity_rows),
|
||||
Constraint::Length(tray_height),
|
||||
Constraint::Length(input_height),
|
||||
])
|
||||
@@ -131,6 +131,16 @@ pub(super) fn build_chat_regions(app: &App, size: Rect) -> ChatRegions {
|
||||
/// blank separator plus the indicator's own row.
|
||||
const ACTIVITY_STRIP_HEIGHT: u16 = 2;
|
||||
|
||||
/// Rows the activity strip takes. Under a transcript, the blank separator keeps the prompt's
|
||||
/// breathing room from it when nothing is running; a peek standing in the transcript's place rules
|
||||
/// off its own footer, so there the separator would only be a gap and the indicator's row is all.
|
||||
fn activity_strip_height(app: &App, diff_column: Option<Rect>) -> u16 {
|
||||
match app.changes.is_some() && diff_column.is_none() {
|
||||
true => ACTIVITY_STRIP_HEIGHT - 1,
|
||||
false => ACTIVITY_STRIP_HEIGHT,
|
||||
}
|
||||
}
|
||||
|
||||
/// Rows of conversation a modal may never take, however tall the panel wants to be.
|
||||
const MIN_TRANSCRIPT_ROWS: u16 = 1;
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
Dashboard@140x44: frame=7428556d77f4c4b8 hits=1cb65015d0bcfe06
|
||||
Dashboard@100x30: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
Dashboard@64x20: frame=2241024789ba0042 hits=b75fb32b555b4fba
|
||||
DashboardContextFiles@140x44: frame=1d0f938686119640 hits=74730c4c8fe758ba
|
||||
DashboardContextFiles@100x30: frame=7d9f4575520ebfc1 hits=b2dc10b008b38609
|
||||
DashboardContextFiles@64x20: frame=406035c59aa9deb4 hits=105b5cc0c2e93aef
|
||||
DashboardTyping@140x44: frame=ed239b00aaab51c6 hits=a16f9b12c4525956
|
||||
DashboardTyping@100x30: frame=8865b16c9d0ceb43 hits=bf61e1af5ec3e308
|
||||
DashboardTyping@64x20: frame=b84228b632019d83 hits=1e0203bf486b2b58
|
||||
DashboardMinimal@140x44: frame=966cc3b3d3dc91d4 hits=14f2b70bde20529b
|
||||
DashboardMinimal@100x30: frame=17ca6b0881f64485 hits=f4b637d13b248263
|
||||
DashboardMinimal@64x20: frame=939001adda3bcbb4 hits=0f39b6e30d251353
|
||||
Dashboard@140x44: frame=0a8a458ab58cae55 hits=0da3ff559c6cfcd0
|
||||
Dashboard@100x30: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
Dashboard@64x20: frame=21359383f3090657 hits=e124e56b51ae06f0
|
||||
DashboardContextFiles@140x44: frame=8c8f151c56882b8c hits=50faad90bc849c30
|
||||
DashboardContextFiles@100x30: frame=5e143f51382fba1d hits=697c79c208d3235c
|
||||
DashboardContextFiles@64x20: frame=b393559bd82297d0 hits=518b7f93e1068099
|
||||
DashboardTyping@140x44: frame=13dbacdfa71feb83 hits=b0114e029a4a5b20
|
||||
DashboardTyping@100x30: frame=7279cb0831ecf316 hits=c591d45ab8434e09
|
||||
DashboardTyping@64x20: frame=2549213a6f0ae50c hits=8c7ae9733df118f2
|
||||
DashboardMinimal@140x44: frame=0bc09dac5a6f2a91 hits=7cc4f9454f141757
|
||||
DashboardMinimal@100x30: frame=63084c0da4280ac8 hits=ae603ca719534409
|
||||
DashboardMinimal@64x20: frame=6581ce2158b547a7 hits=6b21cc134113c8cf
|
||||
Configuration@140x44: frame=73fbef3e76d36c7c hits=03493dafb9356d07
|
||||
Configuration@100x30: frame=644345f8e6340004 hits=04d865ae91d0aa35
|
||||
Configuration@64x20: frame=28ea511ad251f8c2 hits=77b9c8af75245265
|
||||
@@ -25,51 +25,51 @@ Settings@64x20: frame=125e6bc55b79d4a0 hits=f39d9d6dc36254de
|
||||
SettingsTools@140x44: frame=6d10321950d2e310 hits=6616bccda6cac2cb
|
||||
SettingsTools@100x30: frame=271c31ac292537cf hits=a88a7c38aea25a39
|
||||
SettingsTools@64x20: frame=dcdf73ac9e80be44 hits=56896b2217e7b7f8
|
||||
ChatIdle@140x44: frame=8f3a6a0a2f0b92d2 hits=a0cf286ea7fd1d55
|
||||
ChatIdle@100x30: frame=37277ebdbb0d0104 hits=f28115f769459349
|
||||
ChatIdle@64x20: frame=d5330f1c309a6918 hits=1fd57df076a5e100
|
||||
ChatThinking@140x44: frame=cb85f56ee191ef52 hits=57dd670de9e41750
|
||||
ChatThinking@100x30: frame=713f52d8af6e9871 hits=91183601e552563c
|
||||
ChatThinking@64x20: frame=8552649903cdc808 hits=eb606a4e4cfb053a
|
||||
ChatStreaming@140x44: frame=ba8453d7ed81f1c7 hits=06bab310faee6d54
|
||||
ChatStreaming@100x30: frame=cc3ae2d95405065a hits=c63f95971c6a18fc
|
||||
ChatStreaming@64x20: frame=970c22c578c362aa hits=a16a29ea4502d9fb
|
||||
ChatTools@140x44: frame=bbdd9c65f51351f8 hits=db1de58363be363c
|
||||
ChatTools@100x30: frame=7cd8b091af2f6451 hits=9d228eaa9af30b84
|
||||
ChatTools@64x20: frame=0233bef5bd8bc8b0 hits=9b2b3231b63926ce
|
||||
ChatCardBodies@140x44: frame=2eb2cc123501a3b2 hits=0c7b7867a8415fd2
|
||||
ChatCardBodies@100x30: frame=d1c442c5eaa6af7c hits=434a845e1880132c
|
||||
ChatCardBodies@64x20: frame=5638628d5920489e hits=328a37efc8b251f0
|
||||
ChatWideProse@140x44: frame=115e6bb44eef9beb hits=94dbf7b32b37b330
|
||||
ChatWideProse@100x30: frame=4ffb6880f5abff90 hits=bddfef30519a2a3a
|
||||
ChatWideProse@64x20: frame=d2f917fcaa50aeca hits=b3b75080bd6ccea1
|
||||
ChatToolError@140x44: frame=205e8b9d2ec06764 hits=0247483feb740b19
|
||||
ChatToolError@100x30: frame=bf5d84f32dfbbe41 hits=e17adbd05e6a6d3b
|
||||
ChatToolError@64x20: frame=329c49dd3a8bdd5d hits=e4e4f40e90cb3bca
|
||||
ChatToolRun@140x44: frame=23a4d42a0f8ad56c hits=f1514e1cf2ab0514
|
||||
ChatToolRun@100x30: frame=94c5a5920231ad6d hits=ed4e206d929f1002
|
||||
ChatToolRun@64x20: frame=b58a55ad577d37b3 hits=116fb38474c732bb
|
||||
ChatQuestion@140x44: frame=4854f6da0d4e8bed hits=3d24e8bf8375f597
|
||||
ChatQuestion@100x30: frame=089f5cfe357b006e hits=0f98bb30ff5537bf
|
||||
ChatQuestion@64x20: frame=78a535c57f876301 hits=7681468669569173
|
||||
ChatPlan@140x44: frame=c7cc574df002e27c hits=d76108ca7f13f116
|
||||
ChatPlan@100x30: frame=d61c241010275e79 hits=79c1409c0f886542
|
||||
ChatPlan@64x20: frame=97082e9d92c7616d hits=cb490269d9d6b6d3
|
||||
ChatPlanReady@140x44: frame=b30ca9958f2cad32 hits=23da509548f232f0
|
||||
ChatPlanReady@100x30: frame=7e20e1b0a94d94b3 hits=b7ea73f584bfc4ef
|
||||
ChatPlanReady@64x20: frame=0e3d9399fae48508 hits=f077305e4d966dff
|
||||
ChatTurn@140x44: frame=b45b4bb827842816 hits=4a67edb8228eb613
|
||||
ChatTurn@100x30: frame=22919d1047132c86 hits=b8ded94d236c0817
|
||||
ChatTurn@64x20: frame=91595c7c8fb3a9de hits=bc965e96875bbfe6
|
||||
ChatPermission@140x44: frame=8289b864f67fe472 hits=063b591e442cd221
|
||||
ChatPermission@100x30: frame=b2c0e21530b64523 hits=200049ec7749eeb8
|
||||
ChatPermission@64x20: frame=9f98f5664f85406f hits=abbd7bfaa97a4ed0
|
||||
ChatPalette@140x44: frame=19faed2faa7a9b54 hits=40cfef8a8401b132
|
||||
ChatPalette@100x30: frame=2ceacd7336e193e2 hits=c4aaaf53ba134bb2
|
||||
ChatPalette@64x20: frame=ca770995ab283020 hits=23d605e8cac60ffe
|
||||
ChatScreenshot@140x44: frame=40919b4019a285d8 hits=1489393a2950d711
|
||||
ChatScreenshot@100x30: frame=709f9e4b32a7c8f6 hits=f8537762de7b55a2
|
||||
ChatScreenshot@64x20: frame=0a22c420e0e4092e hits=1e33d25e6f2a5032
|
||||
ChatIdle@140x44: frame=f65820ec5fbf9ffb hits=ba090cdf9185f03b
|
||||
ChatIdle@100x30: frame=cdd5a05dd5d94a85 hits=ab6447976a3a5979
|
||||
ChatIdle@64x20: frame=f2f0d5a96c604b79 hits=dfdeefc48254f754
|
||||
ChatThinking@140x44: frame=cc192e06717f137b hits=623cd90da47980f6
|
||||
ChatThinking@100x30: frame=2d7036e5bd149802 hits=7916e6fea4631eb0
|
||||
ChatThinking@64x20: frame=2c4a8a60e1d1007b hits=2954d33aac98b21e
|
||||
ChatStreaming@140x44: frame=e6020779632a3346 hits=5003359eda2f8642
|
||||
ChatStreaming@100x30: frame=6d30dd4809d21c25 hits=8d8751056e9f860c
|
||||
ChatStreaming@64x20: frame=b6b2d56e75c5e910 hits=35eed18e784f1d4f
|
||||
ChatTools@140x44: frame=78b743646d9c39f0 hits=f9ad2868c1725eb6
|
||||
ChatTools@100x30: frame=fee7405f32c22371 hits=67bfeff05c0d5fb4
|
||||
ChatTools@64x20: frame=f253bdee4965ab9e hits=ff4c3c981e4dc4f2
|
||||
ChatCardBodies@140x44: frame=e4bbe2c857f3b33f hits=b8b6f362353c9b78
|
||||
ChatCardBodies@100x30: frame=c6fa299e8d352f2f hits=9dcbe3b78cef0c6c
|
||||
ChatCardBodies@64x20: frame=9a17f8aea8c01d79 hits=4f1c828ce09d1520
|
||||
ChatWideProse@140x44: frame=dd2f7790d94948c6 hits=0646f44ead1be162
|
||||
ChatWideProse@100x30: frame=9d4a9d9e0c9a5973 hits=3ed3f6a36fc4b70e
|
||||
ChatWideProse@64x20: frame=0697d1ee167c4505 hits=459fd9056903f1b1
|
||||
ChatToolError@140x44: frame=c63313748744e4d9 hits=b4f8b19decc4697b
|
||||
ChatToolError@100x30: frame=5d58f52a7c8cf8f2 hits=3a2e7b64254002fb
|
||||
ChatToolError@64x20: frame=8a8bcdff1c10fc1e hits=f0c6b27c0d3b7b7e
|
||||
ChatToolRun@140x44: frame=15b0e192183ff3e7 hits=bde3a344865175fe
|
||||
ChatToolRun@100x30: frame=e449e983f230ef6c hits=2e7625f4f5749242
|
||||
ChatToolRun@64x20: frame=e40816cee507a1f5 hits=2096eefc53c84aab
|
||||
ChatQuestion@140x44: frame=af90fb4e0cfdb794 hits=03d0c374c73fe2f9
|
||||
ChatQuestion@100x30: frame=3b8888f343f92201 hits=c6f9f3bfb3a4c38b
|
||||
ChatQuestion@64x20: frame=0ee52b34e332cc4e hits=998294e50a923f57
|
||||
ChatPlan@140x44: frame=551b532731b54f00 hits=bf8ae70d8d41a5e2
|
||||
ChatPlan@100x30: frame=82661cf2253c726d hits=a203185e4d555f62
|
||||
ChatPlan@64x20: frame=f7ac7cf721911019 hits=d6703ff0c2b53cc3
|
||||
ChatPlanReady@140x44: frame=cfd403c57a7cc306 hits=c0d9e9dac0a90b56
|
||||
ChatPlanReady@100x30: frame=4dafe918f19afc9f hits=43f54162c4cde08f
|
||||
ChatPlanReady@64x20: frame=2f744a1332ffa704 hits=e5f384471e5f572f
|
||||
ChatTurn@140x44: frame=3a2af99e90aba281 hits=ad29529811622215
|
||||
ChatTurn@100x30: frame=172d1608b85e1e1d hits=1f9cdca1ecf2eae7
|
||||
ChatTurn@64x20: frame=01c45983ca820b45 hits=72df4390987d7ad2
|
||||
ChatPermission@140x44: frame=a02c51d79d0e842d hits=ddd7b36fd94b6b0b
|
||||
ChatPermission@100x30: frame=b9b1576fac8edffc hits=50e1f77f55960584
|
||||
ChatPermission@64x20: frame=dbb408089d778820 hits=8afd1db4c47a0a9c
|
||||
ChatPalette@140x44: frame=bf861983bf03164f hits=3a6ea3a3138eaf14
|
||||
ChatPalette@100x30: frame=a65f0019254d0d8e hits=f3b28c50ede92892
|
||||
ChatPalette@64x20: frame=616f4c3514c87f71 hits=52dfa888c2e73dae
|
||||
ChatScreenshot@140x44: frame=de5f11a7f83ed56d hits=c8e14a63097d7a07
|
||||
ChatScreenshot@100x30: frame=cab39388b54859f9 hits=26f52baec3dee1d2
|
||||
ChatScreenshot@64x20: frame=ca6107188a5c7961 hits=221c4d7e7aba3dc2
|
||||
GuidedReviewError@140x44: frame=4cfe3be8529e0715 hits=e84eb4945912e2b4
|
||||
GuidedReviewError@100x30: frame=07e33cea0523c085 hits=e84eb4945912e2b4
|
||||
GuidedReviewError@64x20: frame=7ee17e584e74c041 hits=e84eb4945912e2b4
|
||||
@@ -145,84 +145,84 @@ GuidedReviewNoise@64x20: frame=3528c31dc7357be3 hits=31b20cc44e89c2c4
|
||||
GuidedReviewRefreshing@140x44: frame=1668abd1d9025883 hits=9df927e0266ef722
|
||||
GuidedReviewRefreshing@100x30: frame=4317b6bf215040e7 hits=295bff8546ac5c6b
|
||||
GuidedReviewRefreshing@64x20: frame=09ab7d15dbf61722 hits=7bc94e825dcae38d
|
||||
SessionPicker@140x44: frame=912f8377d1180acc hits=a8942d3fdbcd05fa
|
||||
SessionPicker@100x30: frame=88899dac0687cbcc hits=245cbe04c33898e1
|
||||
SessionPicker@64x20: frame=054360868f390170 hits=4bf7f0b37b2cfe0e
|
||||
ChatPending@140x44: frame=b3d3a6a0888d6dcc hits=bffa58bed6da097d
|
||||
ChatPending@100x30: frame=af25fbea80bc33e0 hits=aed87b5034e6d516
|
||||
SessionPicker@140x44: frame=912f8377d1180acc hits=c60a3dc6b4fa73a4
|
||||
SessionPicker@100x30: frame=88899dac0687cbcc hits=5fd5ba61988aea29
|
||||
SessionPicker@64x20: frame=054360868f390170 hits=7c4d52848398b66a
|
||||
ChatPending@140x44: frame=f909e03a8376f6b1 hits=366de75b6bd95900
|
||||
ChatPending@100x30: frame=ee3d9e6c9614e800 hits=c07dd2ab562e8181
|
||||
ChatPending@64x20: frame=6cf055d281a6e059 hits=a326dcaa5154d3d5
|
||||
ChatPaste@140x44: frame=a114c31fca3067b3 hits=fdaff3e47dccb21c
|
||||
ChatPaste@100x30: frame=1bc91697dbb32003 hits=ab8dbf94c139d6b6
|
||||
ChatPaste@64x20: frame=9a087a91b9e245db hits=c81a12575eed6a9b
|
||||
DockWide@140x44: frame=1dbfc5a41a3416b6 hits=a826df811d38f497
|
||||
DockWide@100x30: frame=690c39c8c1842982 hits=dab83cf7c7b0dcf4
|
||||
ChatPaste@140x44: frame=062b6542933ddd4e hits=ed60a911efc2dc80
|
||||
ChatPaste@100x30: frame=a3c1f3b25bf9b866 hits=c28a07cc52a8036a
|
||||
ChatPaste@64x20: frame=2394954b60ffde86 hits=116b6b72e00e156b
|
||||
DockWide@140x44: frame=71e26329b31893a5 hits=412582aec7078dcf
|
||||
DockWide@100x30: frame=d4cc3c3b37ba3e4c hits=11b06062be632084
|
||||
DockWide@64x20: frame=c2743913ce96feb2 hits=9a683e49f6050f6a
|
||||
DockPullRequest@140x44: frame=6a0782c8b8f2ea02 hits=3d025fbcee7cebb1
|
||||
DockPullRequest@100x30: frame=d9977f7217a61374 hits=0ca570204cd54d62
|
||||
DockPullRequest@140x44: frame=50b8ef72650b2de9 hits=7abd2a4107b035e9
|
||||
DockPullRequest@100x30: frame=dfc474f14fb58c12 hits=c53cd566314fa546
|
||||
DockPullRequest@64x20: frame=5f381b5f389b3bbf hits=8defa6fb47bd7b1c
|
||||
DockOverlay@140x44: frame=1dbfc5a41a3416b6 hits=a826df811d38f497
|
||||
DockOverlay@100x30: frame=690c39c8c1842982 hits=dab83cf7c7b0dcf4
|
||||
DockOverlay@140x44: frame=71e26329b31893a5 hits=412582aec7078dcf
|
||||
DockOverlay@100x30: frame=d4cc3c3b37ba3e4c hits=11b06062be632084
|
||||
DockOverlay@64x20: frame=c2743913ce96feb2 hits=9a683e49f6050f6a
|
||||
DockCompact@140x44: frame=1dbfc5a41a3416b6 hits=a826df811d38f497
|
||||
DockCompact@100x30: frame=690c39c8c1842982 hits=dab83cf7c7b0dcf4
|
||||
DockCompact@140x44: frame=71e26329b31893a5 hits=412582aec7078dcf
|
||||
DockCompact@100x30: frame=d4cc3c3b37ba3e4c hits=11b06062be632084
|
||||
DockCompact@64x20: frame=c2743913ce96feb2 hits=9a683e49f6050f6a
|
||||
ChangesWide@140x44: frame=a97fe98d1e004a98 hits=f56f82edef818dc4
|
||||
ChangesWide@100x30: frame=7f799b893667c928 hits=5ebcfa50c83c624f
|
||||
ChangesWide@140x44: frame=567b4cf787b8530b hits=398055cd95986361
|
||||
ChangesWide@100x30: frame=55f1e47d406de3ad hits=497a209254b5326c
|
||||
ChangesWide@64x20: frame=3531cf4c1d3f2402 hits=a39e334a4bdaa029
|
||||
ChangesNarrow@140x44: frame=4d45021ad9fb0fa7 hits=de2158bdae6d8dfb
|
||||
ChangesNarrow@100x30: frame=2ee7cc81d7896506 hits=6dca1cfbcba4056a
|
||||
ChangesNarrow@64x20: frame=b82352043f680144 hits=65afb8e6ea7f4981
|
||||
ChangesFailed@140x44: frame=b8c525886e754d21 hits=88e878b841c4ee77
|
||||
ChangesFailed@100x30: frame=aba8595c8158cca4 hits=d3e7f3e0ab644214
|
||||
ChangesFailed@64x20: frame=8d0caaba450a4f3a hits=e16f1ab1fbfea007
|
||||
ChangesExternal@140x44: frame=fc75aaae10ddb262 hits=d5c3115642e748ad
|
||||
ChangesExternal@100x30: frame=522c8250b0f50ac4 hits=3dd17e6200cfb4b5
|
||||
ChangesExternal@64x20: frame=d257ba5dbedfc85f hits=a8e0be5b4625e2bc
|
||||
ChatTools+palette: frame=c829d2f08b78c950 hits=fa6287559ab11768
|
||||
ChatTools+slash: frame=994b21c60891c86e hits=c2817c90b9b6135b
|
||||
ChatTools+mention: frame=33c4a73f189a3dcc hits=a2bdd891f205d6cd
|
||||
ChatTools+model: frame=98b419f1ad7ab1ea hits=c1b8d78b51a767b7
|
||||
ChatTools+thinking: frame=3f2738927b6db1ef hits=b78e78ebc5c1a7dc
|
||||
ChatTools+theme: frame=1b1a5f40ea00f08f hits=a78b8d6b414df96c
|
||||
ChatTools+auth: frame=3a06199e21845eef hits=c1b8d78b51a767b7
|
||||
ChatTools+permission: frame=95b9f5bbdfe1bf17 hits=e455918b91b5d273
|
||||
ChatTools+question: frame=c49b4cf700798f0d hits=c4d62e93c9c4be28
|
||||
ChatTools+menu: frame=e7f786c4e9265de1 hits=f34ee075b3a703ce
|
||||
ChatTools+restack: frame=fc33296c0367ab69 hits=1bd4a41c3900100e
|
||||
ChatTools+github: frame=52744ce961495ff1 hits=0c880222e467f603
|
||||
ChatTools+card: frame=0eb34477cc814b1d hits=0c880222e467f603
|
||||
ChatTools+context: frame=7cd8b091af2f6451 hits=9d228eaa9af30b84
|
||||
ChatTools+sessions: frame=2a3363497d99b8ff hits=e84eb4945912e2b4
|
||||
ChangesNarrow@140x44: frame=e59601b04571bc9b hits=5226dd89b096442c
|
||||
ChangesNarrow@100x30: frame=645a3dca4888bfc7 hits=622dfea9442df986
|
||||
ChangesNarrow@64x20: frame=18e3603a52bca373 hits=94fe17cbdafe5700
|
||||
ChangesFailed@140x44: frame=2ea15b6d1a31c596 hits=bf89cf0d86b65b92
|
||||
ChangesFailed@100x30: frame=be6d07a5db0d1aa9 hits=dd9c3f34c90d27a7
|
||||
ChangesFailed@64x20: frame=bff7c3af95b0e119 hits=d0f30a7265d69320
|
||||
ChangesExternal@140x44: frame=9ba37292cb2e6a35 hits=09ec09c89e6ca208
|
||||
ChangesExternal@100x30: frame=db1b39453acf2471 hits=ecf0e58b8b98d69a
|
||||
ChangesExternal@64x20: frame=46f16c1af5432354 hits=83914dad5355f3f3
|
||||
ChatTools+palette: frame=564572ab53c3c18c hits=b71abd26ec373248
|
||||
ChatTools+slash: frame=5d29276dfc082a01 hits=22690e1cbf99a8e7
|
||||
ChatTools+mention: frame=4919b37b0262efc7 hits=7d051367696caa5d
|
||||
ChatTools+model: frame=b3dc5445132acd71 hits=c0d90d507af031e3
|
||||
ChatTools+thinking: frame=b4ffba1f8fdaeab8 hits=7114c7625e158ae0
|
||||
ChatTools+theme: frame=8c28ac94005eae5c hits=669c4b0f7638a9fc
|
||||
ChatTools+auth: frame=c211b47bb0469cca hits=c0d90d507af031e3
|
||||
ChatTools+permission: frame=636b8acaa16bcfb3 hits=99aa21dc6cda1403
|
||||
ChatTools+question: frame=2681674e75a4b089 hits=b74c8eb8fddfee78
|
||||
ChatTools+menu: frame=65da678d1334fc92 hits=23ed3017388989fe
|
||||
ChatTools+restack: frame=fb3fb6b2f0399779 hits=18c23ffc44f91212
|
||||
ChatTools+github: frame=52744ce961495ff1 hits=df11b39e1614db47
|
||||
ChatTools+card: frame=0468c7a21b89fdaa hits=df11b39e1614db47
|
||||
ChatTools+context: frame=fee7405f32c22371 hits=67bfeff05c0d5fb4
|
||||
ChatTools+sessions: frame=a2deec95cd284b23 hits=e84eb4945912e2b4
|
||||
ChatTools+configuration: frame=644345f8e6340004 hits=04d865ae91d0aa35
|
||||
ChatTools+image: frame=43dd64619ec6ac3d hits=0c880222e467f603
|
||||
ChatTools+keys: frame=d3c4357fcb28c0cd hits=c1b8d78b51a767b7
|
||||
Dashboard+palette: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
Dashboard+slash: frame=1972225550a37fa3 hits=7bc21f0311a1f171
|
||||
Dashboard+mention: frame=6091ee9a8ba6bb8e hits=3f150d5f4decbee7
|
||||
Dashboard+model: frame=94b31acf2a644906 hits=de7bc67135fb88ec
|
||||
Dashboard+thinking: frame=2e4f1d6cde8c3b6d hits=f64c038377072b2b
|
||||
Dashboard+theme: frame=186de30e37569285 hits=6ae67c6c9fb14fcd
|
||||
Dashboard+auth: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
Dashboard+permission: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
Dashboard+question: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
Dashboard+menu: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
Dashboard+restack: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
Dashboard+github: frame=c30b575f2402e1d9 hits=61fb1916348ca2c3
|
||||
Dashboard+card: frame=c30b575f2402e1d9 hits=61fb1916348ca2c3
|
||||
Dashboard+context: frame=fa9b603a43071e90 hits=eb277fd5f8d94d5a
|
||||
Dashboard+sessions: frame=328d666b34c64dd4 hits=de7bc67135fb88ec
|
||||
ChatTools+image: frame=43dd64619ec6ac3d hits=df11b39e1614db47
|
||||
ChatTools+keys: frame=45e7418c40ecf6e5 hits=c0d90d507af031e3
|
||||
Dashboard+palette: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
Dashboard+slash: frame=acb3327b6008ed82 hits=5e6d6586c03bcbde
|
||||
Dashboard+mention: frame=4406da17ad9a7147 hits=c7e47c0a20f35e4c
|
||||
Dashboard+model: frame=f3272d2ddbfbfbb2 hits=439d7ed4fc755dd5
|
||||
Dashboard+thinking: frame=d1863d29758d25fe hits=19b544643eeb29f6
|
||||
Dashboard+theme: frame=92148e7ff56b1412 hits=8514413214013e6a
|
||||
Dashboard+auth: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
Dashboard+permission: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
Dashboard+question: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
Dashboard+menu: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
Dashboard+restack: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
Dashboard+github: frame=4cfff6c346b515ec hits=54a24da90021e322
|
||||
Dashboard+card: frame=4cfff6c346b515ec hits=54a24da90021e322
|
||||
Dashboard+context: frame=91d086beb65b1c6b hits=b7478b6ed9acab7f
|
||||
Dashboard+sessions: frame=328d666b34c64dd4 hits=439d7ed4fc755dd5
|
||||
Dashboard+configuration: frame=644345f8e6340004 hits=04d865ae91d0aa35
|
||||
Dashboard+image: frame=c30b575f2402e1d9 hits=61fb1916348ca2c3
|
||||
Dashboard+keys: frame=c30b575f2402e1d9 hits=de7bc67135fb88ec
|
||||
ChatWideProse scrolled: frame=763f6da386997546 hits=3836f0941803048a
|
||||
Dashboard+image: frame=4cfff6c346b515ec hits=54a24da90021e322
|
||||
Dashboard+keys: frame=4cfff6c346b515ec hits=439d7ed4fc755dd5
|
||||
ChatWideProse scrolled: frame=77c262dd3beb2c81 hits=6c1f48358143f9da
|
||||
ChatWideProse searching: frame=1878156c08a54641 hits=00e988aa75182c51
|
||||
ChatWideProse selecting: frame=8c1edde42c1f3700 hits=bddfef30519a2a3a
|
||||
ChatWideProse copied: frame=7757bb42f647c93e hits=bddfef30519a2a3a
|
||||
ChangesWide@180x44: frame=9bbe81ca767acba8 hits=c9c1021bb64d2d75
|
||||
ChangesNarrow unwrapped: frame=13da9745cf50215c hits=c84985bf30e3251e
|
||||
ChangesWide file: frame=1194fa59f8ea5db3 hits=36477f2310641d0c
|
||||
ChangesWide file cursor: frame=833f03816b3313b1 hits=897bb2fabe0e82c5
|
||||
ChangesWide file unwrapped: frame=3617d8bccfa68b3c hits=f64a48041a46cec2
|
||||
ChatWideProse selecting: frame=65c35adc812db9c3 hits=3ed3f6a36fc4b70e
|
||||
ChatWideProse copied: frame=b3533a5d15c5aa11 hits=3ed3f6a36fc4b70e
|
||||
ChangesWide@180x44: frame=b6edb724f606b832 hits=6810988e01cba555
|
||||
ChangesNarrow unwrapped: frame=6669d3971ca2172f hits=20f33e57e8b00a6f
|
||||
ChangesWide file: frame=d83385057b8329e3 hits=b102fa58d79d140d
|
||||
ChangesWide file cursor: frame=f998f3a996a3223f hits=566e80af5b6b5b81
|
||||
ChangesWide file unwrapped: frame=baee09e428676d16 hits=d6db52ab270b8924
|
||||
review help@140x44: frame=ce6ecfdcf523a173 hits=363734d0f1e4973a
|
||||
review help@100x30: frame=f556ce437bd29e48 hits=e4ef9f77a3045de7
|
||||
review details@140x44: frame=74d4463801d34480 hits=5c309ee031fdabbc
|
||||
@@ -246,47 +246,47 @@ GuidedReviewSplit wrapped: frame=744f32f79e0e2cdb hits=0f089258f4d432e1
|
||||
GuidedReviewFindings wrapped: frame=b633d879925abb7d hits=6dbae16ee902d2ad
|
||||
GuidedReviewFindings split: frame=0ca567ccbed0b3c4 hits=ed78edfc97c588fe
|
||||
GuidedReviewFindings split wrapped: frame=198214cf1a5d51f4 hits=a1ef3e921a2f268b
|
||||
login@100x30: frame=b38ac40b582acab9 hits=95ec927979b30d8d
|
||||
login-subscription@100x30: frame=e124818a2e734350 hits=5676dba97e0ea37f
|
||||
login-local@100x30: frame=2e2797e9080feb20 hits=ee2b62ff5ee571b4
|
||||
login-method@100x30: frame=25f0337c7e66d84b hits=d7190c558c1be1a3
|
||||
login-secret@100x30: frame=8e5caa0414d23337 hits=b05996f46f500728
|
||||
login-device@100x30: frame=9678dcaabe255bf8 hits=4f495f0ab9ddfec4
|
||||
login-failed@100x30: frame=7a68823bb655e435 hits=b05996f46f500728
|
||||
github@100x30: frame=29b83b4de4d5e45a hits=6ce218f729777fd8
|
||||
github-detail@100x30: frame=8bff1a38ff99681f hits=6ce218f729777fd8
|
||||
github-search@100x30: frame=53dba34b1752756a hits=6ce218f729777fd8
|
||||
github-conversation@100x30: frame=edf04abf459ed1bd hits=6ce218f729777fd8
|
||||
github-draft@100x30: frame=4422c33d0017af09 hits=6ce218f729777fd8
|
||||
github-issue@100x30: frame=e3d564c4eef215f3 hits=6ce218f729777fd8
|
||||
github-pulls@100x30: frame=cac8411b28b1f011 hits=6ce218f729777fd8
|
||||
github-merged@100x30: frame=e82ed89a22ea11e1 hits=6ce218f729777fd8
|
||||
mention-files-query@100x30: frame=2eb05c671dab8ebc hits=e6c3e66b46987af2
|
||||
mention-files-status@100x30: frame=91f8455b4baf0148 hits=7757c43a2fec458b
|
||||
mention-skills@100x30: frame=6e6877b6dd409095 hits=27fb10f91fed61ab
|
||||
mention-mcp@100x30: frame=038a9d5361f2bc2f hits=0c089633a27c8ae2
|
||||
mention-jira@100x30: frame=f640a573307765d3 hits=27fb10f91fed61ab
|
||||
mention-github@100x30: frame=026d8b9a16953d45 hits=e23658383d089fb6
|
||||
mention-github-signed-out@100x30: frame=d1d8c82792308662 hits=21234e7842378b16
|
||||
login@64x20: frame=3b1d75fe18a971a0 hits=c63cd0e65b0b73cd
|
||||
login-subscription@64x20: frame=9f51f8338dd333a2 hits=faeb76f2da50194c
|
||||
login-local@64x20: frame=1e111e16e697b7d2 hits=cf1a97c489a227e5
|
||||
login-method@64x20: frame=c0818a1d2ffab01b hits=d068b54bba55b395
|
||||
login-secret@64x20: frame=f7cb80562502782e hits=a16a29ea4502d9fb
|
||||
login-device@64x20: frame=d61ec0dc1534f2a5 hits=44ef8648f0a8302d
|
||||
login-failed@64x20: frame=8580d73e67e35808 hits=a16a29ea4502d9fb
|
||||
github@64x20: frame=59c575f5a335deb0 hits=7c38e58fb5f36453
|
||||
github-detail@64x20: frame=15178bfb7c3e702e hits=7c38e58fb5f36453
|
||||
github-search@64x20: frame=6b7a8543e3aeafe6 hits=7c38e58fb5f36453
|
||||
github-conversation@64x20: frame=080fc4fa2d4992fe hits=7c38e58fb5f36453
|
||||
github-draft@64x20: frame=9d8959251dd7d83d hits=7c38e58fb5f36453
|
||||
github-issue@64x20: frame=8add8ff54baf5a03 hits=7c38e58fb5f36453
|
||||
github-pulls@64x20: frame=b3b0eb63f8cd945a hits=7c38e58fb5f36453
|
||||
github-merged@64x20: frame=a84ad5ca4b5dee92 hits=7c38e58fb5f36453
|
||||
mention-files-query@64x20: frame=da23adbd6c69989c hits=b7e5cd3a9d5b2844
|
||||
mention-files-status@64x20: frame=b8032fcc39098b20 hits=93543fda718d1960
|
||||
mention-skills@64x20: frame=1de91f817235caaa hits=907bb533764c9348
|
||||
mention-mcp@64x20: frame=c7116499ec2e6de7 hits=b0a66af049a2990d
|
||||
mention-jira@64x20: frame=7c4e7cbbf9dfbfe4 hits=907bb533764c9348
|
||||
mention-github@64x20: frame=38344f549d6e1c2f hits=b0a66af049a2990d
|
||||
mention-github-signed-out@64x20: frame=cfdc0449ca9d0350 hits=9a375098c9c3f3e9
|
||||
login@100x30: frame=1caa02522105b0a4 hits=c65900fccfd2f119
|
||||
login-subscription@100x30: frame=ef694fede886ac51 hits=923689e32e838cef
|
||||
login-local@100x30: frame=9f7f55a18a26be81 hits=31052750ae9e8d14
|
||||
login-method@100x30: frame=b3ee3a49a702bbae hits=470df220b45e0ff3
|
||||
login-secret@100x30: frame=93e373c9a5ef33ea hits=69cdb7da7a4fd8b8
|
||||
login-device@100x30: frame=b9422a98336a04d9 hits=7559aa044286b6b4
|
||||
login-failed@100x30: frame=24028618e34563c0 hits=69cdb7da7a4fd8b8
|
||||
github@100x30: frame=29b83b4de4d5e45a hits=921d6cc6fc01f208
|
||||
github-detail@100x30: frame=8bff1a38ff99681f hits=921d6cc6fc01f208
|
||||
github-search@100x30: frame=53dba34b1752756a hits=921d6cc6fc01f208
|
||||
github-conversation@100x30: frame=edf04abf459ed1bd hits=921d6cc6fc01f208
|
||||
github-draft@100x30: frame=4422c33d0017af09 hits=921d6cc6fc01f208
|
||||
github-issue@100x30: frame=e3d564c4eef215f3 hits=921d6cc6fc01f208
|
||||
github-pulls@100x30: frame=cac8411b28b1f011 hits=921d6cc6fc01f208
|
||||
github-merged@100x30: frame=e82ed89a22ea11e1 hits=921d6cc6fc01f208
|
||||
mention-files-query@100x30: frame=fc2b648a057dab8f hits=d03d067239bab0ce
|
||||
mention-files-status@100x30: frame=d49ef5ef45b1600f hits=b3dfb2106b890137
|
||||
mention-skills@100x30: frame=d3900df873bf8f70 hits=f31837af6d3b7027
|
||||
mention-mcp@100x30: frame=b1c9d8084676115c hits=95b7fbbf9bfc6c16
|
||||
mention-jira@100x30: frame=60fe180e5c34cea6 hits=f31837af6d3b7027
|
||||
mention-github@100x30: frame=fec9b3fb7bad2760 hits=c5b06921daf6328a
|
||||
mention-github-signed-out@100x30: frame=9f2861cc71304387 hits=732fe7bcf972d86a
|
||||
login@64x20: frame=e8227a337231897b hits=92408d2c72c2ae81
|
||||
login-subscription@64x20: frame=9145a202126051c3 hits=9d8916fd37dd2ef8
|
||||
login-local@64x20: frame=077a9aadfb05b493 hits=3b43ae76fde584c9
|
||||
login-method@64x20: frame=2b9c9bb1ab0bea46 hits=ed664a1f1d726b91
|
||||
login-secret@64x20: frame=f2abdb2b76626c3f hits=35eed18e784f1d4f
|
||||
login-device@64x20: frame=3bd521c2fdf29e98 hits=fe5cd7508c7ee399
|
||||
login-failed@64x20: frame=5850ab999b9207c9 hits=35eed18e784f1d4f
|
||||
github@64x20: frame=59c575f5a335deb0 hits=2bd71fb6cb1f4187
|
||||
github-detail@64x20: frame=15178bfb7c3e702e hits=2bd71fb6cb1f4187
|
||||
github-search@64x20: frame=6b7a8543e3aeafe6 hits=2bd71fb6cb1f4187
|
||||
github-conversation@64x20: frame=080fc4fa2d4992fe hits=2bd71fb6cb1f4187
|
||||
github-draft@64x20: frame=9d8959251dd7d83d hits=2bd71fb6cb1f4187
|
||||
github-issue@64x20: frame=8add8ff54baf5a03 hits=2bd71fb6cb1f4187
|
||||
github-pulls@64x20: frame=b3b0eb63f8cd945a hits=2bd71fb6cb1f4187
|
||||
github-merged@64x20: frame=a84ad5ca4b5dee92 hits=2bd71fb6cb1f4187
|
||||
mention-files-query@64x20: frame=419c41adeaff912f hits=57c4f3180204f234
|
||||
mention-files-status@64x20: frame=80b38a9a6b6a97a7 hits=485bb97567db67b0
|
||||
mention-skills@64x20: frame=b57d410ff3631e07 hits=790a9bf9b4cf0438
|
||||
mention-mcp@64x20: frame=b7c7d59625eb0444 hits=27582af9d9e75a9d
|
||||
mention-jira@64x20: frame=f5a1bb47eead9069 hits=790a9bf9b4cf0438
|
||||
mention-github@64x20: frame=ac1c5ff6fb420aa2 hits=27582af9d9e75a9d
|
||||
mention-github-signed-out@64x20: frame=c42c0a6408a0beed hits=d3baa6186b174d79
|
||||
|
||||
@@ -25,7 +25,7 @@ use diff_render::render_content;
|
||||
use github_post::render_github_post;
|
||||
use overlays::{
|
||||
render_commit_preview, render_finding_details, render_finding_draft, render_finding_fix,
|
||||
render_finish_review, render_help, render_source_picker,
|
||||
render_finish_review, render_help, render_pull_request_description, render_source_picker,
|
||||
};
|
||||
use pull_request_fix::render_pull_request_fix;
|
||||
use pull_request_opening::render_pull_request_opening;
|
||||
@@ -207,6 +207,7 @@ fn render_ready_columns(
|
||||
fn review_modal_open(app: &App) -> bool {
|
||||
matches!(app.guided_review_workspace.source_picker, ReviewSourcePickerState::Open { .. })
|
||||
|| app.guided_review_workspace.help_visible
|
||||
|| app.guided_review_workspace.description_scroll.is_some()
|
||||
|| app.guided_review_workspace.finding_details_visible
|
||||
|| app.guided_review_workspace.finding_fix_visible
|
||||
|| app.guided_review_workspace.finding_draft.is_some()
|
||||
@@ -314,6 +315,9 @@ fn render_review_overlays(frame: &mut Frame, inner: Rect, app: &App) {
|
||||
if let Some(preview) = app.guided_review_workspace.commit_preview.as_ref() {
|
||||
render_commit_preview(frame, inner, app, preview);
|
||||
}
|
||||
if let Some(scroll) = app.guided_review_workspace.description_scroll {
|
||||
render_pull_request_description(frame, inner, app, scroll);
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapped height of the medium-tier context block, so the diff gets every row it does not need.
|
||||
|
||||
@@ -27,10 +27,10 @@ pub(crate) use files::FileOwners;
|
||||
use luxe_core::guided_review::GuidedReview;
|
||||
pub(super) use notices::notice_lines;
|
||||
#[cfg(test)]
|
||||
use pull_request::description_opening;
|
||||
#[cfg(test)]
|
||||
use pull_request::is_closing_reference;
|
||||
pub(super) use pull_request::pull_request_facts;
|
||||
#[cfg(test)]
|
||||
use pull_request::{description_opening, DESCRIPTION_OPENING_CHARS};
|
||||
use pull_request::{earlier_conversation_lines, pull_request_account};
|
||||
|
||||
/// Judgement items past which a review is honestly more than one sitting.
|
||||
@@ -165,12 +165,12 @@ mod tests {
|
||||
fn a_description_opens_with_its_first_paragraphs() {
|
||||
let body = format!(
|
||||
"Fixes #14404\n\n### Description\n\nThe owner casing differed.\n\n{}\n\n{}",
|
||||
"a".repeat(300),
|
||||
"b".repeat(400)
|
||||
"a".repeat(200),
|
||||
"b".repeat(200)
|
||||
);
|
||||
let (opening, more) = description_opening(&body);
|
||||
assert!(opening.starts_with("The owner casing differed."), "{opening}");
|
||||
assert!(opening.contains(&"a".repeat(300)));
|
||||
assert!(opening.contains(&"a".repeat(200)));
|
||||
assert!(!opening.contains('b'), "past the budget");
|
||||
assert!(!opening.contains("Fixes") && !opening.contains("###"), "{opening}");
|
||||
assert!(more);
|
||||
@@ -180,8 +180,26 @@ mod tests {
|
||||
("Short and complete.".into(), false)
|
||||
);
|
||||
assert_eq!(description_opening("Fixes #3"), (String::new(), false));
|
||||
let lone = "x".repeat(900);
|
||||
assert_eq!(description_opening(&lone), (lone.clone(), false), "one paragraph is never cut");
|
||||
}
|
||||
|
||||
/// One long paragraph, the way an agent writes a description, is cut too: at its last
|
||||
/// sentence that fits, and failing one, at a word. Either way it says there is more.
|
||||
#[test]
|
||||
fn a_long_first_paragraph_is_cut_at_a_sentence() {
|
||||
let sentence = "This change moves the parser into its own module for reuse. ";
|
||||
let long = sentence.repeat(10);
|
||||
let (opening, more) = description_opening(&long);
|
||||
assert!(more);
|
||||
assert!(opening.ends_with("for reuse."), "cut after a whole sentence: {opening}");
|
||||
assert!(opening.chars().count() <= DESCRIPTION_OPENING_CHARS, "{}", opening.len());
|
||||
|
||||
let words = "word ".repeat(100);
|
||||
let (opening, more) = description_opening(&words);
|
||||
assert!(more && opening.ends_with("word\u{2026}"), "{opening}");
|
||||
|
||||
// A paragraph that fits is whole, and nothing is said to follow it
|
||||
let short = sentence.repeat(2);
|
||||
assert_eq!(description_opening(&short), (short.trim().to_owned(), false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -104,17 +104,17 @@ fn no_provenance(review: &GuidedReview) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// Color by urgency: a possible credential or a weakened gate outranks an unread edit.
|
||||
/// Color by urgency: a possible credential outranks an unread edit.
|
||||
fn attention_style(app: &App, signal: &AttentionSignal) -> Style {
|
||||
use luxe_core::guided_review::AttentionKind;
|
||||
match signal.kind {
|
||||
AttentionKind::SecretShaped | AttentionKind::GateWeakened => app.theme_styles.error,
|
||||
AttentionKind::SecretShaped => app.theme_styles.error,
|
||||
AttentionKind::BlindEdit => app.theme_styles.warning,
|
||||
}
|
||||
}
|
||||
|
||||
/// How many lines or files of `kind` the review flags: a credential or a weakened gate is a line,
|
||||
/// an unread edit a file.
|
||||
/// How many lines or files of `kind` the review flags: a credential is a line, an unread edit a
|
||||
/// file.
|
||||
fn flagged_total(app: &App, kind: luxe_core::guided_review::AttentionKind) -> usize {
|
||||
app.review.flags.iter().filter(|flag| flag.kind == kind).count()
|
||||
}
|
||||
|
||||
@@ -90,10 +90,8 @@ pub(super) fn pull_request_account(
|
||||
lines.push(Line::default());
|
||||
lines.extend(prose_lines(&opening, app, width, " "));
|
||||
if more {
|
||||
lines.push(Line::from(Span::styled(
|
||||
" The rest of the description is on GitHub \u{b7} o",
|
||||
styles.dim,
|
||||
)));
|
||||
let whole = " Read the whole description \u{b7} p";
|
||||
lines.push(Line::from(Span::styled(whole, styles.dim)));
|
||||
}
|
||||
}
|
||||
if !pr.closing_issues.is_empty() {
|
||||
@@ -299,15 +297,18 @@ fn discussion_item(
|
||||
lines
|
||||
}
|
||||
|
||||
/// Characters of a pull request's description the brief shows before pointing at GitHub.
|
||||
const DESCRIPTION_OPENING_CHARS: usize = 600;
|
||||
/// Characters of a pull request's description the brief shows before pointing at the whole of it:
|
||||
/// a few lines of the guide, enough to hear the author's claim in their own words.
|
||||
pub(super) const DESCRIPTION_OPENING_CHARS: usize = 320;
|
||||
|
||||
/// The first paragraphs of a description, and whether there is more.
|
||||
///
|
||||
/// The guide scrolls to keep the current chapter in view, so a long description in full pushes the
|
||||
/// chapters down and opens the pane in the middle of someone's prose with its heading gone — which
|
||||
/// the first real pull request did. The guide's prompt still gets all of it. Template headings and
|
||||
/// a bare `Fixes #n` are skipped: the issues it closes have their own section.
|
||||
/// the first real pull request did. Even one paragraph is cut, at a sentence where it can be,
|
||||
/// since an agent's opening paragraph alone can fill the pane and `p` reads the rest. The guide's
|
||||
/// prompt still gets all of it. Template headings and a bare `Fixes #n` are skipped: the issues
|
||||
/// it closes have their own section.
|
||||
pub(super) fn description_opening(body: &str) -> (String, bool) {
|
||||
let paragraphs: Vec<&str> = body
|
||||
.split("\n\n")
|
||||
@@ -316,21 +317,41 @@ pub(super) fn description_opening(body: &str) -> (String, bool) {
|
||||
.filter(|paragraph| !paragraph.starts_with('#') || paragraph.contains('\n'))
|
||||
.filter(|paragraph| !is_closing_reference(paragraph))
|
||||
.collect();
|
||||
let mut opening = String::new();
|
||||
let mut taken = 0;
|
||||
for paragraph in ¶graphs {
|
||||
if taken > 0
|
||||
&& opening.chars().count() + paragraph.chars().count() > DESCRIPTION_OPENING_CHARS
|
||||
{
|
||||
let Some(first) = paragraphs.first() else { return (String::new(), false) };
|
||||
let mut opening = clip_at_sentence(first, DESCRIPTION_OPENING_CHARS);
|
||||
let mut taken = 1;
|
||||
let cut = opening.len() < first.len();
|
||||
for paragraph in paragraphs.iter().skip(1).take_while(|_| !cut) {
|
||||
if opening.chars().count() + paragraph.chars().count() > DESCRIPTION_OPENING_CHARS {
|
||||
break;
|
||||
}
|
||||
if taken > 0 {
|
||||
opening.push_str("\n\n");
|
||||
}
|
||||
opening.push_str("\n\n");
|
||||
opening.push_str(paragraph);
|
||||
taken += 1;
|
||||
}
|
||||
(opening, taken < paragraphs.len())
|
||||
(opening, cut || taken < paragraphs.len())
|
||||
}
|
||||
|
||||
/// `text` cut to at most `limit` characters: at the last sentence or line end in the second half
|
||||
/// of that, or failing one, at a word with an ellipsis.
|
||||
fn clip_at_sentence(text: &str, limit: usize) -> String {
|
||||
if text.chars().count() <= limit {
|
||||
return text.to_owned();
|
||||
}
|
||||
let head: String = text.chars().take(limit).collect();
|
||||
// The punctuation is ASCII, so one byte past it is still a character boundary
|
||||
let sentence_end = head
|
||||
.char_indices()
|
||||
.filter(|(at, mark)| matches!(mark, '.' | '!' | '?') && head[at + 1..].starts_with(' '))
|
||||
.map(|(at, _)| at + 1)
|
||||
.next_back();
|
||||
match sentence_end.max(head.rfind('\n')).filter(|end| *end >= head.len() / 2) {
|
||||
Some(end) => head[..end].trim_end().to_owned(),
|
||||
None => {
|
||||
let word = head.rfind(char::is_whitespace).unwrap_or(head.len());
|
||||
format!("{}\u{2026}", head[..word].trim_end())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `Fixes #12`, `closes owner/repo#3`: a line GitHub reads as a link to an issue, and nothing more.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Guided Review overlays — findings drawer, finish/confirm dialogs, finding details,
|
||||
//! draft composer, outline, help, and the source picker.
|
||||
//! draft composer, outline, help, the source picker, and a pull request's whole description.
|
||||
//!
|
||||
//! Two overlay classes (design-tui-polish-and-mouse §A3, D5):
|
||||
//! - **Modal** (source picker, outline, help, finding details, draft composer, finish review):
|
||||
@@ -8,12 +8,14 @@
|
||||
//! - **Drawer** (the findings panel): a non-modal right-edge companion with **no backdrop** —
|
||||
//! the surface stays bright so the reviewer keeps the diff in view while triaging findings.
|
||||
|
||||
mod description;
|
||||
mod evidence;
|
||||
mod finding;
|
||||
mod finish;
|
||||
mod help;
|
||||
|
||||
use crate::app::App;
|
||||
pub(super) use description::render_pull_request_description;
|
||||
pub(super) use evidence::render_finding_fix;
|
||||
pub(super) use finding::{
|
||||
anchor_summary, chapter_kind_label, finding_state_glyph, finding_state_label,
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
//! Pull request description — the author's whole description, scrollable over the review.
|
||||
//!
|
||||
//! The guide shows only its opening, because a long description pushes the chapters out of view.
|
||||
//! The rest used to mean leaving for GitHub, and descriptions written by agents are often long
|
||||
//! enough that the opening is a small part of them, so this reads it here instead.
|
||||
|
||||
use super::overlay_block;
|
||||
use crate::app::App;
|
||||
use crate::glyphs::Icon;
|
||||
use crate::view::guided_review::brief::prose_lines;
|
||||
use luxe_core::guided_review::PullRequestContext;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Clear, Paragraph};
|
||||
use ratatui::Frame;
|
||||
|
||||
/// The widest the reading column gets. Prose much wider than this is hard to follow line to line.
|
||||
const MAX_READING_WIDTH: u16 = 100;
|
||||
|
||||
/// Draws the description over `area`, scrolled down `scroll` rows, and records how far it can
|
||||
/// scroll so the keys stop at its end.
|
||||
pub(in crate::view::guided_review) fn render_pull_request_description(
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
app: &App,
|
||||
scroll: u16,
|
||||
) {
|
||||
let Some(pr) =
|
||||
app.guided_review.as_ref().and_then(|review| review.context.pull_request.as_ref())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let popup = popup_area(area);
|
||||
let block = overlay_block(app, Icon::PullRequest.glyph(), "What the pull request says");
|
||||
let body = crate::widgets::footed_body(&block, popup);
|
||||
let lines = description_lines(app, pr, usize::from(body.width));
|
||||
let total = u16::try_from(lines.len()).unwrap_or(u16::MAX);
|
||||
let room = total.saturating_sub(body.height);
|
||||
app.guided_review_workspace.description_room.set(room);
|
||||
let scroll = scroll.min(room);
|
||||
let count = position(scroll, body.height, total);
|
||||
frame.render_widget(Clear, popup);
|
||||
crate::widgets::render_footed(frame, block, popup, HINT, count.as_deref(), &app.theme_styles);
|
||||
frame.render_widget(Paragraph::new(lines).scroll((scroll, 0)), body);
|
||||
}
|
||||
|
||||
/// The footer's keys.
|
||||
const HINT: &str = "\u{2191}\u{2193} scroll \u{b7} esc close";
|
||||
|
||||
/// Where the window is in the description (`21–40 of 64`), or `None` when it all fits.
|
||||
fn position(first: u16, rows: u16, total: u16) -> Option<String> {
|
||||
(total > rows).then(|| format!("{}\u{2013}{} of {total}", first + 1, (first + rows).min(total)))
|
||||
}
|
||||
|
||||
/// A centered window most of the review's height, at a width prose reads well at.
|
||||
fn popup_area(area: Rect) -> Rect {
|
||||
let width = area.width.saturating_sub(4).min(MAX_READING_WIDTH);
|
||||
let height = area.height.saturating_sub(2);
|
||||
Rect::new(
|
||||
area.x + area.width.saturating_sub(width) / 2,
|
||||
area.y + area.height.saturating_sub(height) / 2,
|
||||
width,
|
||||
height,
|
||||
)
|
||||
}
|
||||
|
||||
/// The title, the branches, and the description as written, every line of it.
|
||||
fn description_lines(app: &App, pr: &PullRequestContext, width: usize) -> Vec<Line<'static>> {
|
||||
let styles = &app.theme_styles;
|
||||
let mut lines = prose_lines(&pr.title, app, width, "");
|
||||
lines.push(Line::from(Span::styled(
|
||||
format!("{} \u{2192} {}", pr.head_ref, pr.base_ref),
|
||||
styles.dim,
|
||||
)));
|
||||
lines.push(Line::default());
|
||||
lines.extend(prose_lines(&pr.body, app, width, ""));
|
||||
lines
|
||||
}
|
||||
@@ -76,6 +76,17 @@ fn help_groups(app: &App) -> Vec<HelpGroup> {
|
||||
if pull_request {
|
||||
feedback.push(row("o", "open on GitHub"));
|
||||
}
|
||||
let mut read = vec![
|
||||
(chord(UiAction::ReviewToggleGuide, "g"), "show or hide the guide".to_owned()),
|
||||
row("z", "show or hide the prose"),
|
||||
(chord(UiAction::ReviewToggleSplit, "ctrl+b"), "side-by-side or unified".to_owned()),
|
||||
row("w", "wrap long lines"),
|
||||
row("f d", "open collapsed churn, say why"),
|
||||
(letter(UiAction::ReviewOpenInEditor, "E"), "open the file in your editor".to_owned()),
|
||||
];
|
||||
if pull_request {
|
||||
read.push(row("p", "read the whole description"));
|
||||
}
|
||||
vec![
|
||||
(
|
||||
"Move",
|
||||
@@ -92,23 +103,7 @@ fn help_groups(app: &App) -> Vec<HelpGroup> {
|
||||
row("/", "find"),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Read",
|
||||
vec![
|
||||
(chord(UiAction::ReviewToggleGuide, "g"), "show or hide the guide".to_owned()),
|
||||
row("z", "show or hide the prose"),
|
||||
(
|
||||
chord(UiAction::ReviewToggleSplit, "ctrl+b"),
|
||||
"side-by-side or unified".to_owned(),
|
||||
),
|
||||
row("w", "wrap long lines"),
|
||||
row("f d", "open collapsed churn, say why"),
|
||||
(
|
||||
letter(UiAction::ReviewOpenInEditor, "E"),
|
||||
"open the file in your editor".to_owned(),
|
||||
),
|
||||
],
|
||||
),
|
||||
("Read", read),
|
||||
("Feedback", feedback),
|
||||
(
|
||||
"Session",
|
||||
|
||||
@@ -13,6 +13,7 @@ use std::path::Path;
|
||||
mod agent_activity;
|
||||
mod attention_in_walkthrough;
|
||||
mod composer;
|
||||
mod description;
|
||||
mod footer_contract;
|
||||
mod guide_interaction;
|
||||
mod rail_divider;
|
||||
|
||||
99
crates/luxe-tui/src/view/guided_review/tests/description.rs
Normal file
99
crates/luxe-tui/src/view/guided_review/tests/description.rs
Normal file
@@ -0,0 +1,99 @@
|
||||
//! A pull request's whole description reads over the review, rather than only on GitHub.
|
||||
|
||||
use crate::app::{App, Msg};
|
||||
use crate::fixture::{seeded_app, FixtureScenario};
|
||||
use crate::main_loop::{route_key, route_mouse, RouteAction};
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind};
|
||||
use ratatui::{backend::TestBackend, Terminal};
|
||||
|
||||
const WIDTH: u16 = 160;
|
||||
const HEIGHT: u16 = 40;
|
||||
|
||||
/// The pull request fixture with a description long enough to need scrolling, its last line
|
||||
/// marked so a test can tell whether it was ever reachable.
|
||||
fn long_description_app() -> App {
|
||||
let mut app = seeded_app("nord", FixtureScenario::GuidedReviewPullRequest).expect("fixture");
|
||||
let body =
|
||||
(1..=80).map(|n| format!("Paragraph {n} of the author's account.")).collect::<Vec<_>>();
|
||||
let body = format!("{}\n\nTHE LAST LINE", body.join("\n\n"));
|
||||
pull_request_mut(&mut app).body = body;
|
||||
app.update(Msg::TerminalResized { width: WIDTH, height: HEIGHT });
|
||||
app
|
||||
}
|
||||
|
||||
fn pull_request_mut(app: &mut App) -> &mut luxe_core::guided_review::PullRequestContext {
|
||||
let review = app.guided_review.as_mut().expect("a review");
|
||||
review.context.pull_request.as_mut().expect("a pull request")
|
||||
}
|
||||
|
||||
fn draw(app: &mut App) -> String {
|
||||
let mut terminal = Terminal::new(TestBackend::new(WIDTH, HEIGHT)).expect("test terminal");
|
||||
terminal.draw(|frame| crate::view::render(frame, app)).expect("render");
|
||||
terminal.backend().buffer().content.iter().map(ratatui::buffer::Cell::symbol).collect()
|
||||
}
|
||||
|
||||
fn press(app: &mut App, code: KeyCode) {
|
||||
if let RouteAction::Msg(message) = route_key(app, &KeyEvent::new(code, KeyModifiers::NONE)) {
|
||||
app.update(*message);
|
||||
}
|
||||
}
|
||||
|
||||
/// The guide points at the reader, `p` opens it at the top, it scrolls to the very end, and `esc`
|
||||
/// shuts it without leaving the review.
|
||||
#[test]
|
||||
fn p_opens_the_whole_description_and_it_scrolls_to_the_end() {
|
||||
let mut app = long_description_app();
|
||||
let guide = draw(&mut app);
|
||||
assert!(guide.contains("Read the whole description"), "the guide names the key");
|
||||
assert!(!guide.contains("THE LAST LINE"));
|
||||
|
||||
press(&mut app, KeyCode::Char('p'));
|
||||
assert_eq!(app.guided_review_workspace.description_scroll, Some(0));
|
||||
let open = draw(&mut app);
|
||||
assert!(open.contains("Paragraph 1 of the author"), "opens at the top");
|
||||
assert!(!open.contains("THE LAST LINE"), "too long to fit, or the test proves nothing");
|
||||
|
||||
press(&mut app, KeyCode::End);
|
||||
assert!(draw(&mut app).contains("THE LAST LINE"), "every line is reachable");
|
||||
let room = app.guided_review_workspace.description_room.get();
|
||||
assert_eq!(app.guided_review_workspace.description_scroll, Some(room), "and stops there");
|
||||
|
||||
press(&mut app, KeyCode::Esc);
|
||||
assert_eq!(app.guided_review_workspace.description_scroll, None);
|
||||
assert!(app.guided_review.is_some(), "esc shut the description, not the review");
|
||||
}
|
||||
|
||||
/// While it is open the review behind does not move: a letter that would step the walkthrough is
|
||||
/// swallowed, and the wheel scrolls the description wherever the pointer is.
|
||||
#[test]
|
||||
fn the_review_behind_the_description_stays_put() {
|
||||
let mut app = long_description_app();
|
||||
draw(&mut app);
|
||||
press(&mut app, KeyCode::Char('p'));
|
||||
draw(&mut app);
|
||||
let position = app.guided_review_workspace.position.clone();
|
||||
press(&mut app, KeyCode::Char('n'));
|
||||
assert_eq!(app.guided_review_workspace.position, position, "n stepped the walkthrough");
|
||||
|
||||
let wheel = MouseEvent {
|
||||
kind: MouseEventKind::ScrollDown,
|
||||
column: 1,
|
||||
row: 1,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
};
|
||||
match route_mouse(&mut app, &wheel) {
|
||||
RouteAction::Msg(message) => app.update(*message),
|
||||
other => panic!("the wheel went elsewhere: {other:?}"),
|
||||
}
|
||||
assert_eq!(app.guided_review_workspace.description_scroll, Some(3));
|
||||
}
|
||||
|
||||
/// A review with no description has nothing to open, so `p` leaves it as it was.
|
||||
#[test]
|
||||
fn p_does_nothing_without_a_description() {
|
||||
let mut app = long_description_app();
|
||||
pull_request_mut(&mut app).body = " ".into();
|
||||
draw(&mut app);
|
||||
press(&mut app, KeyCode::Char('p'));
|
||||
assert_eq!(app.guided_review_workspace.description_scroll, None);
|
||||
}
|
||||
@@ -29,11 +29,11 @@ pub(super) fn height(layout: &TextLayout, terminal_height: u16) -> u16 {
|
||||
(rows as u16 + 2).min(terminal_height.saturating_sub(4).max(3))
|
||||
}
|
||||
|
||||
/// The composer's title: the session's mode, in its own color, and a button under the pointer.
|
||||
/// The session's mode as its icon and name, in its own color, and a button under the pointer.
|
||||
///
|
||||
/// Drawn in both modes rather than only when planning, because a button that appears only once you
|
||||
/// are in plan mode cannot be what gets you there.
|
||||
fn mode_title(app: &App) -> Line<'static> {
|
||||
fn mode_badge(app: &App) -> Line<'static> {
|
||||
let mode = app.status.mode.as_str();
|
||||
let hue = crate::modes::accent(mode, &app.theme_styles);
|
||||
let hovered = app.pointer.hover.as_ref() == Some(&crate::mouse::MouseTarget::ComposerMode);
|
||||
@@ -53,12 +53,31 @@ fn mode_title(app: &App) -> Line<'static> {
|
||||
])
|
||||
}
|
||||
|
||||
/// Draws the mode button at the left end of `row`, the row above the composer, and returns the
|
||||
/// cells it took so the rest of the row starts after it.
|
||||
///
|
||||
/// Above the frame rather than in it, so it holds still at the left edge whatever the row beside it
|
||||
/// is saying: the activity bar while a turn runs, a hint when nothing does.
|
||||
pub(super) fn render_mode_badge(f: &mut Frame, row: Rect, app: &App) -> u16 {
|
||||
if row.width == 0 || row.height == 0 {
|
||||
return 0;
|
||||
}
|
||||
let badge = mode_badge(app);
|
||||
let width = u16::try_from(badge.width()).unwrap_or(u16::MAX).min(row.width);
|
||||
let at = Rect { width, height: 1, ..row };
|
||||
f.render_widget(Paragraph::new(badge), at);
|
||||
// The badge is the mode switch: a click moves to the next mode, as shift+tab does
|
||||
app.hit.borrow_mut().push(at, crate::mouse::MouseTarget::ComposerMode);
|
||||
width
|
||||
}
|
||||
|
||||
/// Renders the prompt composer.
|
||||
///
|
||||
/// The frame wears the mode's color; the mode's name is on the row above, in
|
||||
/// [`render_mode_badge`].
|
||||
pub(super) fn composer(f: &mut Frame, area: Rect, app: &mut App, layout: &TextLayout) {
|
||||
let title = mode_title(app);
|
||||
let block = crate::widgets::panel_block()
|
||||
.border_style(crate::modes::accent(&app.status.mode, &app.theme_styles))
|
||||
.title(title.clone());
|
||||
.border_style(crate::modes::accent(&app.status.mode, &app.theme_styles));
|
||||
let inner = block.inner(area);
|
||||
let width = inner.width.max(1);
|
||||
app.editor.set_viewport_width(width);
|
||||
@@ -93,17 +112,6 @@ pub(super) fn composer(f: &mut Frame, area: Rect, app: &mut App, layout: &TextLa
|
||||
let cursor = app.editor.cursor_in(layout);
|
||||
let scroll_y = cursor.row.saturating_sub(usize::from(inner.height.saturating_sub(1)));
|
||||
f.render_widget(Paragraph::new(lines).block(block).scroll((scroll_y as u16, 0)), area);
|
||||
// The title is the mode switch: a click moves to the next mode, as shift+tab does
|
||||
let title_width = u16::try_from(title.width()).unwrap_or(u16::MAX);
|
||||
app.hit.borrow_mut().push(
|
||||
Rect::new(
|
||||
area.x.saturating_add(1),
|
||||
area.y,
|
||||
title_width.min(area.width.saturating_sub(2)),
|
||||
1,
|
||||
),
|
||||
crate::mouse::MouseTarget::ComposerMode,
|
||||
);
|
||||
|
||||
// A full-window overlay is drawn over the composer, so parking the caret here would leave a
|
||||
// blinking block sitting on top of someone else's surface.
|
||||
|
||||
@@ -52,8 +52,8 @@ pub(super) fn render_configuration(f: &mut Frame, size: ratatui::layout::Rect, a
|
||||
/// Draw the start screen: the wordmark, the session's own composer as its prompt, the list joined
|
||||
/// under it, and the statusline the session will have.
|
||||
///
|
||||
/// The composer is the one a session draws — same widget, same wrapping, same title — so sending
|
||||
/// from here does not change what the prompt is, only what is around it.
|
||||
/// The composer is the one a session draws — same widget, same wrapping, same mode button on the
|
||||
/// row above it — so sending from here does not change what the prompt is, only what is around it.
|
||||
pub(super) fn render_dashboard(f: &mut Frame, size: Rect, app: &mut App) {
|
||||
if app.dashboard.is_none() {
|
||||
return;
|
||||
@@ -76,6 +76,10 @@ pub(super) fn render_dashboard(f: &mut Frame, size: Rect, app: &mut App) {
|
||||
let Some(dashboard) = app.dashboard.as_ref() else { return };
|
||||
let composer = dashboard.view(f, body, &app.theme_styles, &app.hit, app.banner, rows, border);
|
||||
input::composer(f, composer, app, &layout);
|
||||
// The row above is the gap under the wordmark; with no wordmark there is no gap to use
|
||||
if composer.y > body.y {
|
||||
input::render_mode_badge(f, Rect { y: composer.y - 1, height: 1, ..composer }, app);
|
||||
}
|
||||
if let Some(dashboard) = app.dashboard.as_ref() {
|
||||
dashboard.finish(f, composer, &app.theme_styles, border);
|
||||
// An empty prompt says what it is for, past the caret, in the quietest ink there is
|
||||
|
||||
@@ -29,7 +29,7 @@ pub use panel::{
|
||||
code_spans, footed_body, key_hint, key_hint_row, panel_block, panel_title, panel_title_width,
|
||||
render_footed, render_footer, split_footer, titled_panel, FOOTER_ROWS, PANEL_BORDER_TYPE,
|
||||
};
|
||||
pub(crate) use provider_glyph::provider_icon;
|
||||
pub(crate) use provider_glyph::{model_icon, provider_icon};
|
||||
pub use scrollbar::{drag_offset, list_rows_width, list_scrollbar, scrollbar, steered_scrollbar};
|
||||
pub use slab::{
|
||||
badge, fade, idle_badge, ramp, selection_block, selection_row, selection_row_on, slab, Cap,
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
//! provider_glyph — which mark the provider serving a model wears.
|
||||
//! provider_glyph — which brand mark the provider serving a model, and the model, wear.
|
||||
//!
|
||||
//! The provider's id is written beside the mark, so the mark is shine, the same job
|
||||
//! [`super::language_glyph`] does for a code fence. Only the providers with a mark in the Nerd Font
|
||||
//! set get one; the rest share [`Icon::Provider`], because a made-up shape for a brand is worse
|
||||
//! than a plain one.
|
||||
//! The id is written beside the mark, so the mark is shine, the same job
|
||||
//! [`super::language_glyph`] does for a code fence. Only the brands with a mark in the Nerd Font
|
||||
//! set get one; the rest share [`Icon::Provider`] or [`Icon::Model`], because a made-up shape for a
|
||||
//! brand is worse than a plain one. That rules out Anthropic, DeepSeek and Mistral, which have none.
|
||||
//!
|
||||
//! A gateway wears the gateway's mark, not the model maker's: `foundry-anthropic` is served by
|
||||
//! Microsoft, and the dock row is about who serves the model. The model's own name says who made it.
|
||||
//! The two rows answer different questions. The provider row is who serves the model, so a gateway
|
||||
//! wears the gateway's mark: `foundry-anthropic` is Microsoft's. The model row is who made it, so
|
||||
//! `claude-sonnet-5` wears Claude's mark whether Anthropic, Copilot or Foundry serves it.
|
||||
|
||||
use crate::glyphs::{brands, Icon};
|
||||
use crate::glyphs::{brands, Icon, RECENT_BRANDS};
|
||||
|
||||
/// The mark for `provider`, as the dock draws it now.
|
||||
///
|
||||
/// OpenAI, Anthropic and Copilot have marks only the newest Nerd Fonts carry, so where no font on
|
||||
/// the machine has them they fall back to a mark every v3 font does.
|
||||
/// OpenAI and Copilot have marks only the newest Nerd Fonts carry, so where no font on the machine
|
||||
/// has them they fall back to a mark every v3 font does.
|
||||
pub(crate) fn provider_icon(provider: &str) -> Icon {
|
||||
let icon = provider_brand(&provider.to_ascii_lowercase());
|
||||
match brands() {
|
||||
@@ -22,11 +23,20 @@ pub(crate) fn provider_icon(provider: &str) -> Icon {
|
||||
}
|
||||
}
|
||||
|
||||
/// The mark for the model `model`, an id like `claude-opus-5-5` or `openai/gpt-5`, as the dock
|
||||
/// draws it now. A recent brand falls back to the plain model mark where no font has it.
|
||||
pub(crate) fn model_icon(model: &str) -> Icon {
|
||||
let icon = model_brand(&model.to_ascii_lowercase());
|
||||
match brands() || !RECENT_BRANDS.contains(&icon) {
|
||||
true => icon,
|
||||
false => Icon::Model,
|
||||
}
|
||||
}
|
||||
|
||||
/// The brand mark for a lowercased provider id, whatever the font has.
|
||||
fn provider_brand(provider: &str) -> Icon {
|
||||
match provider {
|
||||
"openai" => Icon::ProviderOpenAi,
|
||||
"anthropic" => Icon::ProviderAnthropic,
|
||||
"openai" | "openai-codex" | "codex" | "chatgpt" => Icon::ProviderOpenAi,
|
||||
"github-copilot" | "copilot" => Icon::ProviderCopilot,
|
||||
"google" | "gemini" | "google-gemini" | "google-vertex" | "vertex" => Icon::ProviderGoogle,
|
||||
"bedrock" | "amazon-bedrock" | "aws" => Icon::ProviderAws,
|
||||
@@ -37,12 +47,32 @@ fn provider_brand(provider: &str) -> Icon {
|
||||
}
|
||||
}
|
||||
|
||||
/// The maker's mark for a lowercased model id, whatever the font has.
|
||||
///
|
||||
/// Judged on the last path segment, since a router names a model `anthropic/claude-sonnet-5`.
|
||||
/// Claude is found anywhere in it, because Bedrock writes `us.anthropic.claude-sonnet-5-v1:0`.
|
||||
fn model_brand(model: &str) -> Icon {
|
||||
let name = model.rsplit('/').next().unwrap_or(model);
|
||||
let family = |prefix: &str| name == prefix || name.starts_with(&format!("{prefix}-"));
|
||||
if name.contains("claude") {
|
||||
return Icon::ModelClaude;
|
||||
}
|
||||
if ["gpt", "chatgpt", "codex", "o1", "o3", "o4"].into_iter().any(family) {
|
||||
return Icon::ProviderOpenAi;
|
||||
}
|
||||
if family("gemini") || family("gemma") {
|
||||
return Icon::ProviderGoogle;
|
||||
}
|
||||
Icon::Model
|
||||
}
|
||||
|
||||
/// What a recent brand mark becomes in a font from before it: Copilot keeps GitHub's mark, the
|
||||
/// rest the generic one.
|
||||
fn older_font_mark(icon: Icon) -> Icon {
|
||||
match icon {
|
||||
Icon::ProviderCopilot => Icon::GitHub,
|
||||
Icon::ProviderOpenAi | Icon::ProviderAnthropic => Icon::Provider,
|
||||
Icon::ProviderOpenAi => Icon::Provider,
|
||||
Icon::ModelClaude => Icon::Model,
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
@@ -50,17 +80,23 @@ fn older_font_mark(icon: Icon) -> Icon {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::glyphs::RECENT_BRANDS;
|
||||
|
||||
#[test]
|
||||
fn known_providers_wear_their_own_brand() {
|
||||
assert_eq!(provider_brand("openai"), Icon::ProviderOpenAi);
|
||||
assert_eq!(provider_brand("anthropic"), Icon::ProviderAnthropic);
|
||||
assert_eq!(provider_brand("github-copilot"), Icon::ProviderCopilot);
|
||||
assert_eq!(provider_brand("google"), Icon::ProviderGoogle);
|
||||
assert_eq!(provider_brand("bedrock"), Icon::ProviderAws);
|
||||
}
|
||||
|
||||
/// A ChatGPT subscription is OpenAI serving its own models, so it wears OpenAI's mark too.
|
||||
#[test]
|
||||
fn the_codex_subscription_wears_openais_mark() {
|
||||
for id in ["openai-codex", "codex", "chatgpt"] {
|
||||
assert_eq!(provider_brand(id), Icon::ProviderOpenAi, "{id}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A gateway is who serves the model, so `foundry-anthropic` is Azure's, not Anthropic's.
|
||||
#[test]
|
||||
fn a_gateway_wears_the_gateways_mark() {
|
||||
@@ -70,13 +106,36 @@ mod tests {
|
||||
assert_eq!(provider_brand("azurely"), Icon::Provider, "a prefix, not a substring");
|
||||
}
|
||||
|
||||
/// Anthropic has no mark of its own, and Claude's is its models', not the company's.
|
||||
#[test]
|
||||
fn a_provider_with_no_mark_gets_the_generic_one() {
|
||||
for id in ["deepseek", "zai", "openrouter", "ollama", "mistral", ""] {
|
||||
for id in ["anthropic", "deepseek", "zai", "openrouter", "ollama", "mistral", ""] {
|
||||
assert_eq!(provider_brand(id), Icon::Provider, "{id}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A model wears its maker's mark, whoever serves it and however the id is spelled.
|
||||
#[test]
|
||||
fn a_model_wears_its_makers_mark() {
|
||||
for id in ["claude-opus-5-5", "anthropic/claude-sonnet-5", "us.anthropic.claude-haiku-5"] {
|
||||
assert_eq!(model_brand(id), Icon::ModelClaude, "{id}");
|
||||
}
|
||||
for id in ["gpt-5", "openai/gpt-5-codex", "o3", "o4-mini", "codex-mini", "chatgpt-4o"] {
|
||||
assert_eq!(model_brand(id), Icon::ProviderOpenAi, "{id}");
|
||||
}
|
||||
for id in ["gemini-3-pro", "google/gemma-4"] {
|
||||
assert_eq!(model_brand(id), Icon::ProviderGoogle, "{id}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A family is a whole leading word: `o3` is OpenAI's, `o3d-model` and `opus` are not.
|
||||
#[test]
|
||||
fn a_model_with_no_known_maker_gets_the_plain_mark() {
|
||||
for id in ["deepseek-v4", "qwen3.8-27b", "o3d-model", "gptish", "kimi-k2.5", ""] {
|
||||
assert_eq!(model_brand(id), Icon::Model, "{id}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Every recent brand has a fallback that is not itself a recent brand, so an older font never
|
||||
/// draws a box for one.
|
||||
#[test]
|
||||
@@ -86,5 +145,8 @@ mod tests {
|
||||
}
|
||||
assert_eq!(older_font_mark(Icon::ProviderCopilot), Icon::GitHub);
|
||||
assert_eq!(older_font_mark(Icon::ProviderGoogle), Icon::ProviderGoogle);
|
||||
// Brands are off unless the startup probe finds them, so this is the older font
|
||||
assert_eq!(model_icon("claude-opus-5"), Icon::Model, "the model row's own plain mark");
|
||||
assert_eq!(model_icon("gemini-3"), Icon::ProviderGoogle, "every v3 font has Google's");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,9 @@ fn test_conversation_is_borderless_and_separate_from_composer() {
|
||||
assert!(!top.contains("Conversation"));
|
||||
|
||||
assert!(row_text(&buffer, h - 4, w).trim_start().starts_with('╭'), "composer outline missing");
|
||||
assert!(row_text(&buffer, h - 5, w).trim().is_empty(), "conversation gap missing");
|
||||
let activity = row_text(&buffer, h - 5, w);
|
||||
assert!(activity.trim().ends_with("build"), "the mode button leads the row: {activity:?}");
|
||||
assert!(row_text(&buffer, h - 6, w).trim().is_empty(), "conversation gap missing");
|
||||
assert!(
|
||||
row_text(&buffer, h - 2, w).trim_start().starts_with('╰'),
|
||||
"composer should touch statusline"
|
||||
|
||||
@@ -509,10 +509,11 @@ fn a_copy_is_confirmed_above_the_prompt_and_bound_to_the_terminal_copy_chords()
|
||||
// Flush to the composer's own right margin, and wearing a bold accent on a background so it
|
||||
// catches an eye on its way to the prompt.
|
||||
assert_eq!(buffer[(width - 2, toast)].bg, chip, "the chip runs to the inset right edge");
|
||||
let start = text.find('\u{f0c5}').expect("the clipboard glyph") as u16;
|
||||
// Columns, not bytes: the mode button's icon shares the row
|
||||
let start = column_of(&text, "\u{f0c5}");
|
||||
assert_eq!(buffer[(start, toast)].bg, chip);
|
||||
assert_ne!(buffer[(start - 2, toast)].bg, chip, "and stops there");
|
||||
let label = text.find("Copied").expect("the label") as u16;
|
||||
let label = column_of(&text, "Copied");
|
||||
assert!(buffer[(label, toast)].modifier.contains(ratatui::style::Modifier::BOLD));
|
||||
assert_eq!(buffer[(label, toast)].fg, app.theme_styles.accent.fg.expect("the accent"));
|
||||
|
||||
|
||||
@@ -262,6 +262,27 @@ fn a_narrow_peek_gives_the_diff_the_whole_column() {
|
||||
assert!(!whole.contains("has to wait its turn"), "and the transcript waits: {whole}");
|
||||
}
|
||||
|
||||
/// A peek in the transcript's place runs down to the activity row: its footer is already ruled off,
|
||||
/// so the blank row that sets the activity apart from a transcript would only be a gap.
|
||||
#[test]
|
||||
fn a_narrow_peek_runs_down_to_the_activity_row() {
|
||||
let path = "src/module00/file00.rs";
|
||||
let (width, height) = (110u16, 24);
|
||||
let backend = test_backend(width, height);
|
||||
let (mut app, mut rx) = create_app_with_engine();
|
||||
app.update(Msg::TerminalResized { width, height });
|
||||
app.dock.hide();
|
||||
app.workspace = Some(changed_workspace("peek-activity-gap", 2));
|
||||
open_changes_with(&mut app, &mut rx, path, Some(one_hunk_file(path)));
|
||||
|
||||
let buffer = render_app(&mut app, &backend);
|
||||
let composer_top = (0..height)
|
||||
.find(|&y| row_text(&buffer, y, width).trim_start().starts_with('╭'))
|
||||
.expect("the composer's top border");
|
||||
let above_activity = row_text(&buffer, composer_top - 2, width);
|
||||
assert!(!above_activity.trim().is_empty(), "{}", buffer_to_string(&buffer));
|
||||
}
|
||||
|
||||
/// A pane with room for two readable columns draws two; one without draws the unified list. Nobody
|
||||
/// has to ask for it, which is why the width test has to be conservative rather than eager.
|
||||
#[test]
|
||||
|
||||
@@ -219,24 +219,47 @@ fn clicking_the_dock_review_changes_affordance_opens_review() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Clicking the dock's model row opens the model picker (plan B3): in the wide layout the
|
||||
/// Clicking the dock's model row opens the model picker on the models: in the wide layout the
|
||||
/// statusline hides and MODEL telemetry relocates into the dock footer as a clickable row.
|
||||
#[test]
|
||||
fn clicking_the_dock_model_row_opens_the_model_picker() {
|
||||
use crossterm::event::{MouseButton, MouseEvent, MouseEventKind};
|
||||
let (width, height) = (160, 40);
|
||||
let backend = test_backend(width, height);
|
||||
use luxe_tui::model_picker::PickerStart;
|
||||
let message = click_dock_row("test-model-xyz");
|
||||
let opened = matches!(message, Msg::OpenModelPicker(PickerStart::Models));
|
||||
assert!(opened, "the model row opens the picker on the models, got {message:?}");
|
||||
}
|
||||
|
||||
/// The provider row is its own target, opening on the providers rather than on the models.
|
||||
#[test]
|
||||
fn clicking_the_dock_provider_row_opens_the_providers() {
|
||||
use luxe_tui::model_picker::PickerStart;
|
||||
let message = click_dock_row("test-provider-abc");
|
||||
let opened = matches!(message, Msg::OpenModelPicker(PickerStart::Providers));
|
||||
assert!(opened, "the provider row opens the picker on the providers, got {message:?}");
|
||||
}
|
||||
|
||||
/// An app wide enough to show the dock, on `test-model-xyz` from `test-provider-abc`.
|
||||
fn app_on_test_model(width: u16, height: u16) -> App {
|
||||
let mut app = create_app();
|
||||
app.update(Msg::TerminalResized { width, height });
|
||||
app.workspace = Some(empty_workspace("dock-model-click"));
|
||||
app.status.model = "test-model-xyz".into();
|
||||
app.status.provider = "test-provider-abc".into();
|
||||
app.status.context_window = 128_000;
|
||||
app.status.context_pct = 10.0;
|
||||
app
|
||||
}
|
||||
|
||||
/// The message a click on the dock row showing `text` sends.
|
||||
fn click_dock_row(text: &str) -> Msg {
|
||||
use crossterm::event::{MouseButton, MouseEvent, MouseEventKind};
|
||||
let (width, height) = (160, 40);
|
||||
let backend = test_backend(width, height);
|
||||
let mut app = app_on_test_model(width, height);
|
||||
let buffer = render_app(&mut app, &backend);
|
||||
let row = (0..height)
|
||||
.find(|&y| row_text(&buffer, y, width).contains("test-model-xyz"))
|
||||
.expect("the model row renders in the dock footer");
|
||||
.find(|&y| row_text(&buffer, y, width).contains(text))
|
||||
.unwrap_or_else(|| panic!("{text} renders in the dock"));
|
||||
let click = MouseEvent {
|
||||
kind: MouseEventKind::Down(MouseButton::Left),
|
||||
column: 5,
|
||||
@@ -244,10 +267,8 @@ fn clicking_the_dock_model_row_opens_the_model_picker() {
|
||||
modifiers: KeyModifiers::NONE,
|
||||
};
|
||||
match route_mouse(&mut app, &click) {
|
||||
RouteAction::Msg(message) => {
|
||||
assert!(matches!(*message, Msg::OpenModelPicker), "the model row opens the picker")
|
||||
}
|
||||
other => panic!("expected an open-model-picker message, got {other:?}"),
|
||||
RouteAction::Msg(message) => *message,
|
||||
other => panic!("expected a message, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ fn a_finished_login_walks_into_the_model_picker_inside_the_surface() {
|
||||
let buffer = render_app(&mut app, &backend);
|
||||
let screen: String = buffer.content.iter().map(|cell| cell.symbol()).collect();
|
||||
assert!(screen.contains("Select model"), "{screen}");
|
||||
assert!(screen.contains("GPT-5.6"), "{screen}");
|
||||
assert!(screen.contains("gpt-5.6"), "{screen}");
|
||||
// What the login had to say rides along as the picker's opening line, and with no model
|
||||
// chosen for the reader, the line asks them to choose one.
|
||||
assert!(screen.contains("Signed in to OpenAI"), "{screen}");
|
||||
|
||||
Reference in New Issue
Block a user