Drawer search: the chats whose messages hold the words, under the title matches
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
GET /api/v2/search?in=chats (server f7f2ff2), 400 ms after typing pauses and from two characters; the title filter stays local and instant. Hits under "In the messages" with the snippet as plain text and the server's marks drawn (markedSnippet clamps ranges that do not fit). A failed search leaves the title filter alone. ContractTest reads search.json; ChatGroupsTest the marks; shot 05-drawer-search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
21 files changed
+216
-2
No files matched your search
@@ -1,9 +1,12 @@
|
||||
package eu.llembas.android
|
||||
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import eu.llembas.android.api.Chat
|
||||
import eu.llembas.android.api.Folder
|
||||
import eu.llembas.android.ui.home.folderTree
|
||||
import eu.llembas.android.ui.home.groupChats
|
||||
import eu.llembas.android.ui.home.markedSnippet
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
@@ -87,4 +90,12 @@ class ChatGroupsTest {
|
||||
val found = groupChats(chats, "rye", today, zone, folders)
|
||||
assertEquals(listOf("inner" to listOf("r")), found.folders.map { it.folder.id to it.chats.map { c -> c.id } })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aSnippetsMarksAndOnesThatDoNotFit() {
|
||||
val bold = SpanStyle(fontWeight = FontWeight.Bold)
|
||||
val marked = markedSnippet("how long does lembas keep", listOf(listOf(14, 20), listOf(22, 99), listOf(5), listOf(9, 3)), bold)
|
||||
assertEquals("how long does lembas keep", marked.text)
|
||||
assertEquals(listOf(14 to 20, 22 to 25), marked.spanStyles.map { it.start to it.end })
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import eu.llembas.android.api.Message
|
||||
import eu.llembas.android.api.Metrics
|
||||
import eu.llembas.android.api.ModelList
|
||||
import eu.llembas.android.api.Plan
|
||||
import eu.llembas.android.api.SearchResults
|
||||
import eu.llembas.android.api.StatusFrame
|
||||
import eu.llembas.android.api.SteeredFrame
|
||||
import eu.llembas.android.api.StepsFrame
|
||||
@@ -71,6 +72,18 @@ class ContractTest {
|
||||
assertEquals("mem1", read("memory", MemoryEnvelope.serializer()).memory.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSearchFindsAChatAFileAndAMemory() {
|
||||
val found = read("search", SearchResults.serializer())
|
||||
assertEquals(listOf("chats", "files", "memories"), found.offered)
|
||||
val chat = found.hits("chats").single()
|
||||
assertEquals("chat1", chat.id)
|
||||
assertEquals("lembas", chat.snippet.substring(chat.marks[0][0], chat.marks[0][1]))
|
||||
assertEquals("/home/frodo/bread.md", found.hits("files").single().path)
|
||||
assertEquals("mem1", found.hits("memories").single().id)
|
||||
assertTrue(found.results.first().more)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theVersionIsOneThisAppReads() {
|
||||
val version = LembasJson.parseToJsonElement(text("version")).toString()
|
||||
|
||||
@@ -28,6 +28,7 @@ import eu.llembas.android.api.ScheduleCompiled
|
||||
import eu.llembas.android.api.ScheduleRun
|
||||
import eu.llembas.android.api.SchedulingModel
|
||||
import eu.llembas.android.api.SchedulingModels
|
||||
import eu.llembas.android.api.SearchHit
|
||||
import eu.llembas.android.api.Step
|
||||
import eu.llembas.android.api.SubagentTree
|
||||
import eu.llembas.android.api.SubagentsOffer
|
||||
@@ -327,6 +328,26 @@ object Fakes {
|
||||
groups = listOf(DataGroup("default", "Default"), DataGroup("garden", "The garden")),
|
||||
)
|
||||
|
||||
val chatsFound = chats.copy(
|
||||
foundFor = "bread",
|
||||
found = listOf(
|
||||
SearchHit(
|
||||
kind = "chat",
|
||||
id = "c4",
|
||||
title = "Sourdough timings",
|
||||
snippet = "…leave the bread to rise overnight, then bake it at dawn…",
|
||||
marks = listOf(listOf(11, 16)),
|
||||
),
|
||||
SearchHit(
|
||||
kind = "chat",
|
||||
id = "c6",
|
||||
title = "Why do leaves keep bread fresh, and does it work with any leaf or only some?",
|
||||
snippet = "Mallorn leaves keep waybread fresh for weeks; other leaves dry the bread out within days.",
|
||||
marks = listOf(listOf(20, 28), listOf(67, 72)),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
private val home = Instance(id = "i1", base = "https://llm.example.org", name = "Home", email = "frodo@example.org", sealedToken = "")
|
||||
private val work = Instance(id = "i2", base = "https://ai.example.com", name = "Work", email = "f.baggins@example.com", sealedToken = "")
|
||||
|
||||
|
||||
@@ -123,6 +123,23 @@ class ScreenShots {
|
||||
}
|
||||
shoot("05-drawer", content = drawn)
|
||||
shoot("05-drawer", Phone.Small, content = drawn)
|
||||
// Searching: the titles that match, then what the instance found inside the messages.
|
||||
shoot("05-drawer-search") {
|
||||
ModalNavigationDrawer(
|
||||
drawerState = rememberDrawerState(DrawerValue.Open),
|
||||
drawerContent = {
|
||||
DrawerContent(
|
||||
Fakes.chatsFound,
|
||||
current = null,
|
||||
account = "Home · frodo@example.org",
|
||||
actions = NoDrawerActions,
|
||||
today = Fakes.today,
|
||||
zone = ZoneOffset.UTC,
|
||||
initialQuery = "bread",
|
||||
)
|
||||
},
|
||||
) { ChatContent(Fakes.transcript, NoChatActions, agent = false) }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user