@@ -369,12 +369,6 @@ fn format_search_results(
369369 if !desc. is_empty ( ) {
370370 out. push_str ( & format ! ( " Description: {desc}\n " ) ) ;
371371 }
372- if patch. requires_opt_in == Some ( true ) {
373- if let Some ( note) = & patch. opt_in_note {
374- let note = crate :: ui:: terminal_text ( note) . replace ( '\n' , "\n " ) ;
375- out. push_str ( & format ! ( " Opt-in required: {note}\n " ) ) ;
376- }
377- }
378372 let mut fixes: Vec < ( String , String ) > = patch
379373 . vulnerabilities
380374 . iter ( )
@@ -1292,15 +1286,6 @@ pub async fn run(args: GetArgs) -> i32 {
12921286 crate :: ui:: stderr_color( ) ,
12931287 )
12941288 ) ;
1295- if patch. requires_opt_in == Some ( true ) {
1296- if let Some ( note) = & patch. opt_in_note {
1297- let note = crate :: ui:: terminal_text ( note) . replace ( '\n' , "\n " ) ;
1298- println ! (
1299- "Opt-in required for {}: {note}" ,
1300- crate :: ui:: terminal_purl( & patch. purl)
1301- ) ;
1302- }
1303- }
13041289 }
13051290
13061291 // Record the fetch BEFORE the save+apply step so the
@@ -1349,7 +1334,7 @@ pub async fn run(args: GetArgs) -> i32 {
13491334 // re-fetching with a fresh one, which would re-hit the
13501335 // 401/403 the fallback just recovered from. An explicit
13511336 // UUID is exempt from installed narrowing (exact intent).
1352- return match mode {
1337+ let code = match mode {
13531338 // Save to manifest and apply in place.
13541339 super :: scan:: ScanMode :: Agent => {
13551340 save_and_apply_patch ( & args, & api_client, & patch, & uuid_warnings) . await
@@ -1371,6 +1356,14 @@ pub async fn run(args: GetArgs) -> i32 {
13711356 . await
13721357 }
13731358 } ;
1359+ if !quiet {
1360+ if let Some ( notes) =
1361+ crate :: ui:: opt_in_note_block ( [ crate :: ui:: OptInEntry :: from_response ( & patch) ] )
1362+ {
1363+ println ! ( "\n {notes}" ) ;
1364+ }
1365+ }
1366+ return code;
13741367 }
13751368 // The public proxy answers a paid patch with 403 rather than
13761369 // a tier=paid view: the same outcome as the branch above, not
@@ -1812,11 +1805,7 @@ pub async fn run(args: GetArgs) -> i32 {
18121805 }
18131806
18141807 // Download and apply (agent mode), with the run's client and flags.
1815- let mut params = get_download_params ( & args, args. save_only , /*persist_blobs=*/ true ) ;
1816- params. opt_in_notes_shown = selected
1817- . iter ( )
1818- . map ( crate :: ui:: ShownOptIn :: from_search)
1819- . collect ( ) ;
1808+ let params = get_download_params ( & args, args. save_only , /*persist_blobs=*/ true ) ;
18201809 let run = DownloadRun {
18211810 api_client : & api_client,
18221811 lock_timeout : args. common . lock_timeout ,
@@ -2285,7 +2274,7 @@ fn get_download_params(args: &GetArgs, save_only: bool, persist_blobs: bool) ->
22852274 ecosystems : args. common . ecosystems . clone ( ) ,
22862275 persist_blobs,
22872276 patch_server_url : args. common . patch_server_url . clone ( ) ,
2288- opt_in_notes_shown : Vec :: new ( ) ,
2277+ offline : args . common . offline ,
22892278 }
22902279}
22912280
@@ -2319,7 +2308,7 @@ async fn run_get_hosted(
23192308 // default-off VexEmbedArgs — deliberately NOT env-bound here, so an
23202309 // ambient SOCKET_VEX only affects commands that declare the flag.
23212310 let vex = crate :: commands:: vex:: VexEmbedArgs :: default ( ) ;
2322- super :: scan:: boxed_run_redirect_selected (
2311+ let code = super :: scan:: boxed_run_redirect_selected (
23232312 & args. common ,
23242313 & vex,
23252314 /*prune_requested=*/ false ,
@@ -2331,7 +2320,15 @@ async fn run_get_hosted(
23312320 None ,
23322321 "get" ,
23332322 )
2334- . await
2323+ . await ;
2324+ if !args. common . json && !args. common . silent {
2325+ if let Some ( notes) =
2326+ crate :: ui:: opt_in_note_block ( selected. iter ( ) . map ( crate :: ui:: OptInEntry :: from_search) )
2327+ {
2328+ println ! ( "\n {notes}" ) ;
2329+ }
2330+ }
2331+ code
23352332}
23362333
23372334/// `get … --mode vendored`, both identifier paths: scan's vendored posture
@@ -2462,7 +2459,7 @@ async fn run_get_vendored(
24622459 // records fetched above (moved in — nothing here needs them afterwards)
24632460 // and over this run's client, then the run's telemetry. A per-patch
24642461 // download failure does not skip it (scan parity).
2465- match super :: scan:: boxed_vendor_step ( super :: scan:: VendorStep {
2462+ let code = match super :: scan:: boxed_vendor_step ( super :: scan:: VendorStep {
24662463 common : & args. common ,
24672464 records,
24682465 client : api_client. clone ( ) ,
@@ -2503,7 +2500,13 @@ async fn run_get_vendored(
25032500 }
25042501 1
25052502 }
2503+ } ;
2504+ if !args. common . json && !args. common . silent {
2505+ if let Some ( notes) = env. opt_in_note_block ( ) {
2506+ println ! ( "\n {notes}" ) ;
2507+ }
25062508 }
2509+ code
25072510}
25082511
25092512#[ cfg( test) ]
@@ -4090,7 +4093,7 @@ mod tests {
40904093 ecosystems : None ,
40914094 persist_blobs : false ,
40924095 patch_server_url : None ,
4093- opt_in_notes_shown : Vec :: new ( ) ,
4096+ offline : false ,
40944097 }
40954098 }
40964099
@@ -4791,7 +4794,7 @@ mod tests {
47914794 // The vendor-detached posture this fn exists for.
47924795 persist_blobs : false ,
47934796 patch_server_url : None ,
4794- opt_in_notes_shown : Vec :: new ( ) ,
4797+ offline : false ,
47954798 }
47964799 }
47974800
@@ -5540,6 +5543,8 @@ mod tests {
55405543 "description" : "embedded" ,
55415544 "license" : "MIT" ,
55425545 "tier" : "free" ,
5546+ "requiresOptIn" : true ,
5547+ "optInNote" : "Keep the embedded instruction offline" ,
55435548 }
55445549 } }
55455550 } ) )
@@ -5551,6 +5556,7 @@ mod tests {
55515556 let mut params = detached_params ( tmp. path ( ) ) ;
55525557 params. json = false ;
55535558 params. silent = false ;
5559+ params. offline = true ;
55545560 let ( code, json, records) = download_patch_records ( & selected, & params, & server. uri ( ) ) . await ;
55555561
55565562 assert_eq ! ( code, 0 , "json={json}" ) ;
@@ -5562,6 +5568,11 @@ mod tests {
55625568 Some ( uuid) ,
55635569 "the ledger's embedded record must be reused"
55645570 ) ;
5571+ assert_eq ! ( records[ purl] . requires_opt_in, Some ( true ) ) ;
5572+ assert_eq ! (
5573+ records[ purl] . opt_in_note. as_deref( ) ,
5574+ Some ( "Keep the embedded instruction offline" )
5575+ ) ;
55655576 assert ! (
55665577 server
55675578 . received_requests( )
@@ -6159,16 +6170,22 @@ mod tests {
61596170 )
61606171 . mount ( & server)
61616172 . await ;
6162- // `d` is held in memory and `e` is reused from the ledger: never
6163- // requested .
6164- for u in [ & d, & e ] {
6173+ // `d` is held in memory. `e` is reused from the ledger, but its view
6174+ // still supplies current activation metadata without a download event .
6175+ for u in [ & d] {
61656176 Mock :: given ( method ( "GET" ) )
61666177 . and ( wm_path ( format ! ( "/v0/orgs/test-org/patches/view/{u}" ) ) )
61676178 . respond_with ( ResponseTemplate :: new ( 500 ) )
61686179 . expect ( 0 )
61696180 . mount ( & server)
61706181 . await ;
61716182 }
6183+ mount (
6184+ & e,
6185+ ResponseTemplate :: new ( 200 ) . set_body_json ( view ( & e, & purl ( "e" ) ) ) ,
6186+ )
6187+ . mount ( & server)
6188+ . await ;
61726189 mount (
61736190 & f,
61746191 ResponseTemplate :: new ( 200 ) . set_body_json ( view ( & f, & purl ( "f" ) ) ) ,
@@ -6252,8 +6269,8 @@ mod tests {
62526269 row( "b" , "failed" , "could not fetch details" ) ,
62536270 row( "c" , "failed" , "API request failed with status 500: boom" ) ,
62546271 row( "d" , "downloaded" , "" ) ,
6255- // e: the ledger already holds it at this uuid — reused, no
6256- // fetch and no event ( the vendor engine reports it) .
6272+ // e: its view refreshes activation metadata; the vendor engine
6273+ // reports the reuse, so the download phase still has no event .
62576274 row( "f" , "downloaded" , "" ) ,
62586275 ] ,
62596276 "json={json}"
0 commit comments