Skip to content

refactor: extract OAuth authentication logic into dedicated service - #74

Merged
kubrickcode merged 1 commit into
mainfrom
develop/shlee/54
Nov 29, 2025
Merged

refactor: extract OAuth authentication logic into dedicated service#74
kubrickcode merged 1 commit into
mainfrom
develop/shlee/54

Conversation

@kubrickcode

Copy link
Copy Markdown
Owner

Extracted 77 lines of OAuth logic from popup.ts to auth.service.ts to create independently testable service

  • Reduced popup.ts from 268 to 210 lines (21.6% reduction)
  • Added 21 tests with Chrome identity API mocking
  • Simplified handleLogin() from 77 to 30 lines (60% reduction)

fix #54

@vercel

vercel Bot commented Nov 29, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
github-project-status-viewer Ready Ready Preview Comment Nov 29, 2025 5:13am
github-project-status-viewer-p4ii Ready Ready Preview Comment Nov 29, 2025 5:13am

@github-actions github-actions Bot added the refactor Refactoring code label Nov 29, 2025
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @kubrickcode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the application's OAuth authentication mechanism by extracting it into its own service. This change enhances the modularity and maintainability of the codebase, making the authentication logic independently testable and reducing the complexity of the main popup.ts script. The refactoring also includes comprehensive unit tests for the new authentication service, ensuring its reliability and correctness.

Highlights

  • OAuth Logic Extraction: All OAuth authentication logic has been moved from popup.ts into a new, dedicated service file named auth.service.ts.
  • Improved Testability: A new test file, auth.service.spec.ts, has been added with 21 unit tests to cover the extracted authentication service, including mocking Chrome identity API interactions.
  • Code Reduction and Simplification: The popup.ts file has seen a 21.6% reduction in lines of code, and the handleLogin() function within it has been simplified by 60%.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request is a great refactoring that extracts OAuth authentication logic into a dedicated, testable service (auth.service.ts), significantly cleaning up popup.ts. The addition of a comprehensive test suite for the new service is also excellent. My feedback focuses on a few areas to further improve code quality and align with the repository's style guide, specifically regarding type safety and the use of 'magic strings' for error and UI messages.

Comment thread extension/src/popup.ts Outdated
Comment thread extension/src/services/auth.service.ts Outdated
Comment thread extension/src/services/auth.service.ts
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This is an excellent refactoring that successfully extracts the OAuth logic into a dedicated, testable service. This greatly improves the modularity, readability, and maintainability of the codebase. The new auth.service.ts is well-structured, and the accompanying tests in auth.service.spec.ts are comprehensive, covering many edge cases. I've provided a few suggestions to further align the new code with the repository's style guide and enhance type safety, primarily regarding function parameter patterns and the usage of the chrome.storage API.

Comment thread extension/src/services/auth.service.ts Outdated
Comment thread extension/src/services/auth.service.ts
Comment thread extension/src/services/auth.service.ts Outdated
Comment thread extension/src/services/auth.service.spec.ts Outdated
Extracted 77 lines of OAuth logic from popup.ts to auth.service.ts to create independently testable service

- Reduced popup.ts from 268 to 210 lines (21.6% reduction)
- Added 21 tests with Chrome identity API mocking
- Simplified handleLogin() from 77 to 30 lines (60% reduction)

fix #54
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request does a great job of refactoring the OAuth authentication logic into a dedicated auth.service.ts. This significantly cleans up popup.ts and improves modularity and testability, as demonstrated by the new comprehensive test suite. The changes align well with the repository's coding conventions, such as separating concerns and using constants for magic strings.

I have a few suggestions to further improve consistency and maintainability, mainly within the new auth.service.ts regarding type definitions and data transformation, and a minor improvement to error handling in popup.ts. Overall, this is a solid refactoring.

Comment thread extension/src/popup.ts
Comment thread extension/src/services/auth.service.ts
Comment thread extension/src/services/auth.service.ts
@kubrickcode
kubrickcode merged commit 8dd1e12 into main Nov 29, 2025
9 checks passed
@kubrickcode
kubrickcode deleted the develop/shlee/54 branch November 29, 2025 05:15
@kubrickcode

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 2.0.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

refactor Refactoring code released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract auth service

1 participant