Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
acp_thread: Settle receipt submissions after disconnect (#65646)
Ben Brandt9be5cb613977
diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rsindex 848d438e06c..ea7abde2464 100644--- a/crates/acp_thread/src/acp_thread.rs+++ b/crates/acp_thread/src/acp_thread.rs@@ -4139,6 +4139,17 @@ impl AcpThread {}}+ /// Settles receipt observations without declaring that remote execution stopped.+ pub fn disconnect_submissions(&mut self, cx: &mut Context<Self>) {+ let changed = self.submissions.disconnect();+ if !changed.is_empty() {+ for id in changed {+ cx.emit(AcpThreadEvent::SubmissionUpdated(id));+ }+ cx.notify();+ }+ }+fn register_submission(&mut self,content: Arc<[acp_v2::ContentBlock]>,@@ -4168,13 +4179,38 @@ impl AcpThread {) -> Result<Option<SubmissionResponse>>,) -> Submission {let (sender, receiver) = oneshot::channel();+ let (disconnect_sender, disconnect_receiver) = self+ .uses_reported_activity()+ .then(oneshot::channel::<()>)+ .unzip();let task = cx.spawn(async move |this, cx| {- let response = complete(this.clone(), cx).await;+ let response = {+ let response = complete(this.clone(), cx);+ futures::pin_mut!(response);+ if let Some(disconnected) = disconnect_receiver {+ match futures::future::select(response, disconnected).await {+ futures::future::Either::Left((response, _)) => response,+ futures::future::Either::Right(_) => Err(anyhow!(SubmissionDisconnected)),+ }+ } else {+ response.await+ }+ };let response = match response {Err(error) if error.is::<SubmissionCancelled>() => Ok(None),response => response,};let update = this.update(cx, |this, cx| {+ if this.uses_reported_activity()+ && response.as_ref().err().is_some_and(|error| {+ error.is::<SubmissionDisconnected>()+ || error+ .downcast_ref::<agent_client_protocol::Error>()+ .is_some_and(agent_client_protocol::is_incoming_transport_closed)+ })+ {+ this.disconnect_submissions(cx);+ }let state = match &response {Ok(Some(SubmissionResponse::Accepted(receipt))) => {let echoed = this.entries.iter().any(|entry| {@@ -4187,19 +4223,21 @@ impl AcpThread {Ok(None) => SubmissionState::Cancelled,Err(error) => SubmissionState::Failed(format!("{error:#}").into()),};- this.submissions.settle(id, state);+ let changed = this.submissions.settle(id, state);// The thread owns settlement even when the response observer has gone away.if let Err(Err(error)) = sender.send(response) {log::debug!("Submission observer was dropped: {error:#}");}- cx.emit(AcpThreadEvent::SubmissionUpdated(id));- cx.notify();+ if changed {+ cx.emit(AcpThreadEvent::SubmissionUpdated(id));+ cx.notify();+ }});if let Err(error) = update {log::debug!("Submission thread was released: {error:#}");}});- self.submissions.track(id, task);+ self.submissions.track(id, task, disconnect_sender);Submission::new(id,async move {@@ -11043,6 +11081,193 @@ mod tests {(thread, connection)}+ #[gpui::test]+ async fn test_receipt_disconnect_settles_waiters_and_preserves_recovery(+ cx: &mut TestAppContext,+ ) {+ init_test(cx);+ let (thread, connection) = new_receipt_test_thread(cx).await;+ let receipt = acp_v2::PromptResponse::new("accepted-id").meta(acp_v2::Meta::from_iter([(+ "retain".into(),+ serde_json::json!([null, 7]),+ )]));+ let accepted = thread.update(cx, |thread, cx| {+ thread.submit_receipt(+ vec!["accepted".into()],+ Task::ready(Ok(receipt.clone())),+ cx,+ )+ });+ let accepted_id = accepted.id;+ assert!(matches!(+ accepted.await.expect("receipt"),+ Some(SubmissionResponse::Accepted(_))+ ));+ let _pending_sender = connection.defer_next_receipt_response();+ let pending = thread.update(cx, |thread, cx| thread.send(vec!["pending".into()], cx));+ let pending_id = pending.id;+ let echoed = thread.update(cx, |thread, cx| {+ thread.submit_receipt(+ vec!["confirmed".into()],+ Task::ready(Ok(acp_v2::PromptResponse::new("confirmed-id"))),+ cx,+ )+ });+ let echoed_id = echoed.id;+ echoed.await.expect("receipt");+ thread.update(cx, |thread, cx| {+ thread+ .upsert_user_message(+ acp_v2::UserMessage::new("confirmed-id").content(vec!["confirmed".into()]),+ cx,+ )+ .expect("confirmed echo");+ thread.disconnect_submissions(cx);+ thread.disconnect_submissions(cx);+ assert!(!thread.has_unsettled_submissions());+ assert!(!thread.is_idle_for_retention());+ assert!(+ matches!(&thread.submission(accepted_id).expect("accepted").state,+ SubmissionState::Disconnected { receipt: Some(accepted) } if accepted == &receipt)+ );+ assert!(matches!(+ thread+ .submission(pending_id)+ .expect("unknown acceptance")+ .state,+ SubmissionState::Disconnected { receipt: None }+ ));+ assert!(matches!(+ thread+ .submission(echoed_id)+ .expect("confirmed history")+ .state,+ SubmissionState::Accepted { echoed: true, .. }+ ));+ });+ assert!(+ pending+ .await+ .expect_err("disconnect response")+ .is::<SubmissionDisconnected>()+ );+ thread.update(cx, |thread, cx| {+ assert_eq!(thread.recoverable_submissions().count(), 2);+ for (id, content) in [(accepted_id, "accepted"), (pending_id, "pending")] {+ assert_eq!(+ thread+ .submission(id)+ .expect("retained content")+ .content+ .as_ref(),+ &[content.into()]+ );+ thread.forget_submission(id, cx);+ }+ assert!(thread.recoverable_submissions().next().is_none());+ assert!(thread.is_idle_for_retention());+ });+ }++ #[gpui::test]+ async fn test_receipt_disconnect_keeps_ready_results_terminal(cx: &mut TestAppContext) {+ init_test(cx);+ let receipt = acp_v2::PromptResponse::new("ready-receipt");+ for response in [Ok(receipt), Err(anyhow!("late failure"))] {+ let expected_receipt = response.as_ref().ok().cloned();+ let (thread, _) = new_receipt_test_thread(cx).await;+ let submission = thread.update(cx, |thread, cx| {+ thread+ .update_session_state(+ acp_v2::StateUpdate::Running(acp_v2::RunningStateUpdate::new()),+ cx,+ )+ .expect("reported activity");+ let submission =+ thread.submit_receipt(vec!["ready".into()], Task::ready(response), cx);+ thread.disconnect_submissions(cx);+ submission+ });+ let id = submission.id;+ assert_eq!(submission.await.is_ok(), expected_receipt.is_some());+ thread.read_with(cx, |thread, _| {+ assert!(+ matches!(&thread.submission(id).expect("still disconnected").state,+ SubmissionState::Disconnected { receipt } if receipt == &expected_receipt)+ );+ assert!(!thread.has_unsettled_submissions());+ assert_eq!(thread.foreground_activity(), ForegroundActivity::Running);+ });+ cx.run_until_parked();+ }+ }++ #[gpui::test]+ async fn test_receipt_disconnect_classifies_transport_loss_before_cleanup(+ cx: &mut TestAppContext,+ ) {+ init_test(cx);+ for error in [+ anyhow!("transport stopped").context(SubmissionDisconnected),+ anyhow!(+ agent_client_protocol::Error::internal_error().data(serde_json::json!({+ "reason": agent_client_protocol::INCOMING_TRANSPORT_CLOSED_REASON,+ "method": "session/prompt",+ }))+ ),+ ] {+ let (thread, _) = new_receipt_test_thread(cx).await;+ let pending = thread.update(cx, |thread, cx| {+ thread.submit_receipt(vec!["unknown".into()], Task::ready(Err(error)), cx)+ });+ let pending_id = pending.id;+ assert!(pending.await.is_err());+ thread.read_with(cx, |thread, _| {+ assert!(matches!(+ thread.submission(pending_id).expect("unknown").state,+ SubmissionState::Disconnected { receipt: None }+ ));+ assert!(!thread.has_unsettled_submissions());+ });+ }+ }++ #[gpui::test]+ async fn test_receipt_disconnect_does_not_settle_legacy_prompts(cx: &mut TestAppContext) {+ init_test(cx);+ let project = Project::test(FakeFs::new(cx.executor()), [], cx).await;+ let connection = Rc::new(StubAgentConnection::new());+ let thread = cx+ .update(|cx| {+ connection.clone().new_session(+ project,+ PathList::new(&[Path::new(path!("/test"))]),+ cx,+ )+ })+ .await+ .expect("legacy session");+ let complete = connection.defer_next_prompt_response();+ let submission = thread.update(cx, |thread, cx| thread.send(vec!["legacy".into()], cx));+ let id = submission.id;+ cx.run_until_parked();+ thread.update(cx, |thread, cx| {+ thread.disconnect_submissions(cx);+ assert!(matches!(+ thread.submission(id).expect("still pending").state,+ SubmissionState::Pending+ ));+ assert!(thread.has_unsettled_submissions());+ });+ complete+ .send(Ok(acp_v1::PromptResponse::new(acp_v1::StopReason::EndTurn)))+ .expect("legacy response");+ assert!(matches!(+ submission.await.expect("legacy completion"),+ Some(SubmissionResponse::LegacyCompleted(_))+ ));+ }+#[gpui::test]async fn test_local_prompt_preserves_keyed_identity_source_and_command_marker(cx: &mut TestAppContext,diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rsindex f90bbf17933..95b1f9b08e8 100644--- a/crates/acp_thread/src/connection.rs+++ b/crates/acp_thread/src/connection.rs@@ -319,6 +319,8 @@ pub trait AgentSessionClientUserMessageIds {/// A session-bound prompt transport whose response acknowledges acceptance, not completion./// Implementations must report foreground state separately through `AcpThread::update_session_state`.pub trait ReceiptSessionSubmissions {+ /// Transport loss must carry [`crate::SubmissionDisconnected`] (which may be+ /// added as error context) rather than claiming that the agent rejected insertion.fn prompt(&self,content: Vec<acp_v2::ContentBlock>,diff --git a/crates/acp_thread/src/submission.rs b/crates/acp_thread/src/submission.rsindex fe85999fc51..59a4abd5a7b 100644--- a/crates/acp_thread/src/submission.rs+++ b/crates/acp_thread/src/submission.rs@@ -40,6 +40,18 @@ impl fmt::Display for SubmissionCancelled {impl std::error::Error for SubmissionCancelled {}+/// Local loss of a receipt waiter does not establish that the agent rejected the message.+#[derive(Debug)]+pub struct SubmissionDisconnected;++impl fmt::Display for SubmissionDisconnected {+ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {+ formatter.write_str("Agent connection lost before submission acceptance was confirmed")+ }+}++impl std::error::Error for SubmissionDisconnected {}+pub struct Submission {pub id: SubmissionId,pub response: BoxFuture<'static, anyhow::Result<Option<SubmissionResponse>>>,@@ -69,6 +81,10 @@ pub enum SubmissionState {receipt: acp_v2::PromptResponse,echoed: bool,},+ Disconnected {+ /// Absence means acceptance is unknown, not that insertion failed.+ receipt: Option<acp_v2::PromptResponse>,+ },Completed,Failed(SharedString),Cancelled,@@ -78,6 +94,7 @@ pub struct SubmissionRecord {pub content: Arc<[acp_v2::ContentBlock]>,pub state: SubmissionState,task: Option<Task<()>>,+ disconnect_sender: Option<oneshot::Sender<()>>,}impl fmt::Debug for SubmissionRecord {@@ -102,7 +119,9 @@ impl SubmissionRecord {self.is_unsettled()|| matches!(self.state,- SubmissionState::Failed(_) | SubmissionState::Cancelled+ SubmissionState::Failed(_)+ | SubmissionState::Cancelled+ | SubmissionState::Disconnected { .. })}}@@ -157,22 +176,74 @@ impl SessionSubmissions {content,state: SubmissionState::Pending,task: None,+ disconnect_sender: None,},);id}- pub(crate) fn track(&mut self, id: SubmissionId, task: Task<()>) {+ pub(crate) fn track(+ &mut self,+ id: SubmissionId,+ task: Task<()>,+ disconnect_sender: Option<oneshot::Sender<()>>,+ ) {if let Some(record) = self.records.get_mut(&id) {record.task = Some(task);+ record.disconnect_sender = disconnect_sender;}}- pub(crate) fn settle(&mut self, id: SubmissionId, state: SubmissionState) {- if let Some(record) = self.records.get_mut(&id) {- record.state = state;- }+ pub(crate) fn settle(&mut self, id: SubmissionId, state: SubmissionState) -> bool {+ let changed = self.records.get_mut(&id).is_some_and(|record| {+ drop(record.disconnect_sender.take());+ match &mut record.state {+ SubmissionState::Disconnected { receipt } => {+ // A ready receipt can race with disconnect cleanup. Retain its+ // acceptance evidence without reopening the disconnected record.+ if receipt.is_none()+ && let SubmissionState::Accepted {+ receipt: accepted, ..+ } = state+ {+ *receipt = Some(accepted);+ return true;+ }+ false+ }+ _ => {+ record.state = state;+ true+ }+ }+ });self.prune();+ changed+ }++ pub(crate) fn disconnect(&mut self) -> Vec<SubmissionId> {+ if self.receipt_transport.is_none() {+ return Vec::new();+ }+ let mut changed = Vec::new();+ for (id, record) in &mut self.records {+ let receipt = match &record.state {+ SubmissionState::Pending => None,+ SubmissionState::Accepted {+ receipt,+ echoed: false,+ } => Some(receipt.clone()),+ _ => continue,+ };+ record.state = SubmissionState::Disconnected { receipt };+ if let Some(sender) = record.disconnect_sender.take()+ && sender.send(()).is_err()+ {+ log::debug!("Submission already finished before disconnect notification");+ }+ changed.push(*id);+ }+ changed}pub(crate) fn observe_echo(&mut self, message_id: &acp_v2::MessageId) -> Vec<SubmissionId> {diff --git a/crates/agent_servers/src/acp.rs b/crates/agent_servers/src/acp.rsindex 87f93ba6ff5..7a27ba82491 100644--- a/crates/agent_servers/src/acp.rs+++ b/crates/agent_servers/src/acp.rs@@ -153,11 +153,11 @@ impl ForegroundWorkItem for ForegroundBarrier {}}-struct ElicitationDisconnectWork {+struct ClientDisconnectWork {acknowledgment: futures::channel::oneshot::Sender<()>,}-impl ForegroundWorkItem for ElicitationDisconnectWork {+impl ForegroundWorkItem for ClientDisconnectWork {fn run(self: Box<Self>, cx: &mut AsyncApp, context: &ClientContext) {if let Some(scopes) = &context.active_request_scopes {scopes.borrow_mut().clear();@@ -172,6 +172,7 @@ impl ForegroundWorkItem for ElicitationDisconnectWork {if let Some(thread) = thread.upgrade() {thread.update(cx, |thread, cx| {thread.cancel_outstanding_elicitations(cx);+ thread.disconnect_submissions(cx);cx.notify();});}@@ -189,11 +190,11 @@ impl ForegroundWorkItem for ElicitationDisconnectWork {}}-async fn cancel_elicitations_after_disconnect(+async fn settle_after_disconnect(dispatch_tx: mpsc::UnboundedSender<ForegroundWork>,) -> Result<(), acp::Error> {let (acknowledgment, received) = futures::channel::oneshot::channel();- let work: ForegroundWork = Box::new(ElicitationDisconnectWork { acknowledgment });+ let work: ForegroundWork = Box::new(ClientDisconnectWork { acknowledgment });if let Err(error) = dispatch_tx.unbounded_send(work) {error.into_inner().reject();return Err(dispatch_queue_closed_error());diff --git a/crates/agent_servers/src/acp/runtime.rs b/crates/agent_servers/src/acp/runtime.rsindex 2be788d9c42..84fefafa21f 100644--- a/crates/agent_servers/src/acp/runtime.rs+++ b/crates/agent_servers/src/acp/runtime.rs@@ -1,6 +1,6 @@use super::{- AcpDebugLog, ClientContext, ForegroundWork, cancel_elicitations_after_disconnect,- drain_foreground_queue, exited_load_error_after_drain,+ AcpDebugLog, ClientContext, ForegroundWork, drain_foreground_queue,+ exited_load_error_after_drain, settle_after_disconnect,};use acp_thread::LoadError;use agent_client_protocol::{Error, Result as RpcResult};@@ -91,9 +91,7 @@ impl Drop for ClientRuntime {pub(super) fn disconnect_cleanup(sender: mpsc::UnboundedSender<ForegroundWork>,) -> DisconnectCleanup {- cancel_elicitations_after_disconnect(sender)- .boxed()- .shared()+ settle_after_disconnect(sender).boxed().shared()}pub(super) async fn publish_connection<Connection>(diff --git a/crates/agent_servers/src/acp/v1.rs b/crates/agent_servers/src/acp/v1.rsindex 94e46099410..3d492f0a5e6 100644--- a/crates/agent_servers/src/acp/v1.rs+++ b/crates/agent_servers/src/acp/v1.rs@@ -3502,7 +3502,7 @@ mod tests {(&mut request_response).now_or_never().is_none(),"session destruction does not cancel request-scoped feedback");- cancel_elicitations_after_disconnect(connection.dispatch_tx.clone())+ settle_after_disconnect(connection.dispatch_tx.clone()).await.expect("canonical disconnect cleanup");assert_eq!(@@ -7817,16 +7817,62 @@ exit 7drop(dispatch_task);}+ #[gpui::test]+ async fn receipt_disconnect_sdk_eof_settles_retained_submission_owners(+ cx: &mut gpui::TestAppContext,+ ) {+ let (client, project, _, _, _, _, agent_task) = connect_fake_agent(None, cx).await;+ let connection =+ Rc::new(acp_thread::StubAgentConnection::new().with_receipt_submissions(true));+ let thread = cx+ .update(|cx| {+ connection+ .clone()+ .new_session(project, PathList::default(), cx)+ })+ .await+ .expect("receipt model owner");+ cx.update(|cx| {+ let session_id = thread.read(cx).session_id().clone();+ client.register_session(session_id, &thread, None, None, None, cx);+ });+ let _pending_sender = connection.defer_next_receipt_response();+ let pending = thread.update(cx, |thread, cx| thread.send(vec!["pending".into()], cx));+ let pending_id = pending.id;+ cx.run_until_parked();+ drop(agent_task);+ client.connection.incoming_closed().await;+ drain_foreground_queue(&client.dispatch_tx)+ .await+ .expect("disconnect barrier");+ assert!(+ pending+ .await+ .expect_err("lost transport")+ .is::<acp_thread::SubmissionDisconnected>()+ );+ thread.read_with(cx, |thread, _| {+ assert!(!thread.has_unsettled_submissions());+ assert!(matches!(+ thread+ .submission(pending_id)+ .expect("unknown acceptance")+ .state,+ acp_thread::SubmissionState::Disconnected { receipt: None }+ ));+ });+ }+#[test]fn disconnect_cleanup_reports_queue_failures() {let (sender, receiver) = mpsc::unbounded::<ForegroundWork>();drop(receiver);- let error = futures::executor::block_on(cancel_elicitations_after_disconnect(sender))+ let error = futures::executor::block_on(settle_after_disconnect(sender)).expect_err("closed dispatch queue must reject cleanup");assert_eq!(error.code, ErrorCode::InternalError);let (sender, mut receiver) = mpsc::unbounded::<ForegroundWork>();- let mut cleanup = Box::pin(cancel_elicitations_after_disconnect(sender));+ let mut cleanup = Box::pin(settle_after_disconnect(sender));assert!(cleanup.as_mut().now_or_never().is_none());let accepted = futures::executor::block_on(receiver.next()).expect("accepted cleanup");drop(accepted);@@ -7844,9 +7890,7 @@ exit 7active_request_scopes: None,};let (sender, mut receiver) = mpsc::unbounded::<ForegroundWork>();- let cleanup = cancel_elicitations_after_disconnect(sender.clone())- .boxed()- .shared();+ let cleanup = settle_after_disconnect(sender.clone()).boxed().shared();let mut close_callback = Box::pin(cleanup.clone());let mut connection_finished = Box::pin(cleanup.clone());assert!(close_callback.as_mut().now_or_never().is_none());diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rsindex a4ee3234869..d881dd2f24e 100644--- a/crates/agent_ui/src/conversation_view.rs+++ b/crates/agent_ui/src/conversation_view.rs@@ -5147,6 +5147,46 @@ pub(crate) mod tests {assert!(cx.debug_bounds(second_copy).is_some());}+ #[gpui::test]+ async fn test_receipt_disconnect_preserves_draft_without_restore_or_resend(+ cx: &mut TestAppContext,+ ) {+ init_test(cx);+ let connection = StubAgentConnection::new().with_receipt_submissions(true);+ let (conversation_view, cx) =+ setup_conversation_view(StubAgentServer::new(connection.clone()), cx).await;+ add_to_workspace_with_size(conversation_view.clone(), true, cx);+ let thread_view = active_thread(&conversation_view, cx);+ let thread = thread_view.read_with(cx, |view, _| view.thread.clone());+ let editor = message_editor(&conversation_view, cx);+ let _pending_sender = connection.defer_next_receipt_response();+ editor.update_in(cx, |editor, window, cx| {+ editor.set_text("unknown content", window, cx);+ });+ thread_view.update_in(cx, |view, window, cx| view.send(window, cx));+ cx.run_until_parked();+ let pending_id = thread.read_with(cx, |thread, _| {+ thread.latest_submission_id().expect("pending")+ });+ assert!(connection.take_receipt_prompt().is_some());+ editor.update_in(cx, |editor, window, cx| {+ editor.set_text("keep my draft", window, cx);+ });+ thread.update(cx, |thread, cx| thread.disconnect_submissions(cx));+ cx.run_until_parked();+ assert_eq!(+ editor.read_with(cx, |editor, cx| editor.text(cx)),+ "keep my draft"+ );+ let copy: &'static str =+ Box::leak(format!("copy-submission-{}", pending_id.as_u64()).into_boxed_str());+ let restore: &'static str =+ Box::leak(format!("restore-submission-{}", pending_id.as_u64()).into_boxed_str());+ assert!(cx.debug_bounds(copy).is_some());+ assert!(cx.debug_bounds(restore).is_none());+ assert!(connection.take_receipt_prompt().is_none());+ }+#[gpui::test]async fn test_hidden_command_marker_keeps_empty_editor_mode(cx: &mut TestAppContext) {init_test(cx);diff --git a/crates/agent_ui/src/conversation_view/thread_view.rs b/crates/agent_ui/src/conversation_view/thread_view.rsindex 6295fbf96b6..6d032ce8876 100644--- a/crates/agent_ui/src/conversation_view/thread_view.rs+++ b/crates/agent_ui/src/conversation_view/thread_view.rs@@ -1628,6 +1628,13 @@ impl ThreadView {SubmissionState::Accepted { echoed: false, .. } => {("Waiting for message to appear…".into(), false)}+ SubmissionState::Disconnected { receipt: Some(_) } => {+ ("Message accepted; agent connection lost".into(), true)+ }+ SubmissionState::Disconnected { receipt: None } => (+ "Connection lost; message acceptance is unknown".into(),+ true,+ ),SubmissionState::Failed(error) => (format!("Message failed to send: {}",@@ -1643,6 +1650,10 @@ impl ThreadView {submission_id,status,settled,+ matches!(+ record.state,+ SubmissionState::Failed(_) | SubmissionState::Cancelled+ ),Itertools::intersperse(Self::submission_text_parts(&record.content), "\n").flat_map(str::chars).take(161)@@ -1656,7 +1667,7 @@ impl ThreadView {}let rows = submissions.into_iter()- .map(|(submission_id, status, settled, text)| {+ .map(|(submission_id, status, settled, restorable, text)| {let preview: SharedString = util::truncate_and_trailoff(&text, 160).into();let row_id = submission_id.as_u64();v_flex()@@ -1690,7 +1701,7 @@ impl ThreadView {})),),)- .when(settled, |this| {+ .when(restorable, |this| {this.child(div().debug_selector(move || {@@ -1711,7 +1722,9 @@ impl ThreadView {)),),)- .child(+ })+ .when(settled, |this| {+ this.child(Button::new(("discard-submission", row_id), "Discard").label_size(LabelSize::Small).on_click(cx.listener(move |this, _, _, cx| {