mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix(tui/history): show exec/mcp cards immediately
This commit is contained in:
@@ -5299,6 +5299,9 @@ impl ChatWidget<'_> {
|
||||
seq: u64,
|
||||
) {
|
||||
self.finalize_active_stream();
|
||||
if self.interrupts.has_queued() {
|
||||
self.flush_interrupt_queue();
|
||||
}
|
||||
tracing::info!(
|
||||
"[order] ExecCommandBegin call_id={} seq={}",
|
||||
ev.call_id,
|
||||
@@ -5313,7 +5316,9 @@ impl ChatWidget<'_> {
|
||||
{
|
||||
self.handle_exec_end_now(pending_end, &order2);
|
||||
}
|
||||
self.flush_interrupt_queue();
|
||||
if self.interrupts.has_queued() {
|
||||
self.flush_interrupt_queue();
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle exec command end immediately
|
||||
@@ -13574,19 +13579,12 @@ impl ChatWidget<'_> {
|
||||
);
|
||||
}
|
||||
EventMsg::ExecCommandBegin(ev) => {
|
||||
let ev2 = ev.clone();
|
||||
let seq = event.event_seq;
|
||||
let om_begin = event
|
||||
.order
|
||||
.clone()
|
||||
.expect("missing OrderMeta for ExecCommandBegin");
|
||||
let om_begin_for_handler = om_begin.clone();
|
||||
self.defer_or_handle(
|
||||
move |interrupts| interrupts.push_exec_begin(seq, ev, Some(om_begin)),
|
||||
move |this| {
|
||||
this.handle_exec_begin_ordered(ev2, om_begin_for_handler, seq);
|
||||
},
|
||||
);
|
||||
self.handle_exec_begin_ordered(ev, om_begin, seq);
|
||||
}
|
||||
EventMsg::ExecCommandOutputDelta(ev) => {
|
||||
let call_id = ExecCallId(ev.call_id.clone());
|
||||
@@ -13748,7 +13746,6 @@ impl ChatWidget<'_> {
|
||||
);
|
||||
}
|
||||
EventMsg::McpToolCallBegin(ev) => {
|
||||
let ev2 = ev.clone();
|
||||
let seq = event.event_seq;
|
||||
let order_ok = match event.order.as_ref() {
|
||||
Some(om) => self.provider_order_key_from_order_meta(om),
|
||||
@@ -13757,20 +13754,17 @@ impl ChatWidget<'_> {
|
||||
self.next_internal_key()
|
||||
}
|
||||
};
|
||||
self.defer_or_handle(
|
||||
move |interrupts| interrupts.push_mcp_begin(seq, ev, event.order.clone()),
|
||||
|this| {
|
||||
this.finalize_active_stream();
|
||||
this.flush_interrupt_queue();
|
||||
tracing::info!(
|
||||
"[order] McpToolCallBegin call_id={} seq={}",
|
||||
ev2.call_id,
|
||||
seq
|
||||
);
|
||||
this.ensure_spinner_for_activity("mcp-begin");
|
||||
tools::mcp_begin(this, ev2, order_ok);
|
||||
},
|
||||
self.finalize_active_stream();
|
||||
if self.interrupts.has_queued() {
|
||||
self.flush_interrupt_queue();
|
||||
}
|
||||
tracing::info!(
|
||||
"[order] McpToolCallBegin call_id={} seq={}",
|
||||
ev.call_id,
|
||||
seq
|
||||
);
|
||||
self.ensure_spinner_for_activity("mcp-begin");
|
||||
tools::mcp_begin(self, ev, order_ok);
|
||||
}
|
||||
EventMsg::McpToolCallEnd(ev) => {
|
||||
let ev2 = ev.clone();
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
use code_core::protocol::ApplyPatchApprovalRequestEvent;
|
||||
use code_core::protocol::ExecApprovalRequestEvent;
|
||||
use code_core::protocol::ExecCommandBeginEvent;
|
||||
use code_core::protocol::ExecCommandEndEvent;
|
||||
use code_core::protocol::McpToolCallBeginEvent;
|
||||
use code_core::protocol::McpToolCallEndEvent;
|
||||
use code_core::protocol::PatchApplyEndEvent;
|
||||
|
||||
@@ -15,9 +13,7 @@ use super::tools;
|
||||
pub(crate) enum QueuedInterrupt {
|
||||
ExecApproval { seq: u64, id: String, ev: ExecApprovalRequestEvent },
|
||||
ApplyPatchApproval { seq: u64, id: String, ev: ApplyPatchApprovalRequestEvent },
|
||||
ExecBegin { seq: u64, ev: ExecCommandBeginEvent, order: Option<code_core::protocol::OrderMeta> },
|
||||
ExecEnd { seq: u64, ev: ExecCommandEndEvent, order: Option<code_core::protocol::OrderMeta> },
|
||||
McpBegin { seq: u64, ev: McpToolCallBeginEvent, order: Option<code_core::protocol::OrderMeta> },
|
||||
McpEnd { seq: u64, ev: McpToolCallEndEvent, order: Option<code_core::protocol::OrderMeta> },
|
||||
PatchEnd { seq: u64, ev: PatchApplyEndEvent },
|
||||
}
|
||||
@@ -34,7 +30,6 @@ impl InterruptManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn push_exec_approval(&mut self, seq: u64, id: String, ev: ExecApprovalRequestEvent) {
|
||||
self.queue.push(QueuedInterrupt::ExecApproval { seq, id, ev });
|
||||
}
|
||||
@@ -48,18 +43,10 @@ impl InterruptManager {
|
||||
self.queue.push(QueuedInterrupt::ApplyPatchApproval { seq, id, ev });
|
||||
}
|
||||
|
||||
pub(crate) fn push_exec_begin(&mut self, seq: u64, ev: ExecCommandBeginEvent, order: Option<code_core::protocol::OrderMeta>) {
|
||||
self.queue.push(QueuedInterrupt::ExecBegin { seq, ev, order });
|
||||
}
|
||||
|
||||
pub(crate) fn push_exec_end(&mut self, seq: u64, ev: ExecCommandEndEvent, order: Option<code_core::protocol::OrderMeta>) {
|
||||
self.queue.push(QueuedInterrupt::ExecEnd { seq, ev, order });
|
||||
}
|
||||
|
||||
pub(crate) fn push_mcp_begin(&mut self, seq: u64, ev: McpToolCallBeginEvent, order: Option<code_core::protocol::OrderMeta>) {
|
||||
self.queue.push(QueuedInterrupt::McpBegin { seq, ev, order });
|
||||
}
|
||||
|
||||
pub(crate) fn push_mcp_end(&mut self, seq: u64, ev: McpToolCallEndEvent, order: Option<code_core::protocol::OrderMeta>) {
|
||||
self.queue.push(QueuedInterrupt::McpEnd { seq, ev, order });
|
||||
}
|
||||
@@ -83,20 +70,6 @@ impl InterruptManager {
|
||||
QueuedInterrupt::ApplyPatchApproval { seq: _, id, ev } => {
|
||||
chat.handle_apply_patch_approval_now(id, ev);
|
||||
}
|
||||
QueuedInterrupt::ExecBegin { seq, ev, order, .. } => {
|
||||
match order.as_ref() {
|
||||
Some(ord) => chat.handle_exec_begin_ordered(ev, ord.clone(), seq),
|
||||
None => {
|
||||
tracing::warn!("missing OrderMeta in queued ExecBegin; rendering with synthetic order");
|
||||
let synthetic = code_core::protocol::OrderMeta {
|
||||
request_ordinal: chat.last_seen_request_index,
|
||||
output_index: Some(i32::MAX as u32),
|
||||
sequence_number: Some(0),
|
||||
};
|
||||
chat.handle_exec_begin_ordered(ev, synthetic, seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
QueuedInterrupt::ExecEnd { ev, order, .. } => {
|
||||
match order.as_ref() {
|
||||
Some(ord) => chat.enqueue_or_handle_exec_end(ev, ord.clone()),
|
||||
@@ -111,10 +84,6 @@ impl InterruptManager {
|
||||
}
|
||||
}
|
||||
},
|
||||
QueuedInterrupt::McpBegin { seq: _, ev, order, .. } => {
|
||||
let ok = match order.as_ref() { Some(om) => chat.provider_order_key_from_order_meta(om), None => { tracing::warn!("missing OrderMeta in queued McpBegin; using synthetic key"); chat.next_internal_key() } };
|
||||
tools::mcp_begin(chat, ev, ok);
|
||||
}
|
||||
QueuedInterrupt::McpEnd { ev, order, .. } => {
|
||||
let ok = match order.as_ref() { Some(om) => chat.provider_order_key_from_order_meta(om), None => { tracing::warn!("missing OrderMeta in queued McpEnd; using synthetic key"); chat.next_internal_key() } };
|
||||
tools::mcp_end(chat, ev, ok)
|
||||
@@ -132,9 +101,7 @@ impl InterruptManager {
|
||||
match q {
|
||||
QueuedInterrupt::ExecApproval { seq, .. }
|
||||
| QueuedInterrupt::ApplyPatchApproval { seq, .. }
|
||||
| QueuedInterrupt::ExecBegin { seq, .. }
|
||||
| QueuedInterrupt::ExecEnd { seq, .. }
|
||||
| QueuedInterrupt::McpBegin { seq, .. }
|
||||
| QueuedInterrupt::McpEnd { seq, .. }
|
||||
| QueuedInterrupt::PatchEnd { seq, .. } => *seq,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user