From 9d177d464ddb692d3ba8be37f7313735250c4374 Mon Sep 17 00:00:00 2001 From: adam lazur Date: Sat, 21 Feb 2026 14:11:08 +0900 Subject: [PATCH] fix(github): remove duplicate PR titles in stack comments GitHub automatically expands #123 references to include the PR title with rich previews (hover cards, status badges, etc.). Previously, ryu was explicitly including both the PR title AND #N, resulting in duplicate titles appearing in comments. Changes: - Updated GitHub formatting to only show "#N" instead of "title #N" - GitHub's auto-expansion will show the title once with rich previews - Updated tests to verify PR titles are not in the markdown source - Renamed test to clarify it checks for no duplicate title This is a breaking change in comment format, but it's a bug fix - the old behavior caused duplication. GitLab formatting is unaffected. Co-Authored-By: Claude Opus 4.6 --- src/submit/execute.rs | 10 ++++++---- tests/unit_tests.rs | 10 +++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/submit/execute.rs b/src/submit/execute.rs index 5ed2787..063b5dd 100644 --- a/src/submit/execute.rs +++ b/src/submit/execute.rs @@ -405,15 +405,15 @@ fn format_stack_comment_for_platform( let is_current = i == reversed_idx; match platform { Platform::GitHub => { - // GitHub: "* PR title #N" - #N auto-links to PRs + // GitHub: "* #N" - GitHub auto-expands to show title with rich previews if is_current { let _ = writeln!( body, - "* **{} #{} {STACK_COMMENT_THIS_PR}**", - item.pr_title, item.pr_number + "* **#{} {STACK_COMMENT_THIS_PR}**", + item.pr_number ); } else { - let _ = writeln!(body, "* {} #{}", item.pr_title, item.pr_number); + let _ = writeln!(body, "* #{}", item.pr_number); } } Platform::GitLab => { @@ -801,6 +801,8 @@ mod tests { !body.contains("](https://github.com/test/test/pull"), "GitHub should NOT have markdown links to PRs: {body}" ); + // Title should NOT be in the output - GitHub will auto-expand it + assert!(!body.contains("feat: add auth"), "GitHub auto-expands, so title should not be in source: {body}"); } // === Plan helper tests === diff --git a/tests/unit_tests.rs b/tests/unit_tests.rs index baddca6..3692623 100644 --- a/tests/unit_tests.rs +++ b/tests/unit_tests.rs @@ -724,7 +724,8 @@ mod stack_comment_test { } #[test] - fn test_format_body_contains_pr_title() { + fn test_format_body_github_no_duplicate_title() { + // GitHub format should NOT contain PR title since GitHub auto-expands #N references let data = StackCommentData { version: 1, stack: vec![make_stack_item("feat-a", 1)], @@ -733,9 +734,12 @@ mod stack_comment_test { let body = format_stack_comment(&data, 0).unwrap(); + // Should contain the PR number reference + assert!(body.contains("#1"), "body should contain #1: {body}"); + // Should NOT contain the PR title (GitHub will auto-expand it) assert!( - body.contains("feat: feat-a"), - "body should contain PR title: {body}" + !body.contains("feat: feat-a"), + "body should NOT contain PR title (GitHub auto-expands): {body}" ); } }