Skip to content

fix/25#26

Merged
manuel-plavsic merged 5 commits intomainfrom
fix/25
Jul 19, 2025
Merged

fix/25#26
manuel-plavsic merged 5 commits intomainfrom
fix/25

Conversation

@nank1ro
Copy link
Member

@nank1ro nank1ro commented Jul 19, 2025

closes #25

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved the disposal process for providers that accept arguments, ensuring more reliable cleanup and resource management.
  • Documentation

    • Updated the changelog to include details about the latest fix.
  • Chores

    • Bumped the package version to 1.0.3.

@coderabbitai
Copy link

coderabbitai bot commented Jul 19, 2025

Walkthrough

This update addresses the disposal logic for providers with arguments in the disco package. It modifies the internal disposal callback to ensure correct type casting, streamlines the creation and disposal of intermediate providers, updates the changelog, and increments the package version to 1.0.3.

Changes

Files/Paths Change Summary
packages/disco/lib/src/models/providers/provider_argument.dart Refactored disposal callback in _generateIntermediateProvider to ensure type-safe invocation.
packages/disco/lib/src/widgets/provider_scope.dart Optimized provider creation/disposal: reduced redundant calls and simplified disposal logic.
packages/disco/CHANGELOG.md,
packages/disco/pubspec.yaml
Added changelog entry for 1.0.3 and updated version number.
packages/disco/test/disco_test.dart Extended test "Test provider injection" with a new provider using Provider.withArgument and verified its disposal behavior.

Suggested reviewers

  • manuel-plavsic

Poem

A bug in the meadow, so sly and so neat,
Providers with arguments skipped their retreat.
Now rabbits have patched it, with type-casting flair,
Disposal is proper—no leaks anywhere!
With version bumped up, the changelog in tow,
The disco garden continues to grow! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7254930 and d451a72.

📒 Files selected for processing (2)
  • packages/disco/lib/src/widgets/provider_scope.dart (2 hunks)
  • packages/disco/test/disco_test.dart (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/disco/lib/src/widgets/provider_scope.dart
🔇 Additional comments (6)
packages/disco/test/disco_test.dart (6)

276-277: LGTM: Proper disposal tracking setup.

The boolean flag correctly tracks the disposal state of the fullNameContainerProvider for test verification.


290-295: LGTM: Well-structured provider with argument and disposal callback.

The Provider.withArgument implementation correctly:

  • Creates a MockNameContainer with concatenated name
  • Includes a disposal callback that sets the tracking flag
  • Follows the expected pattern for testing disposal behavior

305-305: LGTM: Correct provider instantiation with argument.

The provider is properly instantiated with the argument 'Smith' and added to the providers list.


312-315: LGTM: Proper provider usage and text concatenation.

The provider is correctly accessed via the context and its name property is properly included in the displayed text.


322-326: LGTM: Test expectations updated correctly.

The finder function signature and assertion have been properly updated to accommodate the additional string value from the new provider. The expected output "Ale 1 100 John Smith" correctly reflects all four provider values.


330-331: LGTM: Comprehensive disposal verification.

The test properly verifies both disposal states:

  • Confirms the disposal callback hasn't been called before widget disposal
  • Confirms the disposal callback is called after widget tree replacement

This validates the fix for disposal logic with providers that accept arguments.

Also applies to: 336-337


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jul 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #26   +/-   ##
=======================================
  Coverage   99.53%   99.53%           
=======================================
  Files           9        9           
  Lines         217      217           
=======================================
  Hits          216      216           
  Misses          1        1           
Files with missing lines Coverage Δ
packages/disco/lib/src/widgets/provider_scope.dart 99.31% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nank1ro nank1ro requested a review from manuel-plavsic July 19, 2025 09:35
@nank1ro nank1ro self-assigned this Jul 19, 2025
@nank1ro nank1ro added the bug Something isn't working label Jul 19, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 286a773 and 7254930.

📒 Files selected for processing (4)
  • packages/disco/CHANGELOG.md (1 hunks)
  • packages/disco/lib/src/models/providers/provider_argument.dart (1 hunks)
  • packages/disco/lib/src/widgets/provider_scope.dart (2 hunks)
  • packages/disco/pubspec.yaml (1 hunks)
🔇 Additional comments (4)
packages/disco/lib/src/models/providers/provider_argument.dart (1)

81-81: Excellent type safety improvement!

The explicit type casting from Object to T before calling _disposeValue prevents potential runtime type errors and makes the disposal callback more robust. The null safety check with ?.call() is also a good defensive programming practice.

packages/disco/lib/src/widgets/provider_scope.dart (1)

300-300: Disposal logic verified – keys are proper Provider instances

All entries in createdProviderValues are intermediate Provider objects (see HashMap<Provider, Object> declaration at line 145), and the _safeDisposeValue(Object) method is defined on Provider in packages/disco/lib/src/models/providers/provider.dart (lines 115–118). Calling key._safeDisposeValue(value) is therefore safe and correct.

packages/disco/pubspec.yaml (1)

3-3: Appropriate version bump for bug fix.

The patch version increment from 1.0.2 to 1.0.3 correctly follows semantic versioning for this bug fix release.

packages/disco/CHANGELOG.md (1)

1-4: Clear and well-formatted changelog entry.

The changelog entry appropriately documents the bug fix with consistent formatting and clear description.

Copy link
Member

@manuel-plavsic manuel-plavsic left a comment

Choose a reason for hiding this comment

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

I would just like you to explain why the change to dispose was made. Otherwise LGTM!

@manuel-plavsic manuel-plavsic merged commit 62b4e03 into main Jul 19, 2025
3 checks passed
@manuel-plavsic manuel-plavsic deleted the fix/25 branch July 19, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When will the dispose method of a Provider get called

2 participants