Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(goals): search the goals page and find goals from the command menu (#23206)

Rdmclin2fc62f7169da6
diff --git a/apps/server/src/routers/lambda/search.ts b/apps/server/src/routers/lambda/search.ts
index d79e9178350..f89ad07fbe9 100644
--- a/apps/server/src/routers/lambda/search.ts
+++ b/apps/server/src/routers/lambda/search.ts
@@ -99,8 +99,7 @@ export const searchRouter = router({
includeMarketplace: z.boolean().optional(),
/**
* Whether an untyped search also returns goals (default false). The
- * command menu has no goal rendering yet; the CLI opts in. `type:
- * 'goal'` always searches goals.
+ * command menu and the CLI opt in. `type: 'goal'` always searches goals.
*/
includeGoals: z.boolean().optional(),
limitPerType: z.number().optional(),
diff --git a/locales/ar/chat.json b/locales/ar/chat.json
index 3b4e46d91df..783e65bb887 100644
--- a/locales/ar/chat.json
+++ b/locales/ar/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "تم التسليم",
"goalPage.metrics.pursuing": "مفتوح",
"goalPage.metrics.total": "إجمالي الأهداف",
+ "goalPage.searchEmptyDescription": "جرّب كلمة مفتاحية أخرى أو بدّل علامة التبويب.",
+ "goalPage.searchEmptyTitle": "لا توجد أهداف تطابق \"{{keyword}}\"",
+ "goalPage.searchPartial": "تم البحث هنا في أحدث {{loaded}} هدفًا فقط من أصل {{total}}. استخدم البحث العام للعثور على الأهداف الأقدم.",
+ "goalPage.searchPlaceholder": "البحث في الأهداف",
"goalPage.title": "نظرة عامة",
"goalPage.view.card": "بطاقات",
"goalPage.view.list": "قائمة",
diff --git a/locales/ar/common.json b/locales/ar/common.json
index 9d28cc7510c..753866bb4eb 100644
--- a/locales/ar/common.json
+++ b/locales/ar/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "ملفات",
"cmdk.search.folder": "مجلد",
"cmdk.search.folders": "مجلدات",
+ "cmdk.search.goal": "هدف",
+ "cmdk.search.goals": "الأهداف",
"cmdk.search.knowledgeBase": "المكتبة",
"cmdk.search.knowledgeBases": "المكتبات",
"cmdk.search.loading": "يتم البحث...",
diff --git a/locales/bg-BG/chat.json b/locales/bg-BG/chat.json
index fd93dbee0d0..81c9132b6e1 100644
--- a/locales/bg-BG/chat.json
+++ b/locales/bg-BG/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Доставени",
"goalPage.metrics.pursuing": "Отворени",
"goalPage.metrics.total": "Общо цели",
+ "goalPage.searchEmptyDescription": "Опитайте друга ключова дума или сменете раздела.",
+ "goalPage.searchEmptyTitle": "Няма цели, съвпадащи с „{{keyword}}“",
+ "goalPage.searchPartial": "Тук бяха претърсени само най-новите {{loaded}} от {{total}} цели. Използвайте глобалното търсене за по-старите.",
+ "goalPage.searchPlaceholder": "Търсене на цели",
"goalPage.title": "Преглед",
"goalPage.view.card": "Карти",
"goalPage.view.list": "Списък",
diff --git a/locales/bg-BG/common.json b/locales/bg-BG/common.json
index 634264325e4..f77aef121bf 100644
--- a/locales/bg-BG/common.json
+++ b/locales/bg-BG/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Файлове",
"cmdk.search.folder": "Папка",
"cmdk.search.folders": "Папки",
+ "cmdk.search.goal": "Цел",
+ "cmdk.search.goals": "Цели",
"cmdk.search.knowledgeBase": "Библиотека",
"cmdk.search.knowledgeBases": "Библиотеки",
"cmdk.search.loading": "Търсене...",
diff --git a/locales/de-DE/chat.json b/locales/de-DE/chat.json
index b53385f8349..76acb515c0d 100644
--- a/locales/de-DE/chat.json
+++ b/locales/de-DE/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Geliefert",
"goalPage.metrics.pursuing": "Offen",
"goalPage.metrics.total": "Gesamtziele",
+ "goalPage.searchEmptyDescription": "Versuche ein anderes Stichwort oder wechsle den Tab.",
+ "goalPage.searchEmptyTitle": "Keine Ziele passen zu „{{keyword}}“",
+ "goalPage.searchPartial": "Hier wurden nur die neuesten {{loaded}} von {{total}} Zielen durchsucht. Ältere Ziele findest du über die globale Suche.",
+ "goalPage.searchPlaceholder": "Ziele durchsuchen",
"goalPage.title": "Übersicht",
"goalPage.view.card": "Karten",
"goalPage.view.list": "Liste",
diff --git a/locales/de-DE/common.json b/locales/de-DE/common.json
index 0b90abe6c21..82bfa148c02 100644
--- a/locales/de-DE/common.json
+++ b/locales/de-DE/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Dateien",
"cmdk.search.folder": "Ordner",
"cmdk.search.folders": "Ordner",
+ "cmdk.search.goal": "Ziel",
+ "cmdk.search.goals": "Ziele",
"cmdk.search.knowledgeBase": "Bibliothek",
"cmdk.search.knowledgeBases": "Bibliotheken",
"cmdk.search.loading": "Suche läuft...",
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 1762588f94b..66b3ae86b88 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -804,6 +804,10 @@
"goalPage.metrics.delivered": "Needs you",
"goalPage.metrics.pursuing": "Others",
"goalPage.metrics.total": "Total goals",
+ "goalPage.searchEmptyDescription": "Try another keyword or switch tabs.",
+ "goalPage.searchEmptyTitle": "No goals match “{{keyword}}”",
+ "goalPage.searchPartial": "Only the newest {{loaded}} of {{total}} goals were searched here. Use global search to find older ones.",
+ "goalPage.searchPlaceholder": "Search goals",
"goalPage.title": "Overview",
"goalPage.view.card": "Cards",
"goalPage.view.list": "List",
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index aae12cb1ee2..5acce9b40f2 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -149,6 +149,8 @@
"cmdk.search.files": "Files",
"cmdk.search.folder": "Folder",
"cmdk.search.folders": "Folders",
+ "cmdk.search.goal": "Goal",
+ "cmdk.search.goals": "Goals",
"cmdk.search.knowledgeBase": "Library",
"cmdk.search.knowledgeBases": "Libraries",
"cmdk.search.loading": "Searching...",
diff --git a/locales/es-ES/chat.json b/locales/es-ES/chat.json
index 62331c2f337..7da1d94449c 100644
--- a/locales/es-ES/chat.json
+++ b/locales/es-ES/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Entregados",
"goalPage.metrics.pursuing": "Abiertos",
"goalPage.metrics.total": "Total de objetivos",
+ "goalPage.searchEmptyDescription": "Prueba otra palabra clave o cambia de pestaña.",
+ "goalPage.searchEmptyTitle": "Ningún objetivo coincide con «{{keyword}}»",
+ "goalPage.searchPartial": "Aquí solo se buscaron los {{loaded}} objetivos más recientes de {{total}}. Usa la búsqueda global para encontrar los anteriores.",
+ "goalPage.searchPlaceholder": "Buscar objetivos",
"goalPage.title": "Resumen",
"goalPage.view.card": "Tarjetas",
"goalPage.view.list": "Lista",
diff --git a/locales/es-ES/common.json b/locales/es-ES/common.json
index 847b9c4cad0..f2f1a9c55f1 100644
--- a/locales/es-ES/common.json
+++ b/locales/es-ES/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Archivos",
"cmdk.search.folder": "Carpeta",
"cmdk.search.folders": "Carpetas",
+ "cmdk.search.goal": "Objetivo",
+ "cmdk.search.goals": "Objetivos",
"cmdk.search.knowledgeBase": "Biblioteca",
"cmdk.search.knowledgeBases": "Bibliotecas",
"cmdk.search.loading": "Buscando...",
diff --git a/locales/fa-IR/chat.json b/locales/fa-IR/chat.json
index c1dac031f38..75d566f0ddb 100644
--- a/locales/fa-IR/chat.json
+++ b/locales/fa-IR/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "تحویل داده شده",
"goalPage.metrics.pursuing": "باز",
"goalPage.metrics.total": "کل اهداف",
+ "goalPage.searchEmptyDescription": "کلیدواژه دیگری امتحان کنید یا زبانه را عوض کنید.",
+ "goalPage.searchEmptyTitle": "هیچ هدفی با «{{keyword}}» مطابقت ندارد",
+ "goalPage.searchPartial": "اینجا فقط {{loaded}} هدف جدیدتر از {{total}} هدف جستجو شد. برای اهداف قدیمی‌تر از جستجوی سراسری استفاده کنید.",
+ "goalPage.searchPlaceholder": "جستجوی اهداف",
"goalPage.title": "نمای کلی",
"goalPage.view.card": "کارت‌ها",
"goalPage.view.list": "لیست",
diff --git a/locales/fa-IR/common.json b/locales/fa-IR/common.json
index ac358171516..7a22bdb44d2 100644
--- a/locales/fa-IR/common.json
+++ b/locales/fa-IR/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "فایل‌ها",
"cmdk.search.folder": "پوشه",
"cmdk.search.folders": "پوشه‌ها",
+ "cmdk.search.goal": "هدف",
+ "cmdk.search.goals": "اهداف",
"cmdk.search.knowledgeBase": "کتابخانه",
"cmdk.search.knowledgeBases": "کتابخانه‌ها",
"cmdk.search.loading": "در حال جستجو...",
diff --git a/locales/fr-FR/chat.json b/locales/fr-FR/chat.json
index 1d58b0fffbf..5c922b36072 100644
--- a/locales/fr-FR/chat.json
+++ b/locales/fr-FR/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Livrés",
"goalPage.metrics.pursuing": "Ouverts",
"goalPage.metrics.total": "Total des objectifs",
+ "goalPage.searchEmptyDescription": "Essayez un autre mot-clé ou changez d’onglet.",
+ "goalPage.searchEmptyTitle": "Aucun objectif ne correspond à « {{keyword}} »",
+ "goalPage.searchPartial": "Seuls les {{loaded}} objectifs les plus récents sur {{total}} ont été recherchés ici. Utilisez la recherche globale pour les plus anciens.",
+ "goalPage.searchPlaceholder": "Rechercher des objectifs",
"goalPage.title": "Vue d'ensemble",
"goalPage.view.card": "Cartes",
"goalPage.view.list": "Liste",
diff --git a/locales/fr-FR/common.json b/locales/fr-FR/common.json
index 694a805b211..86acc44cf31 100644
--- a/locales/fr-FR/common.json
+++ b/locales/fr-FR/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Fichiers",
"cmdk.search.folder": "Dossier",
"cmdk.search.folders": "Dossiers",
+ "cmdk.search.goal": "Objectif",
+ "cmdk.search.goals": "Objectifs",
"cmdk.search.knowledgeBase": "Bibliothèque",
"cmdk.search.knowledgeBases": "Bibliothèques",
"cmdk.search.loading": "Recherche en cours...",
diff --git a/locales/it-IT/chat.json b/locales/it-IT/chat.json
index 54df6210f86..b5bf376b0af 100644
--- a/locales/it-IT/chat.json
+++ b/locales/it-IT/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Consegnati",
"goalPage.metrics.pursuing": "Aperti",
"goalPage.metrics.total": "Obiettivi totali",
+ "goalPage.searchEmptyDescription": "Prova un’altra parola chiave o cambia scheda.",
+ "goalPage.searchEmptyTitle": "Nessun obiettivo corrisponde a “{{keyword}}”",
+ "goalPage.searchPartial": "Qui sono stati cercati solo i {{loaded}} obiettivi più recenti su {{total}}. Usa la ricerca globale per trovare quelli più vecchi.",
+ "goalPage.searchPlaceholder": "Cerca obiettivi",
"goalPage.title": "Panoramica",
"goalPage.view.card": "Schede",
"goalPage.view.list": "Elenco",
diff --git a/locales/it-IT/common.json b/locales/it-IT/common.json
index f0d66d5c786..4a6cc0461b6 100644
--- a/locales/it-IT/common.json
+++ b/locales/it-IT/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "File",
"cmdk.search.folder": "Cartella",
"cmdk.search.folders": "Cartelle",
+ "cmdk.search.goal": "Obiettivo",
+ "cmdk.search.goals": "Obiettivi",
"cmdk.search.knowledgeBase": "Libreria",
"cmdk.search.knowledgeBases": "Librerie",
"cmdk.search.loading": "Ricerca in corso...",
diff --git a/locales/ja-JP/chat.json b/locales/ja-JP/chat.json
index 854a593b1cf..08053e040db 100644
--- a/locales/ja-JP/chat.json
+++ b/locales/ja-JP/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "配信済み",
"goalPage.metrics.pursuing": "進行中",
"goalPage.metrics.total": "総目標数",
+ "goalPage.searchEmptyDescription": "別のキーワードを試すか、タブを切り替えてください。",
+ "goalPage.searchEmptyTitle": "「{{keyword}}」に一致する目標はありません",
+ "goalPage.searchPartial": "ここでは最新の {{loaded}} 件(全 {{total}} 件)のみ検索しました。古い目標はグローバル検索で探してください。",
+ "goalPage.searchPlaceholder": "目標を検索",
"goalPage.title": "概要",
"goalPage.view.card": "カード",
"goalPage.view.list": "リスト",
diff --git a/locales/ja-JP/common.json b/locales/ja-JP/common.json
index b2e1dddcb8c..665803f279b 100644
--- a/locales/ja-JP/common.json
+++ b/locales/ja-JP/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "ファイル",
"cmdk.search.folder": "フォルダー",
"cmdk.search.folders": "フォルダー一覧",
+ "cmdk.search.goal": "目標",
+ "cmdk.search.goals": "目標",
"cmdk.search.knowledgeBase": "ライブラリ",
"cmdk.search.knowledgeBases": "ライブラリ",
"cmdk.search.loading": "検索中…",
diff --git a/locales/ko-KR/chat.json b/locales/ko-KR/chat.json
index 1f2f78fd723..8e396a7cdc7 100644
--- a/locales/ko-KR/chat.json
+++ b/locales/ko-KR/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "전달됨",
"goalPage.metrics.pursuing": "진행 중",
"goalPage.metrics.total": "총 목표",
+ "goalPage.searchEmptyDescription": "다른 키워드를 입력하거나 탭을 바꿔 보세요.",
+ "goalPage.searchEmptyTitle": "“{{keyword}}”와 일치하는 목표가 없습니다",
+ "goalPage.searchPartial": "여기서는 최신 {{loaded}}개(전체 {{total}}개)만 검색했습니다. 이전 목표는 전역 검색으로 찾아보세요.",
+ "goalPage.searchPlaceholder": "목표 검색",
"goalPage.title": "개요",
"goalPage.view.card": "카드",
"goalPage.view.list": "목록",
diff --git a/locales/ko-KR/common.json b/locales/ko-KR/common.json
index f9ee41cab02..df4cafdcc41 100644
--- a/locales/ko-KR/common.json
+++ b/locales/ko-KR/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "파일",
"cmdk.search.folder": "폴더",
"cmdk.search.folders": "폴더들",
+ "cmdk.search.goal": "목표",
+ "cmdk.search.goals": "목표",
"cmdk.search.knowledgeBase": "도서관",
"cmdk.search.knowledgeBases": "도서관들",
"cmdk.search.loading": "검색 중…",
diff --git a/locales/nl-NL/chat.json b/locales/nl-NL/chat.json
index c4b7b6ffd52..34707185ea9 100644
--- a/locales/nl-NL/chat.json
+++ b/locales/nl-NL/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Afgeleverd",
"goalPage.metrics.pursuing": "Open",
"goalPage.metrics.total": "Totale doelen",
+ "goalPage.searchEmptyDescription": "Probeer een ander trefwoord of wissel van tabblad.",
+ "goalPage.searchEmptyTitle": "Geen doelen komen overeen met “{{keyword}}”",
+ "goalPage.searchPartial": "Hier zijn alleen de nieuwste {{loaded}} van {{total}} doelen doorzocht. Gebruik de globale zoekfunctie voor oudere doelen.",
+ "goalPage.searchPlaceholder": "Doelen zoeken",
"goalPage.title": "Overzicht",
"goalPage.view.card": "Kaarten",
"goalPage.view.list": "Lijst",
diff --git a/locales/nl-NL/common.json b/locales/nl-NL/common.json
index 2cf2683a497..aff96ad8442 100644
--- a/locales/nl-NL/common.json
+++ b/locales/nl-NL/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Bestanden",
"cmdk.search.folder": "Map",
"cmdk.search.folders": "Mappen",
+ "cmdk.search.goal": "Doel",
+ "cmdk.search.goals": "Doelen",
"cmdk.search.knowledgeBase": "Bibliotheek",
"cmdk.search.knowledgeBases": "Bibliotheken",
"cmdk.search.loading": "Zoeken...",
diff --git a/locales/pl-PL/chat.json b/locales/pl-PL/chat.json
index 16ec0ad1001..d5b3f6d8817 100644
--- a/locales/pl-PL/chat.json
+++ b/locales/pl-PL/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Dostarczone",
"goalPage.metrics.pursuing": "Otwarte",
"goalPage.metrics.total": "Wszystkie cele",
+ "goalPage.searchEmptyDescription": "Spróbuj innego słowa kluczowego lub zmień kartę.",
+ "goalPage.searchEmptyTitle": "Brak celów pasujących do „{{keyword}}”",
+ "goalPage.searchPartial": "Przeszukano tu tylko {{loaded}} najnowszych z {{total}} celów. Starsze znajdziesz w wyszukiwaniu globalnym.",
+ "goalPage.searchPlaceholder": "Szukaj celów",
"goalPage.title": "Przegląd",
"goalPage.view.card": "Karty",
"goalPage.view.list": "Lista",
diff --git a/locales/pl-PL/common.json b/locales/pl-PL/common.json
index d2ef0f2f393..6b724eb926d 100644
--- a/locales/pl-PL/common.json
+++ b/locales/pl-PL/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Pliki",
"cmdk.search.folder": "Folder",
"cmdk.search.folders": "Foldery",
+ "cmdk.search.goal": "Cel",
+ "cmdk.search.goals": "Cele",
"cmdk.search.knowledgeBase": "Biblioteka",
"cmdk.search.knowledgeBases": "Biblioteki",
"cmdk.search.loading": "Wyszukiwanie...",
diff --git a/locales/pt-BR/chat.json b/locales/pt-BR/chat.json
index 0d43c99ceb5..503c343259c 100644
--- a/locales/pt-BR/chat.json
+++ b/locales/pt-BR/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Entregues",
"goalPage.metrics.pursuing": "Em aberto",
"goalPage.metrics.total": "Total de objetivos",
+ "goalPage.searchEmptyDescription": "Tente outra palavra-chave ou troque de aba.",
+ "goalPage.searchEmptyTitle": "Nenhum objetivo corresponde a “{{keyword}}”",
+ "goalPage.searchPartial": "Aqui foram pesquisados apenas os {{loaded}} objetivos mais recentes de {{total}}. Use a pesquisa global para encontrar os mais antigos.",
+ "goalPage.searchPlaceholder": "Pesquisar objetivos",
"goalPage.title": "Visão geral",
"goalPage.view.card": "Cartões",
"goalPage.view.list": "Lista",
diff --git a/locales/pt-BR/common.json b/locales/pt-BR/common.json
index 5b8e96b5dfd..1f3638621c9 100644
--- a/locales/pt-BR/common.json
+++ b/locales/pt-BR/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Arquivos",
"cmdk.search.folder": "Pasta",
"cmdk.search.folders": "Pastas",
+ "cmdk.search.goal": "Objetivo",
+ "cmdk.search.goals": "Objetivos",
"cmdk.search.knowledgeBase": "Biblioteca",
"cmdk.search.knowledgeBases": "Bibliotecas",
"cmdk.search.loading": "Pesquisando...",
diff --git a/locales/ru-RU/chat.json b/locales/ru-RU/chat.json
index 9bb5a370adf..a9039db0a64 100644
--- a/locales/ru-RU/chat.json
+++ b/locales/ru-RU/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Доставлено",
"goalPage.metrics.pursuing": "Открытые",
"goalPage.metrics.total": "Всего целей",
+ "goalPage.searchEmptyDescription": "Попробуйте другое ключевое слово или переключите вкладку.",
+ "goalPage.searchEmptyTitle": "Нет целей, соответствующих «{{keyword}}»",
+ "goalPage.searchPartial": "Здесь поиск выполнен только по {{loaded}} последним целям из {{total}}. Более старые ищите через глобальный поиск.",
+ "goalPage.searchPlaceholder": "Поиск целей",
"goalPage.title": "Обзор",
"goalPage.view.card": "Карточки",
"goalPage.view.list": "Список",
diff --git a/locales/ru-RU/common.json b/locales/ru-RU/common.json
index 3735fe8dbb8..7b9b97579b4 100644
--- a/locales/ru-RU/common.json
+++ b/locales/ru-RU/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Файлы",
"cmdk.search.folder": "Папка",
"cmdk.search.folders": "Папки",
+ "cmdk.search.goal": "Цель",
+ "cmdk.search.goals": "Цели",
"cmdk.search.knowledgeBase": "Библиотека",
"cmdk.search.knowledgeBases": "Библиотеки",
"cmdk.search.loading": "Поиск...",
diff --git a/locales/tr-TR/chat.json b/locales/tr-TR/chat.json
index f2dd0ba2654..7b7e44b09b5 100644
--- a/locales/tr-TR/chat.json
+++ b/locales/tr-TR/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Teslim edildi",
"goalPage.metrics.pursuing": "Açık",
"goalPage.metrics.total": "Toplam hedefler",
+ "goalPage.searchEmptyDescription": "Başka bir anahtar kelime deneyin veya sekme değiştirin.",
+ "goalPage.searchEmptyTitle": "“{{keyword}}” ile eşleşen hedef yok",
+ "goalPage.searchPartial": "Burada yalnızca en yeni {{loaded}} hedef ({{total}} hedeften) arandı. Daha eski hedefler için genel aramayı kullanın.",
+ "goalPage.searchPlaceholder": "Hedeflerde ara",
"goalPage.title": "Genel Bakış",
"goalPage.view.card": "Kartlar",
"goalPage.view.list": "Liste",
diff --git a/locales/tr-TR/common.json b/locales/tr-TR/common.json
index 7e86b0dbb3d..8c87d67a385 100644
--- a/locales/tr-TR/common.json
+++ b/locales/tr-TR/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Dosyalar",
"cmdk.search.folder": "Klasör",
"cmdk.search.folders": "Klasörler",
+ "cmdk.search.goal": "Hedef",
+ "cmdk.search.goals": "Hedefler",
"cmdk.search.knowledgeBase": "Kütüphane",
"cmdk.search.knowledgeBases": "Kütüphaneler",
"cmdk.search.loading": "Aranıyor...",
diff --git a/locales/vi-VN/chat.json b/locales/vi-VN/chat.json
index 8fb0054f8a9..b80ab430607 100644
--- a/locales/vi-VN/chat.json
+++ b/locales/vi-VN/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "Đã hoàn thành",
"goalPage.metrics.pursuing": "Đang mở",
"goalPage.metrics.total": "Tổng số mục tiêu",
+ "goalPage.searchEmptyDescription": "Hãy thử từ khóa khác hoặc chuyển tab.",
+ "goalPage.searchEmptyTitle": "Không có mục tiêu nào khớp với “{{keyword}}”",
+ "goalPage.searchPartial": "Chỉ tìm trong {{loaded}} mục tiêu mới nhất (trên tổng {{total}}). Dùng tìm kiếm toàn cục để tìm các mục tiêu cũ hơn.",
+ "goalPage.searchPlaceholder": "Tìm mục tiêu",
"goalPage.title": "Tổng quan",
"goalPage.view.card": "Thẻ",
"goalPage.view.list": "Danh sách",
diff --git a/locales/vi-VN/common.json b/locales/vi-VN/common.json
index ab0e28f7f8f..e35572f12b3 100644
--- a/locales/vi-VN/common.json
+++ b/locales/vi-VN/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "Tệp",
"cmdk.search.folder": "Thư mục",
"cmdk.search.folders": "Các thư mục",
+ "cmdk.search.goal": "Mục tiêu",
+ "cmdk.search.goals": "Mục tiêu",
"cmdk.search.knowledgeBase": "Thư viện",
"cmdk.search.knowledgeBases": "Các thư viện",
"cmdk.search.loading": "Đang tìm kiếm...",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index e41db3077a1..edcd87ab2ba 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -804,6 +804,10 @@
"goalPage.metrics.delivered": "等你处理",
"goalPage.metrics.pursuing": "其余",
"goalPage.metrics.total": "目标总数",
+ "goalPage.searchEmptyDescription": "换个关键词,或切换到其他分类看看。",
+ "goalPage.searchEmptyTitle": "没有匹配「{{keyword}}」的目标",
+ "goalPage.searchPartial": "这里只搜索了最新的 {{loaded}} 个目标(共 {{total}} 个),更早的目标请用全局搜索查找。",
+ "goalPage.searchPlaceholder": "搜索目标",
"goalPage.title": "概览",
"goalPage.view.card": "卡片",
"goalPage.view.list": "列表",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index 714f7966f68..c4e126a4161 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -149,6 +149,8 @@
"cmdk.search.files": "文件",
"cmdk.search.folder": "文件夹",
"cmdk.search.folders": "文件夹",
+ "cmdk.search.goal": "目标",
+ "cmdk.search.goals": "目标",
"cmdk.search.knowledgeBase": "知识库",
"cmdk.search.knowledgeBases": "知识库",
"cmdk.search.loading": "搜索中…",
diff --git a/locales/zh-TW/chat.json b/locales/zh-TW/chat.json
index 827ef4344e6..3c5e41a8e09 100644
--- a/locales/zh-TW/chat.json
+++ b/locales/zh-TW/chat.json
@@ -790,6 +790,10 @@
"goalPage.metrics.delivered": "已交付",
"goalPage.metrics.pursuing": "進行中",
"goalPage.metrics.total": "總目標數",
+ "goalPage.searchEmptyDescription": "換個關鍵字,或切換到其他分類看看。",
+ "goalPage.searchEmptyTitle": "沒有符合「{{keyword}}」的目標",
+ "goalPage.searchPartial": "這裡只搜尋了最新的 {{loaded}} 個目標(共 {{total}} 個),較早的目標請使用全域搜尋查找。",
+ "goalPage.searchPlaceholder": "搜尋目標",
"goalPage.title": "概覽",
"goalPage.view.card": "卡片",
"goalPage.view.list": "列表",
diff --git a/locales/zh-TW/common.json b/locales/zh-TW/common.json
index d6bfa0c850c..a426b9fcdad 100644
--- a/locales/zh-TW/common.json
+++ b/locales/zh-TW/common.json
@@ -147,6 +147,8 @@
"cmdk.search.files": "檔案",
"cmdk.search.folder": "資料夾",
"cmdk.search.folders": "資料夾",
+ "cmdk.search.goal": "目標",
+ "cmdk.search.goals": "目標",
"cmdk.search.knowledgeBase": "圖書館",
"cmdk.search.knowledgeBases": "圖書館",
"cmdk.search.loading": "搜尋中...",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 95ac71cb0f8..ceea4dd2939 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -3205,6 +3205,11 @@ export default {
'goalPage.metrics.delivered': 'Needs you',
'goalPage.metrics.pursuing': 'Others',
'goalPage.metrics.total': 'Total goals',
+ 'goalPage.searchEmptyDescription': 'Try another keyword or switch tabs.',
+ 'goalPage.searchEmptyTitle': 'No goals match “{{keyword}}”',
+ 'goalPage.searchPartial':
+ 'Only the newest {{loaded}} of {{total}} goals were searched here. Use global search to find older ones.',
+ 'goalPage.searchPlaceholder': 'Search goals',
'goalPage.title': 'Overview',
'goalPage.view.card': 'Cards',
'goalPage.view.list': 'List',
diff --git a/packages/locales/src/default/common.ts b/packages/locales/src/default/common.ts
index 5ecff126816..cc2bc83b764 100644
--- a/packages/locales/src/default/common.ts
+++ b/packages/locales/src/default/common.ts
@@ -201,6 +201,10 @@ export default {
'cmdk.search.folders': 'Folders',
+ 'cmdk.search.goal': 'Goal',
+
+ 'cmdk.search.goals': 'Goals',
+
'cmdk.search.knowledgeBase': 'Library',
'cmdk.search.knowledgeBases': 'Libraries',
diff --git a/src/features/AgentGoals/AgentGoalsPage.tsx b/src/features/AgentGoals/AgentGoalsPage.tsx
index 5368fa7c044..d01e059c162 100644
--- a/src/features/AgentGoals/AgentGoalsPage.tsx
+++ b/src/features/AgentGoals/AgentGoalsPage.tsx
@@ -9,10 +9,11 @@ import {
Empty,
Flexbox,
ScrollShadow,
+ SearchBar,
Segmented,
Text,
} from '@lobehub/ui';
-import { LayoutGridIcon, ListIcon, PlusIcon, RefreshCwIcon } from 'lucide-react';
+import { LayoutGridIcon, ListIcon, PlusIcon, RefreshCwIcon, SearchXIcon } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -32,6 +33,7 @@ import { goalAgentFilterOptions } from './goalAgentFilterOptions';
import { GoalCardItem } from './GoalCardItem';
import GoalEmptyState from './GoalEmptyState';
import type { GoalExampleSeed } from './goalExamples';
+import { filterGoalsByKeyword, normalizeGoalKeyword } from './goalKeywordFilter';
import { GoalListItem } from './GoalListItem';
import { useGoalListAutoLoad } from './useGoalListAutoLoad';
@@ -75,6 +77,10 @@ const styles = createStaticStyles(({ css }) => ({
border-inline-start: 0;
}
`,
+ search: css`
+ flex: none;
+ width: 200px;
+ `,
sentinel: css`
height: 1px;
`,
@@ -127,6 +133,8 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
const viewMode = useGoalStore((s) => s.goalViewMode);
const visibleLimit = useGoalStore((s) => s.goalListVisibleLimit);
const setFilter = useGoalStore((s) => s.setGoalListFilter);
+ const keyword = useGoalStore((s) => s.goalListKeyword);
+ const setKeyword = useGoalStore((s) => s.setGoalListKeyword);
const setViewMode = useGoalStore((s) => s.setGoalViewMode);
const loadMoreGoals = useGoalStore((s) => s.loadMoreGoals);
// The rows live in the replica view; the hook only orchestrates the fetch, so
@@ -239,12 +247,24 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
() => (filter === 'all' ? goals : (tabView?.goals ?? [])),
[filter, goals, tabView],
);
+ // The search box narrows the tab's rows on the client. It can only see the
+ // page the tab loaded, so a tab holding more goals than that says so below
+ // the matches instead of presenting them as the whole answer.
+ const isSearching = normalizeGoalKeyword(keyword) !== '';
+ const searchedGoals = useMemo(
+ () => filterGoalsByKeyword(filteredGoals, keyword),
+ [filteredGoals, keyword],
+ );
+ const tabTotal = filter === 'all' ? listView?.total : tabView?.total;
+ const isSearchPartial =
+ isSearching && !isTabUnresolved && tabTotal !== undefined && tabTotal > filteredGoals.length;
const isFilterEmpty = !isTabUnresolved && filteredGoals.length === 0;
+ const isSearchEmpty = isSearching && !isFilterEmpty && searchedGoals.length === 0;
// The tab's count is the server's answer for that tab. Until it arrives — or
// when it failed — the list's page cannot stand in for it either.
- const visibleGoalCount = isTabUnresolved ? '—' : filteredGoals.length;
+ const visibleGoalCount = isTabUnresolved ? '—' : searchedGoals.length;
const GoalItem = viewMode === 'list' ? GoalListItem : GoalCardItem;
- const hasMoreGoals = !isTabUnresolved && visibleLimit < filteredGoals.length;
+ const hasMoreGoals = !isTabUnresolved && visibleLimit < searchedGoals.length;
const sentinelRef = useGoalListAutoLoad(hasMoreGoals, loadMoreGoals, visibleLimit);
const openCreateGoal = (seed?: GoalExampleSeed) => {
createGoalModal({
@@ -368,6 +388,16 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
size={24}
style={{ maxWidth: '100%' }}
>
+ <SearchBar
+ allowClear
+ aria-label={t('goalPage.searchPlaceholder')}
+ className={styles.search}
+ placeholder={t('goalPage.searchPlaceholder')}
+ size={'small'}
+ value={keyword}
+ variant={'filled'}
+ onInputChange={setKeyword}
+ />
{isGlobal && (
<GoalAgentFilter
options={agentFilterOptions}
@@ -432,8 +462,16 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
title={t('goalPage.filteredEmptyTitle')}
/>
</Block>
+ ) : isSearchEmpty ? (
+ <Block padding={32} variant={'outlined'}>
+ <Empty
+ description={t('goalPage.searchEmptyDescription')}
+ icon={SearchXIcon}
+ title={t('goalPage.searchEmptyTitle', { keyword: keyword.trim() })}
+ />
+ </Block>
) : (
- filteredGoals
+ searchedGoals
.slice(0, visibleLimit)
.map((item) => (
<GoalItem
@@ -446,6 +484,14 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
)}
</div>
{hasMoreGoals && <div aria-hidden className={styles.sentinel} ref={sentinelRef} />}
+ {isSearchPartial && (
+ <Text align={'center'} fontSize={12} type={'secondary'}>
+ {t('goalPage.searchPartial', {
+ loaded: filteredGoals.length,
+ total: tabTotal,
+ })}
+ </Text>
+ )}
</Flexbox>
</>
)}
diff --git a/src/features/AgentGoals/goalKeywordFilter.test.ts b/src/features/AgentGoals/goalKeywordFilter.test.ts
new file mode 100644
index 00000000000..3ff646903cf
--- /dev/null
+++ b/src/features/AgentGoals/goalKeywordFilter.test.ts
@@ -0,0 +1,42 @@
+import { describe, expect, it } from 'vitest';
+
+import { filterGoalsByKeyword, normalizeGoalKeyword } from './goalKeywordFilter';
+
+const item = (id: string, title: string, requirement: string | null = null) => ({
+ goal: { id, requirement, title } as any,
+});
+
+const items = [
+ item('g1', '桌宠支持 Workspace 与个人账号', '为桌宠增加 Workspace 支持'),
+ item('g2', 'Live2D 素材库扩充', null),
+ item('g3', 'Wallpaper Engine 桌面层', 'Render the pet on the DESKTOP layer'),
+];
+
+describe('normalizeGoalKeyword', () => {
+ it('trims and lower-cases', () => {
+ expect(normalizeGoalKeyword(' Live2D ')).toBe('live2d');
+ });
+});
+
+describe('filterGoalsByKeyword', () => {
+ it('keeps the same array for a blank keyword', () => {
+ expect(filterGoalsByKeyword(items, ' ')).toBe(items);
+ });
+
+ it('matches the title case-insensitively', () => {
+ expect(filterGoalsByKeyword(items, 'live2d').map((i) => i.goal.id)).toEqual(['g2']);
+ });
+
+ it('matches the requirement too', () => {
+ expect(filterGoalsByKeyword(items, 'desktop layer').map((i) => i.goal.id)).toEqual(['g3']);
+ });
+
+ it('requires every term to match', () => {
+ expect(filterGoalsByKeyword(items, '桌宠 workspace').map((i) => i.goal.id)).toEqual(['g1']);
+ expect(filterGoalsByKeyword(items, '桌宠 live2d')).toEqual([]);
+ });
+
+ it('treats regex characters literally', () => {
+ expect(filterGoalsByKeyword(items, '.*')).toEqual([]);
+ });
+});
diff --git a/src/features/AgentGoals/goalKeywordFilter.ts b/src/features/AgentGoals/goalKeywordFilter.ts
new file mode 100644
index 00000000000..f0b8f6252a0
--- /dev/null
+++ b/src/features/AgentGoals/goalKeywordFilter.ts
@@ -0,0 +1,22 @@
+import type { GoalListItem } from '@/store/goal/initialState';
+
+/** The search box's text as the matcher reads it: trimmed and lower-cased. */
+export const normalizeGoalKeyword = (keyword: string): string => keyword.trim().toLowerCase();
+
+/**
+ * The goals page's search: keep the rows whose title or requirement contains
+ * every whitespace-separated term, case-insensitively. A blank keyword keeps
+ * every row (the same array, so memoized consumers do not re-render).
+ */
+export const filterGoalsByKeyword = <T extends Pick<GoalListItem, 'goal'>>(
+ items: T[],
+ keyword: string,
+): T[] => {
+ const terms = normalizeGoalKeyword(keyword).split(/\s+/).filter(Boolean);
+ if (terms.length === 0) return items;
+
+ return items.filter(({ goal }) => {
+ const haystack = `${goal.title}\n${goal.requirement ?? ''}`.toLowerCase();
+ return terms.every((term) => haystack.includes(term));
+ });
+};
diff --git a/src/features/CommandMenu/SearchResults.tsx b/src/features/CommandMenu/SearchResults.tsx
index aec932c0d6f..38b9cb97cce 100644
--- a/src/features/CommandMenu/SearchResults.tsx
+++ b/src/features/CommandMenu/SearchResults.tsx
@@ -16,6 +16,7 @@ import {
Plug,
Puzzle,
Sparkles,
+ Target,
Users,
} from 'lucide-react';
import { memo, type ReactNode, useLayoutEffect } from 'react';
@@ -23,6 +24,7 @@ import { useTranslation } from 'react-i18next';
import AgentAvatar from '@/components/AgentAvatar';
import type { FtsSearchResult } from '@/database/repositories/ftsSearch';
+import { goalItemPath } from '@/features/AgentGoals/goalItemPath';
import { taskDetailPath } from '@/features/AgentTasks/shared/taskDetailPath';
import { useCommandMenuContext } from '@/features/CommandMenu/CommandMenuContext';
import { docsFilePath, docsPagePath } from '@/features/ResourceHome/paths';
@@ -37,6 +39,7 @@ import { markdownToTxt } from '@/utils/markdownToTxt';
import type { CommandMenuResultClick } from './analytics';
import { CommandItem } from './components';
import { styles } from './styles';
+import { goalResultStatusKey } from './utils/goalResults';
import { shouldShowMarketplaceFallback } from './utils/marketplaceFallback';
import { type ValidSearchType } from './utils/queryParser';
import { createVisibleResultPositionMap } from './utils/visibleResultPosition';
@@ -171,6 +174,12 @@ const SearchResults = memo<SearchResultsProps>(
navigate(taskDetailPath(result.identifier ?? result.id, undefined, result.title));
break;
}
+ case 'goal': {
+ // Under its agent when it has one, like an agent's Goals page row;
+ // an agent-less (project) goal opens on the bare route.
+ navigate(goalItemPath({ agentId: result.agentId, goalId: result.id }));
+ break;
+ }
}
onClose();
};
@@ -216,6 +225,9 @@ const SearchResults = memo<SearchResultsProps>(
case 'task': {
return <ListTodo size={16} />;
}
+ case 'goal': {
+ return <Target size={16} />;
+ }
}
};
@@ -260,6 +272,9 @@ const SearchResults = memo<SearchResultsProps>(
case 'task': {
return t('cmdk.search.task');
}
+ case 'goal': {
+ return t('cmdk.search.goal');
+ }
}
};
@@ -330,6 +345,13 @@ const SearchResults = memo<SearchResultsProps>(
return [result.identifier, status, description].filter(Boolean).join(' · ');
}
+ // Goal results: lifecycle first, then the requirement the query may have matched.
+ if (result.type === 'goal') {
+ const statusKey = goalResultStatusKey(result.status);
+ const status = statusKey ? tChat(statusKey) : result.status;
+ return [status, description].filter(Boolean).join(' · ');
+ }
+
// For message results, append creation date
if (result.type === 'message') {
const formattedDate = dayjs(result.createdAt).format('MMM D, YYYY');
@@ -406,11 +428,13 @@ const SearchResults = memo<SearchResultsProps>(
const pluginResults = results.filter((r) => r.type === 'plugin');
const knowledgeBaseResults = results.filter((r) => r.type === 'knowledgeBase');
const taskResults = results.filter((r) => r.type === 'task');
+ const goalResults = results.filter((r) => r.type === 'goal');
const assistantResults = results.filter((r) => r.type === 'communityAgent');
const localResultCount = localImageTopicResults.length + localVideoTopicResults.length;
const visibleResultPositions = createVisibleResultPositionMap<FtsSearchResult>(
[
taskResults,
+ goalResults,
messageResults,
agentResults,
chatGroupResults,
@@ -604,6 +628,13 @@ const SearchResults = memo<SearchResultsProps>(
</Command.Group>
)}
+ {goalResults.length > 0 && (
+ <Command.Group forceMount>
+ {goalResults.map((result) => renderResultItem(result))}
+ {renderSearchMore('goal', goalResults.length)}
+ </Command.Group>
+ )}
+
{messageResults.length > 0 && (
<Command.Group forceMount>
{messageResults.map((result) => renderResultItem(result))}
diff --git a/src/features/CommandMenu/useCommandMenu.ts b/src/features/CommandMenu/useCommandMenu.ts
index 7f3d2db7ad2..91c73cbf34a 100644
--- a/src/features/CommandMenu/useCommandMenu.ts
+++ b/src/features/CommandMenu/useCommandMenu.ts
@@ -1,6 +1,6 @@
import { useDebounce } from 'ahooks';
import { useTheme as useNextThemesTheme } from 'next-themes';
-import { useCallback, useEffect } from 'react';
+import { useCallback, useEffect, useMemo } from 'react';
import useSWR from 'swr';
import type { FtsSearchResult } from '@/database/repositories/ftsSearch';
@@ -19,10 +19,13 @@ import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
import { useGlobalStore } from '@/store/global';
import { globalHelpers } from '@/store/global/helpers';
+import { useUserStore } from '@/store/user';
+import { labPreferSelectors } from '@/store/user/selectors';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
import { useCommandMenuContext } from './CommandMenuContext';
import { type ThemeMode } from './types';
+import { withoutGatedGoals } from './utils/goalResults';
/**
* Shared methods for CommandMenu
@@ -60,14 +63,16 @@ export const useCommandMenu = () => {
// Search functionality
const hasSearch = debouncedSearch.trim().length > 0;
const searchQuery = debouncedSearch.trim();
+ // Goals sit behind a lab: with it off the menu neither asks for them nor shows any.
+ const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
const {
- data: searchResults,
+ data: rawSearchResults,
error: searchError,
isLoading: isSearching,
isValidating: isSearchValidating,
} = useSWR<FtsSearchResult[]>(
- hasSearch ? ['search', searchQuery, agentId, typeFilter] : null,
+ hasSearch ? ['search', searchQuery, agentId, typeFilter, goalsEnabled] : null,
async () => {
const locale = globalHelpers.getCurrentLanguage();
return lambdaClient.search.query.query({
@@ -76,6 +81,9 @@ export const useCommandMenu = () => {
// through the permanent typed-search entries instead of gating every
// keystroke on three remote marketplace round-trips.
includeMarketplace: false,
+ // Goals are not in the full-text index; the server looks them up by
+ // title/requirement only when asked, and the menu renders them.
+ includeGoals: goalsEnabled,
limitPerType: typeFilter ? 50 : 5, // Show more results when filtering by type
locale,
query: searchQuery,
@@ -87,6 +95,10 @@ export const useCommandMenu = () => {
revalidateOnReconnect: false,
},
);
+ const searchResults = useMemo(
+ () => withoutGatedGoals(rawSearchResults, goalsEnabled),
+ [goalsEnabled, rawSearchResults],
+ );
// Close on Escape key and prevent body scroll
useEffect(() => {
diff --git a/src/features/CommandMenu/utils/goalResults.test.ts b/src/features/CommandMenu/utils/goalResults.test.ts
new file mode 100644
index 00000000000..dff444d9f53
--- /dev/null
+++ b/src/features/CommandMenu/utils/goalResults.test.ts
@@ -0,0 +1,36 @@
+import { describe, expect, it } from 'vitest';
+
+import { goalResultStatusKey, withoutGatedGoals } from './goalResults';
+
+const results = [
+ { id: 'agt_1', title: 'Agent', type: 'agent' },
+ { id: 'goal_1', status: 'running', title: 'Goal', type: 'goal' },
+] as any[];
+
+describe('withoutGatedGoals', () => {
+ it('keeps goal results while the Goals lab is on', () => {
+ expect(withoutGatedGoals(results, true)).toBe(results);
+ });
+
+ it('drops goal results while the Goals lab is off', () => {
+ expect(withoutGatedGoals(results, false)?.map((r) => r.type)).toEqual(['agent']);
+ });
+
+ it('passes a missing response through', () => {
+ expect(withoutGatedGoals(undefined, false)).toBeUndefined();
+ });
+});
+
+describe('goalResultStatusKey', () => {
+ it('maps failed goals to the localized needs-attention label', () => {
+ expect(goalResultStatusKey('failed')).toBe('goalList.status.error');
+ });
+
+ it('uses the goal list vocabulary for other statuses', () => {
+ expect(goalResultStatusKey('running')).toBe('goalList.status.running');
+ });
+
+ it('returns undefined for an unknown status', () => {
+ expect(goalResultStatusKey('mystery')).toBeUndefined();
+ });
+});
diff --git a/src/features/CommandMenu/utils/goalResults.ts b/src/features/CommandMenu/utils/goalResults.ts
new file mode 100644
index 00000000000..28ec2cfd1da
--- /dev/null
+++ b/src/features/CommandMenu/utils/goalResults.ts
@@ -0,0 +1,24 @@
+import type { GoalStatus } from '@lobechat/const/goal';
+import { goalStatuses } from '@lobechat/const/goal';
+
+import type { FtsSearchResult } from '@/database/repositories/ftsSearch';
+import { goalStatusKey } from '@/features/AgentGoals/goalPresentation';
+
+/**
+ * Goals sit behind a lab: with it off their routes redirect away, so the menu
+ * shows none — an explicit `type:goal` search included.
+ */
+export const withoutGatedGoals = (
+ results: FtsSearchResult[] | undefined,
+ goalsEnabled: boolean,
+): FtsSearchResult[] | undefined =>
+ goalsEnabled || !results ? results : results.filter((result) => result.type !== 'goal');
+
+/**
+ * The goal list's status label key for a search hit (`failed` reads as "Needs
+ * attention"), or `undefined` for a status this client does not know.
+ */
+export const goalResultStatusKey = (status: string) =>
+ (goalStatuses as readonly string[]).includes(status)
+ ? goalStatusKey(status as GoalStatus)
+ : undefined;
diff --git a/src/features/CommandMenu/utils/queryParser.test.ts b/src/features/CommandMenu/utils/queryParser.test.ts
index 29c11ff4e56..e3f45856805 100644
--- a/src/features/CommandMenu/utils/queryParser.test.ts
+++ b/src/features/CommandMenu/utils/queryParser.test.ts
@@ -105,6 +105,7 @@ describe('parseSearchQuery', () => {
'communityAgent',
'knowledgeBase',
'task',
+ 'goal',
];
for (const type of types) {
diff --git a/src/features/CommandMenu/utils/queryParser.ts b/src/features/CommandMenu/utils/queryParser.ts
index 0996043d988..af87c22eae7 100644
--- a/src/features/CommandMenu/utils/queryParser.ts
+++ b/src/features/CommandMenu/utils/queryParser.ts
@@ -25,6 +25,7 @@ const VALID_TYPES = [
'communityAgent',
'knowledgeBase',
'task',
+ 'goal',
] as const;
export type ValidSearchType = (typeof VALID_TYPES)[number];
diff --git a/src/store/goal/action.test.ts b/src/store/goal/action.test.ts
index fb71cb8ff3b..b9f260ba47c 100644
--- a/src/store/goal/action.test.ts
+++ b/src/store/goal/action.test.ts
@@ -396,6 +396,17 @@ describe('GoalAction', () => {
});
});
+ it('restarts the page window when the search keyword changes', () => {
+ useGoalStore.getState().loadMoreGoals();
+ useGoalStore.getState().setGoalListKeyword('live2d');
+
+ expect(useGoalStore.getState()).toMatchObject({
+ goalListKeyword: 'live2d',
+ goalListVisibleLimit: 10,
+ });
+ useGoalStore.getState().setGoalListKeyword('');
+ });
+
it('deletes a goal through the goal endpoint and drops it from the loaded list', async () => {
useGoalStore.setState({
goalListByAgentId: {
diff --git a/src/store/goal/action.ts b/src/store/goal/action.ts
index a255ba4a2cb..34cd6d9a0cd 100644
--- a/src/store/goal/action.ts
+++ b/src/store/goal/action.ts
@@ -844,6 +844,10 @@ export class GoalActionImpl {
this.#set({ goalListFilter: filter, goalListVisibleLimit: 10 }, false, 'setGoalListFilter');
};
+ setGoalListKeyword = (keyword: string): void => {
+ this.#set({ goalListKeyword: keyword, goalListVisibleLimit: 10 }, false, 'setGoalListKeyword');
+ };
+
setGoalViewMode = (mode: GoalViewMode): void => {
this.#set({ goalViewMode: mode }, false, 'setGoalViewMode');
};
diff --git a/src/store/goal/initialState.ts b/src/store/goal/initialState.ts
index 47005426dc0..782529894c2 100644
--- a/src/store/goal/initialState.ts
+++ b/src/store/goal/initialState.ts
@@ -39,6 +39,12 @@ export interface GoalState {
goalListAgentFilter?: string;
goalListByAgentId: Record<string, GoalListValue>;
goalListFilter: GoalListFilter;
+ /**
+ * The goals page's search box, matched against the loaded rows' title and
+ * requirement. Kept in the store, like the tab, so returning from a goal
+ * keeps the search.
+ */
+ goalListKeyword: string;
/** Local-first bookkeeping for `goalListByAgentId`. */
goalListReplica: ReplicaState<GoalListValue>;
goalListVisibleLimit: number;
@@ -73,6 +79,7 @@ export const initialState: GoalState = {
goalGraphReplica: createReplicaState(),
goalListByAgentId: {},
goalListFilter: 'all',
+ goalListKeyword: '',
goalListReplica: createReplicaState(),
goalListVisibleLimit: 10,
goalMetricSeriesById: {},