feat(favorites): implement user favorites and recents functionality

Introduced a new API client for managing user favorites, allowing users to list, add, and remove starred resources. Enhanced the sidebar to display favorites and recents, improving user navigation. Updated internationalization files to include relevant labels and tooltips for the new features across multiple languages.

Refs: #1303
This commit is contained in:
wizardchen
2026-05-16 23:04:03 +08:00
committed by lyingbug
parent b905f18ebc
commit 8332a0dab6
28 changed files with 1874 additions and 251 deletions
+28
View File
@@ -165,6 +165,34 @@ func (h *CustomAgentHandler) ListAgents(c *gin.Context) {
return
}
// Optional creator filter — see the matching block in
// KnowledgeBaseHandler.ListKnowledgeBases for rationale. Built-in
// agents (IsBuiltin=true, CreatedBy="") are tenant-level fixtures
// rather than user creations; we always keep them regardless of the
// filter so the conversation dropdown never silently loses
// quick-answer / smart-reasoning when a user picks "Created by me".
creatorFilter := strings.ToLower(strings.TrimSpace(c.Query("creator")))
if creatorFilter == "mine" || creatorFilter == "others" {
callerUserID, _ := c.Get(types.UserIDContextKey.String())
callerUserIDStr, _ := callerUserID.(string)
filtered := make([]*types.CustomAgent, 0, len(agents))
for _, ag := range agents {
if ag.IsBuiltin {
filtered = append(filtered, ag)
continue
}
if ag.CreatedBy == "" {
continue
}
if creatorFilter == "mine" && ag.CreatedBy == callerUserIDStr {
filtered = append(filtered, ag)
} else if creatorFilter == "others" && ag.CreatedBy != callerUserIDStr {
filtered = append(filtered, ag)
}
}
agents = filtered
}
// Per-tenant "disabled by me" for own agents (only affects this tenant's conversation dropdown)
tenantIDVal, exists := c.Get(types.TenantIDContextKey.String())
if !exists {