Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 53 minutes and 34 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors sheet background rendering to use a DrawScope lambda, centralizes CoreBottomSheet layout overloads, and changes IME visibility handling: platforms set Changes
Sequence DiagramsequenceDiagram
participant Platform as Platform Layer
participant State as BottomSheetState
participant Layout as CoreBottomSheetLayout
participant Draw as DrawScope
Platform->>State: SideEffect sets imeVisible & hasImeVisibilityUpdated
activate State
State->>State: expand()/peek() invoked
alt animate = true
State->>State: delayIfImeVisible()
Note over State: wait for hasImeVisibilityUpdated (frame polling)
State->>State: check final imeVisible
alt imeVisible = false
State->>State: apply frame delay (with timeout)
else imeVisible = true
State->>State: skip delay
end
end
State->>Layout: trigger layout animation/update
activate Layout
Layout->>Draw: drawSheetBackground(outline)
activate Draw
Note over Draw: precompute outline via drawWithCache<br/>invoke sheetBackground(outline)
Draw->>Draw: drawOutline (color/brush) or custom drawing
deactivate Draw
deactivate Layout
deactivate State
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
sheets-core/src/commonMain/kotlin/com/dokar/sheets/BottomSheetState.kt (1)
349-367:⚠️ Potential issue | 🟠 MajorDon't let the IME latch wait forever.
If the host is already disposed or never enters composition,
hasImeVisibilityUpdatednever flips back totrue, soexpand()/peek()can suspend indefinitely in this loop.sheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.ktLines 229-235 clear the flag again on disposal, and theIllegalStateExceptionfallback only helps when there is no frame clock. This wait needs a bounded/abort path.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@sheets-core/src/commonMain/kotlin/com/dokar/sheets/BottomSheetState.kt` around lines 349 - 367, The unbounded wait in delayIfImeVisible (waiting on hasImeVisibilityUpdated using withFrameNanos) can hang forever; change it to a bounded/abortable wait: wrap the wait-for-hasImeVisibilityUpdated loop in a timeout (e.g., withTimeout or withTimeoutOrNull) or cap the number of frames iterated, and if the timeout/limit is reached treat it as "no IME update" and return so expand()/peek() won't suspend forever; also ensure you don't swallow coroutine cancellation (don't catch CancellationException) and keep the existing IllegalStateException fallback for no-frame-clock cases. Apply these changes inside delayIfImeVisible, replacing the unbounded while(!hasImeVisibilityUpdated) loop, keeping the later repeat(imeVisibleDelayFrames) behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@sheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.kt`:
- Around line 355-379: The content alpha controller currently infers whether to
animate purely from animState, which lets setValue(..., animate = false) still
trigger content animations; fix this by propagating the explicit animate flag
through the state and using it in UpdateContentAlpha: add a boolean (e.g.,
transitionAnimated or isTransitionAnimated) to BottomSheetState that
setValue(...) sets based on its animate param, update any callers (e.g.,
showContent()) to respect/leave that flag, then change UpdateContentAlpha's
snapshotFlow to include that boolean (snapshotFlow { state.value to
state.animState to state.isTransitionAnimated }) and pass it into
contentAlpha.updateBySheetState (or extend updateBySheetState to accept the
animate boolean) so content alpha only runs animateTo when the transition was
requested as animated.
---
Outside diff comments:
In `@sheets-core/src/commonMain/kotlin/com/dokar/sheets/BottomSheetState.kt`:
- Around line 349-367: The unbounded wait in delayIfImeVisible (waiting on
hasImeVisibilityUpdated using withFrameNanos) can hang forever; change it to a
bounded/abortable wait: wrap the wait-for-hasImeVisibilityUpdated loop in a
timeout (e.g., withTimeout or withTimeoutOrNull) or cap the number of frames
iterated, and if the timeout/limit is reached treat it as "no IME update" and
return so expand()/peek() won't suspend forever; also ensure you don't swallow
coroutine cancellation (don't catch CancellationException) and keep the existing
IllegalStateException fallback for no-frame-clock cases. Apply these changes
inside delayIfImeVisible, replacing the unbounded
while(!hasImeVisibilityUpdated) loop, keeping the later
repeat(imeVisibleDelayFrames) behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: abd4af77-5196-4583-8c23-50c5fa178687
📒 Files selected for processing (8)
sheets-core/src/androidMain/kotlin/com/dokar/sheets/Platform.android.ktsheets-core/src/commonMain/kotlin/com/dokar/sheets/BackgroundWithInsetsModifier.ktsheets-core/src/commonMain/kotlin/com/dokar/sheets/BottomSheetState.ktsheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheet.ktsheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.ktsheets-core/src/commonMain/kotlin/com/dokar/sheets/layout/ContentOffsetY.ktsheets-core/src/desktopMain/kotlin/com/dokar/sheets/Platform.desktop.ktsheets-core/src/wasmJsMain/kotlin/com/dokar/sheets/Platform.wasmJs.kt
There was a problem hiding this comment.
🧹 Nitpick comments (2)
sheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.kt (2)
38-38: Unused import:CornerRadius
CornerRadiusis imported but not used anywhere in this file.🧹 Proposed fix
-import androidx.compose.ui.geometry.CornerRadius🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@sheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.kt` at line 38, Remove the unused import androidx.compose.ui.geometry.CornerRadius from the CoreBottomSheetLayout.kt file; locate the CoreBottomSheetLayout declaration and its imports at the top of the file and delete the CornerRadius import line so there are no unused imports left.
364-372: Consider adding a comment to clarify the cancellation-handling logic.The early return when
targetValue != null && animState == None && value != targetValuehandles interrupted animations, but the intent isn't immediately obvious. A brief comment would improve maintainability.📝 Suggested clarification
val oldAnimState = previousAnimState previousAnimState = animState val targetValue = oldAnimState.targetValue() + // Skip update if the previous animation was interrupted before reaching its target. + // This avoids incorrect alpha changes when, e.g., collapsing while expanding. if (targetValue != null && animState == BottomSheetState.AnimState.None && value != targetValue ) { return@collectLatest }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@sheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.kt` around lines 364 - 372, Add a concise inline comment above the if-block inside the collectLatest lambda in CoreBottomSheetLayout.kt explaining the cancellation-handling: note that previousAnimState is preserved, targetValue is read from it, and when targetValue != null && animState == BottomSheetState.AnimState.None && value != targetValue we early-return to ignore this emission because it comes from an interrupted/aborted animation (avoids applying a stale target value). Reference the symbols previousAnimState, animState, BottomSheetState.AnimState.None, targetValue, value and collectLatest so reviewers can find and understand the intent quickly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@sheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.kt`:
- Line 38: Remove the unused import androidx.compose.ui.geometry.CornerRadius
from the CoreBottomSheetLayout.kt file; locate the CoreBottomSheetLayout
declaration and its imports at the top of the file and delete the CornerRadius
import line so there are no unused imports left.
- Around line 364-372: Add a concise inline comment above the if-block inside
the collectLatest lambda in CoreBottomSheetLayout.kt explaining the
cancellation-handling: note that previousAnimState is preserved, targetValue is
read from it, and when targetValue != null && animState ==
BottomSheetState.AnimState.None && value != targetValue we early-return to
ignore this emission because it comes from an interrupted/aborted animation
(avoids applying a stale target value). Reference the symbols previousAnimState,
animState, BottomSheetState.AnimState.None, targetValue, value and collectLatest
so reviewers can find and understand the intent quickly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 27118a2f-ecff-4262-9cda-e070870d2996
📒 Files selected for processing (2)
sheets-core/src/commonMain/kotlin/com/dokar/sheets/BottomSheetState.ktsheets-core/src/commonMain/kotlin/com/dokar/sheets/CoreBottomSheetLayout.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- sheets-core/src/commonMain/kotlin/com/dokar/sheets/BottomSheetState.kt
Summary by CodeRabbit