Fixed web history rewriting incorrectly when started via a link#983
Fixed web history rewriting incorrectly when started via a link#983
Conversation
📝 WalkthroughWalkthroughSimplified the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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)
decompose/src/webMain/kotlin/com/arkivanov/decompose/router/webhistory/WebHistoryNavigation.kt (1)
63-76:⚠️ Potential issue | 🟠 Major
onRewritecallback should protect against navigating into pre-app browser history.
browserHistory.lengthreturns the total browser session history viawindow.history.length, which includes entries before the app loaded. The current code at line 71 (go(-historyLength + 1)) lacks the bounds protection used elsewhere.Compare with line 47 (
onPop), which correctly usescoerceAtMost(browserHistory.currentIndex())to prevent navigation beyond app-tracked state. TheonRewritecallback should apply the same pattern to ensurego()stays within app boundaries.
🤖 Fix all issues with AI agents
In
`@decompose/src/webTest/kotlin/com/arkivanov/decompose/router/webhistory/TestBrowserHistory.kt`:
- Around line 13-21: The length getter currently returns index + 1 which
reflects the current position, not the total session history; update override
val length: Int to return stack.size instead of index + 1 (in
TestBrowserHistory’s properties), so that length reflects the total number of
entries in stack; leave state, go, push/pop logic unchanged but run tests to
ensure callers expecting the old value are adjusted.
decompose/src/webTest/kotlin/com/arkivanov/decompose/router/webhistory/TestBrowserHistory.kt
Show resolved
Hide resolved
bd2b46c to
080ca6a
Compare
Fixed. |
Fixes: #982
Summary by CodeRabbit
Breaking Changes
onRewritecallback signature in web history navigation API—now accepts only the navigation history parameterTests
✏️ Tip: You can customize this high-level summary in your review settings.