fix(#686): implement robust history pagination (#687)

* fix(#686): implement robust history pagination

Honor server-returned offset, degrade gracefully on older servers, and parse JSON tool results.

* fix(ci): repair unit-test compilation and pagination test mocks

- Remove trailing blank line in SessionMessagesResponse.kt (ktlint)
- Replace unresolved io.mockk.eq/coAnswers usage in ChatViewModelTest with
  an ordered-call counter inside coAnswers, which compiles and runs on
  MockK 1.14.11 (eq is a matcher-scope member, not a top-level import)
- Align HermesApiServiceMockWebServerTest with the PR's JsonElement content
  model (contentText) and the new include_compacted=true default query param

All unit tests pass locally with the ByteBuddy agent preload.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-07-23 00:30:48 +03:00
1 parent 34ba93901b
commit def122ab58
5 files changed
+294 -16

No files matched your search

@@ -1,4 +1,5 @@
package com.m57.hermescontrol.data.model
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonPrimitive
@@ -6,15 +7,25 @@ import kotlinx.serialization.json.JsonPrimitive
@Serializable
data class SessionMessagesResponse(
val messages: List<SessionMessage>,
val offset: Int? = null,
val total: Int? = null,
)
@Serializable
data class SessionMessage(
val role: String? = null,
val content: String? = null,
val content: JsonElement? = null,
val timestamp: JsonElement? = null,
val type: String? = null,
) {
val timestampText: String?
get() = (timestamp as? JsonPrimitive)?.content
val contentText: String
get() =
when (content) {
is JsonPrimitive -> content.content
null -> ""
else -> content.toString()
}
}