feat(chat): add @bot mention autocomplete to ChatComposer (#980)

This commit is contained in:
M57 authored and GitHub committed 2026-08-27 01:51:10 +03:00
1 parent 4e666b49a8
commit b422ead921
5 files changed
+162

No files matched your search

@@ -1,5 +1,7 @@
package com.m57.hermescontrol.ui.chat
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.TextFieldValue
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
@@ -143,4 +145,22 @@ class ChatInputPolicyTest {
ChatInputPolicy.sortSlashSuggestions(commands, mapOf("/MODEL" to 3)),
)
}
@Test
fun extractMentionQuery_variousPositions() {
assertEquals("res", ChatInputPolicy.extractMentionQuery("@res", 4))
assertEquals("scout", ChatInputPolicy.extractMentionQuery("hey @scout", 10))
assertEquals("", ChatInputPolicy.extractMentionQuery("ask @", 5))
org.junit.Assert.assertNull(ChatInputPolicy.extractMentionQuery("test@example.com", 16))
org.junit.Assert.assertNull(ChatInputPolicy.extractMentionQuery("hello world", 5))
org.junit.Assert.assertNull(ChatInputPolicy.extractMentionQuery("@bot with spaces", 15))
}
@Test
fun applyMention_insertsHandleAndAdvancesCursor() {
val initial = TextFieldValue("ask @sc", selection = androidx.compose.ui.text.TextRange(7))
val updated = ChatInputPolicy.applyMention(initial, "scout")
assertEquals("ask @scout ", updated.text)
assertEquals(11, updated.selection.end)
}
}