Skip to content

Conversation

vedansh-5
Copy link
Member

@vedansh-5 vedansh-5 commented Jul 29, 2025

Adding commits in draft PRs
Fixes #213

Summary by Sourcery

Enable viewing commit details for draft PRs alongside open PRs when the showCommits option is enabled.

New Features:

  • Render commit lists under existing draft PRs when authenticated and the showCommits toggle is active.

Enhancements:

  • Update the showCommits checkbox label to reference both open and draft PRs.

Chores:

  • Remove outdated comment about filtering existing PRs by commit date range.

Signed-off-by: Vedansh Saini <[email protected]>
Copy link
Contributor

sourcery-ai bot commented Jul 29, 2025

Reviewer's Guide

This PR enables displaying commit details for existing draft pull requests under the “Show commits” toggle by injecting a nested commits list, updates the UI label and all translations to reflect that drafts are included, and removes an obsolete comment from the PR date-range logic.

Sequence diagram for displaying commits in draft PRs

sequenceDiagram
    actor User
    participant UI
    participant scrumHelper
    participant GitHubAPI
    User->>UI: Toggle 'Show commits' option
    UI->>scrumHelper: Request PR list with commits
    scrumHelper->>GitHubAPI: Fetch PRs and their commits
    GitHubAPI-->>scrumHelper: Return PRs (open and draft) with commits
    scrumHelper-->>UI: Render PR list
    UI-->>User: Display PRs with nested commits for open and draft PRs
Loading

File-Level Changes

Change Details Files
Render commit details for existing draft PRs
  • Add conditional block in draft PR branch to check showCommits, existing commits array, and token
  • Log debug information when rendering draft PR commits
  • Generate nested
      list of commit headlines and timestamps inside the PR list item
src/scripts/scrumHelper.js
Update commit display toggle label and translations
  • Change label text to “Show commits on open PRs/ draft PRs”
  • Refresh localized messages in all locale files to include draft PRs in tooltip and label
src/popup.html
src/_locales/*/messages.json
Remove obsolete comment from PR filtering logic
  • Delete outdated comment about date-range filtering for existing PRs
src/scripts/scrumHelper.js

Assessment against linked issues

Issue Objective Addressed Explanation
#213 Enable viewing new commits for draft pull requests, similar to open pull requests.
#213 Provide a toggle (e.g., a checkbox) to enable or disable the display of commits for draft pull requests.
#213 Update UI labels and documentation (including translations) to reflect that commit viewing applies to both open and draft PRs.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Signed-off-by: Vedansh Saini <[email protected]>
@github-actions github-actions bot added javascript Pull requests that update javascript code core labels Jul 30, 2025
@vedansh-5
Copy link
Member Author

image Now the commits are being shown in the draft PRs.

@vedansh-5 vedansh-5 marked this pull request as ready for review July 30, 2025 03:49
@vedansh-5 vedansh-5 requested a review from Preeti9764 July 30, 2025 03:50
@vedansh-5 vedansh-5 self-assigned this Jul 30, 2025
@vedansh-5 vedansh-5 requested a review from hpdang July 30, 2025 03:50
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vedansh-5 - I've reviewed your changes and found some issues that need to be addressed.

  • Rendering commit items as direct
  • children of another
  • breaks HTML semantics—consider wrapping them in a nested
      or similar container inside the parent list item.
    • The inline style attributes on each commit entry could be replaced with CSS classes for better maintainability and theming.
    • Rather than unconditionally calling log(), guard the debug logging behind a log level check or remove it in production to avoid console noise.
    Prompt for AI Agents
    Please address the comments from this code review:
    ## Overall Comments
    - Rendering commit items as direct <li> children of another <li> breaks HTML semantics—consider wrapping them in a nested <ul> or similar container inside the parent list item.
    - The inline style attributes on each commit entry could be replaced with CSS classes for better maintainability and theming.
    - Rather than unconditionally calling log(), guard the debug logging behind a log level check or remove it in production to avoid console noise.

    Sourcery is free for open source - if you like our reviews please consider sharing them ✨
    Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vedansh-5
Copy link
Member Author

@hpdang Ready for review, thankyou.

@hpdang
Copy link
Member

hpdang commented Jul 30, 2025

LGTM! @Saksham-Sirohi could you please test this if it works for you?

@Preeti9764 please review

@Saksham-Sirohi
Copy link
Contributor

@hpdang tested works!

@vedansh-5 vedansh-5 marked this pull request as draft July 30, 2025 07:18
@Saksham-Sirohi
Copy link
Contributor

Can the commits be more indented next to an open pr? This feels like very little indentation for commits inside

@vedansh-5
Copy link
Member Author

vedansh-5 commented Jul 30, 2025

image @Saksham-Sirohi I have added more indent for commits on drafts

Signed-off-by: Vedansh Saini <[email protected]>
@vedansh-5 vedansh-5 marked this pull request as ready for review July 30, 2025 07:24
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vedansh-5 - I've reviewed your changes - here's some feedback:

  • Extract the commit-list markup into a helper (or use Array.map + join) to simplify string concatenation and improve readability.
  • Replace inline styles on the commit list items with CSS classes in your stylesheet for better maintainability.
  • Remove or guard the debug console.log to avoid polluting production logs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract the commit-list markup into a helper (or use Array.map + join) to simplify string concatenation and improve readability.
- Replace inline styles on the commit list items with CSS classes in your stylesheet for better maintainability.
- Remove or guard the debug console.log to avoid polluting production logs.

## Individual Comments

### Comment 1
<location> `src/scripts/scrumHelper.js:1281` </location>
<code_context>
-                    li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_draft_button : ''}</li>`;
+                    li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_draft_button : ''}`;
+                    if (showCommits && item._allCommits && item._allCommits.length && !isNewPR) {
+                        log(`[PR DEBUG] Rendering commits for existing draft PR #${number}:`, item._allCommits);
+                        li += '<ul>';
+                        item._allCommits.forEach(commit => {
</code_context>

<issue_to_address>
Debug logging is present in production code.

Debug logs in production can clutter output and expose sensitive data. Remove this log or restrict it to debug mode if not essential for users.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
                        log(`[PR DEBUG] Rendering commits for existing draft PR #${number}:`, item._allCommits);
                        li += '<ul>';
=======
                        li += '<ul>';
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Preeti9764
Copy link
Contributor

@vedansh-5 The preview report is not getting generated without the token .Please check .Thanks!
image

@Saksham-Sirohi
Copy link
Contributor

@vedansh-5, the draft commits now have good indentation also, I am seeing the same problem as @Preeti9764, without github token, I receive error 422

@vedansh-5 vedansh-5 marked this pull request as draft July 30, 2025 19:18
@vedansh-5
Copy link
Member Author

works properly now!

@vedansh-5, the draft commits now have good indentation also, I am seeing the same problem as @Preeti9764, without github token, I receive error 422

Signed-off-by: Vedansh Saini <[email protected]>
Signed-off-by: Vedansh Saini <[email protected]>
@vedansh-5 vedansh-5 marked this pull request as ready for review July 30, 2025 19:30
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vedansh-5 - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/scripts/scrumHelper.js:1281` </location>
<code_context>
-                    li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_draft_button : ''}</li>`;
+                    li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_draft_button : ''}`;
+                    if (showCommits && item._allCommits && item._allCommits.length && !isNewPR && githubToken) {
+                        log(`[PR DEBUG] Rendering commits for existing draft PR #${number}:`, item._allCommits);
+                        li += '<ul>';
+                        item._allCommits.forEach(commit => {
</code_context>

<issue_to_address>
Debug logging is present in production code.

Debug logs in production can clutter output and expose sensitive data. Please remove or conditionally enable this log with a debug flag.

Suggested implementation:

```javascript
                    if (showCommits && item._allCommits && item._allCommits.length && !isNewPR && githubToken) {
                        if (typeof DEBUG !== 'undefined' && DEBUG) {
                            log(`[PR DEBUG] Rendering commits for existing draft PR #${number}:`, item._allCommits);
                        }
                        li += '<ul>';
                        item._allCommits.forEach(commit => {

```

If a `DEBUG` flag is not already defined in your codebase, you should define it at the top of your script or in your configuration. For example:
```js
const DEBUG = false; // Set to true to enable debug logging
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@hpdang
Copy link
Member

hpdang commented Jul 31, 2025

@Preeti9764 please review this again

@Preeti9764
Copy link
Contributor

The closed is visible in red it should be in purple as in master branch .Please correct that !Thanks.
Screenshot 2025-07-31 230326
for master branch
image

@vedansh-5
Copy link
Member Author

The closed is visible in red it should be in purple as in master branch .Please correct that !Thanks.

Were these changes made in the last merged PR by you? If so, this would be fine in master because there are no conflicts and this would not affect the master branch's behavior. Thankyou!

@vedansh-5
Copy link
Member Author

The closed is visible in red it should be in purple as in master branch .Please correct that !Thanks.

Were these changes made in the last merged PR by you? If so, this would be fine in master because there are no conflicts and this would not affect the master branch's behavior. Thankyou!

Edit - I did not touch any code concerning the labels.

@hpdang hpdang merged commit f98cbc1 into fossasia:master Aug 1, 2025
2 checks passed
@vedansh-5 vedansh-5 deleted the draftCommits branch August 1, 2025 13:22
@vedansh-5 vedansh-5 changed the title commits in draft PRs Minor: commits in draft PRs Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core extension frontend javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Track commits in draft pull requests

4 participants