fix(context): expose history tokens and remove leaked state files

Address remaining review feedback: 1) Add HistoryTokens field to ContextUsage/ContextStats, showing history-only token count in /context and frontend UI alongside SummarizeAtTokens so users can see the actual summarization trigger comparison. 2) Remove .codebuddy/github-contribute/ state files accidentally included in the PR.
This commit is contained in:
程智超0668000959
2026-06-06 00:28:32 +08:00
parent b6030f054d
commit 7a7e205cc8
15 changed files with 25 additions and 90 deletions
+1
View File
@@ -1396,6 +1396,7 @@ func setContextUsagePayload(payload map[string]any, u *bus.ContextUsage) {
payload["context_usage"] = map[string]any{
"used_tokens": u.UsedTokens,
"total_tokens": u.TotalTokens,
"history_tokens": u.HistoryTokens,
"compress_at_tokens": u.CompressAtTokens,
"summarize_at_tokens": u.SummarizeAtTokens,
"used_percent": u.UsedPercent,
+4
View File
@@ -604,6 +604,7 @@ func TestBeginStream_FinalizeIncludesContextUsage(t *testing.T) {
if err := contextStreamer.FinalizeWithContext(context.Background(), "final", &bus.ContextUsage{
UsedTokens: 10,
TotalTokens: 100,
HistoryTokens: 5,
CompressAtTokens: 80,
SummarizeAtTokens: 60,
UsedPercent: 10,
@@ -628,6 +629,9 @@ func TestBeginStream_FinalizeIncludesContextUsage(t *testing.T) {
if got := rawUsage["used_tokens"]; got != float64(10) {
t.Fatalf("used_tokens = %#v, want 10", got)
}
if got := rawUsage["history_tokens"]; got != float64(5) {
t.Fatalf("history_tokens = %#v, want 5", got)
}
if got := rawUsage["summarize_at_tokens"]; got != float64(60) {
t.Fatalf("summarize_at_tokens = %#v, want 60", got)
}