Fix status bar timer: use activity start time, tick every 1s
The status bar timer was showing turn/call elapsed times (0s, 0/60s) instead of the activity's actual elapsed time. Use activity_started from the ActivityEntry directly. Add a 1s tick to the UI select loop when an activity is active so the timer updates live. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
5fe22a5f23
commit
c31d531954
2 changed files with 12 additions and 3 deletions
|
|
@ -902,9 +902,8 @@ impl InteractScreen {
|
||||||
|
|
||||||
// Draw status bar with live activity indicator
|
// Draw status bar with live activity indicator
|
||||||
let timer = if !app.activity.is_empty() {
|
let timer = if !app.activity.is_empty() {
|
||||||
let total = self.turn_started.map(|t| t.elapsed().as_secs()).unwrap_or(0);
|
let elapsed = app.activity_started.map(|t| t.elapsed().as_secs()).unwrap_or(0);
|
||||||
let call = self.call_started.map(|t| t.elapsed().as_secs()).unwrap_or(0);
|
format!(" {}s", elapsed)
|
||||||
format!(" {}s, {}/{}s", total, call, self.call_timeout_secs)
|
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
|
|
@ -1057,6 +1056,8 @@ impl ScreenView for InteractScreen {
|
||||||
app.activity = st.activities.last()
|
app.activity = st.activities.last()
|
||||||
.map(|a| a.label.clone())
|
.map(|a| a.label.clone())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
app.activity_started = st.activities.last()
|
||||||
|
.map(|a| a.started);
|
||||||
}
|
}
|
||||||
if let Ok(ctx) = self.agent.context.try_lock() {
|
if let Ok(ctx) = self.agent.context.try_lock() {
|
||||||
let window = crate::agent::context::context_window();
|
let window = crate::agent::context::context_window();
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,11 @@ async fn run(
|
||||||
let mut startup_done = false;
|
let mut startup_done = false;
|
||||||
let mut dirty = true; // render on first loop
|
let mut dirty = true; // render on first loop
|
||||||
|
|
||||||
|
let mut activity_tick = tokio::time::interval(std::time::Duration::from_secs(1));
|
||||||
|
activity_tick.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
let has_activity = !app.activity.is_empty();
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
biased;
|
biased;
|
||||||
|
|
||||||
|
|
@ -380,6 +384,10 @@ async fn run(
|
||||||
Some(channels) = channel_rx.recv() => {
|
Some(channels) = channel_rx.recv() => {
|
||||||
app.set_channel_status(channels);
|
app.set_channel_status(channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = activity_tick.tick(), if has_activity => {
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// State sync on every wake
|
// State sync on every wake
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue