mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 01:30:21 +00:00
fix: address Android assistant review feedback
This commit is contained in:
@@ -49,9 +49,6 @@
|
||||
android:supportsRtl="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:theme="@style/Theme.OpenClawNode">
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
<service
|
||||
android:name=".NodeForegroundService"
|
||||
android:exported="false"
|
||||
@@ -79,6 +76,9 @@
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|uiMode|density|keyboard|keyboardHidden|navigation">
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
@@ -60,6 +60,37 @@ import ai.openclaw.app.ui.mobileText
|
||||
import ai.openclaw.app.ui.mobileTextSecondary
|
||||
import ai.openclaw.app.ui.mobileTextTertiary
|
||||
|
||||
internal data class DraftApplication(
|
||||
val input: String,
|
||||
val lastAppliedDraft: String?,
|
||||
val consumed: Boolean,
|
||||
)
|
||||
|
||||
internal fun applyDraftText(
|
||||
draftText: String?,
|
||||
currentInput: String,
|
||||
lastAppliedDraft: String?,
|
||||
): DraftApplication {
|
||||
val draft =
|
||||
draftText?.trim()?.ifEmpty { null } ?: return DraftApplication(
|
||||
input = currentInput,
|
||||
lastAppliedDraft = null,
|
||||
consumed = false,
|
||||
)
|
||||
if (draft == lastAppliedDraft) {
|
||||
return DraftApplication(
|
||||
input = currentInput,
|
||||
lastAppliedDraft = lastAppliedDraft,
|
||||
consumed = false,
|
||||
)
|
||||
}
|
||||
return DraftApplication(
|
||||
input = draft,
|
||||
lastAppliedDraft = draft,
|
||||
consumed = true,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ChatComposer(
|
||||
draftText: String?,
|
||||
@@ -80,11 +111,12 @@ fun ChatComposer(
|
||||
var showThinkingMenu by remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(draftText) {
|
||||
val draft = draftText?.trim()?.ifEmpty { null } ?: return@LaunchedEffect
|
||||
if (draft == lastAppliedDraft) return@LaunchedEffect
|
||||
input = draft
|
||||
lastAppliedDraft = draft
|
||||
onDraftApplied()
|
||||
val next = applyDraftText(draftText = draftText, currentInput = input, lastAppliedDraft = lastAppliedDraft)
|
||||
input = next.input
|
||||
lastAppliedDraft = next.lastAppliedDraft
|
||||
if (next.consumed) {
|
||||
onDraftApplied()
|
||||
}
|
||||
}
|
||||
|
||||
val canSend = pendingRunCount == 0 && (input.trim().isNotEmpty() || attachments.isNotEmpty()) && healthOk
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package ai.openclaw.app.ui.chat
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class ChatComposerDraftTest {
|
||||
@Test
|
||||
fun clearsLastAppliedDraftWhenViewModelDraftResets() {
|
||||
val consumed =
|
||||
applyDraftText(
|
||||
draftText = "repeat this",
|
||||
currentInput = "",
|
||||
lastAppliedDraft = null,
|
||||
)
|
||||
|
||||
assertTrue(consumed.consumed)
|
||||
assertEquals("repeat this", consumed.input)
|
||||
assertEquals("repeat this", consumed.lastAppliedDraft)
|
||||
|
||||
val cleared =
|
||||
applyDraftText(
|
||||
draftText = null,
|
||||
currentInput = consumed.input,
|
||||
lastAppliedDraft = consumed.lastAppliedDraft,
|
||||
)
|
||||
|
||||
assertFalse(cleared.consumed)
|
||||
assertEquals("repeat this", cleared.input)
|
||||
assertEquals(null, cleared.lastAppliedDraft)
|
||||
|
||||
val repeated =
|
||||
applyDraftText(
|
||||
draftText = "repeat this",
|
||||
currentInput = cleared.input,
|
||||
lastAppliedDraft = cleared.lastAppliedDraft,
|
||||
)
|
||||
|
||||
assertTrue(repeated.consumed)
|
||||
assertEquals("repeat this", repeated.input)
|
||||
assertEquals("repeat this", repeated.lastAppliedDraft)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user