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
+36
View File
@@ -0,0 +1,36 @@
package opencode
import (
"context"
"encoding/json"
"time"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
// The canonical V2 Session.Message.Compaction union exposes status in history.
// Do not expose its summary, recent context or provider state as assistant text.
func (c *Chat) readCompaction(ctx context.Context, id string) *protocol.ChatCompaction {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
raw, err := c.call(ctx, "get", "/api/session/"+id+"/message?limit=50", nil)
if err != nil {
return nil
}
var page struct {
Data []struct {
Type string `json:"type"`
Status string `json:"status"`
} `json:"data"`
}
if json.Unmarshal(raw, &page) != nil {
return nil
}
for _, message := range page.Data {
if message.Type == "compaction" && message.Status == "running" {
// No id: public started/ended events cannot correlate history ids.
return &protocol.ChatCompaction{Status: "running"}
}
}
return nil
}