robustness: shared HTTP client, HTTP status checks, abort controller, streaming perf

- web.go: reuse shared binanceClient with connection pooling instead of per-request client
- sentinel.go: check HTTP status code before parsing Binance ticker response
- brain.go: check HTTP status codes in news scan and market brief APIs
- brain.go: add cleanStaleSignals() to prevent unbounded sync.Map growth
- scheduler.go: periodically clean expired pending trades
- AgentChatPage.tsx: add AbortController to cancel in-flight requests
- AgentChatPage.tsx: check response.ok before parsing JSON
- AgentChatPage.tsx: batch word streaming (~40 frames max) to reduce re-renders
- AgentChatPage.tsx: handle AbortError gracefully (remove orphan bot message)
This commit is contained in:
shinchan-zhai
2026-03-23 11:10:19 +08:00
parent 7ccac89e2b
commit b9c9f05603
5 changed files with 79 additions and 22 deletions

View File

@@ -43,10 +43,14 @@ func (s *Scheduler) Start(ctx context.Context) {
lastCheck = now
}
// Clean stale chat history every hour (sessions idle > 24h)
// and expired pending trades
if now.Sub(lastCleanup) > 1*time.Hour {
if s.agent.history != nil {
s.agent.history.CleanOld(24 * time.Hour)
}
if s.agent.pending != nil {
s.agent.pending.CleanExpired()
}
lastCleanup = now
}
}