Skip to content

Fix: Show message when user have no activity for selected days#390

Open
Mateeb-Haider wants to merge 9 commits intofossasia:mainfrom
Mateeb-Haider:fix/error-handling
Open

Fix: Show message when user have no activity for selected days#390
Mateeb-Haider wants to merge 9 commits intofossasia:mainfrom
Mateeb-Haider:fix/error-handling

Conversation

@Mateeb-Haider
Copy link
Contributor

@Mateeb-Haider Mateeb-Haider commented Feb 22, 2026

📌 Fixes

Fixes #311


📝 Summary of Changes

  • Added a fallback message in the report output when there is no activity in the selected day/range.
  • Prevented empty report sections by showing a meaningful contribution status instead of an empty list.
  • Kept behavior consistent across popup and email report generation paths.

📸 Screenshots / Demo (if UI-related)

Before
image

After
image


✅ Checklist

  • I’ve tested my changes locally
  • My code follows the project’s code style guidelines

👀 Reviewer Notes

Please verify:

  • No-activity days now render a meaningful message instead of an empty report section.
  • Existing report output remains unchanged when activity exists.

Summary by Sourcery

Show a meaningful fallback message in scrum reports when no activity exists for the selected period and reuse this behavior across email and popup outputs.

Bug Fixes:

  • Display a clear no-contributions message instead of empty report sections when there is no activity in the selected date range.

Enhancements:

  • Introduce a shared helper to build the activity list HTML so email and popup reports use the same no-activity behavior.

Copilot AI review requested due to automatic review settings February 22, 2026 16:20
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 22, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors scrum report generation to centralize building of the "last week" activity list and adds a fallback message when there is no activity in the selected period, ensuring both popup and email reports display a meaningful status instead of an empty list.

Flow diagram for centralized activity list HTML generation

flowchart TD
  A[allIncluded called
outputTarget email or popup] --> B[Process data to populate
lastWeekArray and reviewedPrsArray]
  B --> C{Subject_for_email?}
  C -- yes --> D[Call buildActivityListHtml
for email lastWeekUl]
  C -- no --> E[writeScrumBody for popup]

  E --> F[Call buildActivityListHtml
for popup lastWeekUl]

  subgraph Activity_List_Builder
    G[buildActivityListHtml]
    G --> H{lastWeekArray.length == 0
AND reviewedPrsArray.length == 0}
    H -- yes --> I[Return '<ul><li>No contributions found for selected period.</li></ul>']
    H -- no --> J[Initialize activityList = '<ul>']
    J --> K[Append items from lastWeekArray]
    K --> L[Append items from reviewedPrsArray]
    L --> M[Close list '</ul>' and return activityList]
  end

  D --> N[Compose email body with lastWeekUl]
  F --> O[Compose popup body with lastWeekUl]

  N --> P[User views email report]
  O --> Q[User views popup report]
Loading

File-Level Changes

Change Details Files
Centralized construction of the last-week activity HTML and added a no-activity fallback message used by both email and popup scrum report generation paths.
  • Introduced buildActivityListHtml helper that returns a combined
      of lastWeekArray and reviewedPrsArray items or a single
    • fallback when both are empty.
    • Updated email report generation in allIncluded to use buildActivityListHtml instead of manually concatenating lastWeekArray and reviewedPrsArray into a
        .
      • Updated popup scrum body generation in writeScrumBody to use buildActivityListHtml for the last-week section, keeping next-week list building logic unchanged.
src/scripts/scrumHelper.js

Assessment against linked issues

Issue Objective Addressed Explanation
#311 Detect common GitHub API error responses (e.g., invalid/non-existent usernames, missing or expired tokens, rate limiting, and API errors that lead to empty activity). The PR only adds a fallback message when the activity arrays are empty and does not introduce any logic to inspect or categorize GitHub API responses (such as 401/403/404 or rate-limit errors). No new error-handling or response-detection code was added.
#311 Display clear, user-friendly error messages in the popup UI for these GitHub API error states. The changes introduce a generic 'No contributions found for selected period.' message when there is no activity, but they do not display differentiated, user-friendly messages for specific GitHub API error states (invalid username, missing/expired token, rate limit, etc.), nor are these messages clearly tied to API failures.
#311 Add a robust fallback UI state instead of blank or unclear output when GitHub API errors or empty results occur, keeping changes small and focused on feedback and messaging. The PR adds a basic fallback message for empty activity lists in both popup and email outputs, which improves clarity for no-activity days. However, it does not address fallback states for GitHub API error scenarios specifically, and therefore does not fully implement the broader fallback/error-UI behavior requested in the issue.

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

@github-actions github-actions bot added javascript Pull requests that update javascript code core labels Feb 22, 2026
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 - I've reviewed your changes and they look great!


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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a user-facing fallback message when the selected day/range has no GitHub activity, preventing empty “What did I do…?” sections in both popup and email report generation.

Changes:

  • Refactored “last week” HTML list generation into a shared helper (buildActivityListHtml()).
  • Added a fallback <li> message when both lastWeekArray and reviewedPrsArray are empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


function buildActivityListHtml() {
if (lastWeekArray.length === 0 && reviewedPrsArray.length === 0) {
return '<ul><li>No contributions found for selected period.</li></ul>';
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The fallback string is hard-coded to “selected period”, but the report header switches between “yesterday” and a concrete date range. This can lead to inconsistent/confusing wording for users (e.g., yesterday mode still says “selected period”). Consider deriving the message from yesterdayContribution / startingDate / endingDate so it matches the header context.

Suggested change
return '<ul><li>No contributions found for selected period.</li></ul>';
let periodDescription;
if (typeof yesterdayContribution !== 'undefined' && yesterdayContribution) {
periodDescription = 'yesterday';
} else if (typeof startingDate !== 'undefined' && typeof endingDate !== 'undefined' && startingDate && endingDate) {
periodDescription = `${formatDate(startingDate)}${formatDate(endingDate)}`;
} else {
periodDescription = 'the selected period';
}
return `<ul><li>No contributions found for ${periodDescription}.</li></ul>`;

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Mateeb-Haider
Copy link
Contributor Author

@vedansh-5, @hpdang, @mariobehling
Please review this PR at priority. It fixes empty daily reports by showing a clear “No contributions found for this period” message, which is important for user consistency and avoids confusing blank output. A quick review and merge would help improve reliability for all users.

Copy link
Contributor

@Saksham-Sirohi Saksham-Sirohi left a comment

Choose a reason for hiding this comment

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

It would be appreciated if this message did not appear as a list entry

@Mateeb-Haider
Copy link
Contributor Author

Mateeb-Haider commented Feb 26, 2026

It would be appreciated if this message did not appear as a list entry

image

@Saksham-Sirohi
I implement the change please take a look. Thanku!

Copilot AI review requested due to automatic review settings February 26, 2026 09:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@vedansh-5 vedansh-5 left a comment

Choose a reason for hiding this comment

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

Thanks @Mateeb-Haider for your contribution.


function buildActivityListHtml() {
if (lastWeekArray.length === 0 && reviewedPrsArray.length === 0) {
return '<div style="padding: 0 12px;">No activity to report for this update.</div>';
Copy link
Member

Choose a reason for hiding this comment

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

Please update this to no activity to report for the selected time period.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please update this to no activity to report for the selected time period.

I apply the required change now PR is ready to merge
thanku!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1041 to +1051
function buildActivityListHtml() {
if (lastWeekArray.length === 0 && reviewedPrsArray.length === 0) {
return '<div style="padding: 0 12px;">No activity to report for this update.</div>';
}

let activityList = '<ul>';
for (let i = 0; i < lastWeekArray.length; i++) activityList += lastWeekArray[i];
for (let i = 0; i < reviewedPrsArray.length; i++) activityList += reviewedPrsArray[i];
activityList += '</ul>';
return activityList;
}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

Consider adding similar no-activity handling for the "next week" section. Currently, if nextWeekArray is empty, the code will render <ul></ul> (lines 1004-1006 and 1061-1063) which provides no user feedback. While the "next week" section represents plans rather than completed activities, an empty state might still benefit from a helpful message like "No plans added yet" or similar to maintain consistency with the improved UX for the activity section.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 27, 2026 06:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1063 to +1064
function buildBlockerTextHtml() {
return `<span style="display: inline-block; padding: 0 8px; margin: 0; line-height: 1.2;">${userReason}</span>`;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

userReason is interpolated directly into an HTML string that later gets injected via innerHTML/email adapter. If userReason can contain user-provided text, this enables HTML/script injection. Escape/encode userReason before inserting it into markup (or inject it as text rather than HTML).

Suggested change
function buildBlockerTextHtml() {
return `<span style="display: inline-block; padding: 0 8px; margin: 0; line-height: 1.2;">${userReason}</span>`;
function escapeHtml(str) {
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
function buildBlockerTextHtml() {
return `<span style="display: inline-block; padding: 0 8px; margin: 0; line-height: 1.2;">${escapeHtml(userReason)}</span>`;

Copilot uses AI. Check for mistakes.
Comment on lines +1041 to +1043
if (lastWeekArray.length === 0 && reviewedPrsArray.length === 0) {
return '<span style="display: inline-block; padding: 0 8px; margin: 0; line-height: 1.2;">No activity to report for the selected time period.</span>';
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The same long inline style="display: inline-block; padding: 0 8px; margin: 0; line-height: 1.2;" string is hard-coded in multiple helpers (activity, next-week, blockers). Consider extracting it into a constant or a shared wrapper helper (or a CSS class) to avoid duplication and keep formatting changes centralized.

Copilot uses AI. Check for mistakes.
@Mateeb-Haider
Copy link
Contributor Author

image image

@vedansh-5 I implemented all required changes by you and copilot as well and the output attached after the change please take a look when you have free time
Thanku!

Copy link
Member

@vedansh-5 vedansh-5 left a comment

Choose a reason for hiding this comment

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

Thanks @Mateeb-Haider for your contribution.

Please pull the latest changes from the base branch and rebase your PR. Also resolve the existing merge conflicts.
Other than that, this PR looks good to me.

Copilot AI review requested due to automatic review settings March 3, 2026 05:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

for (let i = 0; i < lastWeekArray.length; i++) lastWeekUl += lastWeekArray[i];
for (let i = 0; i < reviewedPrsArray.length; i++) lastWeekUl += reviewedPrsArray[i];
lastWeekUl += '</ul>';
if (!enableToggle) {
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

enableToggle is referenced here but it is not defined anywhere in scrumHelper.js (and a repo-wide search only finds it being removed from storage in popup.js). This will throw a ReferenceError when writeScrumBody() runs in the non-email path. Remove this guard or replace it with a locally-defined flag (e.g., read from storage) and a safe check that won’t crash when undefined.

Suggested change
if (!enableToggle) {
let isEnabled = true;
if (typeof enableToggle !== 'undefined' && !enableToggle) {
isEnabled = false;
}
if (!isEnabled) {

Copilot uses AI. Check for mistakes.
@Mateeb-Haider
Copy link
Contributor Author

@vedansh-5
PTAL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve user feedback for GitHub API errors and edge cases

4 participants