Skip to content

Scrum report is now being generated when the extension is freshly unpacked. #153

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

vedansh-5
Copy link
Contributor

@vedansh-5 vedansh-5 commented Jun 23, 2025

Fixes #148

📝 Summary of Changes

Earlier the extension was using locally saved data to generate a scrum report. This logic was resulting in the scrum report not being generated when the extension was freshly unpacked into the chrome extension module.
In this PR I have implemented to use the data present in form section to fetch the report which is then saved into the local browser storage, with this approach, the extension properly generates the scrum report when it is freshly unpacked.

✅ Checklist

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

👀 Reviewer Notes

Add any special notes for the reviewer here

Summary by Sourcery

Use form inputs to seed local storage when empty, ensuring scrum reports generate on first load; refactor storage and GitHub data caching logic for robust cache management and token support.

Bug Fixes:

  • Generate scrum report immediately after fresh unpack by sourcing username, project, token, and reason from the popup form when storage is empty.

Enhancements:

  • Abstract Chrome storage operations with saveToStorage/loadFromStorage and manage cache TTL and key matching.
  • Enhance fetchGithubData to support authenticated requests, stale cache detection, and queue concurrent fetch calls.
  • Add invalid GitHub token handling UI feedback in the extension popup.
  • Cache and restore the email subject along with report data to maintain consistency across sessions.

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

sourcery-ai bot commented Jun 23, 2025

Reviewer's Guide

Instead of relying solely on existing storage data, the PR enhances initialization by reading form inputs on unpack and merging them into local storage, refactors storage/cache handling using dedicated helpers, enriches GitHub API fetch logic with token support and queuing, and defers report injection until all data is ready to ensure reports generate correctly upon fresh unpacking.

File-Level Changes

Change Details Files
Reworked storage initialization to merge form inputs into local storage when freshly unpacked
  • Read GitHub username, project name, token, and blocker reason from DOM in popup context
  • Merge these inputs into chrome.storage.local and then assign to internal variables
  • Unified feature-flag handling for toggles like showOpenLabel and date selections
src/scripts/scrumHelper.js
Abstracted cache persistence with getCacheTTL, saveToStorage, and loadFromStorage helpers
  • Introduced asynchronous getCacheTTL to derive TTL from storage
  • Added saveToStorage and loadFromStorage to manage githubCache lifecycle
  • Replaced inline storage reads/writes with these helpers in fetchGithubData
src/scripts/scrumHelper.js
Enhanced fetchGithubData to support authenticated requests, queue concurrent calls, and handle errors gracefully
  • Attach Authorization header when githubToken is available
  • Throttle requests and queue overlapping calls until fetch completes
  • Implement showInvalidTokenMessage for popup/email contexts on 401/403 responses
src/scripts/scrumHelper.js
Deferred report subject/body injection until both issues and PR review data are processed
  • Removed premature writeScrumBody invocation from interval
  • Introduced issuesDataProcessed/prsReviewDataProcessed flags and triggerScrumGeneration
  • Adjusted interval logic for subject detection and removed reliance on showClosedLabel
src/scripts/scrumHelper.js
Cleaned up storage keys in main.js
  • Removed obsolete 'showClosedLabel' from storage.get in main.js
src/scripts/main.js

Assessment against linked issues

Issue Objective Addressed Explanation

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

@vedansh-5 vedansh-5 self-assigned this Jun 23, 2025
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!


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
Contributor Author

I have considered Sourcerys' suggestions.

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

@Preeti9764 Preeti9764 left a comment

Choose a reason for hiding this comment

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

@vedansh-5 @hpdang for me the current changes did not solve the issue, it still needs refresh after loading and works fine.Thanks!

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

@Preeti9764 Please check the latest changes to see whether they fix the issue for you or not. Thanks!

@vedansh-5 vedansh-5 requested a review from Preeti9764 June 24, 2025 16:19
@Preeti9764
Copy link
Contributor

@vedansh-5 No proper handling in case of username not provided, some unknown elements appears in ui .Can you fix that.Thanks!
image

Copy link
Contributor

@Preeti9764 Preeti9764 left a comment

Choose a reason for hiding this comment

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

there is as scope of race condition in cache loading if multiple calls happened simultaneously. The loadFromStorage() call is not protected by the fetching flag.

@vedansh-5
Copy link
Contributor Author

vedansh-5 commented Jun 25, 2025

there is as scope of race condition in cache loading if multiple calls happened simultaneously. The loadFromStorage() call is not protected by the fetching flag.

@Preeti9764 This is not a practical problem as the mentioned loadFromStorage() is just a read function and does not write anything into the local storage even if a race condition is triggered it won't affect the results in any way. Even if two calls happen at once, both will just read the the same cache and produce consistent results.
Also a point to notice is loadFromStorage() is called only from fetchGihtubData() which is race condition protected so no race condition can occur in loadFromStorage(). Thanks!

@vedansh-5
Copy link
Contributor Author

@vedansh-5 No proper handling in case of username not provided, some unknown elements appears in ui .Can you fix that.Thanks! image

I have fixed this, can you take a look @Preeti9764 , Thanks!

@vedansh-5 vedansh-5 requested a review from Preeti9764 June 25, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Does not generate scrum preview when unpacked.
2 participants