Live agent todo list: compact scrollable strip above the composer
Add a todo.update frame (server->app) carrying the agent's full current todo list. The gateway emits it whenever the hermes todo tool completes (the tool result is authoritative even for merge writes) and re-sends a snapshot right after hello so a reconnecting device re-learns the plan. Ephemeral: never outboxed. The app renders it as a compact strip above the composer (max 3 lines, the rest scrollable) mirroring the hermes desktop composer status stack: pending = hollow ring, in_progress = spinner, completed = green check, cancelled = struck through. It auto-scrolls to the current task whenever the active task changes, and hides itself once the list is empty or fully resolved.
This commit is contained in:
1 parent
1ff2ef380c
commit
742916903b
10 files changed
+447
-3
No files matched your search
@@ -2,10 +2,14 @@ package iris.data
|
||||
|
||||
import iris.protocol.Frame
|
||||
import iris.protocol.IrisJson
|
||||
import iris.protocol.TYPE_TODO_UPDATE
|
||||
import iris.protocol.TYPE_TOOL_START
|
||||
import iris.protocol.TodoItem
|
||||
import iris.protocol.TodoUpdatePayload
|
||||
import iris.protocol.ToolStartPayload
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
class ChatStoreCacheTest {
|
||||
@Test
|
||||
@@ -110,4 +114,42 @@ class ChatStoreCacheTest {
|
||||
val ids = store.lanes.value["default"]!!.map { it.id }
|
||||
assertEquals(ids.size, ids.toSet().size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun todoUpdateSetsLaneListLastWriteWins() {
|
||||
val store = ChatStore()
|
||||
assertNull(store.todos.value["default"])
|
||||
store.onFrame(todoFrame("default", listOf(TodoItem("1", "a", "in_progress"))))
|
||||
assertEquals(listOf("1"), store.todos.value["default"]!!.map { it.id })
|
||||
// A second update REPLACES the list (the gateway always sends the
|
||||
// full list), and other lanes are untouched.
|
||||
store.onFrame(
|
||||
todoFrame(
|
||||
"default",
|
||||
listOf(TodoItem("1", "a", "completed"), TodoItem("2", "b", "pending")),
|
||||
),
|
||||
)
|
||||
store.onFrame(todoFrame("chan_7", listOf(TodoItem("9", "z", "pending"))))
|
||||
assertEquals(listOf("1", "2"), store.todos.value["default"]!!.map { it.id })
|
||||
assertEquals("completed", store.todos.value["default"]!![0].status)
|
||||
assertEquals(listOf("9"), store.todos.value["chan_7"]!!.map { it.id })
|
||||
// An empty list clears the lane (the agent dropped its plan).
|
||||
store.onFrame(todoFrame("default", emptyList()))
|
||||
assertNull(store.todos.value["default"])
|
||||
assertEquals(listOf("9"), store.todos.value["chan_7"]!!.map { it.id })
|
||||
}
|
||||
|
||||
private fun todoFrame(
|
||||
chatId: String,
|
||||
todos: List<TodoItem>,
|
||||
): Frame =
|
||||
Frame(
|
||||
type = TYPE_TODO_UPDATE,
|
||||
chatId = chatId,
|
||||
payload =
|
||||
IrisJson.instance.encodeToJsonElement(
|
||||
TodoUpdatePayload.serializer(),
|
||||
TodoUpdatePayload(todos = todos),
|
||||
),
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user