diff --git a/src/serena/dashboard.py b/src/serena/dashboard.py index b2a64f5e..d59ff8f1 100644 --- a/src/serena/dashboard.py +++ b/src/serena/dashboard.py @@ -49,6 +49,7 @@ class ResponseConfigOverview(BaseModel): available_tools: list[dict[str, str | bool]] available_modes: list[dict[str, str | bool]] available_contexts: list[dict[str, str | bool]] + available_memories: list[str] | None class SerenaDashboardAPI: @@ -155,6 +156,7 @@ class SerenaDashboardAPI: project_info = { "name": active_project_name, "language": ", ".join([l.value for l in project.project_config.languages]) if project else None, + "path": str(project.project_root) if project else None, } # Get context info @@ -162,11 +164,12 @@ class SerenaDashboardAPI: context_info = { "name": context.name, "description": context.description, + "path": SerenaAgentContext.get_path(context.name), } # Get active modes modes = self._agent.get_active_modes() - modes_info = [{"name": mode.name, "description": mode.description} for mode in modes] + modes_info = [{"name": mode.name, "description": mode.description, "path": SerenaAgentMode.get_path(mode.name)} for mode in modes] active_mode_names = [mode.name for mode in modes] # Get active tools @@ -203,6 +206,7 @@ class SerenaDashboardAPI: { "name": mode_name, "is_active": mode_name in active_mode_names, + "path": SerenaAgentMode.get_path(mode_name), } ) @@ -214,6 +218,7 @@ class SerenaDashboardAPI: { "name": context_name, "is_active": context_name == context.name, + "path": SerenaAgentContext.get_path(context_name), } ) @@ -223,6 +228,11 @@ class SerenaDashboardAPI: full_stats = self._tool_usage_stats.get_tool_stats_dict() tool_stats_summary = {name: {"num_calls": stats["num_times_called"]} for name, stats in full_stats.items()} + # Get available memories if ReadMemoryTool is active + available_memories = None + if self._agent.tool_is_active("read_memory") and project is not None: + available_memories = project.memories_manager.list_memories() + return ResponseConfigOverview( active_project=project_info, context=context_info, @@ -233,6 +243,7 @@ class SerenaDashboardAPI: available_tools=available_tools, available_modes=available_modes, available_contexts=available_contexts, + available_memories=available_memories, ) def _shutdown(self) -> None: diff --git a/src/serena/resources/dashboard/dashboard.js b/src/serena/resources/dashboard/dashboard.js index b1c53bc3..e63fdd29 100644 --- a/src/serena/resources/dashboard/dashboard.js +++ b/src/serena/resources/dashboard/dashboard.js @@ -89,7 +89,10 @@ class Dashboard { // Register event handlers this.$loadButton.click(this.loadLogs.bind(this)); - this.$menuShutdown.click(this.shutdown.bind(this)); + this.$menuShutdown.click(function(e) { + e.preventDefault(); + self.shutdown(); + }); this.$menuToggle.click(this.toggleMenu.bind(this)); this.$themeToggle.click(this.toggleTheme.bind(this)); this.$refreshStats.click(this.loadStats.bind(this)); @@ -184,6 +187,7 @@ class Dashboard { url: '/get_config_overview', type: 'GET', success: function(response) { + self.failureCount = 0; self.configData = response; self.displayConfig(response); self.displayBasicStats(response.tool_stats_summary); @@ -194,6 +198,11 @@ class Dashboard { }, error: function(xhr, status, error) { console.error('Error loading config overview:', error); + self.failureCount++; + if (self.failureCount >= 3) { + console.log('Server appears to be down, closing tab'); + window.close(); + } self.$configDisplay.html('
'); self.$basicStatsDisplay.html(''); self.$projectsDisplay.html(''); @@ -210,32 +219,38 @@ class Dashboard { } displayConfig(config) { - // Check if tools section is currently expanded - const $existingContent = $('#tools-content'); - const wasExpanded = $existingContent.is(':visible'); + // Check if tools and memories sections are currently expanded + const $existingToolsContent = $('#tools-content'); + const $existingMemoriesContent = $('#memories-content'); + const wasToolsExpanded = $existingToolsContent.is(':visible'); + const wasMemoriesExpanded = $existingMemoriesContent.is(':visible'); let html = '