T39: review round 2: a hidden session whose row turns to waiting marks it until shown, though it went on within the same output, so one output marks as two would; a change of herdr's records draws the view again, so an open hover follows them though the state holds

This commit is contained in:
ZacharyZhang-NY committed 2026-10-17 15:41:39 -04:00
1 parent 31de5e44ef
commit 3aaeb36bd1
5 files changed
+20 -19

No files matched your search

+2 -9
View File
@@ -76,12 +76,7 @@ pub fn follow(cx: &mut Context<TerminalView>) -> Task<()> {
"terminal {pid}: herdr left the foreground, its agents' records with it"
);
states.clear();
let gone = view.update(cx, |view, cx| {
if view.records.herdr(&[]) && view.restate(cx) {
view.tell_state(cx);
}
});
if gone.is_err() {
if view.update(cx, |view, cx| view.agents(&[], cx)).is_err() {
break;
}
}
@@ -127,9 +122,7 @@ pub fn follow(cx: &mut Context<TerminalView>) -> Task<()> {
let Ok(still) = view.update(cx, |view, cx| {
let still = view.reports == reports;
if still {
if view.records.herdr(&agents) && view.restate(cx) {
view.tell_state(cx);
}
view.agents(&agents, cx);
if let Some(folder) = report.clone() {
cx.emit(TerminalEvent::Folder(folder));
}
+11 -1
View File
@@ -4,7 +4,7 @@ use gpui::{Context, SharedString, SystemNotification};
use super::{
notify::{self, Ask, CLOSES, Notice},
status::{self, State, Status},
status::{self, Record, State, Status},
view::{TerminalEvent, TerminalView},
};
use crate::{
@@ -133,6 +133,16 @@ impl TerminalView {
changed
}
/// herdr's agents in place of the last ones; an open hover reads them, so the view draws again.
pub(super) fn agents(&mut self, agents: &[(String, Record)], cx: &mut Context<Self>) {
if self.records.herdr(agents) {
if self.restate(cx) {
self.tell_state(cx);
}
cx.notify();
}
}
/// Posts the state its row shows when it turned to waiting, done or error.
pub(super) fn tell_state(&mut self, cx: &mut Context<Self>) {
let body = match self.records.shown() {
+5 -7
View File
@@ -37,14 +37,12 @@ impl Workspace {
session.bell = true;
}
TerminalEvent::Bell => {}
TerminalEvent::Shows(state) => {
let now = session.terminal.read(cx).records().shows();
// A hidden session that starts waiting, and still waits, marks its row until it is shown.
if *state == Some(State::Blocked) && now == *state && index != self.active {
log::debug!("app: hidden session {} waits", index + 1);
session.waiting = true;
}
// A hidden session that starts waiting marks its row until it is shown.
TerminalEvent::Shows(Some(State::Blocked)) if index != self.active => {
log::debug!("app: hidden session {} waits", index + 1);
session.waiting = true;
}
TerminalEvent::Shows(_) => {}
TerminalEvent::Exited(status) => {
let pid = session.terminal.read(cx).pid();
log::info!("app: session {pid}'s program ended, {status}");