Merge branch 'code-branch-20251003-220814'

This commit is contained in:
James Peter
2025-10-04 12:17:46 +10:00
2 changed files with 19 additions and 11 deletions
+15 -6
View File
@@ -575,6 +575,7 @@ impl ExecCell {
let wait_state = self.wait_state_snapshot();
let status_label = if wait_state.waiting { "Waiting" } else { "Running" };
let elapsed_since_start = self.elapsed_since_start();
let (pre, mut out, status) = if self.parsed.is_empty() {
self.exec_render_parts_generic(status_label)
} else {
@@ -584,14 +585,14 @@ impl ExecCell {
meta,
self.output.as_ref(),
self.stream_preview.as_ref(),
self.start_time,
elapsed_since_start,
status_label,
),
None => exec_render_parts_parsed(
&self.parsed,
self.output.as_ref(),
self.stream_preview.as_ref(),
self.start_time,
elapsed_since_start,
status_label,
),
}
@@ -740,6 +741,16 @@ impl ExecCell {
highlighted_cmd
}
fn elapsed_since_start(&self) -> Option<Duration> {
if !matches!(self.record.status, ExecStatus::Running) {
return None;
}
match SystemTime::now().duration_since(self.record.started_at) {
Ok(duration) => Some(duration),
Err(_) => self.start_time.map(|start| start.elapsed()),
}
}
fn streaming_status_line_for_label(&self, status_label: &str) -> Option<Line<'static>> {
if self.output.is_some() {
return None;
@@ -747,8 +758,7 @@ impl ExecCell {
if self.parsed.is_empty() {
let mut message = format!("{status_label}...");
if let Some(start) = self.start_time {
let elapsed = start.elapsed();
if let Some(elapsed) = self.elapsed_since_start() {
if !elapsed.is_zero() {
message = format!("{message} ({})", format_duration(elapsed));
}
@@ -768,8 +778,7 @@ impl ExecCell {
Some(p) => format!("{status_label}... in {p}"),
None => format!("{status_label}..."),
};
if let Some(start) = self.start_time {
let elapsed = start.elapsed();
if let Some(elapsed) = self.elapsed_since_start() {
if !elapsed.is_zero() {
message = format!("{message} ({})", format_duration(elapsed));
}
+4 -5
View File
@@ -1414,7 +1414,7 @@ fn exec_render_parts_parsed_with_meta(
meta: &ParsedExecMetadata,
output: Option<&CommandOutput>,
stream_preview: Option<&CommandOutput>,
start_time: Option<Instant>,
elapsed_since_start: Option<Duration>,
status_label: &str,
) -> (
Vec<Line<'static>>,
@@ -1446,8 +1446,7 @@ fn exec_render_parts_parsed_with_meta(
Some(p) => format!("{}... in {p}", status_label),
None => format!("{}...", status_label),
};
if let Some(start) = start_time {
let elapsed = start.elapsed();
if let Some(elapsed) = elapsed_since_start {
message = format!("{message} ({})", format_duration(elapsed));
}
running_status = Some(running_status_line(message));
@@ -1840,7 +1839,7 @@ fn exec_render_parts_parsed(
parsed_commands: &[ParsedCommand],
output: Option<&CommandOutput>,
stream_preview: Option<&CommandOutput>,
start_time: Option<Instant>,
elapsed_since_start: Option<Duration>,
status_label: &str,
) -> (
Vec<Line<'static>>,
@@ -1853,7 +1852,7 @@ fn exec_render_parts_parsed(
&meta,
output,
stream_preview,
start_time,
elapsed_since_start,
status_label,
)
}