Skip to content

fixed report preview bug #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

Preeti9764
Copy link
Contributor

@Preeti9764 Preeti9764 commented Jun 24, 2025

πŸ“Œ Fixes

Fixes #163


πŸ“ Summary of Changes

-The preview report will be generated when button get clicked after the organization name change.

πŸ“Έ Screenshots / Demo (if UI-related)

Screenshot 2025-06-24 090406


βœ… Checklist

  • I’ve tested my changes locally
  • I’ve added tests (if applicable)
  • I’ve updated documentation (if applicable)
  • My code follows the project’s code style guidelines

πŸ‘€ Reviewer Notes

Add any special notes for the reviewer here

Summary by Sourcery

Fix report preview bug by clearing cache and updating UI placeholder on organization change, adjusting debounce timing, and forcing preview content to refresh

Bug Fixes:

  • Fix report preview not updating correctly after organization change

Enhancements:

  • Clear githubCache and display placeholder message on organization change
  • Reduce organization input debounce delay from 3000ms to 2500ms
  • Reprocess and rewrite GitHub issues, PRs, and reviews when generating popup preview

Copy link
Contributor

sourcery-ai bot commented Jun 24, 2025

Reviewer's Guide

Updates popup behavior to clear cached GitHub data and prompt manual report generation on organization change, adjusts input debounce timing, and adds popup-specific data writing logic in the scrum helper.

Sequence diagram for report preview generation after organization change

sequenceDiagram
    actor User
    participant Popup
    participant Storage
    participant ScrumHelper
    User->>Popup: Change organization name
    Popup->>Storage: Set orgName, clear githubCache
    Popup->>Popup: Show message: "Click 'Generate Report' to fetch new data."
    User->>Popup: Click "Generate Report"
    Popup->>ScrumHelper: Call generateScrumReport()
    ScrumHelper->>Storage: Fetch new data
    ScrumHelper->>Popup: Update report preview
Loading

Class diagram for popup and scrumHelper changes

classDiagram
    class Popup {
        +handleOrgInput()
        +generateScrumReport()
    }
    class Storage {
        +set(orgName, githubCache)
        +get()
    }
    class ScrumHelper {
        +allIncluded(outputTarget)
        +writeGithubIssuesPrs()
        +writeGithubPrsReviews()
        -issuesDataProcessed
        -prsReviewDataProcessed
    }
    Popup --> Storage : uses
    Popup --> ScrumHelper : calls generateScrumReport
    ScrumHelper --> Storage : uses
    ScrumHelper : +allIncluded(outputTarget) now resets and writes data if outputTarget == 'popup'
Loading

File-Level Changes

Change Details Files
Modify popup org change behavior to clear cache and prompt manual report generation
  • Clear githubCache when storing new orgName
  • Replace automatic report generation with UI message prompting user to click 'Generate Report'
  • Remove invocation of window.generateScrumReport on org change
src/scripts/popup.js
Adjust debounce delay for organization input handling
  • Change delay from 3000ms to 2500ms in DOMContentLoaded handler
src/scripts/popup.js
Implement popup-specific data writing in scrum helper after fetching
  • Reset issuesDataProcessed and prsReviewDataProcessed flags when outputTarget is 'popup'
  • Invoke writeGithubIssuesPrs and writeGithubPrsReviews for popup target
src/scripts/scrumHelper.js

Assessment against linked issues

Issue Objective Addressed Explanation
#163 The scrum preview report should not be automatically generated when the organization name is changed in the settings. βœ…
#163 The scrum preview report should only be generated after clicking the 'Generate Report' button after an organization name change. βœ…

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

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 @Preeti9764 - I've reviewed your changes - here's some feedback:

  • Consider extracting the hardcoded 2500ms debounce into a named constant so the timing is easier to adjust and understand.
  • Move the inline HTML and style update for the β€œOrganisation changed” message into a dedicated render function or CSS class rather than injecting raw markup.
  • Refactor the manual reset of processed flags and subsequent calls in scrumHelper.js into a single reset method to reduce duplication and clarify the report regeneration flow.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the hardcoded 2500ms debounce into a named constant so the timing is easier to adjust and understand.
- Move the inline HTML and style update for the β€œOrganisation changed” message into a dedicated render function or CSS class rather than injecting raw markup.
- Refactor the manual reset of processed flags and subsequent calls in scrumHelper.js into a single reset method to reduce duplication and clarify the report regeneration flow.

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 Preeti9764 requested review from vedansh-5 and hpdang June 24, 2025 03:34
@vedansh-5
Copy link
Contributor

Hello @Preeti9764, I have reviewed your work and would like to make a suggestion for a better approach to this issue.
Currently when we set a new organization the old cached data is fetched. A thing to notice here is, this only happens when we do not change the date we are fetching for, as when we change the date, the cache is cleared and new fetch requests are made, this happens because the cacheKey is no longer valid.
A better and simpler approach for this would be to add organization name in the cacheKey instead of storing multiple data entries in cache, that way whenever we change organization name, new fetch request will be made. Also I was working on the codebase and noticed this line, here we are making an automatic request when user changes the organization, but its obvious user will generate the scrum report again when they change the organization so we don't really need this and can be safely removed.
For this issue please revert the changes you made in the caching mechanism and change the cacheKey, it will effectively solve the issue with minimal code changes, you can remove the mentioned line in this same PR, as it concerns the same.
Thanks!

@vedansh-5
Copy link
Contributor

Also I was working on the codebase and noticed this line, here we are making an automatic request when user changes the organization, but its obvious user will generate the scrum report again when they change the organization so we don't really need this and can be safely removed.

@hpdang Please share your views on this. Thanks.

@hpdang
Copy link
Member

hpdang commented Jun 24, 2025

What @vedansh-5 suggested sounds good to me

@Preeti9764 Preeti9764 marked this pull request as draft June 25, 2025 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Better Handling after organization name changed
3 participants