Vain attempts to stop script

This commit is contained in:
Uber Veng
2026-05-22 22:06:32 +07:00
parent 6a79fb2c54
commit 25ccff3a37
7 changed files with 296 additions and 52 deletions

View File

@@ -127,7 +127,9 @@ fn render_popup(f: &mut Frame, popup: &mut Popup) {
Popup::ExecutingStructured {
reply_tx: _,
script_pid: _,
kill_tx: _,
task_handles: _,
log_buffer,
current_command,
input_buffer,
@@ -184,13 +186,27 @@ fn render_popup(f: &mut Frame, popup: &mut Popup) {
let at_bottom = pos >= max_pos;
let at_top = pos == 0;
// Reusable scroll hint based on current position
let scroll_hint = if total <= visible {
// All content fits — nothing to scroll
String::new()
} else if at_top && at_bottom {
String::new()
} else if at_top {
format!(" │ PgDn/↓ вниз ({}/{})", end, total)
} else if at_bottom {
format!(" │ PgUp/↑ вверх ({}/{})", end, total)
} else {
format!(" │ PgUp ↑ PgDn ↓ ({}/{})", end, total)
};
let (title, border_color): (String, Color) = match finished {
Some(0) => (
" ✓ Завершено — Esc закрыть │ PgUp/↑↓ скролл ".to_string(),
format!(" ✓ Завершено — Esc закрыть{} ", scroll_hint),
Color::Green,
),
Some(code) => (
format!(" ✗ Ошибка (код {}) — Esc закрыть │ PgUp/↑↓ скролл ", code),
format!(" ✗ Ошибка (код {}) — Esc закрыть{} ", code, scroll_hint),
Color::Red,
),
None if at_top && at_bottom => (
@@ -486,22 +502,49 @@ fn render_command(
}
executor::StructuredCommand::Progress { percent, message } => {
let bar_width = area.width.saturating_sub(4) as usize;
let filled = (*percent as usize * bar_width) / 100;
let bar = format!(
"[{}{}] {}%",
"".repeat(filled),
"".repeat(bar_width.saturating_sub(filled)),
percent
);
let msg = message.as_deref().unwrap_or("");
let paragraph = Paragraph::new(vec![Line::from(bar), Line::from(msg)]).block(
Block::default()
.borders(Borders::ALL)
.title(" Прогресс ")
.border_style(Style::default().fg(Color::Cyan)),
);
f.render_widget(paragraph, area);
match percent {
Some(pct) => {
let bar_width = area.width.saturating_sub(4) as usize;
let filled = (*pct as usize * bar_width) / 100;
let bar = format!(
"[{}{}] {}%",
"".repeat(filled),
"".repeat(bar_width.saturating_sub(filled)),
pct
);
let paragraph = Paragraph::new(vec![
Line::from(bar),
Line::from(msg),
])
.block(
Block::default()
.borders(Borders::ALL)
.title(" Прогресс ")
.border_style(Style::default().fg(Color::Cyan)),
);
f.render_widget(paragraph, area);
}
None => {
// Indeterminate: spinning braille dots
const SPINNER: &[&str] =
&["", "", "", "", "", "", "", "", "", ""];
let frame = (std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_millis()
/ 120) as usize;
let spinner = SPINNER[frame % SPINNER.len()];
let line = format!("{} {}", spinner, msg);
let paragraph = Paragraph::new(line).block(
Block::default()
.borders(Borders::ALL)
.title(" Прогресс ")
.border_style(Style::default().fg(Color::Cyan)),
);
f.render_widget(paragraph, area);
}
}
}
executor::StructuredCommand::Form { prompt, fields } => {