MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / spawn_draft_reject

Function spawn_draft_reject

crates/openshell-tui/src/lib.rs:1805–1843  ·  view source on GitHub ↗

Reject the currently selected draft chunk.

(app: &App, tx: mpsc::UnboundedSender<Event>)

Source from the content-addressed store, hash-verified

1803
1804/// Reject the currently selected draft chunk.
1805fn spawn_draft_reject(app: &App, tx: mpsc::UnboundedSender<Event>) {
1806 let mut client = app.client.clone();
1807 let name = match app.selected_sandbox_name() {
1808 Some(n) => n.to_string(),
1809 None => return,
1810 };
1811 let abs = app.draft_scroll + app.draft_selected;
1812 let chunk_id = match app.draft_chunks.get(abs) {
1813 Some(c) => c.id.clone(),
1814 None => return,
1815 };
1816 let rule_name = app
1817 .draft_chunks
1818 .get(abs)
1819 .map_or_else(String::new, |c| c.rule_name.clone());
1820
1821 tokio::spawn(async move {
1822 let req = openshell_core::proto::RejectDraftChunkRequest {
1823 name,
1824 chunk_id,
1825 reason: String::new(),
1826 };
1827 match tokio::time::timeout(Duration::from_secs(5), client.reject_draft_chunk(req)).await {
1828 Ok(Ok(_)) => {
1829 let _ = tx.send(Event::DraftActionResult(Ok(format!(
1830 "Rejected '{rule_name}'"
1831 ))));
1832 }
1833 Ok(Err(e)) => {
1834 let _ = tx.send(Event::DraftActionResult(Err(e.message().to_string())));
1835 }
1836 Err(_) => {
1837 let _ = tx.send(Event::DraftActionResult(
1838 Err("reject timed out".to_string()),
1839 ));
1840 }
1841 }
1842 });
1843}
1844
1845/// Approve all pending draft chunks via the bulk `ApproveAllDraftChunks` RPC.
1846///

Callers 1

runFunction · 0.85

Calls 5

selected_sandbox_nameMethod · 0.80
messageMethod · 0.80
spawnFunction · 0.50
getMethod · 0.45
reject_draft_chunkMethod · 0.45

Tested by

no test coverage detected