From 5d3ecb1399f2ec43370b25c7df9b204d552297b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 17:28:50 +0000 Subject: [PATCH] Add new comment types for WIP prefix changes - Added CommentTypeMarkedAsWorkInProgress and CommentTypeMarkedAsReadyForReview - Updated ChangeIssueTitle to detect WIP prefix changes - Added locale strings for the new messages - Updated template to render new comment types Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com> --- models/issues/comment.go | 5 +++++ models/issues/issue_update.go | 17 ++++++++++++++- options/locale/locale_en-US.json | 2 ++ .../repo/issue/view_content/comments.tmpl | 21 ++++++++++++++++++- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/models/issues/comment.go b/models/issues/comment.go index f15618bf50..0f7adbd87a 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -116,6 +116,9 @@ const ( CommentTypeUnpin // 37 unpin Issue/PullRequest CommentTypeChangeTimeEstimate // 38 Change time estimate + + CommentTypeMarkedAsWorkInProgress // 39 Mark PR as work in progress + CommentTypeMarkedAsReadyForReview // 40 Mark PR as ready for review ) var commentStrings = []string{ @@ -158,6 +161,8 @@ var commentStrings = []string{ "pin", "unpin", "change_time_estimate", + "marked_as_work_in_progress", + "marked_as_ready_for_review", } func (t CommentType) String() string { diff --git a/models/issues/issue_update.go b/models/issues/issue_update.go index 0a320ffc56..19f3d9fd8b 100644 --- a/models/issues/issue_update.go +++ b/models/issues/issue_update.go @@ -209,8 +209,23 @@ func ChangeIssueTitle(ctx context.Context, issue *Issue, doer *user_model.User, return fmt.Errorf("loadRepo: %w", err) } + // Determine the comment type based on WIP prefix changes for pull requests + commentType := CommentTypeChangeTitle + if issue.IsPull { + hadWIP := HasWorkInProgressPrefix(oldTitle) + hasWIP := HasWorkInProgressPrefix(issue.Title) + + if !hadWIP && hasWIP { + // WIP prefix was added + commentType = CommentTypeMarkedAsWorkInProgress + } else if hadWIP && !hasWIP { + // WIP prefix was removed + commentType = CommentTypeMarkedAsReadyForReview + } + } + opts := &CreateCommentOptions{ - Type: CommentTypeChangeTitle, + Type: commentType, Doer: doer, Repo: issue.Repo, Issue: issue, diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index 417698544f..5525ca0a5a 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -1447,6 +1447,8 @@ "repo.issues.remove_assignee_at": "was unassigned by %s %s", "repo.issues.remove_self_assignment": "removed their assignment %s", "repo.issues.change_title_at": "changed title from %s to %s %s", + "repo.issues.marked_as_work_in_progress": "marked the pull request as work in progress %s", + "repo.issues.marked_as_ready_for_review": "marked the pull request as ready for review %s", "repo.issues.change_ref_at": "changed reference from %s to %s %s", "repo.issues.remove_ref_at": "removed reference %s %s", "repo.issues.add_ref_at": "added reference %s %s", diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 0eeb10cba7..06e8efc318 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -13,7 +13,8 @@ 29 = PULL_PUSH_EVENT, 30 = PROJECT_CHANGED, 31 = PROJECT_BOARD_CHANGED 32 = DISMISSED_REVIEW, 33 = COMMENT_TYPE_CHANGE_ISSUE_REF, 34 = PR_SCHEDULE_TO_AUTO_MERGE, 35 = CANCEL_SCHEDULED_AUTO_MERGE_PR, 36 = PIN_ISSUE, 37 = UNPIN_ISSUE, - 38 = COMMENT_TYPE_CHANGE_TIME_ESTIMATE --> + 38 = COMMENT_TYPE_CHANGE_TIME_ESTIMATE, 39 = MARKED_AS_WORK_IN_PROGRESS, + 40 = MARKED_AS_READY_FOR_REVIEW --> {{if eq .Type 0}}
{{if .OriginalAuthor}} @@ -692,6 +693,24 @@ {{end}}
+ {{else if eq .Type 39}} +
+ {{svg "octicon-x-circle"}} + {{template "shared/user/avatarlink" dict "user" .Poster}} + + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.marked_as_work_in_progress" $createdStr}} + +
+ {{else if eq .Type 40}} +
+ {{svg "octicon-check-circle"}} + {{template "shared/user/avatarlink" dict "user" .Poster}} + + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.marked_as_ready_for_review" $createdStr}} + +
{{end}} {{end}} {{end}}