mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-09 22:25:02 +03:00
fix(cli-rs): refresh subagent rows when a child session starts or stops
This commit is contained in:
@@ -226,10 +226,14 @@ impl Transcript {
|
||||
let pending = changes.pending(session);
|
||||
// A tool row waiting on a permission request takes the warning color.
|
||||
let permissions = changes.permissions(session);
|
||||
if !changes.any_message(session) && !changes.session(session) && !catalogs && !pending && !permissions {
|
||||
// A subagent row spins while its child session runs.
|
||||
let children = !changes.status.is_empty()
|
||||
&& tui.data.read(|state| state.family(session).iter().any(|id| id != session && changes.status(id)));
|
||||
let force =
|
||||
changes.messages(session) || changes.session(session) || catalogs || pending || permissions || children;
|
||||
if !force && !changes.any_message(session) {
|
||||
return;
|
||||
}
|
||||
let force = changes.messages(session) || changes.session(session) || catalogs || pending || permissions;
|
||||
if !force
|
||||
&& let Some(messages) = changes.message.get(session)
|
||||
&& self.0.patch(tui, session, messages)
|
||||
|
||||
@@ -256,6 +256,28 @@ fn a_subagent_row_opens_its_child_session() {
|
||||
assert!(support::lines(&h.log).iter().any(|line| line == "GET /api/session/ses_child/message"),);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_background_subagent_row_follows_its_child_status() {
|
||||
let messages = turn(vec![tool(
|
||||
"c1",
|
||||
"task",
|
||||
completed(
|
||||
json!({ "description": "Check the docs", "agent": "general" }),
|
||||
"done",
|
||||
json!({ "sessionID": "ses_child", "status": "running" }),
|
||||
),
|
||||
)]);
|
||||
let h = open(100, 30, messages);
|
||||
h.wait_for(" ✓ General Subagent — Check the docs Background\n");
|
||||
let child = support::merge(session("ses_child", "Child work"), json!({ "parentID": "ses_t" }));
|
||||
h.tui.data.remember(serde_json::from_value(child).unwrap());
|
||||
let child = SessionID("ses_child".into());
|
||||
h.tui.data.set_status(&child, opencode_store::SessionStatus::Running);
|
||||
h.wait_for(" ⋯ General Subagent — Check the docs Background\n");
|
||||
h.tui.data.set_status(&child, opencode_store::SessionStatus::Idle);
|
||||
h.wait_for(" ✓ General Subagent — Check the docs Background\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute_lists_its_calls_and_opens_the_dialog() {
|
||||
let calls = json!([
|
||||
|
||||
Reference in New Issue
Block a user