@@ -1338,6 +1338,7 @@ pub mod coresdk {
13381338 retry_policy : r. retry_policy . map ( fix_retry_policy) ,
13391339 priority : r. priority ,
13401340 is_local : false ,
1341+ run_id : r. activity_run_id ,
13411342 } ,
13421343 ) ) ,
13431344 }
@@ -2931,9 +2932,52 @@ pub fn proto_ts_to_system_time(ts: &prost_types::Timestamp) -> Option<std::time:
29312932
29322933#[ cfg( test) ]
29332934mod tests {
2935+ use crate :: protos:: coresdk:: activity_task;
2936+ use crate :: protos:: coresdk:: activity_task:: ActivityTask ;
29342937 use crate :: protos:: temporal:: api:: failure:: v1:: Failure ;
2938+ use crate :: protos:: temporal:: api:: workflowservice:: v1:: PollActivityTaskQueueResponse ;
29352939 use anyhow:: anyhow;
29362940
2941+ #[ test]
2942+ fn start_from_poll_resp_standalone_activity_populates_run_id ( ) {
2943+ let resp = PollActivityTaskQueueResponse {
2944+ task_token : vec ! [ 1 , 2 , 3 ] ,
2945+ activity_run_id : "test-run-id-123" . to_string ( ) ,
2946+ activity_id : "my-activity" . to_string ( ) ,
2947+ ..Default :: default ( )
2948+ } ;
2949+ let task = ActivityTask :: start_from_poll_resp ( resp) ;
2950+ let start = match task. variant {
2951+ Some ( activity_task:: activity_task:: Variant :: Start ( s) ) => s,
2952+ _ => panic ! ( "expected Start variant" ) ,
2953+ } ;
2954+ assert_eq ! ( start. run_id, "test-run-id-123" ) ;
2955+ assert ! ( !start. is_local) ;
2956+ }
2957+
2958+ #[ test]
2959+ fn start_from_poll_resp_workflow_activity_has_empty_run_id ( ) {
2960+ use crate :: protos:: temporal:: api:: common:: v1:: WorkflowExecution ;
2961+ let resp = PollActivityTaskQueueResponse {
2962+ task_token : vec ! [ 4 , 5 , 6 ] ,
2963+ activity_id : "my-workflow-activity" . to_string ( ) ,
2964+ workflow_execution : Some ( WorkflowExecution {
2965+ workflow_id : "wf-123" . to_string ( ) ,
2966+ run_id : "wf-run-456" . to_string ( ) ,
2967+ } ) ,
2968+ // activity_run_id intentionally absent — this is a workflow-scheduled activity
2969+ ..Default :: default ( )
2970+ } ;
2971+ let task = ActivityTask :: start_from_poll_resp ( resp) ;
2972+ let start = match task. variant {
2973+ Some ( activity_task:: activity_task:: Variant :: Start ( s) ) => s,
2974+ _ => panic ! ( "expected Start variant" ) ,
2975+ } ;
2976+ assert ! ( start. run_id. is_empty( ) ) ;
2977+ // workflow_execution is preserved and distinct from run_id
2978+ assert_eq ! ( start. workflow_execution. unwrap( ) . run_id, "wf-run-456" ) ;
2979+ }
2980+
29372981 #[ test]
29382982 fn anyhow_to_failure_conversion ( ) {
29392983 let no_causes: Failure = anyhow ! ( "no causes" ) . into ( ) ;
0 commit comments