Agent Zero AI framework
projects prototype, email parser
frdel2b7b1ac623ce
diff --git a/.dockerignore b/.dockerignoreindex 790ff9ed4..809234058 100644--- a/.dockerignore+++ b/.dockerignore@@ -5,9 +5,10 @@# Large / generated datamemory/**-# Logs & tmp+# Logs, tmp, usrlogs/*tmp/*+usr/*# Knowledge directory – keep only default/knowledge/**diff --git a/.gitignore b/.gitignoreindex 17d47e1c8..ed07e1cb0 100644--- a/.gitignore+++ b/.gitignore@@ -6,6 +6,7 @@#Ignore cursor rules.cursor/+.windsurf/# ignore test files in root dir/*.test.py@@ -20,8 +21,9 @@ memory/**# Handle logs directorylogs/*-# Handle tmp directory+# Handle tmp and usr directorytmp/*+usr/*# Handle knowledge directoryknowledge/**diff --git a/agent.py b/agent.pyindex 1d8a210e9..c1478cd95 100644--- a/agent.py+++ b/agent.py@@ -54,6 +54,7 @@ class AgentContext:type: AgentContextType = AgentContextType.USER,last_message: datetime | None = None,data: dict | None = None,+ output_data: dict | None = None,):# build contextself.id = id or AgentContext.generate_id()@@ -70,6 +71,7 @@ class AgentContext:self.no = AgentContext._counterself.last_message = last_message or datetime.now(timezone.utc)self.data = data or {}+ self.output_data = output_data or {}existing = self._contexts.get(self.id, None)if existing:@@ -121,6 +123,10 @@ class AgentContext:# recursive is not used now, prepared for context hierarchyself.data[key] = value+ def set_output_data(self, key: str, value: Any, recursive: bool = True):+ # recursive is not used now, prepared for context hierarchy+ self.output_data[key] = value+def output(self):return {"id": self.id,@@ -141,6 +147,7 @@ class AgentContext:else Localization.get().serialize_datetime(datetime.fromtimestamp(0))),"type": self.type.value,+ **self.output_data,}@staticmethoddiff --git a/prompts/agent.system.projects.active.md b/prompts/agent.system.projects.active.mdnew file mode 100644index 000000000..fa7433905--- /dev/null+++ b/prompts/agent.system.projects.active.md@@ -0,0 +1,11 @@+## Active project+Path: {{project_path}}+Title: {{project_name}}+Description: {{project_description}}+++### Important project instructions MUST follow+- always work inside {{project_path}} directory+- do not rename project directory, do no change meta files in .a0proj folder++{{project_instructions}}\ No newline at end of filediff --git a/prompts/agent.system.projects.inactive.md b/prompts/agent.system.projects.inactive.mdnew file mode 100644index 000000000..5cdd94390--- /dev/null+++ b/prompts/agent.system.projects.inactive.md@@ -0,0 +1 @@+no project currently activated\ No newline at end of filediff --git a/prompts/agent.system.projects.main.md b/prompts/agent.system.projects.main.mdnew file mode 100644index 000000000..b062e00e7--- /dev/null+++ b/prompts/agent.system.projects.main.md@@ -0,0 +1,5 @@+# Projects+- user can create and activate projects+- projects have work folder and instructions+- when activated agent works in project follows project instructions+- agent cannot manipulate or switch projects\ No newline at end of filediff --git a/python/api/projects.py b/python/api/projects.pyindex bd0b3bee2..a214c0567 100644--- a/python/api/projects.py+++ b/python/api/projects.py@@ -7,8 +7,22 @@ class Projects(ApiHandler):action = input.get("action", "")try:- if action == "list":- data = self.get_projects_list()+ if action == "list-active":+ data = self.get_active_projects_list()+ elif action == "list-archive":+ data = self.get_archived_projects_list()+ elif action == "load":+ data = self.load_project(input.get("path", None))+ elif action == "create":+ data = self.create_project(input.get("project", None))+ elif action == "update":+ data = self.update_project(input.get("project", None))+ elif action == "delete":+ data = self.delete_project(input.get("path", None))+ elif action == "activate":+ data = self.activate_project(input.get("context_id", None), input.get("path", None))+ elif action == "deactivate":+ data = self.deactivate_project(input.get("context_id", None))else:raise Exception("Invalid action")@@ -22,5 +36,44 @@ class Projects(ApiHandler):"error": str(e),}- async def get_projects_list(self):- return await projects.get_projects_list()+ def get_active_projects_list(self):+ return projects.get_active_projects_list()++ def get_archived_projects_list(self):+ return projects.get_archived_projects_list()++ def create_project(self, project: dict|None):+ if project is None:+ raise Exception("Project data is required")+ data = projects.BasicProjectData(**project)+ path = projects.create_project(project["name"], data)+ return projects.load_edit_project_data(path)++ def load_project(self, path: str|None):+ if path is None:+ raise Exception("Project path is required")+ return projects.load_edit_project_data(path)++ def update_project(self, project: dict|None):+ if project is None:+ raise Exception("Project data is required")+ data = projects.BasicProjectData(**project)+ path = projects.update_project(project["path"], data)+ return projects.load_edit_project_data(path)++ def delete_project(self, path: str|None):+ if path is None:+ raise Exception("Project path is required")+ return projects.delete_project(path)++ def activate_project(self, context_id: str|None, path: str|None):+ if context_id is None:+ raise Exception("Context ID is required")+ if path is None:+ raise Exception("Project path is required")+ return projects.activate_project(context_id, path)++ def deactivate_project(self, context_id: str|None):+ if context_id is None:+ raise Exception("Context ID is required")+ return projects.deactivate_project(context_id)diff --git a/python/extensions/system_prompt/_10_system_prompt.py b/python/extensions/system_prompt/_10_system_prompt.pyindex eb0089779..b4af2cfbd 100644--- a/python/extensions/system_prompt/_10_system_prompt.py+++ b/python/extensions/system_prompt/_10_system_prompt.py@@ -3,16 +3,23 @@ from python.helpers.extension import Extensionfrom python.helpers.mcp_handler import MCPConfigfrom agent import Agent, LoopDatafrom python.helpers.settings import get_settings+from python.helpers import projectsclass SystemPrompt(Extension):- async def execute(self, system_prompt: list[str] = [], loop_data: LoopData = LoopData(), **kwargs: Any):+ async def execute(+ self,+ system_prompt: list[str] = [],+ loop_data: LoopData = LoopData(),+ **kwargs: Any+ ):# append main system prompt and toolsmain = get_main_prompt(self.agent)tools = get_tools_prompt(self.agent)mcp_tools = get_mcp_tools_prompt(self.agent)secrets_prompt = get_secrets_prompt(self.agent)+ project_prompt = get_project_prompt(self.agent)system_prompt.append(main)system_prompt.append(tools)@@ -20,6 +27,8 @@ class SystemPrompt(Extension):system_prompt.append(mcp_tools)if secrets_prompt:system_prompt.append(secrets_prompt)+ if project_prompt:+ system_prompt.append(project_prompt)def get_main_prompt(agent: Agent):@@ -29,7 +38,7 @@ def get_main_prompt(agent: Agent):def get_tools_prompt(agent: Agent):prompt = agent.read_prompt("agent.system.tools.md")if agent.config.chat_model.vision:- prompt += '\n\n' + agent.read_prompt("agent.system.tools_vision.md")+ prompt += "\n\n" + agent.read_prompt("agent.system.tools_vision.md")return prompt@@ -37,7 +46,9 @@ def get_mcp_tools_prompt(agent: Agent):mcp_config = MCPConfig.get_instance()if mcp_config.servers:pre_progress = agent.context.log.progress- agent.context.log.set_progress("Collecting MCP tools") # MCP might be initializing, better inform via progress bar+ agent.context.log.set_progress(+ "Collecting MCP tools"+ ) # MCP might be initializing, better inform via progress bartools = MCPConfig.get_instance().get_tools_prompt()agent.context.log.set_progress(pre_progress) # return original progressreturn tools@@ -48,6 +59,7 @@ def get_secrets_prompt(agent: Agent):try:# Use lazy import to avoid circular dependenciesfrom python.helpers.secrets import SecretsManager+secrets_manager = SecretsManager.get_instance()secrets = secrets_manager.get_secrets_for_prompt()vars = get_settings()["variables"]@@ -55,3 +67,16 @@ def get_secrets_prompt(agent: Agent):except Exception as e:# If secrets module is not available or has issues, return empty stringreturn ""+++def get_project_prompt(agent: Agent):+ result = agent.read_prompt("agent.system.projects.main.md")+ project_path = agent.context.get_data(projects.CONTEXT_DATA_KEY_PROJECT_PATH)+ if project_path:+ project_vars = projects.build_system_prompt_vars(project_path)+ result += "\n\n" + agent.read_prompt(+ "agent.system.projects.active.md", **project_vars+ )+ else:+ result += "\n\n" + agent.read_prompt("agent.system.projects.inactive.md")+ return resultdiff --git a/python/helpers/files.py b/python/helpers/files.pyindex 544b520d3..e72ee8b1f 100644--- a/python/helpers/files.py+++ b/python/helpers/files.py@@ -346,21 +346,21 @@ def move_dir(old_path: str, new_path: str):pass # suppress all errors, keep behavior consistent# move dir safely, remove with number if needed-def move_dir_safe(src, dst):+def move_dir_safe(src, dst, rename_format="{name}_{number}"):base_dst = dsti = 2while exists(dst):- dst = f"{base_dst} {i}"+ dst = rename_format.format(name=base_dst, number=i)i += 1move_dir(src, dst)return dst# create dir safely, add number if needed-def create_dir_safe(dst):+def create_dir_safe(dst, rename_format="{name}_{number}"):base_dst = dsti = 2while exists(dst):- dst = f"{base_dst} {i}"+ dst = rename_format.format(name=base_dst, number=i)i += 1create_dir(dst)return dstdiff --git a/python/helpers/persist_chat.py b/python/helpers/persist_chat.pyindex 290bf9c87..55867e6fe 100644--- a/python/helpers/persist_chat.py+++ b/python/helpers/persist_chat.py@@ -123,6 +123,10 @@ def _serialize_context(context: AgentContext):agents.append(_serialize_agent(agent))agent = agent.data.get(Agent.DATA_NAME_SUBORDINATE, None)++ data = {k: v for k, v in context.data.items() if not k.startswith("_")}+ output_data = {k: v for k, v in context.output_data.items() if not k.startswith("_")}+return {"id": context.id,"name": context.name,@@ -142,6 +146,8 @@ def _serialize_context(context: AgentContext):context.streaming_agent.number if context.streaming_agent else 0),"log": _serialize_log(context.log),+ "data": data,+ "output_data": output_data,}@@ -190,6 +196,8 @@ def _deserialize_context(data):),log=log,paused=False,+ data=data.get("data", {}),+ output_data=data.get("output_data", {}),# agent0=agent0,# streaming_agent=straming_agent,)diff --git a/python/helpers/projects.py b/python/helpers/projects.pyindex 9a0927850..ea8861c55 100644--- a/python/helpers/projects.py+++ b/python/helpers/projects.py@@ -1,17 +1,19 @@-from dataclasses import dataclassimport osfrom typing import TypedDict-from torch import ne-from python.helpers import files, dirty_json+from python.helpers import files, dirty_json, persist_chatfrom python.helpers.print_style import PrintStyle-PROJECTS_PARENT_DIR = "tmp/projects"-PROJECTS_ARCHIVE_DIR = "tmp/projects-archived"+PROJECTS_PARENT_DIR = "usr/projects"+PROJECTS_ARCHIVE_DIR = "usr/projects-archived"PROJECT_META_DIR = ".a0proj"PROJECT_INSTRUCTIONS_DIR = "instructions"PROJECT_HEADER_FILE = "project.json"+CONTEXT_DATA_KEY_PROJECT_PATH = "project_path"+CONTEXT_DATA_KEY_PROJECT_COLOR = "project_color"+CONTEXT_DATA_KEY_PROJECT_NAME = "project_name"+class BasicProjectData(TypedDict):title: str | None@@ -20,6 +22,11 @@ class BasicProjectData(TypedDict):color: str | None+class EditProjectData(BasicProjectData):+ name: str+ path: str++def get_projects_parent_folder():return files.get_abs_path(PROJECTS_PARENT_DIR)@@ -38,54 +45,84 @@ def get_archived_project_folder(name: str):def archive_project(name: str):return files.move_dir_safe(- get_project_folder(name), get_archived_project_folder(name)+ get_project_folder(name), get_archived_project_folder(name), rename_format="{name}_{number}")def unarchive_project(name: str):return files.move_dir_safe(- get_archived_project_folder(name), get_project_folder(name)+ get_archived_project_folder(name), get_project_folder(name), rename_format="{name}_{number}")def delete_project(path: str):files.delete_dir(path)+ deactivate_project_in_chats(path)+ return path++def create_project(name: str, data: BasicProjectData):+ new_path = files.create_dir_safe(get_project_folder(name), rename_format="{name}_{number}")+ data = _normalizeBasicData(data)+ save_project_files(new_path, data)+ return new_path-async def create_project(name: str, data: BasicProjectData):- new_name = files.create_dir_safe(get_project_folder(name))- save_project_files(new_name, data)++def load_project_header(path: str):+ header: dict = dirty_json.parse(+ files.read_file(files.get_abs_path(path, PROJECT_META_DIR, PROJECT_HEADER_FILE))+ ) # type: ignore+ header["path"] = path+ return header+++def _normalizeBasicData(data: BasicProjectData):+ return BasicProjectData(+ title=data.get("title", ""),+ description=data.get("description", ""),+ instructions=data.get("instructions", ""),+ color=data.get("color", ""),+ )-async def update_project(path: str, data: BasicProjectData):- current: BasicProjectData = load_basic_project_data(path) # type: ignore- current.update(data)+def update_project(path: str, data: BasicProjectData):+ current: BasicProjectData = load_edit_project_data(path) # type: ignore+ current.update(_normalizeBasicData(data))save_project_files(path, current)+ reactivate_project_in_chats(path)+ return path-def load_basic_project_data(path: str) -> BasicProjectData:- data = dirty_json.parse(- files.read_file(- files.get_abs_path(path, PROJECT_HEADER_FILE)- )- )- return data # type: ignore+def load_edit_project_data(path: str) -> BasicProjectData:+ data = BasicProjectData(+ **dirty_json.parse(+ files.read_file(+ files.get_abs_path(path, PROJECT_META_DIR, PROJECT_HEADER_FILE)+ )+ ) # type: ignore+ )+ data = _normalizeBasicData(data)+ data = EditProjectData(**data, name=os.path.basename(path), path=path)+ return data # type: ignoredef save_project_files(path: str, data: BasicProjectData):# save project header fileheader = dirty_json.stringify(data)files.write_file(- files.get_abs_path(path, PROJECT_HEADER_FILE), header+ files.get_abs_path(path, PROJECT_META_DIR, PROJECT_HEADER_FILE), header)-async def get_active_projects_list():- return await get_projects_list(get_projects_parent_folder())-async def get_archived_projects_list():- return await get_projects_list(get_projects_archive_folder())+def get_active_projects_list():+ return _get_projects_list(get_projects_parent_folder())+++def get_archived_projects_list():+ return _get_projects_list(get_projects_archive_folder())+-async def get_projects_list(parent_dir):+def _get_projects_list(parent_dir):projects = []# folders in project directory@@ -94,18 +131,81 @@ async def get_projects_list(parent_dir):path = os.path.join(parent_dir, name)if os.path.isdir(path):- project_data = load_basic_project_data(path)-- projects.append({- "name": name,- "path": path,- "title": project_data.get("title", ""),- "description": project_data.get("description", ""),- })+ project_data = load_edit_project_data(path)++ projects.append(+ {+ "name": name,+ "path": path,+ "title": project_data.get("title", ""),+ "description": project_data.get("description", ""),+ "color": project_data.get("color", ""),+ }+ )except Exception as e:PrintStyle.error(f"Error loading project {name}: {str(e)}")# sort projects by name-+projects.sort(key=lambda x: x["name"])return projects+++def activate_project(context_id: str, path: str):+ from agent import AgentContext++ data = load_edit_project_data(path)+ context = AgentContext.get(context_id)+ if context is None:+ raise Exception("Context not found")+ name = str(data.get("title", data.get("name", data.get("path", ""))))+ name = name[:22] + "..." if len(name) > 25 else name+ context.set_data(CONTEXT_DATA_KEY_PROJECT_PATH, path)+ context.set_output_data(CONTEXT_DATA_KEY_PROJECT_PATH, path)+ context.set_output_data(CONTEXT_DATA_KEY_PROJECT_COLOR, data.get("color", ""))+ context.set_output_data(CONTEXT_DATA_KEY_PROJECT_NAME, name)++ # persist+ persist_chat.save_tmp_chat(context)+++def deactivate_project(context_id: str):+ from agent import AgentContext++ context = AgentContext.get(context_id)+ if context is None:+ raise Exception("Context not found")+ context.set_data(CONTEXT_DATA_KEY_PROJECT_PATH, None)+ context.set_output_data(CONTEXT_DATA_KEY_PROJECT_PATH, None)+ context.set_output_data(CONTEXT_DATA_KEY_PROJECT_COLOR, None)+ context.set_output_data(CONTEXT_DATA_KEY_PROJECT_NAME, None)++ # persist+ persist_chat.save_tmp_chat(context)+++def reactivate_project_in_chats(path: str):+ from agent import AgentContext++ for context in AgentContext.all():+ if context.get_data(CONTEXT_DATA_KEY_PROJECT_PATH) == path:+ activate_project(context.id, path)+ persist_chat.save_tmp_chat(context)++def deactivate_project_in_chats(path: str):+ from agent import AgentContext++ for context in AgentContext.all():+ if context.get_data(CONTEXT_DATA_KEY_PROJECT_PATH) == path:+ deactivate_project(context.id)+ persist_chat.save_tmp_chat(context)++def build_system_prompt_vars(project_path: str):+ project_data = load_edit_project_data(project_path)+ return {+ "project_path": project_path,+ "project_name": project_data.get("title", ""),+ "project_description": project_data.get("description", ""),+ "project_instructions": project_data.get("instructions", ""),+ }+diff --git a/tests/email_parser_test.py b/tests/email_parser_test.pynew file mode 100644index 000000000..c90a8e749--- /dev/null+++ b/tests/email_parser_test.py@@ -0,0 +1,23 @@+import sys, os++sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))++import asyncio+from python.helpers.email_client import read_messages+from python.helpers.dotenv import get_dotenv_value, load_dotenv+++async def test():+ load_dotenv()+ messages = await read_messages(+ account_type=get_dotenv_value("TEST_SERVER_TYPE", "imap"),+ server=get_dotenv_value("TEST_EMAIL_SERVER"),+ port=int(get_dotenv_value("TEST_EMAIL_PORT", 993)),+ username=get_dotenv_value("TEST_EMAIL_USERNAME"),+ password=get_dotenv_value("TEST_EMAIL_PASSWORD"),+ )+ print(messages)+++if __name__ == "__main__":+ asyncio.run(test())diff --git a/webui/components/notifications/notification-store.js b/webui/components/notifications/notification-store.jsindex 6335e23c1..60534f291 100644--- a/webui/components/notifications/notification-store.js+++ b/webui/components/notifications/notification-store.js@@ -17,8 +17,8 @@ export const NotificationPriority = {export const defaultPriority = NotificationPriority.NORMAL;-const maxNotifications = 100-const maxToasts = 5+const maxNotifications = 100;+const maxToasts = 5;const model = {notifications: [],@@ -30,7 +30,7 @@ const model = {// NEW: Toast stack managementtoastStack: [],-+init() {this.initialize();},@@ -615,35 +615,38 @@ const model = {title = "",display_time = 5,group = "",- priority = defaultPriority+ priority = defaultPriority,+ frontendOnly = false) {// Try to send to backend first if connected- if (this.isConnected()) {- try {- const notificationId = await this.createNotification(- type,- message,- title,- "",- display_time,- group,- priority- );- if (notificationId) {- // Backend handled it, notification will arrive via polling- return notificationId;+ if (!frontendOnly) {+ if (this.isConnected()) {+ try {+ const notificationId = await this.createNotification(+ type,+ message,+ title,+ "",+ display_time,+ group,+ priority+ );+ if (notificationId) {+ // Backend handled it, notification will arrive via polling+ return notificationId;+ }+ } catch (error) {+ console.log(+ `Backend unavailable for notification, showing as frontend-only: ${+ error.message || error+ }`+ );}- } catch (error) {- console.log(- `Backend unavailable for notification, showing as frontend-only: ${- error.message || error- }`- );+ } else {+ console.log("Backend disconnected, showing as frontend-only toast");}- } else {- console.log("Backend disconnected, showing as frontend-only toast");}-+// Fallback to frontend-only toastreturn this.addFrontendToastOnly(type,@@ -669,7 +672,8 @@ const model = {title,display_time,group,- priority+ priority,+ frontendOnly);},@@ -686,7 +690,8 @@ const model = {title,display_time,group,- priority+ priority,+ frontendOnly);},@@ -695,7 +700,8 @@ const model = {title = "Info",display_time = 3,group = "",- priority = defaultPriority+ priority = defaultPriority,+ frontendOnly = false) {return await this.addFrontendToast(NotificationType.INFO,@@ -703,7 +709,8 @@ const model = {title,display_time,group,- priority+ priority,+ frontendOnly);},@@ -712,7 +719,8 @@ const model = {title = "Success",display_time = 3,group = "",- priority = defaultPriority+ priority = defaultPriority,+ frontendOnly = false) {return await this.addFrontendToast(NotificationType.SUCCESS,@@ -720,7 +728,8 @@ const model = {title,display_time,group,- priority+ priority,+ frontendOnly);},};@@ -729,8 +738,21 @@ const model = {const store = createStore("notificationStore", model);export { store };+// export toast functions+const toastFrontendInfo = store.frontendInfo.bind(store);+const toastFrontendSuccess = store.frontendSuccess.bind(store);+const toastFrontendWarning = store.frontendWarning.bind(store);+const toastFrontendError = store.frontendError.bind(store);++export {+ toastFrontendInfo,+ toastFrontendSuccess,+ toastFrontendWarning,+ toastFrontendError,+};+// add toasts to global for backward compatibility with older scripts-globalThis.toastFrontendInfo = store.frontendInfo.bind(store);-globalThis.toastFrontendSuccess = store.frontendSuccess.bind(store);-globalThis.toastFrontendWarning = store.frontendWarning.bind(store);-globalThis.toastFrontendError = store.frontendError.bind(store);+globalThis.toastFrontendInfo = toastFrontendInfo;+globalThis.toastFrontendSuccess = toastFrontendSuccess;+globalThis.toastFrontendWarning = toastFrontendWarning;+globalThis.toastFrontendError = toastFrontendError;diff --git a/webui/components/projects/project-basic-data-form.html b/webui/components/projects/project-basic-data-form.htmlnew file mode 100644index 000000000..e0da32eb1--- /dev/null+++ b/webui/components/projects/project-basic-data-form.html@@ -0,0 +1,152 @@+<html>++<head>+ <title>Project basic data</title>+ <script type="module">+ import { store } from "/components/projects/projectsStore.js";+ </script>+</head>++<body>+ <div x-data>+ <template x-if="$store.projects && $store.projects.selectedProject">+ <div>+ <!-- <div class="project-detail-header">+ <div class="projects-project-card-title">Project details</div>+ <div class="project-path" x-text="$store.projects.selectedProject.path"></div>+ </div> -->++ <template x-if="!$store.projects.selectedProject._meta.creating">+ <div class="projects-form-group">+ <label class="projects-form-label">Folder name</label>+ <span class="projects-form-description">Project files and settings are located in+ <strong>/a0/usr/projects/<span+ x-text="$store.projects.selectedProject.name"></span></strong></span>+ <input class="projects-form-input projects-disabled" type="text" x-model="$store.projects.selectedProject.name" disabled>+ </div>+ </template>++ <div class="projects-form-group">+ <label class="projects-form-label">Title</label>+ <span class="projects-form-description">Title and description are visible to both you and the agent+ and can help it understand the project.</span>+ <input class="projects-form-input" type="text" x-model="$store.projects.selectedProject.title"+ placeholder="Optional title">+ </div>++ <!-- <div class="projects-form-group">+ <label class="projects-form-label">Description</label>+ <textarea class="projects-form-textarea" x-model="$store.projects.selectedProject.description"+ rows="5" placeholder="Optional description"></textarea>+ </div> -->++ <div class="projects-form-group">+ <label class="projects-form-label">Color</label>+ <div class="projects-color-row">+ <div class="projects-color-ball projects-color-none"+ :class="{'selected': !$store.projects.selectedProject.color}"+ @click="$store.projects.selectedProject.color = ''">+ <span class="projects-color-x">×</span>+ </div>+ <template x-for="c in $store.projects.colors" :key="c">+ <div class="projects-color-ball" :style="`background:${c}`"+ :class="{'selected': $store.projects.selectedProject.color === c}"+ @click="$store.projects.selectedProject.color = c">+ </div>+ </template>+ </div>+ </div>+ </div>+++ </template>+ </div>+</body>+<style>+ .project-path {+ font-size: 0.8em;+ opacity: 0.7;+ margin-top: 0.25em;+ word-break: break-all;+ }++ .projects-form-group {+ display: flex;+ flex-direction: column;+ gap: 0.35em;+ margin-bottom: 0.8em;+ }++ .projects-form-label {+ font-size: 1em;+ font-weight: bolder;+ opacity: 1;+ }++ .projects-form-description {+ font-size: 0.8em;+ }++ .projects-form-input,+ .projects-form-textarea {+ background: var(--color-input);+ color: var(--color-text);+ border: 1px solid var(--color-border);+ border-radius: 0.375em;+ padding: 0.5em 0.6em;+ outline: none;+ }++ .projects-form-input:focus,+ .projects-form-textarea:focus {+ border-color: var(--color-primary);+ background: var(--color-input-focus);+ }++ .projects-color-row {+ display: flex;+ gap: 0.5em;+ align-items: center;+ flex-wrap: wrap;+ }++ .projects-color-ball {+ width: 24px;+ height: 24px;+ border-radius: 50%;+ /* border: 2px solid var(--color-border); */+ cursor: pointer;+ box-shadow: none;+ background-clip: padding-box;+ transition: opacity 0.15s ease;+ }++ .projects-color-ball:hover {+ opacity: 0.9;+ }++ .projects-color-ball.selected {+ box-shadow: 0 0 0 2px var(--color-panel), 0 0 0 4px var(--color-primary);+ }++ .projects-color-none {+ background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(127, 127, 127, 0.12) 6px 12px);+ display: flex;+ align-items: center;+ justify-content: center;+ position: relative;+ }++ .projects-color-x {+ font-size: 16px;+ line-height: 1;+ color: var(--color-text);+ opacity: 0.7;+ }++ .projects-disabled {+ opacity: 0.7;+ }+</style>++</html>\ No newline at end of filediff --git a/webui/components/projects/project-create.html b/webui/components/projects/project-create.htmlnew file mode 100644index 000000000..f47a0c684--- /dev/null+++ b/webui/components/projects/project-create.html@@ -0,0 +1,46 @@+<html>++<head>+ <title>Create a new project</title>+ <script type="module">+ import { store } from "/components/projects/projectsStore.js";+ </script>+</head>++<body>+ <div x-data>+ <template x-if="$store.projects && $store.projects.selectedProject">+ <div>+ <div class="project-detail">++ <x-component path="projects/project-basic-data-form.html">+ </x-component>++ <div class="buttons-right">+ <button type="button" class="button cancel"+ @click="$store.projects.cancelCreate()">Cancel</button>+ <button type="button" class="button confirm" @click="$store.projects.confirmCreate()">Create and+ continue</button>+ </div>+ </div>+++ </div>+ </template>+ </div>+</body>+<style>+ .project-detail {+ border: 1px solid var(--color-border);+ border-radius: 0.5em;+ padding: 1em;+ margin: 1em;+ background: var(--color-panel);+ }++ .project-detail-header {+ margin-bottom: 1em;+ }+</style>++</html>\ No newline at end of filediff --git a/webui/components/projects/project-edit.html b/webui/components/projects/project-edit.htmlnew file mode 100644index 000000000..e68049a88--- /dev/null+++ b/webui/components/projects/project-edit.html@@ -0,0 +1,71 @@+<html>++<head>+ <title>Edit project</title>+ <script type="module">+ import { store } from "/components/projects/projectsStore.js";+ </script>+</head>++<body>+ <div x-data>+ <template x-if="$store.projects && $store.projects.selectedProject">+ <div>+++ <div class="buttons-container" style="margin-top: 1em; margin-bottom: 2em;">+ <div class="buttons-left">+ <button type="button" class="button cancel" @click="$store.projects.deleteProjectAndCloseModal()">Delete</button>+ </div>+ <div class="buttons-right">+ <button type="button" class="button cancel" @click="$store.projects.cancelEdit()">Cancel</button>+ <button type="button" class="button confirm" @click="$store.projects.confirmEdit()">Save</button>+ </div>+ </div>++ <div class="project-detail">+ <div class="project-detail-header">+ <span class="projects-project-card-title">Basic info</span>+ </div>+ <x-component path="projects/project-basic-data-form.html">+ </x-component>+ </div>++ <div class="project-detail">+ <div class="project-detail-header">+ <span class="projects-project-card-title">Instructions</span>+ </div>+ <x-component path="projects/project-instructions-form.html">+ </x-component>+ </div>++ <div class="buttons-container" style="margin-top: 2em;">+ <div class="buttons-left">+ <button type="button" class="button cancel" @click="$store.projects.deleteProjectAndCloseModal()">Delete</button>+ </div>+ <div class="buttons-right">+ <button type="button" class="button cancel" @click="$store.projects.cancelEdit()">Cancel</button>+ <button type="button" class="button confirm" @click="$store.projects.confirmEdit()">Save</button>+ </div>+ </div>+++ </div>+ </template>+ </div>+</body>+<style>+ .project-detail {+ border: 1px solid var(--color-border);+ border-radius: 0.5em;+ padding: 1em;+ margin: 1em;+ background: var(--color-panel);+ }++ .project-detail-header {+ margin-bottom: 1em;+ }+</style>++</html>\ No newline at end of filediff --git a/webui/components/projects/project-instructions-form.html b/webui/components/projects/project-instructions-form.htmlnew file mode 100644index 000000000..f0d1e63c7--- /dev/null+++ b/webui/components/projects/project-instructions-form.html@@ -0,0 +1,41 @@+<html>++<head>+ <title>Create a new project</title>+ <script type="module">+ import { store } from "/components/projects/projectsStore.js";+ </script>+</head>++<body>+ <div x-data>+ <template x-if="$store.projects && $store.projects.selectedProject">+ <div>+ <!-- <div class="project-detail-header">+ <div class="projects-project-card-title">Project details</div>+ <div class="project-path" x-text="$store.projects.selectedProject.path"></div>+ </div> -->++ <div class="projects-form-group">+ <label class="projects-form-label">Description</label>+ <span class="projects-form-description">Describe the project. This helps both you and the agent understand the project context.</span>+ <textarea class="projects-form-textarea" x-model="$store.projects.selectedProject.description"+ rows="5" placeholder="Enter project description"></textarea>+ </div>++ <div class="projects-form-group">+ <label class="projects-form-label">Instructions</label>+ <span class="projects-form-description">Provide specific instructions for the agent related to this project.</span>+ <textarea class="projects-form-textarea" style="min-height: 25em;" x-model="$store.projects.selectedProject.instructions"+ rows="5" placeholder="Enter project instructions"></textarea>+ </div>+ </div>+++ </template>+ </div>+</body>+<style>+</style>++</html>\ No newline at end of filediff --git a/webui/components/projects/project-list.html b/webui/components/projects/project-list.htmlnew file mode 100644index 000000000..c654c2699--- /dev/null+++ b/webui/components/projects/project-list.html@@ -0,0 +1,176 @@+<html>++<head>+ <title>Projects</title>+ <script type="module">+ import { store as projectsStore } from "/components/projects/projectsStore.js";+ import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";+ </script>+</head>++<body>+ <div x-data>+ <template x-if="$store.projects && $store.chats">+ <div>+ <p class="projects-intro">Projects in Agent Zero are used to separate different use cases with custom+ instructions and files.+ You can create projects for your tasks and switch between them easily.</p>+ <div class="projects-list-header">+ <div x-show="$store.chats.selectedContext?.project_path" class="active-project-display">+ <span style="display: inline-flex; align-items: center; gap: 0.5em;">+ <span>Active:</span>+ <span class="project-color-ball" :style="$store.chats.selectedContext.project_color ? { backgroundColor: $store.chats.selectedContext.project_color } : { border: '1px solid var(--color-border)' }"></span>+ <strong x-text="$store.chats.selectedContext?.project_name"></strong>+ </span>+ <button type="button" class="button cancel icon-button" title="Deactivate" @click="$store.projects.deactivateProject()">+ <span class="icon material-symbols-outlined">close</span>+ </button>+ <button type="button" class="button icon-button" title="Edit" @click="$store.projects.openEditModal($store.chats.selectedContext?.project_path)">+ <span class="icon material-symbols-outlined">edit</span>+ </button>+ </div>+ <button @click="$store.projects.openCreateModal()" type="button"+ class="button projects-create-btn-top">+ <span class="icon material-symbols-outlined">add</span> Create project+ </button>+ </div>++ <template :key="project.name" x-for="project in $store.projects.projectList">+ <div class="projects-project-card" :class="{ 'projects-active': project.path === $store.chats.selectedContext?.project_path }">+ <div class="projects-project-card-header" style="display: flex; align-items: start; justify-content: space-between; gap: 1em;">+ <div>+ <div class="projects-project-card-title">+ <span class="project-color-ball" :style="project.color ? { backgroundColor: project.color } : { border: '1px solid var(--color-border)' }"></span>+ <span x-text="project.title"></span>+ </div>+ <div class="projects-project-card-name">/<span x-text="project.name"></span></div>+ </div>+ <div class="projects-project-card-actions" style="display: flex; gap: 0.5em;">+ <template x-if="project.path === $store.chats.selectedContext?.project_path">+ <button type="button" class="button cancel" title="Deactivate" style="width:9em" @click="$store.projects.deactivateProject()">+ <span class="icon material-symbols-outlined">close</span> Deactivate+ </button>+ </template>+ <template x-if="project.path !== $store.chats.selectedContext?.project_path">+ <button type="button" class="button confirm" title="Activate" style="width:9em" @click="$store.projects.activateProject(project.path)">+ <span class="icon material-symbols-outlined">play_arrow</span> Activate+ </button>+ </template>+ <button type="button" class="button icon-button" title="Edit" @click="$store.projects.openEditModal(project.path)">+ <span class="icon material-symbols-outlined">edit</span>+ </button>+ <button type="button" class="button cancel icon-button" title="Delete" @click="$store.projects.deleteProject(project.path)">+ <span class="icon material-symbols-outlined">delete</span>+ </button>+ </div>+</div>+<!-- <div class="projects-project-card-description"><span x-text="project.description"></span></div> -->+ </div>+ </template>++ <template x-if="$store.projects.projectList.length === 0">+ <div class="projects-no-projects">+ <div class="projects-project-card-title">There are no projects yet</div>+ <div class="projects-no-projects-actions">+ <button @click="$store.projects.openCreateModal()" type="button"+ class="button"><span class="icon material-symbols-outlined">add</span>Create project</button>+ </div>+ </div>+ </template>++ </div>+ </template>+ </div>+</body>+<style>+ .projects-project-card {+ border: 1px solid var(--color-border);+ border-radius: 0.5em;+ padding: 1em;+ margin-top: 1em;+ }++ .projects-project-card.projects-active {+ border-color: var(--color-highlight);+ }++ .projects-project-card-title {+ font-weight: bold;+ font-size: 1.2em;+ display: flex;+ align-items: center;+ }++ .project-color-ball {+ width: 0.6em;+ height: 0.6em;+ border-radius: 50%;+ display: inline-block;+ margin-right: 0.5em;+ flex-shrink: 0;+ box-sizing: border-box;+ }++ .projects-project-card-description {+ font-size: 0.9em;+ color: var(--color-text);+ }++ .projects-no-projects {+ border: 1px dashed var(--color-border);+ border-radius: 0.5em;+ padding: 2em;+ margin: 1em;+ text-align: center;+ background: var(--color-panel);+ }++ .projects-no-projects-actions {+ margin-top: 1em;+ display: flex;+ justify-content: center;+ }++ .projects-create-btn-top {+ float: right;+ margin-bottom: 1em;+ margin-top: 0.2em;+ }++ .projects-list-header {+ width: 100%;+ display: flex;+ justify-content: flex-end;+ align-items: center;+ margin-bottom: 0.5em;+ }+</style>++<style>+ .active-project-display {+ display: flex;+ align-items: center;+ gap: 0.5em;+ border: 1px solid var(--color-highlight);+ padding: 0.5em;+ border-radius: 0.5em;+ margin-right: auto;+ }+</style>+<style>+ @media (max-width: 600px) {+ .projects-list-header {+ flex-wrap: wrap;+ gap: 1em;+ }+ .projects-project-card-header {+ flex-direction: column;+ gap: 1em;+ }+ .active-project-display {+ width: 100%;+ justify-content: space-between;+ }+ }+</style>+</html>\ No newline at end of filediff --git a/webui/components/projects/project-selector.html b/webui/components/projects/project-selector.htmlindex d286a5a65..ccdae79a5 100644--- a/webui/components/projects/project-selector.html+++ b/webui/components/projects/project-selector.html@@ -2,23 +2,44 @@<head><script type="module">- import { store } from "/components/projects/projectsStore.js";+ import { store as projectsStore } from "/components/projects/projectsStore.js";+ import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";</script></head><body>- <!-- <div x-data>- <template x-if="$store.projects">+ <div x-data>+ <template x-if="$store.projects && $store.chats"><div>- <template x-if="$store.selectedProject">- <button type="button" class="btn btn-outline-primary" x-text="$store.selectedProject.name"></button>+ <template x-if="$store.chats.selectedContext?.project_name">+ <button @click="$store.projects.openProjectsModal()" type="button" class="button project-button">+ <span class="project-color-ball" :style="$store.chats.selectedContext.project_color ? { backgroundColor: $store.chats.selectedContext.project_color } : { border: '1px solid var(--color-border)' }"></span>+ <span x-text="$store.chats.selectedContext?.project_name"></span>+ </button></template>- <template x-if="!$store.selectedProject">- <button type="button" class="btn btn-outline-secondary">No project</button>+ <template x-if="!$store.chats.selectedContext?.project_name">+ <button @click="$store.projects.openProjectsModal()" type="button" class="button project-button">+ No project</button></template></div></template>- </div> -->+ </div></body>+<style>+ .project-button {+ display: inline-flex;+ align-items: center;+ gap: 0.3em;+ padding-left: 0.5em;+ padding-right: 0.5em;+ }+ .project-color-ball {+ width: 0.6em;+ height: 0.6em;+ border-radius: 50%;+ display: inline-block;+ box-sizing: border-box;+ }+</style></html>\ No newline at end of filediff --git a/webui/components/projects/projectsStore.js b/webui/components/projects/projectsStore.jsindex ef77ca5dd..60812f817 100644--- a/webui/components/projects/projectsStore.js+++ b/webui/components/projects/projectsStore.js@@ -1,22 +1,301 @@import { createStore } from "/js/AlpineStore.js";import * as api from "/js/api.js";+import * as modals from "/js/modals.js";+import * as notifications from "/components/notifications/notification-store.js";+import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";++const listModal = "projects/project-list.html";+const createModal = "projects/project-create.html";+const editModal = "projects/project-edit.html";// define the model object holding data and functionsconst model = {projectList: [],selectedProject: null,+ editData: null,+ colors: [+ "#7b2cbf", // Deep Purple+ "#8338ec", // Blue Violet+ "#9b5de5", // Amethyst+ "#d0bfff", // Lavender+ "#002975ff", // Prussian Blue+ "#3a86ff", // Azure+ "#0077b6", // Star Command Blue+ "#4cc9f0", // Bright Blue+ "#00bbf9", // Deep Sky Blue+ "#a5d8ff", // Baby Blue+ "#00f5d4", // Electric Blue+ "#06d6a0", // Teal+ "#1a7431", // Dartmouth Green+ "#2a9d8f", // Jungle Green+ "#b2f2bb", // Light Mint+ "#9ef01a", // Lime Green+ "#e9c46a", // Saffron+ "#fee440", // Lemon Yellow+ "#ffec99", // Pale Yellow+ "#ff9f43", // Bright Orange+ "#fb5607", // Orange Peel+ "#ffddb5", // Peach+ "#f95738", // Coral+ "#e76f51", // Burnt Sienna+ "#ff6b6b", // Vibrant Red+ "#ffc9c9", // Light Coral+ "#f15bb5", // Hot Pink+ "#ff006e", // Magenta+ "#ffafcc", // Carnation Pink+ "#adb5bd", // Cool Gray+ "#6c757d", // Slate Gray+ ],++ _toFolderName(str) {+ if (!str) return '';+ // a helper function to convert title to a folder safe name+ const s = str.normalize('NFD') // remove all diacritics and replace it with the latin character+ .replace(/[\u0300-\u036f]/g, '')+ .toLowerCase()+ .replace(/[^a-z0-9\s-]/g, '_') // replace all special symbols with _+ .replace(/\s+/g, '_') // replace spaces with _+ .replace(/_{2,}/g, '_') // condense multiple underscores into 1+ .replace(/^-+|-+$/g, '') // remove any leading and trailing underscores+ .replace(/^_+|_+$/g, '');+ return s;+ },++ async openProjectsModal() {+ await this.loadProjectsList();+ await modals.openModal(listModal);+ },++ async openCreateModal() {+ this.selectedProject = this._createNewProjectData();+ await modals.openModal(createModal);+ this.selectedProject = null;+ },++ async openEditModal(projectPath) {+ this.selectedProject = await this._createEditProjectData(projectPath);+ await modals.openModal(editModal);+ this.selectedProject = null;+ },++ async cancelCreate() {+ await modals.closeModal(createModal);+ },++ async cancelEdit() {+ await modals.closeModal(editModal);+ },++ async confirmCreate() {+ // create folder name based on title+ this.selectedProject.name = this._toFolderName(this.selectedProject.title);+ const project = await this.saveSelectedProject(true);+ await this.loadProjectsList();+ await modals.closeModal(createModal);+ await this.openEditModal(project.path);+ },++ async confirmEdit() {+ const project = await this.saveSelectedProject(false);+ await this.loadProjectsList();+ await modals.closeModal(editModal);+ },++ async activateProject(projectPath) {+ try {+ await api.callJsonApi("projects", {+ action: "activate",+ context_id: chatsStore.getSelectedChatId(),+ path: projectPath,+ });+ notifications.toastFrontendSuccess(+ "Project activated successfully",+ "Project activated",+ 3,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ } catch (error) {+ console.error("Error activating project:", error);+ notifications.toastFrontendError(+ "Error activating project: " + error,+ "Error activating project",+ 5,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ }+ await this.loadProjectsList();+ },++ async deactivateProject() {+ try {+ await api.callJsonApi("projects", {+ action: "deactivate",+ context_id: chatsStore.getSelectedChatId(),+ });+ notifications.toastFrontendSuccess(+ "Project deactivated successfully",+ "Project deactivated",+ 3,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ } catch (error) {+ console.error("Error deactivating project:", error);+ notifications.toastFrontendError(+ "Error deactivating project: " + error,+ "Error deactivating project",+ 5,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ }+ await this.loadProjectsList();+ },++ async deleteProjectAndCloseModal() {+ await this.deleteProject(this.selectedProject.path);+ await modals.closeModal(editModal);+ },++ async deleteProject(projectPath) {+ // show confirmation dialog before proceeding+ const confirmed = window.confirm(+ "Are you sure you want to permanently delete this project? This action is irreversible and ALL FILES will be deleted."+ );+ if (!confirmed) return;+ try {+ const response = await api.callJsonApi("projects", {+ action: "delete",+ path: projectPath,+ });+ if (response.ok) {+ notifications.toastFrontendSuccess(+ "Project deleted successfully",+ "Project deleted",+ 3,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ await this.loadProjectsList();+ } else {+ notifications.toastFrontendError(+ response.error || "Error deleting project",+ "Error deleting project",+ 5,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ }+ } catch (error) {+ console.error("Error deleting project:", error);+ notifications.toastFrontendError(+ "Error deleting project: " + error,+ "Error deleting project",+ 5,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ }+ },async loadProjectsList() {this.loading = true;try {- const response = await api.callJsonApi("projects", { action: "list" });- this.projectList = response.data;+ const response = await api.callJsonApi("projects", {+ action: "list-active",+ });+ this.projectList = response.data || [];} catch (error) {console.error("Error loading projects list:", error);} finally {this.loading = false;}},++ async saveSelectedProject(creating) {+ try {+ // prepare data+ const data = {+ ...this.selectedProject,+ _meta: undefined,+ };+ // call backend+ const response = await api.callJsonApi("projects", {+ action: creating ? "create" : "update",+ project: data,+ });+ // notifications+ if (response.ok) {+ notifications.toastFrontendSuccess(+ "Project saved successfully",+ "Project saved",+ 3,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ return response.data;+ } else {+ notifications.toastFrontendError(+ response.error || "Error saving project",+ "Error saving project",+ 5,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ return null;+ }+ } catch (error) {+ console.error("Error saving project:", error);+ notifications.toastFrontendError(+ "Error saving project: " + error,+ "Error saving project",+ 5,+ "projects",+ notifications.NotificationPriority.NORMAL,+ true+ );+ return null;+ }+ },++ _createNewProjectData() {+ return {+ _meta: {+ creating: true,+ },+ name: ``,+ title: `Project #${this.projectList.length + 1}`,+ description: "",+ color: "",+ };+ },++ async _createEditProjectData(projectPath) {+ const projectData = (+ await api.callJsonApi("projects", {+ action: "load",+ path: projectPath,+ })+ ).data;+ // const project = this.projectList.find((p) => p.path === projectPath);+ return {+ _meta: {+ creating: false,+ },+ ...projectData,+ };+ },};// convert it to alpine storediff --git a/webui/components/sidebar/chats/chats-list.html b/webui/components/sidebar/chats/chats-list.htmlindex 229cc03c3..c8b5077e3 100644--- a/webui/components/sidebar/chats/chats-list.html+++ b/webui/components/sidebar/chats/chats-list.html@@ -12,12 +12,14 @@<ul class="config-list chats-config-list" x-show="$store.chats.contexts.length > 0"><template x-for="context in $store.chats.contexts" :key="context.id"><li>- <div :class="{'chat-list-button': true, 'font-bold': context.id === $store.chats.selected}"- @click="$store.chats.selectChat(context.id)">- <span class="chat-name" :title="context.name ? context.name : 'Chat #' + context.no"- x-text="context.name ? context.name : 'Chat #' + context.no"></span>+ <div :class="{'chat-container': true, 'chat-selected': context.id === $store.chats.selected}">+ <div class="chat-stripe" :style="'background-color: ' + (context.project_color || 'transparent')"></div>+ <div class="chat-list-button" @click="$store.chats.selectChat(context.id)">+ <span class="chat-name" :title="context.name ? context.name : 'Chat #' + context.no"+ x-text="context.name ? context.name : 'Chat #' + context.no"></span>+ </div>+ <button class="edit-button" @click.stop="$store.chats.killChat(context.id)">X</button></div>- <button class="edit-button" @click.stop="$store.chats.killChat(context.id)">X</button></li></template></ul>@@ -58,32 +60,77 @@display: none;}- .chat-list-button { display: block; width: 100%; padding: 8px 5px; cursor: pointer; overflow: hidden; position: relative; border-radius: 4px; transition: background-color 0.2s ease-in-out; }- .chat-list-button.has-task-container { padding-top: 6px; padding-bottom: 6px; }- .chat-list-button:hover { background-color: rgba(255, 255, 255, 0.03); }- .light-mode .chat-list-button:hover { background-color: rgba(0, 0, 0, 0.02); }-- .chat-name { display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; padding: 3px 8px; border-radius: 4px; transition: background-color 0.2s; margin-right: 60px; font-size: var(--font-size-small); }- .chat-name:hover { background-color: rgba(255, 255, 255, 0.1); text-decoration: none; }- .light-mode .chat-name:hover { background-color: rgba(0, 0, 0, 0.05); }-- .chat-container { display: flex; align-items: center; position: relative; width: 100%; min-height: 30px; gap: 0; }-- .edit-button { background-color: transparent; border: 1px solid var(--color-border); border-radius: 0.1875rem; color: var(--color-primary); cursor: pointer; padding: 0.125rem 0.5rem; -webkit-transition: all var(--transition-speed) ease-in-out; transition: all var(--transition-speed) ease-in-out; width: 2rem; height: 2rem; }- .edit-button:hover { border-color: var(--color-primary); background-color: #32455690; }- .edit-button:active { background-color: #131a2090; color: rgba(253, 253, 253, 0.35); }- .light-mode .edit-button { border-color: var(--color-primary-light); color: var(--color-primary-light); }- .light-mode .edit-button:hover { background-color: #e4e7f0; }- .light-mode .edit-button:active { background-color: #979fb9; color: rgba(0,0,0,0.35); }+ .chat-container {+ position: relative; /* Anchor for the stripe */+ display: flex;+ align-items: center;+ justify-content: space-between;+ width: 100%;+ min-height: 40px;+ border-radius: 4px;+ transition: background-color 0.2s ease-in-out;+ overflow: hidden; /* Important for containing the stripe's corners */+ }+ .chat-container:hover {+ background-color: rgba(255, 255, 255, 0.03);+ }++ .chat-list-button {+ display: flex;+ align-items: center;+ flex-grow: 1;+ cursor: pointer;+ padding: 8px 8px 8px 10px; /* Top/Right/Bottom/Left - Left padding for stripe */+ overflow: hidden;+ }++ .chat-stripe {+ position: absolute;+ left: 0;+ top: 0;+ width: 5px;+ height: 100%;+ border-radius: 0; /* No rounded corners */+ }++ .chat-name {+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ font-size: var(--font-size-small);+ }++ .edit-button {+ flex-shrink: 0;+ margin-right: 8px;+ background-color: transparent;+ border: 1px solid var(--color-border);+ border-radius: 0.1875rem;+ color: var(--color-primary);+ cursor: pointer;+ padding: 0.125rem 0.5rem;+ transition: all var(--transition-speed) ease-in-out;+ width: 2rem;+ height: 2rem;+ }+ .edit-button:hover {+ border-color: var(--color-primary);+ background-color: #32455690;+ }+ .edit-button:active {+ background-color: #131a2090;+ color: rgba(253, 253, 253, 0.35);+ }.empty-list-message { display: flex; justify-content: center; align-items: center; height: 100px; color: var(--color-secondary); text-align: center; opacity: 0.7; font-style: italic; }.light-mode .empty-list-message { color: var(--color-secondary-light); }/* Selected chat accent */- .chat-list-button.font-bold { position: relative; background-color: var(--color-border) 0.05; }- .chat-list-button.font-bold::before { content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 3px; background-color: var(--color-border); border-top-left-radius: 3px; border-bottom-left-radius: 3px; }- .light-mode .chat-list-button.font-bold { background-color: var(--color-border) 0.05; }- .light-mode .chat-list-button.font-bold::before { background-color: var(--color-border); }+ .chat-selected { font-weight:bold; background-color: var(--color-border) 0.2; }+ /* .chat-list-button.font-bold { position: relative; background-color: var(--color-border) 0.05; } */+ /* .chat-list-button.font-bold::before { content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 3px; background-color: var(--color-border); border-top-left-radius: 3px; border-bottom-left-radius: 3px; } */+ /* .light-mode .chat-list-button.font-bold { background-color: var(--color-border) 0.05; } */+ /* .light-mode .chat-list-button.font-bold::before { background-color: var(--color-border); } */</style></body></html>diff --git a/webui/components/sidebar/chats/chats-store.js b/webui/components/sidebar/chats/chats-store.jsindex 5e959b9f6..9ca8a7cf2 100644--- a/webui/components/sidebar/chats/chats-store.js+++ b/webui/components/sidebar/chats/chats-store.js@@ -5,6 +5,12 @@ import { store as notificationStore } from "/components/notifications/notificaticonst model = {contexts: [],selected: "",+ selectedContext: null,++ // for convenience+ getSelectedChatId() {+ return this.selected;+ },init() {// Initialize from localStorage@@ -259,6 +265,7 @@ const model = {// Set selected contextsetSelected(contextId) {this.selected = contextId;+ this.selectedContext = this.contexts.find((ctx) => ctx.id === contextId);localStorage.setItem("lastSelectedChat", contextId);},diff --git a/webui/css/buttons.css b/webui/css/buttons.cssnew file mode 100644index 000000000..8836591fd--- /dev/null+++ b/webui/css/buttons.css@@ -0,0 +1,63 @@+/* Button Styles */+.button {+ background: var(--color-panel);+ font-weight: 500;+ padding: 0.5rem 1.5rem;+ border-radius: 0.25rem;+ cursor: pointer;+ border: 1px solid var(--color-border);+ color: var(--color-text);+ font-size: 0.875rem;+ font-family: "Rubik", Arial, Helvetica, sans-serif;+ transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);+ min-height: 2em; /* Standard height */+ display: inline-flex;+ align-items: center;+ justify-content: center;+ box-sizing: border-box;+}++.button.confirm {+ background: var(--color-highlight);+ color: #fff;+}++.button.cancel {+ background: var(--color-panel);+ color: var(--color-accent);+ /* border: 1px solid var(--color-accent); */+}++.button:hover {+ transform: scale(1.05);+ filter: brightness(1.05);+}++.button.cancel:hover {+ background: var(--color-panel);+ border-color: var(--color-accent);+ color: var(--color-accent);+}++.buttons-container {+ display: flex;+ justify-content: space-between;+ align-items: center;+}++.buttons-left {+ display: flex;+ justify-content: flex-start;+ gap: 0.5em;+}++.buttons-right {+ display: flex;+ justify-content: flex-end;+ gap: 0.5em;+}++.icon-button {+ padding-left: 0.75rem;+ padding-right: 0.75rem;+}diff --git a/webui/index.css b/webui/index.cssindex e46b182fb..585295e54 100644--- a/webui/index.css+++ b/webui/index.css@@ -15,6 +15,7 @@--color-secondary-dark: #656565;--color-accent-dark: #cf6679;--color-message-bg-dark: #2d2d2d;+ --color-highlight-dark: #2b5ab9;--color-message-text-dark: #e0e0e0;--color-panel-dark: #1a1a1a;--color-border-dark: #444444a8;@@ -28,6 +29,7 @@--color-secondary-light: #e8eaf6;--color-accent-light: #b00020;--color-message-bg-light: #ffffff;+ --color-highlight-light: #2563eb;--color-message-text-light: #333333;--color-panel-light: #f0f0f0;--color-border-light: #e0e0e0c7;@@ -41,6 +43,7 @@--color-secondary: var(--color-secondary-dark);--color-accent: var(--color-accent-dark);--color-message-bg: var(--color-message-bg-dark);+ --color-highlight: var(--color-highlight-dark);--color-message-text: var(--color-message-text-dark);--color-panel: var(--color-panel-dark);--color-border: var(--color-border-dark);diff --git a/webui/index.html b/webui/index.htmlindex 11c9f68a6..cea7b9eee 100644--- a/webui/index.html+++ b/webui/index.html@@ -15,6 +15,7 @@<link rel="stylesheet" href="css/speech.css"><link rel="stylesheet" href="css/scheduler-datepicker.css"><link rel="stylesheet" href="css/notification.css">+ <link rel="stylesheet" href="css/buttons.css"><!-- Flatpickr for datetime picker --><link rel="stylesheet" href="vendor/flatpickr/flatpickr.min.css">diff --git a/webui/js/modals.js b/webui/js/modals.jsindex 9688ff5c8..770e1967c 100644--- a/webui/js/modals.js+++ b/webui/js/modals.js@@ -49,11 +49,11 @@ function updateModalZIndexes() {}// Function to create a new modal element-function createModalElement(name) {+function createModalElement(path) {// Create modal elementconst newModal = document.createElement("div");newModal.className = "modal";- newModal.modalName = name; // save name to the object+ newModal.path = path; // save name to the object// Add click handler to the modal element to close when clicking outside contentnewModal.addEventListener("click", (event) => {@@ -93,6 +93,7 @@ function createModalElement(name) {updateModalZIndexes();return {+ path: path,element: newModal,title: newModal.querySelector(".modal-title"),body: newModal.querySelector(".modal-bd"),@@ -109,7 +110,7 @@ export function openModal(modalPath) {return new Promise((resolve) => {try {// Create new modal instance- const modal = createModalElement();+ const modal = createModalElement(modalPath);new MutationObserver((_, o) =>@@ -158,6 +159,7 @@ export function openModal(modalPath) {// Add modal to stack and show it// Add modal to stack+ modal.path = modalPath;modalStack.push(modal);modal.element.classList.add("show");document.body.style.overflow = "hidden";@@ -172,15 +174,15 @@ export function openModal(modalPath) {}// Function to close modal-export function closeModal(modalName = null) {+export function closeModal(modalPath = null) {if (modalStack.length === 0) return;let modalIndex = modalStack.length - 1; // Default to last modallet modal;- if (modalName) {+ if (modalPath) {// Find the modal with the specified name in the stack- modalIndex = modalStack.findIndex((modal) => modal.modalName === modalName);+ modalIndex = modalStack.findIndex((modal) => modal.path === modalPath);if (modalIndex === -1) return; // Modal not found in stack// Get the modal from stack at the found index@@ -203,24 +205,32 @@ export function closeModal(modalName = null) {// First remove the show class to trigger the transitionmodal.element.classList.remove("show");- // Remove the modal element from DOM after animation- modal.element.addEventListener(- "transitionend",- () => {- // Make sure the modal is completely removed from the DOM- if (modal.element.parentNode) {- modal.element.parentNode.removeChild(modal.element);- }- },- { once: true }- );-- // Fallback in case the transition event doesn't fire- setTimeout(() => {- if (modal.element.parentNode) {- modal.element.parentNode.removeChild(modal.element);- }- }, 500); // 500ms should be enough for the transition to complete+ // commented out to prevent race conditions++ // // Remove the modal element from DOM after animation+ // modal.element.addEventListener(+ // "transitionend",+ // () => {+ // // Make sure the modal is completely removed from the DOM+ // if (modal.element.parentNode) {+ // modal.element.parentNode.removeChild(modal.element);+ // }+ // },+ // { once: true }+ // );++ // // Fallback in case the transition event doesn't fire+ // setTimeout(() => {+ // if (modal.element.parentNode) {+ // modal.element.parentNode.removeChild(modal.element);+ // }+ // }, 500); // 500ms should be enough for the transition to complete++ // remove immediately+ if (modal.element.parentNode) {+ modal.element.parentNode.removeChild(modal.element);+ }+// Handle backdrop visibility and body overflowif (modalStack.length === 0) {