Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)

Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
  nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 12:37:52 +01:00
parent e37a0deba9
commit 7c1c6dfa8d
10306 changed files with 748026 additions and 748088 deletions

View File

@@ -0,0 +1,191 @@
//! A compact footer advertises primary actions; help lists the configured task shortcuts.
use super::*;
use crate::key_hint;
use crate::shortcut_help::Group;
use crate::shortcut_help::Shortcut;
use crate::style::footer_hint_label_style;
pub(super) fn hint_line(items: &[(String, String)]) -> Line<'static> {
let mut line = Line::default();
for (key, label) in items.iter().filter(|(key, _)| !key.is_empty()) {
if !line.spans.is_empty() {
line.spans.push(" ".dim());
}
line.spans.extend(key_hint::key_label_spans(key));
line.spans.push(Span::styled(
format!(" {label}"),
footer_hint_label_style().not_bold(),
));
}
line
}
impl AgentsOverviewView {
fn center_list_hint(&self, action: ListAction) -> Option<ShortcutHint> {
self.keymap.primary_hint(action).filter(|hint| {
!matches!(hint, ShortcutHint::Single(binding) if [
&self.agents_keymap.resume,
&self.agents_keymap.search,
&self.agents_keymap.new_task,
&self.agents_keymap.new_worktree,
&self.agents_keymap.fork,
&self.agents_keymap.rename,
&self.agents_keymap.stop,
&self.agents_keymap.archive,
&self.agents_keymap.delete,
&self.agents_keymap.hide,
&self.agents_keymap.toggle_pin,
&self.agents_keymap.toggle_grouping,
].into_iter().any(|bindings| bindings.contains(binding)))
})
}
pub(super) fn center_filter_hint(&self) -> String {
[key_hint::plain(KeyCode::Tab), key_hint::shift(KeyCode::Tab)]
.into_iter()
.filter(|hint| {
let (code, modifiers) = hint.parts();
!self
.center_shortcut_keys
.is_pressed(KeyEvent::new(code, modifiers))
})
.map(|hint| hint.display_label())
.collect::<Vec<_>>()
.join("/")
}
pub(super) fn center_help_lines(&self, width: u16) -> Vec<Line<'static>> {
let mut navigate = Group {
title: "Navigate",
entries: Vec::new(),
};
for (action, label) in [
(ListAction::MoveUp, "Up"),
(ListAction::MoveDown, "Down"),
(ListAction::Accept, "Open"),
(ListAction::PageUp, "Page up"),
(ListAction::PageDown, "Page down"),
] {
navigate.push(self.center_list_hint(action), label);
}
navigate
.entries
.push(Shortcut::new(key_hint::ctrl(KeyCode::Char('c')), "Quit"));
let mut tasks = Group {
title: "Tasks",
entries: Vec::new(),
};
for (action, bindings, label) in [
("new_task", &self.agents_keymap.new_task, "New"),
(
"new_worktree",
&self.agents_keymap.new_worktree,
"New worktree",
),
("resume", &self.agents_keymap.resume, "Resume"),
("fork", &self.agents_keymap.fork, "Fork"),
("rename", &self.agents_keymap.rename, "Rename"),
("stop", &self.agents_keymap.stop, "Stop"),
("archive", &self.agents_keymap.archive, "Archive"),
("hide", &self.agents_keymap.hide, "Hide"),
("delete", &self.agents_keymap.delete, "Delete"),
("toggle_pin", &self.agents_keymap.toggle_pin, "Pin/unpin"),
] {
if (action != "new_worktree" || self.worktrees_enabled)
&& (action != "toggle_pin" || self.can_toggle_selected_pin())
{
tasks.push(self.agents_keymap.primary_hint(action, bindings), label);
}
}
let mut view = Group {
title: "View",
entries: Vec::new(),
};
let filter = self.center_filter_hint();
if !filter.is_empty() {
view.entries.push(Shortcut {
key: filter,
action: "Filter",
});
}
for (action, bindings, label) in [
("search", &self.agents_keymap.search, "Search"),
(
"toggle_grouping",
&self.agents_keymap.toggle_grouping,
"Group",
),
] {
view.push(self.agents_keymap.primary_hint(action, bindings), label);
}
let mut lines = vec!["Task shortcuts".bold().into(), Line::default()];
lines.extend(crate::shortcut_help::group_lines(
[navigate, tasks, view],
width,
));
crate::wrapping::word_wrap_lines(lines, usize::from(width.max(/*other*/ 1)))
}
pub(super) fn center_footer_hints(&self) -> Vec<(String, String)> {
let state = self.state();
if let Some(items) = &state.key_chord_hint {
return items.clone();
}
let mut hints = Vec::new();
if !state.help
&& !state.editing_metadata()
&& ![KeyModifiers::NONE, KeyModifiers::SHIFT]
.into_iter()
.any(|modifiers| {
self.center_shortcut_keys
.is_pressed(KeyEvent::new(KeyCode::Char('?'), modifiers))
})
{
hints.push(("?".into(), "help".into()));
}
let cancel = if state.help {
self.keymap.primary_hint(ListAction::Cancel)
} else if state.editing_metadata() || self.can_return_to_chat {
self.center_list_hint(ListAction::Cancel)
} else {
None
};
if let Some(hint) = cancel {
hints.push((hint.display_label(), "back".into()));
}
if state.help {
return hints;
}
if !state.editing_metadata() {
let navigation = [ListAction::MoveUp, ListAction::MoveDown]
.into_iter()
.filter_map(|action| self.center_list_hint(action))
.map(ShortcutHint::display_label)
.collect::<Vec<_>>()
.join("/");
if !navigation.is_empty() {
hints.push((navigation, "move".into()));
}
}
if let Some(hint) = self.center_list_hint(ListAction::Accept) {
hints.push((
hint.display_label(),
if state.rename_target.is_some() {
"rename"
} else {
"open"
}
.into(),
));
}
if !state.editing_metadata()
&& let Some(hint) = self
.agents_keymap
.primary_hint("new_task", &self.agents_keymap.new_task)
{
hints.push((hint.display_label(), "new".into()));
}
hints
}
}

View File

@@ -0,0 +1,110 @@
//! Shared rename editing and task shortcuts respect configured editor and list bindings.
use super::*;
use crossterm::event::KeyEventKind;
impl AgentsOverviewView {
pub(in crate::app::agents_overview_view) fn rename_key(&mut self, key: KeyEvent) -> bool {
let mut state = self.state();
if state.rename_target.is_none() {
return false;
}
let input = &mut state.input;
let editing = input.should_handle_vim_insert_escape(key) || input.is_vim_operator_pending();
if !editing {
match self.keymap.action_for(key) {
Some(ListAction::Cancel) => {
drop(state);
self.on_ctrl_c();
return true;
}
Some(ListAction::Accept) if !is_plain_text_key_event(key) => {
let online = state.connection_notice.is_none() && !state.creating_worktree;
drop(state);
if online {
self.activate();
}
return true;
}
_ => {}
}
}
let editor_binding = crate::keymap::keymap_action_ids()
.filter(|action| action.context == input.keymap_context())
.any(|action| {
crate::keymap::bindings_for_action(
&self.editor_keymap,
action.context.config_name(),
action.action,
)
.is_some_and(|bindings| bindings.is_pressed(key))
});
if editing
|| is_plain_text_key_event(key)
|| editor_binding
|| !self.center_shortcut_keys.is_pressed(key)
{
input.input(key);
return !crate::keymap::is_dispatch_token_event(key);
}
false
}
pub(in crate::app::agents_overview_view) fn command_center_key(
&mut self,
key: KeyEvent,
) -> bool {
if self.state().editing_metadata() {
if self.keymap.action_for(key) == Some(ListAction::Cancel) {
self.on_ctrl_c();
return true;
}
return false;
}
let mut state = self.state();
if state.help && self.keymap.action_for(key) == Some(ListAction::Cancel) {
state.help = false;
return true;
}
if state.help {
if key.code == KeyCode::Char('?')
&& key.kind == KeyEventKind::Press
&& !key
.modifiers
.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT)
{
state.help = false;
}
return true;
}
if self.center_shortcut_keys.is_pressed(key) {
return false;
}
if key.code == KeyCode::Char('?')
&& key.kind == KeyEventKind::Press
&& !key
.modifiers
.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT)
{
state.help = !state.help;
return true;
}
if key.code == KeyCode::Tab
&& !key
.modifiers
.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT)
{
let step = if key.modifiers.contains(KeyModifiers::SHIFT) {
TASK_FILTERS.len() - 1
} else {
1
};
state.status_filter = (state.status_filter + step) % TASK_FILTERS.len();
state.scroll = 0;
drop(state);
self.reconcile_command_center_selection();
return true;
}
false
}
}

View File

@@ -0,0 +1,36 @@
//! Status filters and viewport state survive refreshes of the shared task projection.
mod hints;
mod input;
mod navigation;
mod render;
mod rows;
use super::*;
// Counts and filtering use the same status groups.
pub(super) const TASK_FILTERS: &[(&str, Option<AgentsOverviewGroup>)] = &[
("All", None),
("Needs you", Some(AgentsOverviewGroup::NeedsYou)),
("Working", Some(AgentsOverviewGroup::Working)),
("Ready", Some(AgentsOverviewGroup::Ready)),
("Inactive", Some(AgentsOverviewGroup::Finished)),
];
impl AgentsOverviewView {
pub(in crate::app::agents_overview_view) fn selectable_indices(&self) -> Vec<usize> {
let mut indices = self.visible_indices();
if self.state().more_available() {
indices.push(usize::MAX);
}
indices
}
pub(in crate::app::agents_overview_view) fn reconcile_command_center_selection(&mut self) {
let visible = self.selectable_indices();
if !visible.contains(&self.selected) {
self.selected = visible.first().copied().unwrap_or(usize::MAX);
self.state().show_more_selected = false;
}
}
}

View File

@@ -0,0 +1,92 @@
//! Page navigation shares the rendered row layout, including group headings.
//! Command-center paging moves the viewport and selection together without wrapping at either end.
use super::*;
pub(super) enum CenterRow {
Group(usize),
Task(usize),
Gap,
ShowMore,
}
impl AgentsOverviewView {
pub(super) fn center_rows(
&self,
indices: &[usize],
grouping: AgentsOverviewGrouping,
) -> Vec<CenterRow> {
let mut entries = Vec::new();
let mut previous = None;
for index in indices.iter().copied() {
if index == usize::MAX {
entries.push(CenterRow::Gap);
entries.push(CenterRow::ShowMore);
continue;
}
if previous.is_none_or(|previous| !self.same_group(grouping, previous, index)) {
if previous.is_some() {
entries.push(CenterRow::Gap);
}
entries.push(CenterRow::Group(index));
}
entries.push(CenterRow::Task(index));
previous = Some(index);
}
entries
}
pub(in crate::app::agents_overview_view) fn page_selection(&mut self, action: ListAction) {
let indices = self.selectable_indices();
let mut state = self.state();
if state.rename_target.is_some() || indices.is_empty() {
return;
}
let forward = action == ListAction::PageDown;
let entries = self.center_rows(&indices, state.grouping);
let tasks = entries
.iter()
.enumerate()
.filter_map(|(position, row)| {
if let CenterRow::Task(index) = row {
Some((position, *index))
} else if matches!(row, CenterRow::ShowMore) {
Some((position, usize::MAX))
} else {
None
}
})
.collect::<Vec<_>>();
let current = tasks
.iter()
.find(|(_, index)| *index == self.selected)
.map(|(position, _)| *position)
.unwrap_or(tasks[0].0);
let height = state.page_height.max(/*other*/ 1);
let target = if forward {
current.saturating_add(height)
} else {
current.saturating_sub(height)
};
let selected = if forward {
tasks
.partition_point(|(position, _)| *position < target)
.min(tasks.len() - 1)
} else {
tasks
.partition_point(|(position, _)| *position <= target)
.saturating_sub(1)
};
let selected = tasks[selected].1;
let scroll = state.scroll;
state.scroll = (if forward {
scroll.saturating_add(height)
} else {
scroll.saturating_sub(height)
})
.min(entries.len().saturating_sub(height));
drop(state);
self.selected = selected;
self.state().show_more_selected = selected == usize::MAX;
}
}

View File

@@ -0,0 +1,273 @@
//! Status tabs, task rows, the rename editor and details share a wide/narrow layout.
use super::hints::hint_line;
use super::*;
use crate::bottom_pane::render_filled_tab_bar;
use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
use crossterm::cursor::SetCursorStyle;
use ratatui::widgets::WidgetRef;
use unicode_segmentation::UnicodeSegmentation;
pub(super) fn row(area: Rect, offset: u16, height: u16) -> Rect {
let offset = offset.min(area.height);
Rect::new(
area.x,
area.y + offset,
area.width,
height.min(area.height - offset),
)
}
pub(super) fn line(text: impl Into<Line<'static>>, area: Rect, buf: &mut Buffer) {
if !area.is_empty() {
truncate_line_with_ellipsis_if_overflow(text.into(), usize::from(area.width))
.render(row(area, /*offset*/ 0, /*height*/ 1), buf);
}
}
fn visible_suffix(input: &str, available: usize) -> &str {
let mut start = input.len();
let mut visible_width = 0;
for (offset, grapheme) in input.grapheme_indices(/*is_extended*/ true).rev() {
let width = grapheme.width();
if visible_width + width > available {
break;
}
visible_width += width;
start = offset;
}
&input[start..]
}
struct CenterLayout {
header: Rect,
list: Rect,
gap: Rect,
details: Rect,
search: Rect,
footer: Rect,
}
impl AgentsOverviewView {
fn center_layout(&self, area: Rect) -> CenterLayout {
let state = self.state();
let footer_height = u16::from(area.height >= 2);
let header_height = if area.height >= 6 { 3 } else { 0 };
let footer = row(area, area.height - footer_height, footer_height);
let header = row(area, /*offset*/ 0, header_height);
let body = row(area, header_height, footer.y - header.bottom())
.inner(Margin::new(/*horizontal*/ 2, /*vertical*/ 0));
let [list, gap, details] = if body.width >= 90 {
Layout::horizontal([
Constraint::Min(46),
Constraint::Length(3),
Constraint::Length(38),
])
.areas(body)
} else {
[body, Rect::default(), Rect::default()]
};
let search = row(list, /*offset*/ 0, u16::from(state.editing_metadata()));
let list = row(
list,
search.height,
list.height.saturating_sub(search.height),
);
CenterLayout {
header,
list,
gap,
details,
search,
footer,
}
}
}
impl Renderable for AgentsOverviewView {
fn desired_height(&self, _width: u16) -> u16 {
24
}
fn cursor_style(&self, _area: Rect) -> SetCursorStyle {
let state = self.state();
if state.rename_target.is_some() && state.input.uses_vim_insert_cursor() {
SetCursorStyle::SteadyBar
} else {
SetCursorStyle::DefaultUserShape
}
}
fn cursor_pos(&self, area: Rect) -> Option<(u16, u16)> {
let layout = self.center_layout(area);
let state = self.state();
if state.editing_metadata() && !layout.search.is_empty() {
if state.rename_target.is_some() {
let mut area = layout.search;
let prefix_width = 9.min(area.width);
area.x += prefix_width;
area.width -= prefix_width;
return state.input.cursor_pos(area);
}
let input = &state.search;
let prefix = "Search › ";
let available = usize::from(layout.search.width).saturating_sub(prefix.width() + 1);
return Some((
layout.search.x
+ (prefix.width() + visible_suffix(input, available).width())
.min(usize::from(layout.search.width.saturating_sub(/*rhs*/ 1)))
as u16,
layout.search.y,
));
}
None
}
fn render(&self, area: Rect, buf: &mut Buffer) {
Clear.render(area, buf);
let layout = self.center_layout(area);
let inset =
|area: Rect| area.inner(Margin::new(/*horizontal*/ 2, /*vertical*/ 0));
let footer_hints = self.center_footer_hints();
let state = self.state();
let filter_keys = if state.editing_metadata() {
String::new()
} else {
self.center_filter_hint()
};
let grouping = match state.grouping {
AgentsOverviewGrouping::Project => "Project",
AgentsOverviewGrouping::Directory => "Directory",
AgentsOverviewGrouping::Status => "Status",
AgentsOverviewGrouping::Model => "Model",
};
let group_key = self
.agents_keymap
.primary_hint("toggle_grouping", &self.agents_keymap.toggle_grouping)
.map(ShortcutHint::display_label)
.unwrap_or_default();
line(
vec![
"Agent command center".bold(),
format!(" Group: {grouping} {group_key}").dim(),
],
inset(layout.header),
buf,
);
let history = state.history.as_ref();
let labels = TASK_FILTERS
.iter()
.map(|(label, group)| {
let count = self
.rows
.iter()
.filter(|row| state.includes_row(row))
.filter(|row| group.is_none_or(|group| group == row.group))
.count();
format!("{label} {count}")
})
.collect::<Vec<_>>();
let mut tabs = inset(row(layout.header, /*offset*/ 1, /*height*/ 1));
let filter_hint = hint_line(&[(filter_keys, "filter".into())]);
if tabs.width >= 80 && filter_hint.width() > 0 {
let hint_width = filter_hint.width() as u16;
filter_hint.render(
Rect::new(tabs.right() - hint_width, tabs.y, hint_width, tabs.height),
buf,
);
tabs.width = tabs.width.saturating_sub(hint_width + 2);
}
render_filled_tab_bar(
&labels.iter().map(String::as_str).collect::<Vec<_>>(),
state.status_filter,
tabs,
buf,
);
line(
"─"
.repeat(usize::from(area.width.saturating_sub(/*rhs*/ 4)))
.dim(),
inset(row(layout.header, /*offset*/ 2, /*height*/ 1)),
buf,
);
if state.editing_metadata() {
buf.set_style(layout.search, crate::bottom_pane::active_tab_style());
if state.rename_target.is_some() {
line("Rename › ".cyan().bold(), layout.search, buf);
let mut area = layout.search;
let prefix_width = 9.min(area.width);
area.x += prefix_width;
area.width -= prefix_width;
WidgetRef::render_ref(&&state.input, area, buf);
} else {
let label = "Search › ";
let available = usize::from(layout.search.width).saturating_sub(label.width() + 1);
line(
vec![
label.cyan().bold(),
visible_suffix(&state.search, available).to_owned().into(),
],
layout.search,
buf,
);
}
}
let notice = state
.connection_notice
.map(str::to_owned)
.or_else(|| {
state
.creating_worktree
.then(|| "Creating worktree…".to_owned())
})
.or_else(|| {
state.removal.map(|action| match action {
AgentsOverviewAction::Archive => {
"Archiving task… You can still browse.".to_owned()
}
AgentsOverviewAction::Delete => {
"Deleting task… You can still browse.".to_owned()
}
})
})
.or_else(|| {
let failed = state.refresh_failed || history.is_some_and(|s| s.failed);
(failed && !state.loading).then(|| "Error loading tasks".to_owned())
})
.or_else(|| state.server_version_notice.clone());
if let Some(notice) = notice.filter(|_| !state.help && state.key_chord_hint.is_none()) {
line(notice.dim(), inset(layout.footer), buf);
} else {
line(hint_line(&footer_hints), inset(layout.footer), buf);
}
let help = state.help;
drop(state);
if help {
let body = row(
area,
layout.header.height,
layout.footer.y - layout.header.bottom(),
);
Clear.render(inset(body), buf);
let body = inset(body);
let mut lines = self.center_help_lines(body.width);
if lines.len() > usize::from(body.height) {
lines.truncate(usize::from(body.height.saturating_sub(/*rhs*/ 1)));
lines.push("… resize to see all".dim().into());
}
Paragraph::new(lines).render(body, buf);
return;
}
for y in layout.gap.y..layout.gap.bottom() {
if layout.gap.width > 1 {
buf[(layout.gap.x + 1, y)]
.set_symbol("│")
.set_style(Style::default().dim());
}
}
self.render_center_rows(layout.list, buf);
if !layout.details.is_empty() {
self.render_details(layout.details, buf);
}
}
}

View File

@@ -0,0 +1,296 @@
//! Grouped live tasks with shared identity colors and stable title, status and age columns.
//! Full titles use the flexible column; metadata drops at narrow widths.
//! The final cell stays blank inside the full-width selection highlight.
use super::navigation::CenterRow;
use super::render::line;
use super::render::row;
use super::*;
use crate::bottom_pane::selection_style;
use crate::resume_picker::format_relative_time;
use crate::status::format_directory_display;
fn columns(area: Rect) -> (Rect, Rect, Rect) {
let metadata = if area.width >= 56 { 24 } else { 0 };
let gutter = area.width.min(/*other*/ 4);
let title = Rect::new(
area.x + gutter,
area.y,
area.width - gutter - metadata,
area.height,
);
let updated = Rect::new(
area.right() - metadata.min(/*other*/ 9),
area.y,
metadata.min(/*other*/ 9),
area.height,
);
let status = Rect::new(
title.right() + metadata.min(/*other*/ 2),
area.y,
if metadata == 24 { 11 } else { 0 },
area.height,
);
(title, status, updated)
}
impl AgentsOverviewView {
pub(super) fn render_center_rows(&self, area: Rect, buf: &mut Buffer) {
let row_width = area.width;
let area = Rect {
width: row_width.saturating_sub(/*rhs*/ 1),
..area
};
if area.is_empty() {
return;
}
let indices = self.selectable_indices();
let mut state = self.state();
if indices.is_empty() {
line(
if state.connection_notice.is_some() {
"Reconnecting…"
} else if state.history.is_some() {
"No matching tasks"
} else if state.loading && self.rows.is_empty() {
"Loading tasks…"
} else if state.refresh_failed {
"Could not load tasks"
} else if self.rows.is_empty() {
"No tasks yet"
} else {
"No matching tasks"
}
.dim(),
area,
buf,
);
return;
}
let entries = self.center_rows(&indices, state.grouping);
let selected = entries
.iter()
.position(|row| match row {
CenterRow::Task(index) => *index == self.selected,
CenterRow::ShowMore => self.selected == usize::MAX,
_ => false,
})
.unwrap_or_default();
let padding = u16::from(area.height >= 3);
let viewport = row(area, padding, area.height - padding * 2);
if padding > 0 {
let (title, status, updated) = columns(row(area, /*offset*/ 0, /*height*/ 1));
line("Tasks".dim(), title, buf);
line("Status".dim(), status, buf);
Line::from("Updated".dim())
.right_aligned()
.render(updated, buf);
}
let reference = chrono::Utc::now();
let height = usize::from(viewport.height);
state.page_height = height;
let mut start = state.scroll.min(entries.len().saturating_sub(height));
if selected < start {
start = if height > 1
&& selected > 0
&& matches!(entries[selected - 1], CenterRow::Group(_))
{
selected - 1
} else {
selected
};
}
if selected >= start + height {
start = selected.saturating_add(/*rhs*/ 1).saturating_sub(height);
}
state.scroll = start;
for (offset, entry) in entries.iter().skip(start).take(height).enumerate() {
let index = match entry {
CenterRow::Group(index) | CenterRow::Task(index) => *index,
CenterRow::Gap => continue,
CenterRow::ShowMore => {
let rect = row(viewport, offset as u16, /*height*/ 1);
let selected = self.selected == usize::MAX;
let style = if selected {
selection_style()
} else {
Style::default()
};
buf.set_style(
Rect {
width: row_width,
..rect
},
style,
);
let label = if let Some(search) = &state.history {
if search.loading {
"Searching history…"
} else if search.failed {
"Show more (retry)"
} else {
"Show more matches"
}
} else if state.loading {
"Loading more…"
} else if state.refresh_failed {
"Show more (retry)"
} else {
"Show more"
};
let marker = if selected { "›" } else { " " };
line(
Line::from(format!("{marker} {label}")).style(style),
rect,
buf,
);
continue;
}
};
let task = &self.rows[index];
let rect = row(viewport, offset as u16, /*height*/ 1);
if matches!(entry, CenterRow::Group(_)) {
let group = match state.grouping {
AgentsOverviewGrouping::Status => task.group.label().to_owned(),
_ if self.is_pinned(index) => "Pinned".to_owned(),
AgentsOverviewGrouping::Project => format_directory_display(
&self.project_groups[index].heading,
/*max_width*/ None,
),
AgentsOverviewGrouping::Directory => format_directory_display(
self.rows[index].thread.cwd.as_path(),
/*max_width*/ None,
),
AgentsOverviewGrouping::Model => model_name(&task.thread).to_owned(),
};
let count = indices
.iter()
.filter(|&&candidate| {
candidate != usize::MAX && self.same_group(state.grouping, candidate, index)
})
.count();
let total = (0..self.rows.len())
.filter(|&i| state.includes_row(&self.rows[i]))
.filter(|&candidate| self.same_group(state.grouping, candidate, index))
.count();
let count = if count == total {
count.to_string()
} else {
format!("{count} of {total}")
};
let group = if matches!(
state.grouping,
AgentsOverviewGrouping::Project | AgentsOverviewGrouping::Directory
) && !self.is_pinned(index)
{
crate::text_formatting::center_truncate_path(
&group,
usize::from(rect.width)
.saturating_sub(count.width() + 2)
.min(/*other*/ 64),
)
} else {
group
};
line(format!("{group} {count}").dim(), rect, buf);
continue;
}
let style = if index == self.selected {
selection_style()
} else {
Style::default()
};
buf.set_style(
Rect {
width: row_width,
..rect
},
style,
);
let (status, mut dot) = Self::status(task);
let idle = matches!(
task.group,
AgentsOverviewGroup::Ready | AgentsOverviewGroup::Finished
);
if task.unread || idle {
dot = crate::style::task_marker(task.unread, style);
} else if index == self.selected {
dot.style = style;
}
line(
Line::from(if index == self.selected { "›" } else { " " }).style(style),
rect,
buf,
);
line(
Line::from(dot),
Rect::new(
rect.x + rect.width.min(/*other*/ 2),
rect.y,
rect.width.saturating_sub(/*rhs*/ 2).min(/*other*/ 1),
/*height*/ 1,
),
buf,
);
let (mut title, status_area, updated) = columns(rect);
if task.has_voice && title.width >= 8 {
let badge = Rect::new(
title.right() - 8,
title.y,
/*width*/ 8,
/*height*/ 1,
);
title.width -= 8;
line(Line::from(" voice").style(style), badge, buf);
}
let title_style = if index == self.selected {
style
} else {
self.title_style(task.thread_id)
};
let task_title = display_title(&task.thread);
// On narrow rows the result dot shares the only slot for the working or alert icon.
let task_title = if task.unread && !idle && status_area.is_empty() {
format!("{status}: {task_title}")
} else {
task_title.to_owned()
};
let task_title =
if state.grouping == AgentsOverviewGrouping::Status && self.is_pinned(index) {
format!("📌 {task_title}")
} else {
task_title
};
line(Line::from(task_title).style(title_style), title, buf);
line(Line::from(status).style(style), status_area, buf);
if !updated.is_empty() {
let age = format_relative_time(
reference,
chrono::DateTime::from_timestamp(task.thread.updated_at, /*nsecs*/ 0),
);
Line::from(age)
.style(if index == self.selected {
style
} else {
style.dim()
})
.right_aligned()
.render(updated, buf);
}
}
if padding > 0 && start > 0 {
line("↑".dim(), row(area, /*offset*/ 0, /*height*/ 1), buf);
}
if padding > 0 && start + height < entries.len() {
line(
"↓".dim(),
row(
area,
area.height.saturating_sub(/*rhs*/ 1),
/*height*/ 1,
),
buf,
);
}
}
}