Expose native chat compaction activity and retained replay

This commit is contained in:
2026-10-20 22:17:13 +01:00
parent d8b111913e
commit 4969d667b3
17 changed files with 666 additions and 26 deletions
+23 -8
View File
@@ -64,14 +64,15 @@ type chatMessage struct {
}
type chatTurn struct {
sessionID string
order []string
messages map[string]*chatMessage
step *protocol.ChatStep
usage *protocol.ChatUsage
size int
overflow bool
updated time.Time
compaction *protocol.ChatCompaction
sessionID string
order []string
messages map[string]*chatMessage
step *protocol.ChatStep
usage *protocol.ChatUsage
size int
overflow bool
updated time.Time
// permissions holds the request ids already pushed to the client so a
// repeated poll cannot push the same pending request twice; permissionOrder
// bounds it to chatPermissionRetainedLimit.
@@ -143,7 +144,21 @@ func (h *chatHub) applyLocked(frame protocol.ChatEventFrame) {
}
turn := h.turnLocked(frame.SessionID)
switch frame.Kind {
case protocol.ChatEventCompaction:
if frame.Compaction == nil {
return
}
if frame.Compaction.Status == "running" {
copy := *frame.Compaction
turn.compaction = &copy
} else if turn.compaction != nil && (frame.Compaction.ID == "" || turn.compaction.ID == frame.Compaction.ID) {
turn.compaction = nil
}
return
case protocol.ChatEventStep:
if frame.Step != nil && frame.Step.Status == protocol.ChatStepEnded && !frame.Step.Intermediate {
turn.compaction = nil
}
turn.step = frame.Step
return
case protocol.ChatEventUsage: