Route the stop control's interrupt through one tested builder
Extract the single chat_interrupt frame into ChatProtocol.interruptRequest and have PipelinesRepository.chatInterrupt send it, so production and its unit test share the one wire shape instead of the repository building it inline. Add chatInterruptRequestCarriesTheRunningSession, which asserts the frame the stop control sends is chat_interrupt carrying the running session's id (and no chat prompt/reply) and that it survives the client's JSON round-trip. Document the slice and its emulator-5556 evidence in android/README.md.
This commit is contained in:
@@ -8,6 +8,7 @@ import kotlinx.serialization.json.JsonElement
|
||||
import net.awan.pipelines.data.protocol.ChatCreateRequest
|
||||
import net.awan.pipelines.data.protocol.ChatMessage
|
||||
import net.awan.pipelines.data.protocol.ChatPromptRequest
|
||||
import net.awan.pipelines.data.protocol.ChatProtocol
|
||||
import net.awan.pipelines.data.protocol.ChatQuery
|
||||
import net.awan.pipelines.data.protocol.ChatReplyRequest
|
||||
import net.awan.pipelines.data.protocol.ChatSession
|
||||
@@ -174,7 +175,7 @@ class PipelinesRepository(
|
||||
|
||||
suspend fun chatInterrupt(sessionId: String) {
|
||||
if (sessionId.isBlank()) throw ProtocolException("Select a chat session first.")
|
||||
client.call(Message(type = Protocol.CHAT_INTERRUPT, chatQuery = ChatQuery(sessionId = sessionId)))
|
||||
client.call(ChatProtocol.interruptRequest(sessionId))
|
||||
}
|
||||
|
||||
suspend fun chatReply(sessionId: String, requestId: String, decision: String, message: String = "") {
|
||||
|
||||
@@ -195,4 +195,12 @@ object ChatProtocol {
|
||||
TOOL_STREAMING, TOOL_RUNNING -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
/**
|
||||
* The `chat_interrupt` frame the composer's stop control sends: the server
|
||||
* aborts the in-flight turn for [sessionId]. Built here (not inline in the
|
||||
* repository) so production and its unit test share the one wire shape.
|
||||
*/
|
||||
fun interruptRequest(sessionId: String): Message =
|
||||
Message(type = Protocol.CHAT_INTERRUPT, chatQuery = ChatQuery(sessionId = sessionId))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user