Skip to content

Conversation

@arkivanov
Copy link
Owner

@arkivanov arkivanov commented Nov 3, 2025

Summary by CodeRabbit

  • Refactor

    • Panel handling simplified: child rendering and empty-state detection updated for clearer behavior and fewer special cases.
    • Predictive-back gating and broadcast logic streamlined with a fixed threshold for more consistent gestures.
  • Breaking Changes

    • Two previously exported panel properties were removed from the public API; update integrations accordingly.

@coderabbitai
Copy link

coderabbitai bot commented Nov 3, 2025

Walkthrough

Replaces the sealed PanelChild variant with a nullable-child PanelChild class, removes the count parameter from rememberBroadcastPredictiveBackParams, and updates panel APIs and rendering/predictive-back logic to use nullable-child checks and stack size/emptiness conditions.

Changes

Cohort / File(s) Summary
Panel data structure & API
extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/panels/ChildPanels.kt, extensions-compose-experimental/api/extensions-compose-experimental.klib.api
Replaced sealed PanelChild (with Panel and Empty) by a private PanelChild<C,T> class holding nullable child and a companion Empty; added isEmpty extension; updated asPanelChild() signatures; removed PanelChild_Panel and PanelChild_Empty stable props from API manifest.
Predictive back params helper
.../panels/ChildPanels.kt
Removed count parameter from rememberBroadcastPredictiveBackParams(key, params); hardcoded onBack threshold to 2; updated all call sites to omit count.
Panel usages & rendering logic
.../panels/ChildPanels.kt (MainPanel, DetailsPanel, ExtraPanel and helpers)
Updated panel function parameter types to use PanelChild<C,T>; replaced pattern-matching with nullable child retrieval (it.instance.child) and isEmpty checks; adjusted predictive-back gating to rely on stack.items.size and first-item emptiness; preserved placeholder rendering for empty cases.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant UI as UI / Panels
    participant Stack as PanelsStack
    participant Helper as rememberBroadcastPredictiveBackParams
    participant Renderer as PanelRenderer

    UI->>Stack: read stack.items / active.instance
    Note right of Stack: provides items, size, and first-item emptiness
    UI->>Helper: call with key (panels) and params lambda
    Helper->>Helper: invoke params() -> PredictiveBackParams?
    alt stack size threshold (hardcoded 2) met
        Helper->>UI: broadcast predictive onBack
    else
        Helper-->>UI: no broadcast
    end
    UI->>Renderer: pass PanelChild (nullable child)
    alt child != null
        Renderer->>UI: render child content
    else
        Renderer->>UI: render placeholder
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to consistent replacement of the sealed PanelChild pattern across call sites.
  • Verify API manifest removals match intended public surface (ensure no consumer breakage).
  • Review predictive-back threshold logic and edge cases around stack size and first-item emptiness.

Possibly related PRs

Poem

🐰
I hopped through code and made a nest,
One nullable child fits best.
Count left the meadow, two stays near,
Panels render — cheer and cheer! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: a refactoring of the ChildPanels composable, which is the primary focus of modifications across the file.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ChildPanels-refactoring

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1603710 and 04dd6eb.

📒 Files selected for processing (1)
  • extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/panels/ChildPanels.kt (9 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-28T22:32:21.630Z
Learnt from: arkivanov
Repo: arkivanov/Decompose PR: 880
File: docs/extensions/compose.md:429-431
Timestamp: 2025-05-28T22:32:21.630Z
Learning: In Decompose documentation, the correct import path for `subscribeAsState` in the Child Items navigation example is `com.arkivanov.decompose.extensions.compose.subscribeAsState`, not the jetbrains-specific variant. The import paths vary depending on the specific compose variant being used (general compose vs jetbrains/multiplatform compose).

Applied to files:

  • extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/panels/ChildPanels.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build on Linux
  • GitHub Check: Build on macOS

@arkivanov arkivanov force-pushed the ChildPanels-refactoring branch from 04dd6eb to cb92f84 Compare November 3, 2025 18:33
@arkivanov arkivanov force-pushed the ChildPanels-refactoring branch from cb92f84 to 42e50b2 Compare November 3, 2025 20:06
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

🧹 Nitpick comments (1)
extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/panels/ChildPanels.kt (1)

419-419: Consider slight Kotlin idiom enhancement (optional).

The isEmpty extension is clear and works well. For even more idiomatic Kotlin in the rendering blocks, you could optionally use ?.let instead of explicit null checks, though the current if-statements are equally readable:

// Optional alternative at lines 283-286, 323-325, 367-369:
it.instance.child?.let { child -> content(child) }

This is purely stylistic—the current code is perfectly fine.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb92f84 and 42e50b2.

📒 Files selected for processing (2)
  • extensions-compose-experimental/api/extensions-compose-experimental.klib.api (0 hunks)
  • extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/panels/ChildPanels.kt (9 hunks)
💤 Files with no reviewable changes (1)
  • extensions-compose-experimental/api/extensions-compose-experimental.klib.api
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-28T22:32:21.630Z
Learnt from: arkivanov
Repo: arkivanov/Decompose PR: 880
File: docs/extensions/compose.md:429-431
Timestamp: 2025-05-28T22:32:21.630Z
Learning: In Decompose documentation, the correct import path for `subscribeAsState` in the Child Items navigation example is `com.arkivanov.decompose.extensions.compose.subscribeAsState`, not the jetbrains-specific variant. The import paths vary depending on the specific compose variant being used (general compose vs jetbrains/multiplatform compose).

Applied to files:

  • extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/panels/ChildPanels.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build on Linux
  • GitHub Check: Build on macOS
🔇 Additional comments (5)
extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/panels/ChildPanels.kt (5)

215-215: LGTM! Clean API simplification.

Removing the count parameter and hardcoding it to 2 (line 388) is a valid simplification since all call sites were using the same value. This reduces API surface area without losing functionality.


259-288: LGTM! MainPanel refactoring is sound.

The signature change to PanelChild<MC, MT> aligns with the new nullable-child design. The rendering logic correctly extracts and null-checks the child before rendering. The predictive back condition (items.size == 2) appropriately enables the back gesture when transitioning between panels.


293-329: LGTM! DetailsPanel refactoring correctly addresses previous critical issue.

The switch from stack.backStack.first() to stack.items.first() at line 315 is safe because items always contains at least the active element, eliminating the crash risk when the back stack is empty. The predictive back logic correctly enables the gesture only when there are non-empty items to navigate back from. The nullable-child rendering pattern is properly implemented.


335-373: LGTM! ExtraPanel refactoring correctly addresses previous critical issue.

Similar to DetailsPanel, the use of stack.items.first() at line 359 safely avoids exceptions. The predictive back condition (stack.items.first() == EmptyChild1 && stack.size > 1) correctly enables the gesture only when the extra panel is actually present. The nullable-child rendering is properly handled.


412-417: LGTM! Elegant simplification of PanelChild design.

Replacing the sealed interface with a simple nullable-child class reduces complexity while maintaining clear semantics. The Empty companion object provides a clean way to represent absent panels.

@arkivanov arkivanov merged commit f58cba6 into master Nov 3, 2025
3 checks passed
@arkivanov arkivanov deleted the ChildPanels-refactoring branch November 3, 2025 20:46
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