Files
wehub-resource-sync f99010fae1
Desktop Artifacts / Desktop Build (Linux) (push) Waiting to run
Desktop Artifacts / Desktop Build (Windows) (push) Waiting to run
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Waiting to run
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:36 +08:00

59 lines
1.6 KiB
Go

package sync
import (
"runtime/debug"
"go.kenn.io/agentsview/internal/db"
)
const recomputeHeapReleaseDefaultThreshold = 256 << 20
var (
recomputeHeapReleaseThreshold = recomputeHeapReleaseDefaultThreshold
freeRecomputeHeap = debug.FreeOSMemory
)
type recomputeHeapReleaser struct {
pendingBytes int
}
func (r *recomputeHeapReleaser) Account(heapBytes int) {
r.pendingBytes += heapBytes
if r.pendingBytes < recomputeHeapReleaseThreshold {
return
}
r.pendingBytes = 0
freeRecomputeHeap()
}
func recomputeHeapBytes(
msgs []db.Message, findings []db.SecretFinding,
) int {
total := 0
for _, msg := range msgs {
total += len(msg.Content) + len(msg.ThinkingText) +
len(msg.Timestamp) + len(msg.Model) + len(msg.TokenUsage) +
len(msg.ClaudeMessageID) + len(msg.ClaudeRequestID) +
len(msg.SourceType) + len(msg.SourceSubtype) +
len(msg.SourceUUID) + len(msg.SourceParentUUID)
for _, tc := range msg.ToolCalls {
total += len(tc.ToolName) + len(tc.Category) +
len(tc.ToolUseID) + len(tc.InputJSON) +
len(tc.FilePath) + len(tc.SkillName) +
len(tc.ResultContent) + len(tc.SubagentSessionID)
for _, ev := range tc.ResultEvents {
total += len(ev.ToolUseID) + len(ev.AgentID) +
len(ev.SubagentSessionID) + len(ev.Source) +
len(ev.Status) + len(ev.Content) +
len(ev.Timestamp)
}
}
}
for _, finding := range findings {
total += len(finding.SessionID) + len(finding.RuleName) +
len(finding.Confidence) + len(finding.LocationKind) +
len(finding.RedactedMatch) + len(finding.RulesVersion)
}
return total
}