Skip to content

refactor(core): unify network layer into a shared singleton provider#50

Open
syed-tp wants to merge 7 commits intomainfrom
ref/dio-singleton
Open

refactor(core): unify network layer into a shared singleton provider#50
syed-tp wants to merge 7 commits intomainfrom
ref/dio-singleton

Conversation

@syed-tp
Copy link
Copy Markdown
Collaborator

@syed-tp syed-tp commented Mar 26, 2026

  • Centralize multiple client instances to ensure consistent request handling.
  • Eliminate redundant connection pools and enable global 401 session invalidation.
  • Consolidate device metadata logic into the unified network stack to reduce boilerplate.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 core network layer to establish a more robust, maintainable, and efficient architecture. By unifying the Dio HTTP client into a single Riverpod-managed provider, the system gains consistent interceptor application and global control over network-related concerns. The changes also introduce a smarter authentication interceptor capable of path-aware token handling and centralized 401 response management, alongside streamlining user-agent generation. This refactoring improves the overall structure and reliability of network operations without altering external API functionality.

Highlights

  • Unified Network Layer: Centralized the Dio HTTP client into a single, shared Riverpod provider, ensuring consistent request handling, eliminating redundant connection pools, and improving resource efficiency across the application.
  • Smart Authentication Interceptor: Refactored the AuthInterceptor to intelligently handle token injection by excluding specific public paths and to trigger global session invalidation upon receiving a 401 Unauthorized response.
  • Streamlined Dependency Injection: Updated network-dependent services (AuthApiService, HttpDataSource) to receive their Dio instance via constructor injection, enhancing modularity and testability.
  • Consolidated User-Agent Logic: Merged the UserAgentHelper functionality directly into the UserAgentInterceptor, reducing boilerplate and encapsulating device metadata logic within its usage context.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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.

Copy link
Copy Markdown

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

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 refactors the network layer to centralize Dio instance management using a Riverpod dioProvider, enhancing authentication handling with a 'smart' AuthInterceptor. The AuthInterceptor now supports path-aware token injection, excluding login paths, and includes an onError handler for global 401 unauthorized response handling. Additionally, the UserAgentHelper logic has been merged directly into UserAgentInterceptor for streamlining, and network services now receive Dio instances via constructor injection. A review comment points out that the AuthInterceptor.onError implementation does not include the warning log for 401 errors as specified in the design document, suggesting an alignment between the design and implementation.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f2eb01827

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@syed-tp syed-tp force-pushed the ref/dio-singleton branch from c14c07a to 37e6aef Compare March 30, 2026 05:59
@syed-tp syed-tp force-pushed the ref/dio-singleton branch from 6552994 to 8ce80bf Compare March 30, 2026 13:30
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.

2 participants