feat: add Citations and WatchlistChat components, integrate with API
- Implemented Citations component to display citation data. - Created WatchlistDrawer and ChatSidebar components for managing watchlists and AI chat functionality. - Integrated API calls for watchlist management and chat interactions. - Updated index.tsx to include new components in the main application layout. - Added API client in lib/api.ts for structured API interactions. - Developed Alerts, Dashboard, Portfolio, Routines, Screener, and Report pages with relevant data fetching and UI components. - Introduced styles in tokens.css for consistent theming across the application. - Configured TypeScript and Vite for project setup and development.
This commit is contained in:
1 parent
0db2cf28b3
commit
8c184ccae1
111 files changed
+12349
-62
No files matched your search
@@ -0,0 +1,52 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"flowsight/internal/model"
|
||||
)
|
||||
|
||||
// Health serves GET /api/health: last cycle time + credits spent today +
|
||||
// scheduler state + stale flags (docs/API.md).
|
||||
func (s *Server) Health(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Query().Get("force") == "1" {
|
||||
_ = s.Sched.RunCycle(r.Context()) // synchronous probe cycle
|
||||
}
|
||||
lastCycle, schedOK := s.Sched.Status()
|
||||
today := time.Now().Format("2006-01-02")
|
||||
credits := s.DB.CreditsToday(today)
|
||||
lastDate, _, _, _ := s.DB.LatestBriefing()
|
||||
cutoff := model.StaleSession(time.Now())
|
||||
stale := []string{}
|
||||
if lastDate != "" {
|
||||
if t, err := time.Parse("2006-01-02", lastDate[:10]); err == nil && t.Before(cutoff) {
|
||||
stale = append(stale, "briefing older than one session ("+lastDate+")")
|
||||
} else if lastDate < today {
|
||||
stale = append(stale, "briefing older than today ("+lastDate+")")
|
||||
}
|
||||
}
|
||||
if !s.Cfg.HasSectorsKey() {
|
||||
stale = append(stale, "offline mode: SECTORS_API_KEY unset, serving seed data")
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"last_cycle_at": lastCycle,
|
||||
"credits_today": credits,
|
||||
"scheduler_ok": schedOK,
|
||||
"stale_flags": stale,
|
||||
"citations": []model.Citation{},
|
||||
})
|
||||
}
|
||||
|
||||
// Accuracy serves GET /api/accuracy: per-agent {calls, resolved, hits, hit_rate}.
|
||||
func (s *Server) Accuracy(w http.ResponseWriter, r *http.Request) {
|
||||
stats, err := s.DB.AccuracyStats()
|
||||
if err != nil {
|
||||
writeErr(w, http.StatusBadGateway, "db: "+err.Error())
|
||||
return
|
||||
}
|
||||
if stats == nil {
|
||||
stats = []map[string]any{}
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"agents": stats})
|
||||
}
|
||||
Reference in new issue
Block a user