anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: theopenconversationkit/tock
Issue: Missing check on end called between checkPreconditions and invoke of StoryDataStep

Missing if (!isEndCalled(bus)) in StoryHandlerBase handle between StoryDataStep?.checkPreconditions() and StoryDataStep.handler()

Then when I call bus.end() in StoryDataStep.checkPreconditions() method the current StoryDataStep handle is invoked, and potentially call another time bus.end()

Changed files:
bot/engine/src/main/kotlin/definition/StoryHandlerBase.kt

diff --git a/bot/engine/src/main/kotlin/definition/StoryHandlerBase.kt b/bot/engine/src/main/kotlin/definition/StoryHandlerBase.kt
index 5e7581335..57c8af50b 100644
--- a/bot/engine/src/main/kotlin/definition/StoryHandlerBase.kt
+++ b/bot/engine/src/main/kotlin/definition/StoryHandlerBase.kt
@@ -127,11 +127,13 @@ abstract class StoryHandlerBase<out T : StoryHandlerDefinition>(
                     @Suppress("UNCHECKED_CAST")
                     val data = (step as? StoryDataStep<T, Any, *>)?.checkPreconditions()?.invoke(handler, mainData)?.takeUnless { it is Unit }
                         ?: mainData
-                    @Suppress("UNCHECKED_CAST")
-                    if (step is StoryDataStep<*, *, *>) {
-                        (step as StoryDataStep<T, Any, Any>).handler().invoke(handler, data)
-                    } else {
-                        (step as StoryStep<T>).answer().invoke(handler)
+                    if (!isEndCalled(bus)) {
+                        @Suppress("UNCHECKED_CAST")
+                        if (step is StoryDataStep<*, *, *>) {
+                            (step as StoryDataStep<T, Any, Any>).handler().invoke(handler, data)
+                        } else {
+                            (step as StoryStep<T>).answer().invoke(handler)
+                        }
                     }
                 }
                 if (!isEndCalled(bus)) {
Repository: splendo/kaluga
Issue: MutableState does not update if underlying WithMutableState has been updated

**Describe the bug**
If displaying a composable layout is updated it does not properly invalidate variables created by mutableState()

**To Reproduce**
Create a composableLayout that gets dynamically provided a WithMutableState property and display its value using mutableState()
It will be displaying old states and prevent the new one from being updated.

**Expected behavior**
The view should display the properties of the last emitted WithMutableState.


Changed files:
architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/observables.kt
architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/viewModel/ViewModelComposable.kt

diff --git a/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/observables.kt b/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/observables.kt
index dd7ab641d..80245f98f 100644
--- a/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/observables.kt
+++ b/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/observables.kt
@@ -34,7 +34,7 @@ inline fun <R> WithState<R>.state(): State<R> =
 fun <R> WithMutableState<R>.mutableState(): MutableState<R> {
     val readState = state()
 
-    return remember {
+    return remember(this) {
         object : MutableState<R> {
             override var value: R
                 get() = readState.value
diff --git a/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/viewModel/ViewModelComposable.kt b/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/viewModel/ViewModelComposable.kt
index 3c8a44b33..390fde01a 100644
--- a/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/viewModel/ViewModelComposable.kt
+++ b/architecture-compose/src/androidLibMain/kotlin/com/splendo/kaluga/architecture/compose/viewModel/ViewModelComposable.kt
@@ -44,6 +44,16 @@ fun <VM : BaseViewModel> storeAndRemember(provider: @DisallowComposableCalls ()
     remember(provider)
 }
 
+/**
+ * Stores and remembers a view model in the local [ViewModelStore].
+ * Use if the view model was created manually and is not located in Activity/Fragment [ViewModelStore].
+ * provider will only be evaluated during the composition. Recomposition will always return the value produced by provider.
+ */
+@Composable
+fun <VM : BaseViewModel> storeAndRemember(key: Any?, provider: @DisallowComposableCalls () -> VM): VM = store {
+    remember(key, provider)
+}
+
 @Composable
 private fun <VM : BaseViewModel> handleLocalViewModelStore(viewModel: VM): VM {
     // we delegate VM cleanup to the ViewModelStore, which lives in scope of the current @Composable
Repository: splendo/kaluga
Issue: Compose navigation breaks on back button with latest compose

**Describe the bug**
When doing a back navigation (i.e. Back, PopTo, etc) the latest library fails due to Compose changing part of the APi to become restricted.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a compose navigation
2. Navigate From screen A to screen B
3. Make screen B navigate back

**Expected behavior**
A clear and concise description of what you expected to happen.


Changed files:
architecture-compose/src/main/kotlin/com/splendo/kaluga/architecture/compose/navigation/RouteController.kt

diff --git a/architecture-compose/src/main/kotlin/com/splendo/kaluga/architecture/compose/navigation/RouteController.kt b/architecture-compose/src/main/kotlin/com/splendo/kaluga/architecture/compose/navigation/RouteController.kt
index c48867841..bd79fe552 100644
--- a/architecture-compose/src/main/kotlin/com/splendo/kaluga/architecture/compose/navigation/RouteController.kt
+++ b/architecture-compose/src/main/kotlin/com/splendo/kaluga/architecture/compose/navigation/RouteController.kt
@@ -105,7 +105,7 @@ sealed class ProvidingNavHostRouteController<Provider>(
 
     override fun back(result: Route.Result): Boolean {
         val navHostController = provider.value?.provide()
-        return if (navHostController != null && navHostController.backQueue.isNotEmpty()) {
+        return if (navHostController?.currentBackStackEntry != null) {
             navHostController.previousBackStackEntry?.setResult(result)
             navHostController.popBackStack()
         } else {
@@ -194,7 +194,7 @@ class BottomSheetSheetContentRouteController(
         val rootId = NavDestination("").apply {
             route = ROOT_VIEW
         }.id
-        return if (navHostController != null && navHostController.backQueue.isNotEmpty() && navHostController.previousBackStackEntry?.destination?.id != rootId) {
+        return if (navHostController?.currentBackStackEntry != null && navHostController.previousBackStackEntry?.destination?.id != rootId) {
             navHostController.previousBackStackEntry?.setResult(result)
             navHostController.popBackStack()
         } else {
Repository: splendo/kaluga
Issue: Invalid log level

**Describe the bug**
A clear and concise description of what the bug is.


Info log level doesn't looks like info in logcat panel

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

![Screenshot 2023-07-13 at 10 11 22](https://github.com/splendo/kaluga/assets/1481436/dddbb2b6-2724-49c9-a28f-cd91de9d3294)


**Desktop (please complete the following information):**
 - OS: [e.g. iOS]
 - Browser [e.g. chrome, safari]
 - Version [e.g. 22]

**Smartphone (please complete the following information):**
 - Device: [e.g. iPhone6]
 - OS: [e.g. iOS8.1]
 - Browser [e.g. stock browser, safari]
 - Version [e.g. 22]

**Additional context**
Add any other context about the problem here.


Changed files:
logging/src/commonMain/kotlin/NapierLogger.kt

diff --git a/logging/src/commonMain/kotlin/NapierLogger.kt b/logging/src/commonMain/kotlin/NapierLogger.kt
index 0284644c0..d80da7690 100644
--- a/logging/src/commonMain/kotlin/NapierLogger.kt
+++ b/logging/src/commonMain/kotlin/NapierLogger.kt
@@ -20,17 +20,11 @@ import com.splendo.kaluga.logging.LogLevel as KalugaLogLevel
 import io.github.aakira.napier.Antilog as NapierLog
 import io.github.aakira.napier.LogLevel as NapierLogLevel
 
-internal val logLevel = arrayOf(
-    NapierLogLevel.VERBOSE,
-    NapierLogLevel.DEBUG,
-    NapierLogLevel.INFO,
-    NapierLogLevel.WARNING,
-    NapierLogLevel.ERROR,
-    NapierLogLevel.ASSERT,
-)
-
-internal fun KalugaLogLevel.logLevel(): NapierLogLevel {
-    return logLevel[this.ordinal]
+internal val KalugaLogLevel.napierLogLevel: NapierLogLevel get() = when (this) {
+    KalugaLogLevel.DEBUG -> NapierLogLevel.DEBUG
+    KalugaLogLevel.ERROR -> NapierLogLevel.ERROR
+    KalugaLogLevel.WARN -> NapierLogLevel.WARNING
+    KalugaLogLevel.INFO -> NapierLogLevel.INFO
 }
 
 /**
@@ -39,6 +33,6 @@ internal fun KalugaLogLevel.logLevel(): NapierLogLevel {
  */
 class NapierLogger(val logger: NapierLog) : Logger {
     override fun log(level: KalugaLogLevel, tag: String?, throwable: Throwable?, message: (() -> String)?) {
-        logger.log(priority = level.logLevel(), tag = tag, throwable = throwable, message = message?.invoke())
+        logger.log(priority = level.napierLogLevel, tag = tag, throwable = throwable, message = message?.invoke())
     }
 }