feat: harden support, localize knowledge and add operator availability [skip ci]

Source-only publication of reviewed commit 64e96a7f423673dc29ad56485be9fc79bce8af1c.

Passed in isolation: focused frontend/backend tests, race checks, TypeScript typecheck, lint, Go compilation, Flowgram build, and deterministic SDK build/tests.

Not accepted as a production release: Next.js export/native assembly remains blocked by environment memory limits; browser interaction and MySQL staging acceptance remain unverified. No production server, database/schema, runtime configuration, deployment, release tag, or workflow execution was performed.

Expected source tree: 0a4a7528e9.
This commit is contained in:
2026-10-16 15:21:42 +00:00
parent 299ea50fb5
commit 2f7a491666
176 changed files with 11869 additions and 2716 deletions

View File

@@ -1,3 +1,4 @@
// Modified in AgentDeskNext: authenticated support availability and calendars.
package services
import (
@@ -117,11 +118,18 @@ func (s *dashboardService) GetOverview(rangeValue string, locale string) respons
}
func (s *dashboardService) buildAgentStats(now time.Time, teams []models.AgentTeam, profiles []models.AgentProfile, schedules []models.AgentTeamSchedule, conversations []models.Conversation) (int64, int64, int64, []response.DashboardTeamLoadResponse) {
const onlineWindow = 15 * time.Minute
userIDs := make([]int64, 0, len(profiles))
for _, profile := range profiles {
userIDs = append(userIDs, profile.UserID)
}
online, _ := SupportAvailabilityService.onlineUsers(sqls.DB(), userIDs, now)
scheduledTeamIDs := make(map[int64]bool, len(schedules))
for _, item := range schedules {
scheduledTeamIDs[item.TeamID] = true
for _, team := range teams {
calendar, err := SupportCalendarService.Evaluate(sqls.DB(), team.ID, now)
if err == nil {
scheduledTeamIDs[team.ID] = calendar.Open
}
}
type teamCounter struct {
@@ -151,10 +159,10 @@ func (s *dashboardService) buildAgentStats(now time.Time, teams []models.AgentTe
}
counter.totalAgents++
counter.maxConcurrentCapacity += int64(profile.MaxConcurrentCount)
if profile.LastOnlineAt != nil && now.Sub(*profile.LastOnlineAt) <= onlineWindow {
if online[profile.UserID] {
counter.onlineAgents++
onlineAgents++
if profile.ServiceStatus == enums.ServiceStatusBusy {
if effectiveSupportStatus(profile, now) == enums.ServiceStatusBusy {
counter.busyAgents++
busyAgents++
}
@@ -254,8 +262,11 @@ func (s *dashboardService) buildAlerts(now time.Time, db *gorm.DB, aiAgents []mo
}
scheduledTeamIDs := make(map[int64]bool, len(schedules))
for _, item := range schedules {
scheduledTeamIDs[item.TeamID] = true
for _, team := range teams {
calendar, err := SupportCalendarService.Evaluate(sqls.DB(), team.ID, now)
if err == nil {
scheduledTeamIDs[team.ID] = calendar.Open
}
}
var scheduleMissingCount int64
for _, team := range teams {