mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 09:28:56 +00:00
Search loaded chat and task titles and messages from the sidebar, with Standard, Compact, and No search modes in the existing filters menu. Preserve project, status, and activity filters, keep matching child conversations accessible, and leave Welcome Chats search independent. Show compact, title-aligned excerpts with Unicode-safe match emphasis and no duplicate title previews. Use the Search placeholder and the chat composer's background, border, and focus transition. Retain authentication, query validation, stale-response protection, and keyboard navigation. Validation: 33 focused Python tests and both frontend suites passed. Checked search modes, persistence, child/task fixtures, dark and light themes, keyboard focus, and touch emulation against the live Docker runtime. Final CSS polish was visually checked; git diff --check passed.
22 lines
1.0 KiB
Python
22 lines
1.0 KiB
Python
import asyncio
|
|
|
|
from agent import AgentContext, AgentContextType
|
|
from helpers.api import ApiHandler, Request, Response
|
|
from helpers.task_scheduler import TaskScheduler
|
|
from plugins._sidebar_folders.helpers.search import search_contexts
|
|
|
|
|
|
class Search(ApiHandler):
|
|
async def process(self, input: dict, request: Request):
|
|
if not isinstance(input, dict):
|
|
return Response("Search request must be an object.", status=400)
|
|
query = input.get("query", "")
|
|
if not isinstance(query, str) or len(query) > 200:
|
|
return Response("Query must be text of at most 200 characters.", status=400)
|
|
query = query.strip()
|
|
if not query:
|
|
return {"matches": []}
|
|
contexts = [context for context in AgentContext.all() if context.type != AgentContextType.BACKGROUND]
|
|
titles = {task.uuid: task.name for task in TaskScheduler.get().get_tasks() if task.is_dedicated()}
|
|
return {"matches": await asyncio.to_thread(search_contexts, contexts, query, titles)}
|