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
|
||||
let timer = if !app.activity.is_empty() {
|
||||
let total = self.turn_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, {}/{}s", total, call, self.call_timeout_secs)
|
||||
let elapsed = app.activity_started.map(|t| t.elapsed().as_secs()).unwrap_or(0);
|
||||
format!(" {}s", elapsed)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
|
@ -1057,6 +1056,8 @@ impl ScreenView for InteractScreen {
|
|||
app.activity = st.activities.last()
|
||||
.map(|a| a.label.clone())
|
||||
.unwrap_or_default();
|
||||
app.activity_started = st.activities.last()
|
||||
.map(|a| a.started);
|
||||
}
|
||||
if let Ok(ctx) = self.agent.context.try_lock() {
|
||||
let window = crate::agent::context::context_window();
|
||||
|
|
|
|||
|
|
@ -358,7 +358,11 @@ async fn run(
|
|||
let mut startup_done = false;
|
||||
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 {
|
||||
let has_activity = !app.activity.is_empty();
|
||||
tokio::select! {
|
||||
biased;
|
||||
|
||||
|
|
@ -380,6 +384,10 @@ async fn run(
|
|||
Some(channels) = channel_rx.recv() => {
|
||||
app.set_channel_status(channels);
|
||||
}
|
||||
|
||||
_ = activity_tick.tick(), if has_activity => {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// State sync on every wake
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue