From 181e9b53bd465f9dee971189b38c4c858f6b06f2 Mon Sep 17 00:00:00 2001 From: William Holcombe Date: Sat, 4 Jul 2026 15:09:18 -0600 Subject: [PATCH] fix: enforce dynamic MaterialTheme colors in ComponentRegistry and prevent ActionList dashboard clearing --- .../meatbag/client/ComponentRegistry.kt | 27 ++++++++++--------- .../kotlin/meatbag/client/MeatbagClient.kt | 7 +++-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/client/src/commonMain/kotlin/meatbag/client/ComponentRegistry.kt b/client/src/commonMain/kotlin/meatbag/client/ComponentRegistry.kt index 5dedc2a..db5f817 100644 --- a/client/src/commonMain/kotlin/meatbag/client/ComponentRegistry.kt +++ b/client/src/commonMain/kotlin/meatbag/client/ComponentRegistry.kt @@ -18,6 +18,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults +import androidx.compose.material.MaterialTheme import androidx.compose.material.OutlinedTextField import androidx.compose.material.Text import androidx.compose.material.TextFieldDefaults @@ -137,13 +138,13 @@ object ComponentRegistry { .fillMaxWidth() .padding(8.dp) .clip(RoundedCornerShape(16.dp)) - .background(CardBg) + .background(MaterialTheme.colors.surface) .border( 1.dp, Brush.linearGradient( listOf( - AccentTeal.copy(alpha = 0.3f), - AccentPurple.copy(alpha = 0.3f) + MaterialTheme.colors.primary.copy(alpha = 0.3f), + MaterialTheme.colors.secondary.copy(alpha = 0.3f) ) ), RoundedCornerShape(16.dp) @@ -290,7 +291,7 @@ fun ApprovalRequestComponent( // Target underneath ("two words underneath can say what its for") Text( text = request.target.uppercase(), - color = AccentTeal, + color = MaterialTheme.colors.primary, fontSize = 14.sp, fontWeight = FontWeight.Bold, fontFamily = FontFamily.Monospace, @@ -343,7 +344,7 @@ fun ActionListComponent( list.actions.forEach { actionItem -> Button( onClick = { onActionSelected(actionItem.id) }, - colors = ButtonDefaults.buttonColors(backgroundColor = DeepBg), + colors = ButtonDefaults.buttonColors(backgroundColor = MaterialTheme.colors.background), shape = RoundedCornerShape(12.dp), modifier = Modifier .fillMaxWidth() @@ -352,8 +353,8 @@ fun ActionListComponent( 1.dp, Brush.linearGradient( listOf( - AccentTeal.copy(alpha = 0.5f), - AccentPurple.copy(alpha = 0.5f) + MaterialTheme.colors.primary.copy(alpha = 0.5f), + MaterialTheme.colors.secondary.copy(alpha = 0.5f) ) ), RoundedCornerShape(12.dp) @@ -372,7 +373,7 @@ fun ActionListComponent( ) Text( text = ">", - color = AccentTeal, + color = MaterialTheme.colors.primary, fontSize = 18.sp, fontWeight = FontWeight.Bold ) @@ -415,9 +416,9 @@ fun TextInputComponent( placeholder = { Text(input.placeholder, color = TextSecondary) }, colors = TextFieldDefaults.outlinedTextFieldColors( textColor = TextPrimary, - focusedBorderColor = AccentTeal, + focusedBorderColor = MaterialTheme.colors.primary, unfocusedBorderColor = TextSecondary.copy(alpha = 0.5f), - cursorColor = AccentTeal + cursorColor = MaterialTheme.colors.primary ), shape = RoundedCornerShape(12.dp), modifier = Modifier.fillMaxWidth() @@ -425,7 +426,7 @@ fun TextInputComponent( Button( onClick = { onSubmit(textVal) }, - colors = ButtonDefaults.buttonColors(backgroundColor = AccentPurple), + colors = ButtonDefaults.buttonColors(backgroundColor = MaterialTheme.colors.secondary), shape = RoundedCornerShape(12.dp), modifier = Modifier .fillMaxWidth() @@ -473,7 +474,7 @@ fun MessageComponent( Button( onClick = { onAcknowledge(message.primaryAction?.id) }, - colors = ButtonDefaults.buttonColors(backgroundColor = AccentTeal), + colors = ButtonDefaults.buttonColors(backgroundColor = MaterialTheme.colors.primary), shape = RoundedCornerShape(12.dp), modifier = Modifier .fillMaxWidth() @@ -482,7 +483,7 @@ fun MessageComponent( ) { Text( text = message.primaryAction?.label ?: "Acknowledge", - color = DeepBg, + color = MaterialTheme.colors.background, fontWeight = FontWeight.Bold, fontSize = 15.sp ) diff --git a/client/src/commonMain/kotlin/meatbag/client/MeatbagClient.kt b/client/src/commonMain/kotlin/meatbag/client/MeatbagClient.kt index 2db1bb5..30dd400 100644 --- a/client/src/commonMain/kotlin/meatbag/client/MeatbagClient.kt +++ b/client/src/commonMain/kotlin/meatbag/client/MeatbagClient.kt @@ -173,8 +173,11 @@ class MeatbagClient( } if (httpResponse.status.isSuccess()) { log("Response submitted successfully! Server returned 200 OK", LogType.SUCCESS) - if (_currentPayload.value?.uiPrimitive?.id == response.requestId) { - _currentPayload.value = null + val currentPrimitive = _currentPayload.value?.uiPrimitive + if (currentPrimitive?.id == response.requestId) { + if (currentPrimitive !is meatbag.common.ActionList) { + _currentPayload.value = null + } } true } else {