Skip to content

Agent Zero AI framework

memory dashboard polishing

frdelc817e3918628
diff --git a/python/api/memory_dashboard.py b/python/api/memory_dashboard.py
index d2a3f0d87..3ade90d82 100644
--- a/python/api/memory_dashboard.py
+++ b/python/api/memory_dashboard.py
@@ -24,16 +24,11 @@ class MemoryDashboard(ApiHandler):
"success": False,
"error": f"Unknown action: {action}",
"memories": [],
- "total_count": 0
+ "total_count": 0,
}
except Exception as e:
- return {
- "success": False,
- "error": str(e),
- "memories": [],
- "total_count": 0
- }
+ return {"success": False, "error": str(e), "memories": [], "total_count": 0}
async def _delete_memory(self, input: dict) -> dict:
"""Delete a memory by ID from the specified subdirectory."""
@@ -42,44 +37,25 @@ class MemoryDashboard(ApiHandler):
memory_id = input.get("memory_id")
if not memory_id:
- return {
- "success": False,
- "error": "Memory ID is required for deletion"
- }
+ return {"success": False, "error": "Memory ID is required for deletion"}
+
+ memory = await Memory.get_by_subdir(memory_subdir, preload_knowledge=False)
- # Check if memory database exists
- if Memory.index.get(memory_subdir) is None:
+ rem = await memory.delete_documents_by_ids([memory_id])
+
+ if len(rem) == 0:
return {
"success": False,
- "error": f"Memory database '{memory_subdir}' not initialized"
+ "error": f"Memory with ID '{memory_id}' not found",
}
-
- # Get the MyFaiss database directly
- myFaiss_db = Memory.index[memory_subdir]
-
- # Delete the memory by ID (replicate logic from Memory.delete_documents_by_ids)
- rem_docs = await myFaiss_db.aget_by_ids([memory_id])
- if rem_docs:
- rem_ids = [doc.metadata["id"] for doc in rem_docs]
- await myFaiss_db.adelete(ids=rem_ids)
- # Persist changes to disk
- Memory._save_db_file(myFaiss_db, memory_subdir)
else:
return {
- "success": False,
- "error": f"Memory with ID '{memory_id}' not found"
+ "success": True,
+ "message": f"Memory {memory_id} deleted successfully",
}
- return {
- "success": True,
- "message": f"Memory {memory_id} deleted successfully"
- }
-
except Exception as e:
- return {
- "success": False,
- "error": f"Failed to delete memory: {str(e)}"
- }
+ return {"success": False, "error": f"Failed to delete memory: {str(e)}"}
async def _bulk_delete_memories(self, input: dict) -> dict:
"""Delete multiple memories by IDs from the specified subdirectory."""
@@ -90,101 +66,69 @@ class MemoryDashboard(ApiHandler):
if not memory_ids:
return {
"success": False,
- "error": "No memory IDs provided for bulk deletion"
+ "error": "No memory IDs provided for bulk deletion",
}
if not isinstance(memory_ids, list):
return {
"success": False,
- "error": "Memory IDs must be provided as a list"
+ "error": "Memory IDs must be provided as a list",
}
- # Check if memory database exists
- if Memory.index.get(memory_subdir) is None:
- return {
- "success": False,
- "error": f"Memory database '{memory_subdir}' not initialized"
- }
+ # delete
+ memory = await Memory.get_by_subdir(memory_subdir, preload_knowledge=False)
+ rem = await memory.delete_documents_by_ids(memory_ids)
- # Get the MyFaiss database directly
- myFaiss_db = Memory.index[memory_subdir]
-
- # Delete memories in batch
- deleted_count = 0
- failed_ids = []
-
- for memory_id in memory_ids:
- try:
- # Get memory to check if it exists
- rem_docs = await myFaiss_db.aget_by_ids([memory_id])
- if rem_docs:
- rem_ids = [doc.metadata["id"] for doc in rem_docs]
- await myFaiss_db.adelete(ids=rem_ids)
- deleted_count += 1
- else:
- failed_ids.append(memory_id)
- except Exception:
- failed_ids.append(memory_id)
-
- # Persist changes to disk if any deletions were successful
- if deleted_count > 0:
- Memory._save_db_file(myFaiss_db, memory_subdir)
-
- if deleted_count == len(memory_ids):
+ if len(rem) == len(memory_ids):
return {
"success": True,
- "message": f"Successfully deleted {deleted_count} memories"
+ "message": f"Successfully deleted {len(memory_ids)} memories",
}
- elif deleted_count > 0:
+ elif len(rem) > 0:
return {
"success": True,
- "message": f"Successfully deleted {deleted_count} memories. {len(failed_ids)} failed: {failed_ids[:5]}"
+ "message": f"Successfully deleted {len(rem)} memories. {len(memory_ids) - len(rem)} failed.",
}
else:
return {
"success": False,
- "error": f"Failed to delete any memories. Not found: {failed_ids[:10]}"
+ "error": f"Failed to delete any memories.",
}
except Exception as e:
return {
"success": False,
- "error": f"Failed to bulk delete memories: {str(e)}"
+ "error": f"Failed to bulk delete memories: {str(e)}",
}
async def _get_current_memory_subdir(self, request: Request) -> dict:
"""Get the current memory subdirectory from the active context."""
try:
# Try to get the context from the request
- context_id = getattr(request, 'context_id', None)
+ context_id = getattr(request, "context_id", None)
if not context_id:
# Fallback to default if no context available
- return {
- "success": True,
- "memory_subdir": "default"
- }
+ return {"success": True, "memory_subdir": "default"}
# Import AgentContext here to avoid circular imports
from agent import AgentContext
# Get the context and extract memory subdirectory
context = AgentContext.get(context_id)
- if context and hasattr(context, 'config') and hasattr(context.config, 'memory_subdir'):
+ if (
+ context
+ and hasattr(context, "config")
+ and hasattr(context.config, "memory_subdir")
+ ):
memory_subdir = context.config.memory_subdir or "default"
- return {
- "success": True,
- "memory_subdir": memory_subdir
- }
+ return {"success": True, "memory_subdir": memory_subdir}
else:
- return {
- "success": True,
- "memory_subdir": "default"
- }
+ return {"success": True, "memory_subdir": "default"}
except Exception:
return {
"success": True, # Still success, just fallback to default
- "memory_subdir": "default"
+ "memory_subdir": "default",
}
async def _get_memory_subdirs(self) -> dict:
@@ -197,15 +141,12 @@ class MemoryDashboard(ApiHandler):
if "default" not in subdirs:
subdirs.insert(0, "default")
- return {
- "success": True,
- "subdirs": subdirs
- }
+ return {"success": True, "subdirs": subdirs}
except Exception as e:
return {
"success": False,
"error": f"Failed to get memory subdirectories: {str(e)}",
- "subdirs": ["default"]
+ "subdirs": ["default"],
}
async def _search_memories(self, input: dict) -> dict:
@@ -216,111 +157,72 @@ class MemoryDashboard(ApiHandler):
area_filter = input.get("area", "") # Filter by memory area
search_query = input.get("search", "") # Full-text search query
limit = input.get("limit", 100) # Number of results to return
+ threshold = input.get("threshold", 0.6) # Similarity threshold
- # Initialize memory if not already done
- if Memory.index.get(memory_subdir) is None:
- # Create default embeddings model config
- embeddings_config = ModelConfig(
- type=ModelType.EMBEDDING,
- provider="huggingface",
- name="sentence-transformers/all-MiniLM-L6-v2",
- ctx_length=512,
- limit_requests=0,
- limit_input=0,
- limit_output=0,
- vision=False,
- kwargs={}
- )
-
- # Initialize memory database (with log_item=None to prevent status blinking)
- db, created = Memory.initialize(
- log_item=None,
- model_config=embeddings_config,
- memory_subdir=memory_subdir,
- in_memory=False
- )
-
- # Store in the Memory index
- Memory.index[memory_subdir] = db
-
- # Get the MyFaiss database directly
- myFaiss_db = Memory.index[memory_subdir]
+ memory = await Memory.get_by_subdir(memory_subdir, preload_knowledge=False)
memories = []
if search_query:
- # If search query provided, use similarity search
- threshold = 0.6 # Lower threshold for broader search in dashboard
- comparator = Memory._get_comparator(f"area == '{area_filter}'") if area_filter else None
-
- # Get ALL matching results, don't limit in query
- docs = await myFaiss_db.asearch(
- search_query,
- search_type="similarity_score_threshold",
- k=10000, # Get all matches up to reasonable max
- score_threshold=threshold,
- filter=comparator,
+ docs = await memory.search_similarity_threshold(
+ query=search_query,
+ limit=limit,
+ threshold=threshold,
+ filter=f"area == '{area_filter}'" if area_filter else "",
)
memories = docs
else:
# If no search query, get all memories from specified area(s)
- all_docs = myFaiss_db.get_all_docs()
-
+ all_docs = memory.db.get_all_docs()
for doc_id, doc in all_docs.items():
# Apply area filter if specified
if area_filter and doc.metadata.get("area", "") != area_filter:
continue
-
memories.append(doc)
+ # sort by timestamp
+ def get_sort_key(m):
+ timestamp = m.metadata.get("timestamp", "0000-00-00 00:00:00")
+ return timestamp
+
+ memories.sort(key=get_sort_key, reverse=True)
+
+ # Apply limit AFTER sorting to get the newest entries
+ if limit and len(memories) > limit:
+ memories = memories[:limit]
+
# Format memories for the dashboard
formatted_memories: list[dict] = []
- for memory in memories:
- metadata = memory.metadata
+ for m in memories:
+ metadata = m.metadata
# Extract key information
memory_data = {
"id": metadata.get("id", "unknown"),
"area": metadata.get("area", "unknown"),
"timestamp": metadata.get("timestamp", "unknown"),
- "content_preview": memory.page_content[:200] + ("..." if len(memory.page_content) > 200 else ""),
- "content_full": memory.page_content,
+ "content_preview": m.page_content[:200]
+ + ("..." if len(m.page_content) > 200 else ""),
+ "content_full": m.page_content,
"knowledge_source": metadata.get("knowledge_source", False),
"source_file": metadata.get("source_file", ""),
"file_type": metadata.get("file_type", ""),
"consolidation_action": metadata.get("consolidation_action", ""),
"tags": metadata.get("tags", []),
- "metadata": metadata # Include full metadata for advanced users
+ "metadata": metadata, # Include full metadata for advanced users
}
formatted_memories.append(memory_data)
- # Sort ALL results by timestamp (newest first) - handle "unknown" timestamps
- def get_sort_key(memory):
- timestamp = memory["timestamp"]
- if timestamp == "unknown" or not timestamp:
- return "0000-00-00 00:00:00" # Put unknown timestamps at the end
- return timestamp
-
- formatted_memories.sort(key=get_sort_key, reverse=True)
-
- # Apply limit AFTER sorting to get the newest entries
- if limit and len(formatted_memories) > limit:
- formatted_memories = formatted_memories[:limit]
-
# Get summary statistics
total_memories = len(formatted_memories)
- knowledge_count = sum(1 for m in formatted_memories if m["knowledge_source"])
+ knowledge_count = sum(
+ 1 for m in formatted_memories if m["knowledge_source"]
+ )
conversation_count = total_memories - knowledge_count
# Get total count of all memories in database (unfiltered)
- all_docs = myFaiss_db.get_all_docs()
- total_db_count = len(all_docs)
-
- areas_count: dict[str, int] = {}
- for memory_dict in formatted_memories:
- area = memory_dict["area"]
- areas_count[area] = areas_count.get(area, 0) + 1
+ total_db_count = len(memory.db.get_all_docs())
return {
"success": True,
@@ -329,16 +231,10 @@ class MemoryDashboard(ApiHandler):
"total_db_count": total_db_count,
"knowledge_count": knowledge_count,
"conversation_count": conversation_count,
- "areas_count": areas_count,
"search_query": search_query,
"area_filter": area_filter,
- "memory_subdir": memory_subdir
+ "memory_subdir": memory_subdir,
}
except Exception as e:
- return {
- "success": False,
- "error": str(e),
- "memories": [],
- "total_count": 0
- }
+ return {"success": False, "error": str(e), "memories": [], "total_count": 0}
diff --git a/python/api/memory_delete.py b/python/api/memory_delete.py
deleted file mode 100644
index c35f7a965..000000000
--- a/python/api/memory_delete.py
+++ /dev/null
@@ -1,55 +0,0 @@
-from python.helpers.api import ApiHandler, Request, Response
-from python.helpers.memory import Memory
-
-
-class MemoryDelete(ApiHandler):
-
- async def process(self, input: dict, request: Request) -> dict | Response:
- try:
- # Get memory ID to delete
- memory_id = input.get("memory_id", "")
- if not memory_id:
- return {
- "success": False,
- "error": "Memory ID is required"
- }
-
- # Get context and agent
- ctxid = input.get("context", "")
- context = self.get_context(ctxid)
-
- # Check if memory is initialized to avoid triggering preload
- memory_subdir = context.agent0.config.memory_subdir or "default"
- if Memory.index.get(memory_subdir) is None:
- return {
- "success": False,
- "error": "Memory database not initialized"
- }
-
- # Get already initialized memory instance (no initialization triggered)
- db = Memory(
- agent=context.agent0,
- db=Memory.index[memory_subdir],
- memory_subdir=memory_subdir,
- )
-
- # Delete the memory by ID
- deleted_docs = await db.delete_documents_by_ids([memory_id])
-
- if deleted_docs:
- return {
- "success": True,
- "message": f"Memory {memory_id} deleted successfully",
- "deleted_count": len(deleted_docs)
- }
- else:
- return {
- "success": False,
- "error": f"Memory {memory_id} not found or already deleted"
- }
-
- except Exception as e:
- return {
- "success": False,
- "error": str(e)
- }
diff --git a/python/helpers/memory.py b/python/helpers/memory.py
index 0eb203cbb..d3f9282dd 100644
--- a/python/helpers/memory.py
+++ b/python/helpers/memory.py
@@ -76,7 +76,7 @@ class Memory:
False,
)
Memory.index[memory_subdir] = db
- wrap = Memory(agent, db, memory_subdir=memory_subdir)
+ wrap = Memory(db, memory_subdir=memory_subdir)
if agent.config.knowledge_subdirs:
await wrap.preload_knowledge(
log_item, agent.config.knowledge_subdirs, memory_subdir
@@ -84,11 +84,30 @@ class Memory:
return wrap
else:
return Memory(
- agent=agent,
db=Memory.index[memory_subdir],
memory_subdir=memory_subdir,
)
+ @staticmethod
+ async def get_by_subdir(memory_subdir: str, log_item: LogItem | None = None, preload_knowledge: bool = True):
+ if not Memory.index.get(memory_subdir):
+ import initialize
+ agent_config = initialize.initialize_agent()
+ model_config = agent_config.embeddings_model
+ db, _created = Memory.initialize(
+ log_item=log_item,
+ model_config=model_config,
+ memory_subdir=memory_subdir,
+ in_memory=False,
+ )
+ wrap = Memory(db, memory_subdir=memory_subdir)
+ if preload_knowledge and agent_config.knowledge_subdirs:
+ await wrap.preload_knowledge(
+ log_item, agent_config.knowledge_subdirs, memory_subdir
+ )
+ Memory.index[memory_subdir] = db
+ return Memory(db=Memory.index[memory_subdir], memory_subdir=memory_subdir)
+
@staticmethod
async def reload(agent: Agent):
memory_subdir = agent.config.memory_subdir or "default"
@@ -212,11 +231,9 @@ class Memory:
def __init__(
self,
- agent: Agent,
db: MyFaiss,
memory_subdir: str,
):
- self.agent = agent
self.db = db
self.memory_subdir = memory_subdir
diff --git a/webui/components/settings/memory/memory-dashboard-store.js b/webui/components/settings/memory/memory-dashboard-store.js
index 1c33a9239..d70f8125b 100644
--- a/webui/components/settings/memory/memory-dashboard-store.js
+++ b/webui/components/settings/memory/memory-dashboard-store.js
@@ -45,7 +45,11 @@ const memoryDashboardStore = {
// Polling
pollingInterval: null,
- pollingEnabled: true,
+ pollingEnabled: false,
+
+ init(){
+ this.initialize();
+ },
async initialize() {
// Reset state when opening (but keep directory from context)
@@ -175,7 +179,6 @@ const memoryDashboardStore = {
this.totalDbCount = response.total_db_count || 0;
this.knowledgeCount = response.knowledge_count || 0;
this.conversationCount = response.conversation_count || 0;
- this.areasCount = response.areas_count || {};
if (!silent) {
this.message = response.message || null;
diff --git a/webui/components/settings/memory/memory-dashboard.html b/webui/components/settings/memory/memory-dashboard.html
index cad01257d..e12499ad5 100644
--- a/webui/components/settings/memory/memory-dashboard.html
+++ b/webui/components/settings/memory/memory-dashboard.html
@@ -1,54 +1,34 @@
<html>
+
<head>
<title>Memory Dashboard</title>
<script type="module">
import { store } from "/components/settings/memory/memory-dashboard-store.js";
</script>
</head>
-<body>
-<div x-data>
- <template x-if="$store.memoryDashboardStore">
- <div x-init="
- $store.memoryDashboardStore.initialize();
-
- // Setup cleanup when component is removed from DOM
- const observer = new MutationObserver((mutations) => {
- mutations.forEach((mutation) => {
- if (mutation.type === 'childList') {
- mutation.removedNodes.forEach((node) => {
- if (node.contains && node.contains($el)) {
- // Dashboard is being removed, cleanup polling
- $store.memoryDashboardStore.cleanup();
- observer.disconnect();
- }
- });
- }
- });
- });
-
- // Watch for DOM changes
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- " class="memory-dashboard">
-
+<body>
+ <div x-data>
+ <template x-if="$store.memoryDashboardStore">
+ <div x-create="$store.memoryDashboardStore.searchMemories()"
+ x-destroy="$store.memoryDashboardStore.cleanup()" class="memory-dashboard">
<!-- Search and Filters -->
<div class="filters-section">
<div class="filter-row">
<div class="filter-group">
<label for="memory-subdir-select">Memory Directory:</label>
- <select id="memory-subdir-select"
- x-model="$store.memoryDashboardStore.selectedMemorySubdir"
- @change="$store.memoryDashboardStore.onMemorySubdirChange()"
- :disabled="$store.memoryDashboardStore.loadingSubdirs">
+ <select id="memory-subdir-select" x-model="$store.memoryDashboardStore.selectedMemorySubdir"
+ @change="$store.memoryDashboardStore.onMemorySubdirChange()"
+ :disabled="$store.memoryDashboardStore.loadingSubdirs">
<template x-for="subdir in $store.memoryDashboardStore.memorySubdirs" :key="subdir">
- <option :value="subdir" x-text="subdir"></option>
+ <option :value="subdir" x-text="subdir"
+ :selected="subdir === $store.memoryDashboardStore.selectedMemorySubdir">
+ </option>
</template>
</select>
- <span x-show="$store.memoryDashboardStore.loadingSubdirs" class="loading-text">Loading...</span>
+ <span x-show="$store.memoryDashboardStore.loadingSubdirs"
+ class="loading-text">Loading...</span>
</div>
<div class="filter-group">
@@ -65,22 +45,22 @@
<div class="filter-group">
<label for="search-input">Search:</label>
<input type="text" id="search-input" x-model="$store.memoryDashboardStore.searchQuery"
- placeholder="Search memory content..."
- @keyup.enter="$store.memoryDashboardStore.searchMemories()" />
+ placeholder="Search memory content..."
+ @keyup.enter="$store.memoryDashboardStore.searchMemories()" />
</div>
<div class="filter-group">
<label for="limit-input">Limit:</label>
<input type="number" id="limit-input" x-model.number="$store.memoryDashboardStore.limit"
- min="10" max="1000" step="10"
- style="min-width: 100px;" />
+ min="10" max="1000" step="10" style="min-width: 100px;" />
</div>
<div class="filter-actions">
<button class="btn primary slim" @click="$store.memoryDashboardStore.searchMemories()"
- :disabled="$store.memoryDashboardStore.loading || $store.memoryDashboardStore.loadingSubdirs">
+ :disabled="$store.memoryDashboardStore.loading || $store.memoryDashboardStore.loadingSubdirs">
<span x-show="!$store.memoryDashboardStore.initializingMemory">Search</span>
- <span x-show="$store.memoryDashboardStore.initializingMemory">Initializing Memory...</span>
+ <span x-show="$store.memoryDashboardStore.initializingMemory">Initializing
+ Memory...</span>
</button>
<button class="btn slim" @click="$store.memoryDashboardStore.clearSearch()">
Clear
@@ -101,210 +81,226 @@
<span x-text="$store.memoryDashboardStore.error"></span>
</div>
- <!-- Memory table -->
- <div x-show="!$store.memoryDashboardStore.loading && !$store.memoryDashboardStore.error"
- class="memory-table-container">
-
- <!-- Combined stats and pagination header -->
- <div class="stats-pagination-header" x-show="!$store.memoryDashboardStore.loading">
- <!-- Statistics -->
- <div class="memory-stats-compact">
- <div class="stat-item">
- <span class="stat-label">DB Total:</span>
- <span class="stat-value" x-text="$store.memoryDashboardStore.totalDbCount"></span>
- </div>
- <div class="stat-item">
- <span class="stat-label">Filtered:</span>
- <span class="stat-value" x-text="$store.memoryDashboardStore.totalCount"></span>
- </div>
- <div class="stat-item">
- <span class="stat-label">Knowledge:</span>
- <span class="stat-value" x-text="$store.memoryDashboardStore.knowledgeCount"></span>
- </div>
- <div class="stat-item">
- <span class="stat-label">Conversation:</span>
- <span class="stat-value" x-text="$store.memoryDashboardStore.conversationCount"></span>
- </div>
+ <!-- Memory table -->
+ <div x-show="!$store.memoryDashboardStore.loading && !$store.memoryDashboardStore.error"
+ class="memory-table-container">
+
+ <!-- Combined stats and pagination header -->
+ <div class="stats-pagination-header" x-show="!$store.memoryDashboardStore.loading">
+ <!-- Statistics -->
+ <div class="memory-stats-compact">
+ <div class="stat-item">
+ <span class="stat-label">DB Total:</span>
+ <span class="stat-value" x-text="$store.memoryDashboardStore.totalDbCount"></span>
</div>
-
- <!-- Pagination controls -->
- <div class="pagination-controls-compact" x-show="$store.memoryDashboardStore.totalPages > 1">
- <div class="pagination-info-inline">
- <span>Page <span x-text="$store.memoryDashboardStore.currentPage"></span>
- of <span x-text="$store.memoryDashboardStore.totalPages"></span>
- </span>
- </div>
-
- <div class="pagination-controls">
- <button class="btn slim" @click="$store.memoryDashboardStore.prevPage()"
- :disabled="$store.memoryDashboardStore.currentPage === 1">
- Previous
- </button>
-
- <select class="page-select"
- x-model.number="$store.memoryDashboardStore.currentPage"
- @change="$store.memoryDashboardStore.goToPage($store.memoryDashboardStore.currentPage)">
- <template x-for="page in Array.from({length: $store.memoryDashboardStore.totalPages}, (_, i) => i + 1)" :key="page">
- <option :value="page" x-text="'Page ' + page"></option>
- </template>
- </select>
-
- <button class="btn slim" @click="$store.memoryDashboardStore.nextPage()"
- :disabled="$store.memoryDashboardStore.currentPage === $store.memoryDashboardStore.totalPages">
- Next
- </button>
- </div>
+ <div class="stat-item">
+ <span class="stat-label">Filtered:</span>
+ <span class="stat-value" x-text="$store.memoryDashboardStore.totalCount"></span>
+ </div>
+ <div class="stat-item">
+ <span class="stat-label">Knowledge:</span>
+ <span class="stat-value" x-text="$store.memoryDashboardStore.knowledgeCount"></span>
+ </div>
+ <div class="stat-item">
+ <span class="stat-label">Conversation:</span>
+ <span class="stat-value" x-text="$store.memoryDashboardStore.conversationCount"></span>
</div>
</div>
- <!-- Mass action toolbar -->
- <div x-show="$store.memoryDashboardStore.selectedCount > 0" class="mass-action-toolbar">
- <div class="selection-info">
- <span x-text="$store.memoryDashboardStore.selectedCount"></span> memories selected
+ <!-- Pagination controls -->
+ <div class="pagination-controls-compact" x-show="$store.memoryDashboardStore.totalPages > 1">
+ <div class="pagination-info-inline">
+ <span>Page <span x-text="$store.memoryDashboardStore.currentPage"></span>
+ of <span x-text="$store.memoryDashboardStore.totalPages"></span>
+ </span>
</div>
- <div class="mass-actions">
- <button class="btn-mass copy" @click="$store.memoryDashboardStore.bulkCopyMemories()"
- title="Copy Selected Content">
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
- </svg>
- Copy
+ <div class="pagination-controls">
+ <button class="btn slim" @click="$store.memoryDashboardStore.prevPage()"
+ :disabled="$store.memoryDashboardStore.currentPage === 1">
+ Previous
</button>
- <button class="btn-mass export" @click="$store.memoryDashboardStore.bulkExportMemories()"
- title="Export Selected Memories">
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
- <polyline points="7,10 12,15 17,10"></polyline>
- <line x1="12" y1="15" x2="12" y2="3"></line>
- </svg>
- Export
+ <select class="page-select" x-model.number="$store.memoryDashboardStore.currentPage"
+ @change="$store.memoryDashboardStore.goToPage($store.memoryDashboardStore.currentPage)">
+ <template
+ x-for="page in Array.from({length: $store.memoryDashboardStore.totalPages}, (_, i) => i + 1)"
+ :key="page">
+ <option :value="page" x-text="'Page ' + page"></option>
+ </template>
+ </select>
+
+ <button class="btn slim" @click="$store.memoryDashboardStore.nextPage()"
+ :disabled="$store.memoryDashboardStore.currentPage === $store.memoryDashboardStore.totalPages">
+ Next
</button>
+ </div>
+ </div>
+ </div>
- <button class="btn-mass delete" @click="$store.memoryDashboardStore.bulkDeleteMemories()"
- title="Delete Selected Memories">
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <polyline points="3,6 5,6 21,6"></polyline>
- <path d="M19,6V20a2,2,0,0,1-2,2H7a2,2,0,0,1-2-2V6m3,0V4a2,2,0,0,1,2-2h4a2,2,0,0,1,2,2V6"></path>
- <line x1="10" y1="11" x2="10" y2="17"></line>
- <line x1="14" y1="11" x2="14" y2="17"></line>
- </svg>
- Delete
- </button>
+ <!-- Mass action toolbar -->
+ <div x-show="$store.memoryDashboardStore.selectedCount > 0" class="mass-action-toolbar">
+ <div class="selection-info">
+ <span x-text="$store.memoryDashboardStore.selectedCount"></span> memories selected
+ </div>
- <button class="btn-mass clear" @click="$store.memoryDashboardStore.clearSelection()"
- title="Clear Selection">
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <line x1="18" y1="6" x2="6" y2="18"></line>
- <line x1="6" y1="6" x2="18" y2="18"></line>
- </svg>
- Clear
- </button>
- </div>
+ <div class="mass-actions">
+ <button class="btn-mass copy" @click="$store.memoryDashboardStore.bulkCopyMemories()"
+ title="Copy Selected Content">
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ stroke-width="2">
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
+ </svg>
+ Copy
+ </button>
+
+ <button class="btn-mass export" @click="$store.memoryDashboardStore.bulkExportMemories()"
+ title="Export Selected Memories">
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ stroke-width="2">
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
+ <polyline points="7,10 12,15 17,10"></polyline>
+ <line x1="12" y1="15" x2="12" y2="3"></line>
+ </svg>
+ Export
+ </button>
+
+ <button class="btn-mass delete" @click="$store.memoryDashboardStore.bulkDeleteMemories()"
+ title="Delete Selected Memories">
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ stroke-width="2">
+ <polyline points="3,6 5,6 21,6"></polyline>
+ <path
+ d="M19,6V20a2,2,0,0,1-2,2H7a2,2,0,0,1-2-2V6m3,0V4a2,2,0,0,1,2-2h4a2,2,0,0,1,2,2V6">
+ </path>
+ <line x1="10" y1="11" x2="10" y2="17"></line>
+ <line x1="14" y1="11" x2="14" y2="17"></line>
+ </svg>
+ Delete
+ </button>
+
+ <button class="btn-mass clear" @click="$store.memoryDashboardStore.clearSelection()"
+ title="Clear Selection">
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ stroke-width="2">
+ <line x1="18" y1="6" x2="6" y2="18"></line>
+ <line x1="6" y1="6" x2="18" y2="18"></line>
+ </svg>
+ Clear
+ </button>
</div>
+ </div>
- <div class="table-wrapper">
- <table class="memory-table">
- <thead>
- <tr>
- <th class="col-select">
- <input type="checkbox"
- :checked="$store.memoryDashboardStore.allSelected"
- :indeterminate="$store.memoryDashboardStore.someSelected && !$store.memoryDashboardStore.allSelected"
- @change="$store.memoryDashboardStore.toggleSelectAll()"
- title="Select/Deselect All" />
- </th>
- <th class="col-metadata">Metadata</th>
- <th class="col-preview">Preview</th>
- <th class="col-actions"></th>
- </tr>
- </thead>
- <tbody>
- <template x-for="memory in $store.memoryDashboardStore.paginatedMemories" :key="memory.id">
- <tr class="memory-row" :class="{'selected': memory.selected}"
- @click="$store.memoryDashboardStore.showMemoryDetails(memory)"
- style="cursor: pointer;">
- <!-- Selection checkbox -->
- <td class="select-cell" @click.stop>
- <input type="checkbox"
- x-model="memory.selected" />
- </td>
-
- <!-- Metadata (merged Area, Timestamp, Source) -->
- <td class="metadata-cell">
- <div class="metadata-info">
- <div class="metadata-row">
- <span class="area-badge"
- :style="`background-color: ${$store.memoryDashboardStore.getAreaColor(memory.area)}`"
- x-text="(memory.area || 'UNKNOWN').toUpperCase()"></span>
- </div>
- <div class="metadata-row metadata-timestamp">
- <span x-text="$store.memoryDashboardStore.formatTimestamp(memory.timestamp, true)"
- :title="$store.memoryDashboardStore.formatTimestamp(memory.timestamp, false)"></span>
+ <div class="table-wrapper">
+ <table class="memory-table">
+ <thead>
+ <tr>
+ <th class="col-select">
+ <input type="checkbox" :checked="$store.memoryDashboardStore.allSelected"
+ :indeterminate="$store.memoryDashboardStore.someSelected && !$store.memoryDashboardStore.allSelected"
+ @change="$store.memoryDashboardStore.toggleSelectAll()"
+ title="Select/Deselect All" />
+ </th>
+ <th class="col-metadata">Metadata</th>
+ <th class="col-preview">Preview</th>
+ <th class="col-actions"></th>
+ </tr>
+ </thead>
+ <tbody>
+ <template x-for="memory in $store.memoryDashboardStore.paginatedMemories"
+ :key="memory.id">
+ <tr class="memory-row" :class="{'selected': memory.selected}"
+ @click="$store.memoryDashboardStore.showMemoryDetails(memory)"
+ style="cursor: pointer;">
+ <!-- Selection checkbox -->
+ <td class="select-cell" @click.stop>
+ <input type="checkbox" x-model="memory.selected" />
+ </td>
+
+ <!-- Metadata (merged Area, Timestamp, Source) -->
+ <td class="metadata-cell">
+ <div class="metadata-info">
+ <div class="metadata-row">
+ <span class="area-badge"
+ :style="`background-color: ${$store.memoryDashboardStore.getAreaColor(memory.area)}`"
+ x-text="(memory.area || 'UNKNOWN').toUpperCase()"></span>
+ </div>
+ <div class="metadata-row metadata-timestamp">
+ <span
+ x-text="$store.memoryDashboardStore.formatTimestamp(memory.timestamp, true)"
+ :title="$store.memoryDashboardStore.formatTimestamp(memory.timestamp, false)"></span>
+ </div>
+ <div class="metadata-row">
+ <template x-if="memory.knowledge_source">
+ <span class="source-type knowledge">Knowledge</span>
+ </template>
+ <template x-if="!memory.knowledge_source">
+ <span class="source-type conversation">Conversation</span>
+ </template>
+ </div>
</div>
- <div class="metadata-row">
- <template x-if="memory.knowledge_source">
- <span class="source-type knowledge">Knowledge</span>
- </template>
- <template x-if="!memory.knowledge_source">
- <span class="source-type conversation">Conversation</span>
+ </td>
+
+ <!-- Content preview -->
+ <td class="preview-cell">
+ <div class="content-preview" x-text="memory.content_preview"></div>
+ <div class="tags" x-show="memory.tags && memory.tags.length > 0">
+ <template x-for="tag in memory.tags" :key="tag">
+ <span class="tag" x-text="tag"></span>
</template>
</div>
- </div>
- </td>
-
- <!-- Content preview -->
- <td class="preview-cell">
- <div class="content-preview" x-text="memory.content_preview"></div>
- <div class="tags" x-show="memory.tags && memory.tags.length > 0">
- <template x-for="tag in memory.tags" :key="tag">
- <span class="tag" x-text="tag"></span>
- </template>
- </div>
- </td>
-
- <!-- Actions -->
- <td class="actions-cell" @click.stop>
- <div class="actions-wrapper">
- <button class="btn-action copy" @click="$store.memoryDashboardStore.copyToClipboard($store.memoryDashboardStore.formatMemoryForCopy(memory))"
- title="Copy Memory">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
- </svg>
- </button>
+ </td>
- <button class="btn-action delete" @click="$store.memoryDashboardStore.deleteMemory(memory)"
+ <!-- Actions -->
+ <td class="actions-cell" @click.stop>
+ <div class="actions-wrapper">
+ <button class="btn-action copy"
+ @click="$store.memoryDashboardStore.copyToClipboard($store.memoryDashboardStore.formatMemoryForCopy(memory))"
+ title="Copy Memory">
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none"
+ stroke="currentColor" stroke-width="2">
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
+ <path
+ d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1">
+ </path>
+ </svg>
+ </button>
+
+ <button class="btn-action delete"
+ @click="$store.memoryDashboardStore.deleteMemory(memory)"
title="Delete Memory">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <polyline points="3,6 5,6 21,6"></polyline>
- <path d="M19,6V20a2,2,0,0,1-2,2H7a2,2,0,0,1-2-2V6M8,6V4a2,2,0,0,1,2-2h4a2,2,0,0,1,2,2V6"></path>
- <line x1="10" y1="11" x2="10" y2="17"></line>
- <line x1="14" y1="11" x2="14" y2="17"></line>
- </svg>
- </button>
- </div>
- </td>
- </tr>
- </template>
- </tbody>
- </table>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none"
+ stroke="currentColor" stroke-width="2">
+ <polyline points="3,6 5,6 21,6"></polyline>
+ <path
+ d="M19,6V20a2,2,0,0,1-2,2H7a2,2,0,0,1-2-2V6M8,6V4a2,2,0,0,1,2-2h4a2,2,0,0,1,2,2V6">
+ </path>
+ <line x1="10" y1="11" x2="10" y2="17"></line>
+ <line x1="14" y1="11" x2="14" y2="17"></line>
+ </svg>
+ </button>
+ </div>
+ </td>
+ </tr>
+ </template>
+ </tbody>
+ </table>
</div>
- <!-- No memories message -->
- <div x-show="$store.memoryDashboardStore.memories.length === 0 && !$store.memoryDashboardStore.message" class="no-memories">
- No memories found matching the current filters.
- </div>
+ <!-- No memories message -->
+ <div x-show="$store.memoryDashboardStore.memories.length === 0 && !$store.memoryDashboardStore.message"
+ class="no-memories">
+ No memories found matching the current filters.
+ </div>
- <!-- Initialization message -->
- <div x-show="$store.memoryDashboardStore.message" class="init-message">
- <span x-text="$store.memoryDashboardStore.message"></span>
- </div>
+ <!-- Initialization message -->
+ <div x-show="$store.memoryDashboardStore.message" class="init-message">
+ <span x-text="$store.memoryDashboardStore.message"></span>
+ </div>
@@ -423,7 +419,8 @@
color: var(--color-text);
}
- .filter-group input, .filter-group select {
+ .filter-group input,
+ .filter-group select {
padding: 0.5rem;
border: 1px solid var(--color-border);
background: var(--color-background);
@@ -435,7 +432,8 @@
box-sizing: border-box;
}
- .filter-group input:focus, .filter-group select:focus {
+ .filter-group input:focus,
+ .filter-group select:focus {
outline: none;
border-color: var(--color-primary);
box-shadow: 0 0 0 2px rgba(115, 122, 129, 0.2);
@@ -467,7 +465,10 @@
font-style: italic;
}
- .loading-state, .error-state, .no-memories, .init-message {
+ .loading-state,
+ .error-state,
+ .no-memories,
+ .init-message {
text-align: center;
padding: 2rem;
color: var(--color-text);
@@ -518,7 +519,9 @@
}
@keyframes spin {
- to { transform: rotate(360deg); }
+ to {
+ transform: rotate(360deg);
+ }
}
.memory-table-container {
@@ -541,10 +544,21 @@
}
/* Fixed column widths for proper fit */
- .col-select { width: 5%; }
- .col-metadata { width: 25%; }
- .col-preview { width: 60%; }
- .col-actions { width: 10%; }
+ .col-select {
+ width: 5%;
+ }
+
+ .col-metadata {
+ width: 25%;
+ }
+
+ .col-preview {
+ width: 60%;
+ }
+
+ .col-actions {
+ width: 10%;
+ }
.memory-table th,
.memory-table td {
@@ -587,7 +601,8 @@
}
/* Selection column styling */
- .select-cell, .col-select {
+ .select-cell,
+ .col-select {
text-align: center;
padding: 0.5rem !important;
}
@@ -680,6 +695,7 @@
opacity: 0;
transform: translateY(-10px);
}
+
to {
opacity: 1;
transform: translateY(0);
@@ -1003,6 +1019,7 @@
transform: translateY(20px) scale(0.95);
opacity: 0;
}
+
to {
transform: translateY(0) scale(1);
opacity: 1;
@@ -1290,7 +1307,8 @@
align-items: stretch;
}
- .filter-group input, .filter-group select {
+ .filter-group input,
+ .filter-group select {
min-width: unset;
width: 100%;
}
@@ -1306,10 +1324,21 @@
width: 60px;
}
- .col-select { width: 8%; }
- .col-metadata { width: 27%; }
- .col-preview { width: 55%; }
- .col-actions { width: 10%; }
+ .col-select {
+ width: 8%;
+ }
+
+ .col-metadata {
+ width: 27%;
+ }
+
+ .col-preview {
+ width: 55%;
+ }
+
+ .col-actions {
+ width: 10%;
+ }
.memory-detail-modal {
width: 98%;
@@ -1382,7 +1411,8 @@
align-items: center;
}
- .timestamp-badge, .source-badge {
+ .timestamp-badge,
+ .source-badge {
padding: 0.25rem 0.75rem;
border-radius: 12px;
font-size: 0.75rem;
@@ -1604,7 +1634,8 @@
}
</style>
- </template>
+ </template>
</div>
</body>
-</html>
+
+</html>
\ No newline at end of file
diff --git a/webui/js/initFw.js b/webui/js/initFw.js
index cdc83adaf..69abde220 100644
--- a/webui/js/initFw.js
+++ b/webui/js/initFw.js
@@ -1,9 +1,9 @@
-import * as initializer from "./initializer.js"
+import * as initializer from "./initializer.js";
import * as _modals from "./modals.js";
import * as _components from "./components.js";
// initialize required elements
-await initializer.initialize()
+await initializer.initialize();
// import alpine library
await import("../vendor/alpine/alpine.min.js");
@@ -16,3 +16,9 @@ Alpine.directive(
cleanup(() => onDestroy());
}
);
+
+// add x-create directive to alpine
+Alpine.directive("create", (_el, { expression }, { evaluateLater }) => {
+ const onCreate = evaluateLater(expression);
+ onCreate();
+});