Skip to content

Commit 79194cc

Browse files
author
xlx1212
committed
fix(loopx): expose publication outcome and align stop copy
1 parent 97005d0 commit 79194cc

3 files changed

Lines changed: 72 additions & 6 deletions

File tree

‎src/crates/contracts/product-domains/src/miniapp/builtin/assets/bitfun-loopx/ui.js‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ const COPY = {
173173
summaryWontFixReasonInvalid: '无需处理(无可执行请求)',
174174
summaryWontFixReasonEvaluationPending: '评估中,暂不处理',
175175
state_completed_needs_fix: '已处理,待发布',
176-
state_completed_needs_fix_no_release: '已处理,未发布',
176+
state_completed_needs_fix_no_release: '已处理,未创建 PR',
177+
state_completed_automation_stopped: '自动修复已停止',
178+
state_completed_pr_created: '已处理,PR 已创建',
177179
summaryShowFullConclusion: '展开完整结论',
178180
summaryBackground: '背景',
179181
summarySectionCompleted: '已完成',
@@ -185,7 +187,7 @@ const COPY = {
185187
taskLabelsMore: '+{value}',
186188
summaryMissingInfo: '判断所需信息',
187189
summaryCompletedTitlePlain: '处理结果',
188-
summaryCompletedNoFollowup: '处理已完成,系统不再自动跟进;如需继续,请使用「重新尝试」提交新任务。',
190+
summaryCompletedNoFollowup: '处理已完成,系统不再自动跟进。',
189191
issueDescriptionEmpty: '(该 Issue 没有正文描述)',
190192
summarySegmentEvidence: '调查取证',
191193
summarySegmentRouteDecision: '方案决策',
@@ -649,7 +651,9 @@ const COPY = {
649651
summaryWontFixReasonInvalid: 'No action needed (nothing actionable)',
650652
summaryWontFixReasonEvaluationPending: 'Under evaluation',
651653
state_completed_needs_fix: 'Handled, pending release',
652-
state_completed_needs_fix_no_release: 'Handled, not published',
654+
state_completed_needs_fix_no_release: 'Handled, no PR created',
655+
state_completed_automation_stopped: 'Automation stopped',
656+
state_completed_pr_created: 'Handled, PR created',
653657
summaryShowFullConclusion: 'Show full conclusion',
654658
summaryBackground: 'Background',
655659
summarySectionCompleted: 'Completed',
@@ -661,7 +665,7 @@ const COPY = {
661665
taskLabelsMore: '+{value}',
662666
summaryMissingInfo: 'Information needed to decide',
663667
summaryCompletedTitlePlain: 'Outcome',
664-
summaryCompletedNoFollowup: 'Handling is complete; automation stops here. Use the new-attempt action if you want to continue.',
668+
summaryCompletedNoFollowup: 'Handling is complete; automation stops here.',
665669
issueDescriptionEmpty: '(This issue has no body text.)',
666670
summarySegmentEvidence: 'Evidence',
667671
summarySegmentRouteDecision: 'Route decision',
@@ -2440,8 +2444,16 @@ function completionLabel(task) {
24402444
if (verdict === 'already_fixed_upstream') return summaryEnumLabel('summaryVerdict', 'already_fixed_upstream');
24412445
if (verdict === 'needs_info') return summaryEnumLabel('summaryVerdict', 'needs_info');
24422446
if (verdict === 'needs_fix') {
2443-
if (taskHasProducedPullRequest(task)) return text('resolvedItem');
24442447
if (task.pendingGateId) return text('state_completed_needs_fix');
2448+
const publicationState = String(structured.publication_state || '');
2449+
const automationOutcome = String(structured.automation_outcome || '');
2450+
const producedPullRequest = taskHasProducedPullRequest(task);
2451+
if (publicationState === 'created' || producedPullRequest) {
2452+
return producedPullRequest ? text('state_completed_pr_created') : text('resolvedItem');
2453+
}
2454+
if (automationOutcome === 'stopped_without_pr') {
2455+
return text('state_completed_automation_stopped');
2456+
}
24452457
return text('state_completed_needs_fix_no_release');
24462458
}
24472459
return '';
@@ -2457,7 +2469,10 @@ function completionTone(task) {
24572469
}
24582470
if (verdict === 'needs_info') return 'info';
24592471
if (verdict === 'already_fixed_upstream') return 'success';
2460-
if (verdict === 'needs_fix') return taskHasProducedPullRequest(task) ? 'success' : 'muted';
2472+
if (verdict === 'needs_fix') {
2473+
const publicationState = String(structured.publication_state || '');
2474+
return publicationState === 'created' && taskHasProducedPullRequest(task) ? 'success' : 'muted';
2475+
}
24612476
return '';
24622477
}
24632478

‎src/crates/contracts/product-domains/src/miniapp/loopx/policy.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,33 @@ fn inject_summary_artifact_roles(value: &mut serde_json::Value) {
730730
}));
731731
}
732732

733+
let publication_state = if produced.is_empty() {
734+
"not_requested"
735+
} else {
736+
"created"
737+
};
738+
let verdict = object
739+
.get("issue_verdict")
740+
.and_then(|value| value.as_str())
741+
.unwrap_or("");
742+
let automation_outcome = if !produced.is_empty() {
743+
"created"
744+
} else if creation_is_negative {
745+
"stopped_without_pr"
746+
} else if matches!(verdict, "wont_fix" | "already_fixed_upstream") {
747+
"closed_without_artifact"
748+
} else {
749+
"completed_without_artifact"
750+
};
751+
752+
object.insert(
753+
"publication_state".to_string(),
754+
serde_json::Value::String(publication_state.to_string()),
755+
);
756+
object.insert(
757+
"automation_outcome".to_string(),
758+
serde_json::Value::String(automation_outcome.to_string()),
759+
);
733760
object.insert(
734761
"artifact_events".to_string(),
735762
serde_json::Value::Array(artifact_events),

‎src/crates/contracts/product-domains/tests/loopx_contracts.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,18 @@ fn structured_summary_keeps_referenced_closed_pull_requests_out_of_produced_arti
748748
.filter_map(|value| value.as_str())
749749
.collect::<Vec<_>>();
750750
assert!(referenced_urls.contains(&"https://github.com/xielixing/dynamic-workflows-lab/pull/4"));
751+
assert_eq!(
752+
parsed
753+
.get("publication_state")
754+
.and_then(|value| value.as_str()),
755+
Some("not_requested")
756+
);
757+
assert_eq!(
758+
parsed
759+
.get("automation_outcome")
760+
.and_then(|value| value.as_str()),
761+
Some("stopped_without_pr")
762+
);
751763
let events = parsed
752764
.get("artifact_events")
753765
.and_then(|value| value.as_array())
@@ -790,6 +802,18 @@ fn structured_summary_marks_a_created_pull_request_as_produced() {
790802
produced_urls,
791803
vec!["https://github.com/xielixing/dynamic-workflows-lab/pull/9"]
792804
);
805+
assert_eq!(
806+
parsed
807+
.get("publication_state")
808+
.and_then(|value| value.as_str()),
809+
Some("created")
810+
);
811+
assert_eq!(
812+
parsed
813+
.get("automation_outcome")
814+
.and_then(|value| value.as_str()),
815+
Some("created")
816+
);
793817
let events = parsed
794818
.get("artifact_events")
795819
.and_then(|value| value.as_array())

0 commit comments

Comments
 (0)