diff --git a/clients/cli/build.gradle.kts b/clients/cli/build.gradle.kts index ff27982..6511cff 100644 --- a/clients/cli/build.gradle.kts +++ b/clients/cli/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "com.jaytux.phoebench" -version = rootProject.version as PhoebenchVersion +version = PhoebenchVersion(1, 2, 1, "patch0") if((version as PhoebenchVersion) < (rootProject.version as PhoebenchVersion)) throw GradleException("CLI Client version must be at least as high as protocol/common version") diff --git a/clients/compose/build.gradle.kts b/clients/compose/build.gradle.kts index 3f9c9ea..fe10b7f 100644 --- a/clients/compose/build.gradle.kts +++ b/clients/compose/build.gradle.kts @@ -13,7 +13,7 @@ plugins { alias(libs.plugins.buildconfig) } -version = rootProject.version as PhoebenchVersion +version = PhoebenchVersion(1, 2, 1, "autoscroll") if((version as PhoebenchVersion) < (rootProject.version as PhoebenchVersion)) throw GradleException("UI Clients version must be at least as high as protocol/common version") diff --git a/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt b/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt index 3553b9b..a198893 100644 --- a/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt +++ b/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment @@ -161,6 +162,15 @@ fun MonitorMessage(msg: ServerMonitorEvent.ITextEvent) = when(msg) { @Composable fun MonitorDialog(name: String, logs: List, onClose: () -> Unit, onClear: () -> Unit) { + var autoFollow by remember { mutableStateOf(true) } + val state = rememberLazyListState() + + LaunchedEffect(autoFollow, logs) { + if(autoFollow) { + state.animateScrollToItem(logs.size - 1) + } + } + Dialog(onDismissRequest = onClose, properties = DialogProperties(usePlatformDefaultWidth = false)) { Surface(Modifier.padding(15.dp).fillMaxHeight(0.8f).widthIn(min = 300.dp, max = 2000.dp), shape = MaterialTheme.shapes.medium) { Column(Modifier.padding(8.dp)) { @@ -175,9 +185,20 @@ fun MonitorDialog(name: String, logs: List, onClo } else { CompositionLocalProvider(LocalTextStyle provides LocalTextStyle.current.makeMonospaced()) { - LazyColumn(Modifier.weight(1f).padding(10.dp).background(MaterialTheme.colorScheme.surfaceDim)) { - items(logs) { - MonitorMessage(it) + Box(Modifier.weight(1f)) { + LazyColumn(Modifier.fillMaxHeight().fillMaxWidth().padding(10.dp).background(MaterialTheme.colorScheme.surfaceDim), state) { + items(logs) { + MonitorMessage(it) + } + } + + Box(Modifier.align(Alignment.TopEnd).padding(25.dp)) { + val colors = if(autoFollow) + IconButtonDefaults.iconButtonColors(containerColor = LocalContentColor.current, contentColor = MaterialTheme.colorScheme.surface) + else IconButtonDefaults.iconButtonColors(containerColor = MaterialTheme.colorScheme.surface, contentColor = LocalContentColor.current) + IconButton({ autoFollow = !autoFollow }, colors = colors) { + Icon(Lucide.ArrowDownToLine, "Follow") + } } } } diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 8e4fae4..09d268c 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.jaytux.phoebench" -version = rootProject.version as PhoebenchVersion +version = PhoebenchVersion(1, 2, 1, "patch0") if((version as PhoebenchVersion) < (rootProject.version as PhoebenchVersion)) throw GradleException("Server version must be at least as high as protocol/common version")