Skip to content
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

Annotate StackNavigator#push as delicate API #747

Merged
merged 1 commit into from
Jul 29, 2024
Merged

Conversation

arkivanov
Copy link
Owner

@arkivanov arkivanov commented Jul 29, 2024

Closes #741.

Summary by CodeRabbit

  • New Features

    • Introduced the DelicateDecomposeApi annotation to signal APIs that require careful handling.
    • Updated navigation methods across various components to utilize pushNew, enhancing navigation behavior.
  • Documentation

    • Improved documentation for the push function, clarifying its usage and suggesting alternatives.
  • Bug Fixes

    • Enhanced API safety and clarity by marking delicate APIs and refining navigation logic to prevent duplicate configurations.

Copy link

coderabbitai bot commented Jul 29, 2024

Walkthrough

The recent changes enhance the Decompose framework by introducing the DelicateDecomposeApi annotation, which warns developers to use certain APIs with caution. Additionally, the push function has been updated to pushNew across various components, improving navigation clarity and urging developers to avoid pushing duplicate configurations. These modifications aim to promote safer usage patterns and clearer documentation within the API.

Changes

Files Change Summary
decompose/src/commonMain/kotlin/com/arkivanov/decompose/Annotations.kt Introduced a new annotation class DelicateDecomposeApi to indicate APIs that require special attention.
decompose/src/commonMain/kotlin/com/arkivanov/decompose/router/stack/StackNavigatorExt.kt Added @DelicateDecomposeApi annotation to push function; enhanced documentation regarding handling duplicate configurations and recommended pushNew.
docs/navigation/stack/navigation.md Updated documentation for push(configuration) to clarify its usage during interactions and suggest pushNew as an alternative.
sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/DefaultCardsComponent.kt Replaced push with pushNew in navigation logic to improve configuration handling.
sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/DefaultCountersComponent.kt Updated onNext function to use pushNew for navigating to the next component, indicating a change in navigation handling.
sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/dynamicfeatures/DefaultDynamicFeaturesComponent.kt Modified onFeature2 callback to utilize pushNew, reflecting an update in navigation logic for dynamic features.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StackNavigator
    participant Component

    User->>Component: Initiates action (e.g. button click)
    Component->>StackNavigator: Calls pushNew(configuration)
    StackNavigator-->>Component: Updates navigation stack
    Component-->>User: Reflects new state or configuration
Loading

🐇 In the realm of code, where functions play,
A new annotation guides the way.
With pushNew we hop, avoiding the mess,
Clarity blooms, and we code with finesse!
So jump in the stack, let’s dance and delight,
A safer adventure, our future is bright! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4cb68bc and 82f85be.

Files selected for processing (6)
  • decompose/src/commonMain/kotlin/com/arkivanov/decompose/Annotations.kt (1 hunks)
  • decompose/src/commonMain/kotlin/com/arkivanov/decompose/router/stack/StackNavigatorExt.kt (2 hunks)
  • docs/navigation/stack/navigation.md (1 hunks)
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/DefaultCardsComponent.kt (2 hunks)
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/DefaultCountersComponent.kt (2 hunks)
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/dynamicfeatures/DefaultDynamicFeaturesComponent.kt (2 hunks)
Files skipped from review due to trivial changes (1)
  • docs/navigation/stack/navigation.md
Additional comments not posted (9)
decompose/src/commonMain/kotlin/com/arkivanov/decompose/Annotations.kt (1)

26-32: LGTM! The new annotation class is consistent and well-documented.

The DelicateDecomposeApi annotation is appropriately defined with @RequiresOptIn and @Retention annotations. The documentation comment provides clear guidance on its usage.

sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/DefaultCountersComponent.kt (2)

9-9: LGTM! The import statement for pushNew is necessary and correct.

The import statement for pushNew is required for the updated onNext function.


39-39: LGTM! The updated onNext function improves navigation.

The onNext lambda function now uses pushNew to create a new configuration with an incremented index and isBackEnabled set to true.

sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/DefaultCardsComponent.kt (2)

10-10: LGTM! The import statement for pushNew is necessary and correct.

The import statement for pushNew is required for the updated onAddClicked function.


Line range hint 57-62:
LGTM! The updated onAddClicked function improves navigation.

The onAddClicked function now uses pushNew to create a new configuration with an incremented number and sets the color based on the number.

sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/dynamicfeatures/DefaultDynamicFeaturesComponent.kt (2)

8-8: LGTM! The import change is appropriate.

The import statement for push has been replaced with pushNew, which aligns with the updated method usage in the file.


54-54: LGTM! The onFeature2 callback update is appropriate.

The onFeature2 callback now uses pushNew instead of push, which improves navigation clarity and avoids pushing duplicate configurations.

decompose/src/commonMain/kotlin/com/arkivanov/decompose/router/stack/StackNavigatorExt.kt (2)

3-4: LGTM! The import change is appropriate.

The import statement for DelicateDecomposeApi has been added, which aligns with the addition of the DelicateDecomposeApi annotation in the file.


16-24: LGTM! The push function update is appropriate.

The push function has been annotated with DelicateDecomposeApi and its documentation has been updated to provide clearer guidance on the usage and implications of this method.

However, ensure that all function calls to push are reviewed to verify correct usage.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 82f85be and 06f4a03.

Files selected for processing (9)
  • decompose/api/android/decompose.api (1 hunks)
  • decompose/api/decompose.klib.api (1 hunks)
  • decompose/api/jvm/decompose.api (1 hunks)
  • decompose/src/commonMain/kotlin/com/arkivanov/decompose/Annotations.kt (1 hunks)
  • decompose/src/commonMain/kotlin/com/arkivanov/decompose/router/stack/StackNavigatorExt.kt (2 hunks)
  • docs/navigation/stack/navigation.md (1 hunks)
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/DefaultCardsComponent.kt (2 hunks)
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/DefaultCountersComponent.kt (2 hunks)
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/dynamicfeatures/DefaultDynamicFeaturesComponent.kt (2 hunks)
Files skipped from review as they are similar to previous changes (6)
  • decompose/src/commonMain/kotlin/com/arkivanov/decompose/Annotations.kt
  • decompose/src/commonMain/kotlin/com/arkivanov/decompose/router/stack/StackNavigatorExt.kt
  • docs/navigation/stack/navigation.md
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/DefaultCardsComponent.kt
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/DefaultCountersComponent.kt
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/dynamicfeatures/DefaultDynamicFeaturesComponent.kt
Additional comments not posted (4)
decompose/api/jvm/decompose.api (1)

78-79: Annotation DelicateDecomposeApi is correctly defined.

The annotation is properly defined and follows best practices.

decompose/api/android/decompose.api (1)

91-92: Annotation DelicateDecomposeApi is correctly defined.

The annotation is properly defined and follows best practices.

decompose/api/decompose.klib.api (2)

253-255: LGTM!

The DelicateDecomposeApi annotation class is correctly implemented as a marker.


256-258: LGTM!

The ExperimentalDecomposeApi annotation class is correctly implemented as a marker.

@arkivanov arkivanov merged commit d16e901 into master Jul 29, 2024
2 checks passed
@arkivanov arkivanov deleted the push-delicate branch July 29, 2024 18:59
* Marks delicate Decompose API that requires special attention when used.
* See the docs of the annotated API for more information.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
Copy link

Choose a reason for hiding this comment

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

I'd recommend marking the level as ERROR to force people to read the description. Otherwise the issue may persist

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks. I will keep it as warning for now, similar to DelicateCoroutinesApi.

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.

Consider renaming push to pushOrThrow
2 participants