feat: add warning/error message type and skip TTS in voice mode
Add `type: "warning"` to context compression and memory optimization notifications on the Go server. Propagate messageType through the Android data layer (Entity → Mapper → Domain) so voice mode can detect warning/error messages and display them without reading aloud. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a66be29993
commit
1e5d740bf2
6 changed files with 16 additions and 6 deletions
|
|
@ -10,5 +10,6 @@ data class MessageEntity(
|
|||
val sender: String,
|
||||
val imagePathList: String?,
|
||||
val timestamp: Long,
|
||||
val status: String
|
||||
val status: String,
|
||||
val messageType: String? = null
|
||||
)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ object MessageMapper {
|
|||
sender = MessageSender.valueOf(entity.sender),
|
||||
images = images,
|
||||
timestamp = entity.timestamp,
|
||||
status = MessageStatus.valueOf(entity.status)
|
||||
status = MessageStatus.valueOf(entity.status),
|
||||
messageType = entity.messageType
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +48,8 @@ object MessageMapper {
|
|||
sender = MessageSender.AGENT.name,
|
||||
imagePathList = null,
|
||||
timestamp = System.currentTimeMillis(),
|
||||
status = MessageStatus.RECEIVED.name
|
||||
status = MessageStatus.RECEIVED.name,
|
||||
messageType = dto.type
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ data class ChatMessage(
|
|||
val sender: MessageSender,
|
||||
val images: List<ImageData> = emptyList(),
|
||||
val timestamp: Long,
|
||||
val status: MessageStatus
|
||||
val status: MessageStatus,
|
||||
val messageType: String? = null
|
||||
)
|
||||
|
||||
enum class MessageSender { USER, AGENT }
|
||||
|
|
|
|||
|
|
@ -97,11 +97,15 @@ class VoiceModeManager(
|
|||
msg.status == MessageStatus.RECEIVED
|
||||
) {
|
||||
spokenIds.add(msg.id)
|
||||
if (msg.messageType == "warning" || msg.messageType == "error") {
|
||||
_state.update { it.copy(responseText = msg.content) }
|
||||
} else {
|
||||
speechQueue.send(msg.content)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
while (isActive) {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ fun VoiceModeOverlay(
|
|||
)
|
||||
}
|
||||
|
||||
if (state.responseText.isNotEmpty() && state.phase == VoicePhase.SPEAKING) {
|
||||
if (state.responseText.isNotEmpty() && (state.phase == VoicePhase.SPEAKING || state.phase == VoicePhase.THINKING)) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text = state.responseText,
|
||||
|
|
|
|||
|
|
@ -663,6 +663,7 @@ func (al *AgentLoop) runLLMIteration(ctx context.Context, messages []providers.M
|
|||
Channel: opts.Channel,
|
||||
ChatID: opts.ChatID,
|
||||
Content: "⚠️ Context window exceeded. Compressing history and retrying...",
|
||||
Type: "warning",
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -947,6 +948,7 @@ func (al *AgentLoop) maybeSummarize(sessionKey, channel, chatID string) {
|
|||
Channel: channel,
|
||||
ChatID: chatID,
|
||||
Content: "⚠️ Memory threshold reached. Optimizing conversation history...",
|
||||
Type: "warning",
|
||||
})
|
||||
}
|
||||
al.summarizeSession(sessionKey)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue