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

Function spawn_draft_approve_all

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

Approve all pending draft chunks via the bulk `ApproveAllDraftChunks` RPC. Uses the server-side bulk endpoint which respects the `security_notes` safety gate — security-flagged chunks are skipped unless explicitly included. The `snapshot` parameter is retained for the confirmation modal count display but is not iterated for per-chunk approval.

(
    app: &App,
    _snapshot: Vec<openshell_core::proto::PolicyChunk>,
    tx: mpsc::UnboundedSender<Event>,
)

Source from the content-addressed store, hash-verified

1849/// included. The `snapshot` parameter is retained for the confirmation
1850/// modal count display but is not iterated for per-chunk approval.
1851fn spawn_draft_approve_all(
1852 app: &App,
1853 _snapshot: Vec<openshell_core::proto::PolicyChunk>,
1854 tx: mpsc::UnboundedSender<Event>,
1855) {
1856 let mut client = app.client.clone();
1857 let name = match app.selected_sandbox_name() {
1858 Some(n) => n.to_string(),
1859 None => return,
1860 };
1861
1862 tokio::spawn(async move {
1863 let req = openshell_core::proto::ApproveAllDraftChunksRequest {
1864 name,
1865 include_security_flagged: false,
1866 };
1867 match tokio::time::timeout(
1868 Duration::from_secs(30),
1869 client.approve_all_draft_chunks(req),
1870 )
1871 .await
1872 {
1873 Ok(Ok(resp)) => {
1874 let inner = resp.into_inner();
1875 let msg = if inner.chunks_skipped > 0 {
1876 format!(
1877 "Approved {} chunks, skipped {} security-flagged -> policy v{}",
1878 inner.chunks_approved, inner.chunks_skipped, inner.policy_version
1879 )
1880 } else {
1881 format!(
1882 "Approved {} chunks -> policy v{}",
1883 inner.chunks_approved, inner.policy_version
1884 )
1885 };
1886 let _ = tx.send(Event::DraftActionResult(Ok(msg)));
1887 }
1888 Ok(Err(e)) => {
1889 let _ = tx.send(Event::DraftActionResult(Err(e.message().to_string())));
1890 }
1891 Err(_) => {
1892 let _ = tx.send(Event::DraftActionResult(Err(
1893 "approve-all timed out".to_string()
1894 )));
1895 }
1896 }
1897 });
1898}
1899
1900// ---------------------------------------------------------------------------
1901// Data refresh

Callers 1

runFunction · 0.85

Calls 4

selected_sandbox_nameMethod · 0.80
messageMethod · 0.80
spawnFunction · 0.50

Tested by

no test coverage detected