Pinned chats and folders in the drawer: pin, move, new, rename, fold, delete
CI / check (push) Canceled after 0s

The web sidebar's order: Pinned chats (wherever filed), the folders as a tree (folderTree:
position order, a folder whose parent is missing goes to the top), then today / earlier /
agent chats unfiled. PATCH /chats/{id} `pinned` and `folder_id` (server 96240be, f7f2ff2);
POST/PATCH/DELETE /folders. A tap folds a folder through PATCH `collapsed`, so the web folds
the same. Long press: Pin chat / Move to folder / Archive; on a folder Rename / Delete (its
chats stay). Strings from the server's catalogue. ChatGroupsTest, ContractTest (folders.json,
folder.json); the drawer shot now has a pinned chat, nested and collapsed folders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-10 13:49:03 +00:00
1 parent cd88c3e712
commit 737105add2
19 files changed
+586 -24

No files matched your search

@@ -1,8 +1,11 @@
package eu.llembas.android
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 org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import java.time.LocalDate
@@ -41,4 +44,47 @@ class ChatGroupsTest {
assertEquals(listOf("a"), groupChats(chats, " BREAD ", today, zone).earlier.map { it.id })
assertTrue(groupChats(chats, "nothing", today, zone).isEmpty)
}
@Test
fun pinnedFirstWhereverFiledAndFoldersAsATree() {
val folders = listOf(
Folder("inner", "Recipes", parentId = "top", position = 0),
Folder("top", "Waybread", position = 1),
Folder("first", "Letters", position = 0),
// Its parent is not in the list: shown at the top rather than lost.
Folder("stray", "Stray", parentId = "gone", position = 2),
)
assertEquals(listOf("first" to 0, "top" to 0, "inner" to 1, "stray" to 0), folderTree(folders).map { it.first.id to it.second })
val chats = listOf(
Chat(id = "p", title = "Pinned and filed", folderId = "inner", pinned = true),
Chat(id = "r", title = "Rye", folderId = "inner"),
Chat(id = "w", title = "Wrapping", folderId = "top"),
Chat(id = "u", title = "Unfiled", updatedAt = "2026-03-10T08:00:00+00:00"),
Chat(id = "x", title = "In a folder this list does not have", folderId = "elsewhere"),
)
val groups = groupChats(chats, "", today, zone, folders)
assertEquals(listOf("p"), groups.pinned.map { it.id })
assertEquals(
listOf("first" to emptyList(), "top" to listOf("w"), "inner" to listOf("r"), "stray" to emptyList<String>()),
groups.folders.map {
it.folder.id to
it.chats.map { c -> c.id }
},
)
assertEquals(listOf("u"), groups.today.map { it.id })
assertEquals(listOf("x"), groups.earlier.map { it.id })
}
@Test
fun aCollapsedFolderHidesItsChatsAndTheFoldersInside() {
val folders = listOf(Folder("top", "Waybread", collapsed = true), Folder("inner", "Recipes", parentId = "top"), Folder("next", "Letters", position = 1))
val chats = listOf(Chat(id = "r", title = "Rye", folderId = "inner"), Chat(id = "w", title = "Wrapping", folderId = "top"))
val groups = groupChats(chats, "", today, zone, folders)
assertEquals(listOf("top" to emptyList(), "next" to emptyList<String>()), groups.folders.map { it.folder.id to it.chats.map { c -> c.id } })
assertFalse(groups.isEmpty)
// Searching opens everything, and leaves out folders without a match.
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 } })
}
}
@@ -9,6 +9,8 @@ import eu.llembas.android.api.ChatPage
import eu.llembas.android.api.DoneFrame
import eu.llembas.android.api.FileContent
import eu.llembas.android.api.FileListing
import eu.llembas.android.api.FolderEnvelope
import eu.llembas.android.api.FolderList
import eu.llembas.android.api.JobsFrame
import eu.llembas.android.api.LembasJson
import eu.llembas.android.api.LiveReply
@@ -47,6 +49,15 @@ class ContractTest {
private fun <T> read(name: String, serializer: KSerializer<T>): T = LembasJson.decodeFromString(serializer, text(name))
@Test
fun theFoldersAndOne() {
val folders = read("folders", FolderList.serializer()).folders
assertEquals(listOf("fold1", "fold2"), folders.map { it.id })
assertEquals("fold1", folders[1].parentId)
assertTrue(folders[1].collapsed)
assertEquals("Waybread", read("folder", FolderEnvelope.serializer()).folder.name)
}
@Test
fun theVersionIsOneThisAppReads() {
val version = LembasJson.parseToJsonElement(text("version")).toString()
@@ -8,6 +8,7 @@ import eu.llembas.android.api.AgentsSetting
import eu.llembas.android.api.Attachment
import eu.llembas.android.api.Chat
import eu.llembas.android.api.ContextPart
import eu.llembas.android.api.Folder
import eu.llembas.android.api.LembasJson
import eu.llembas.android.api.LinkedDevice
import eu.llembas.android.api.LiveReply
@@ -264,6 +265,14 @@ object Fakes {
Chat(id = "c5", title = "Translate the recipe into Slovak", updatedAt = "2026-03-08T10:00:00+00:00"),
Chat(id = "c6", title = "Why do leaves keep bread fresh, and does it work with any leaf or only some?", updatedAt = "2026-03-01T10:00:00+00:00"),
Chat(id = "c7", title = "Clean up the build scripts", kind = "agent", updatedAt = "2026-03-02T10:00:00+00:00"),
Chat(id = "c8", title = "The cram recipe, for the long road", folderId = "f2", pinned = true, updatedAt = "2026-02-20T10:00:00+00:00"),
Chat(id = "c9", title = "Honey cakes for the party", folderId = "f2", updatedAt = "2026-02-21T10:00:00+00:00"),
Chat(id = "c10", title = "Which leaves to wrap it in", folderId = "f1", updatedAt = "2026-02-22T10:00:00+00:00"),
),
folders = listOf(
Folder(id = "f1", name = "Baking", position = 0),
Folder(id = "f2", name = "Recipes from the Shire, the long list", parentId = "f1", position = 0),
Folder(id = "f3", name = "Letters", position = 1, collapsed = true),
),
)