From 973e120bdf9f19a785299064b588846eefacca23 Mon Sep 17 00:00:00 2001 From: false200 <214800619+false200@users.noreply.github.com> Date: Thu, 20 Aug 2026 14:35:28 +0530 Subject: [PATCH] fix: merge reset-agent chat options and refresh the session list --- app/agent_base.py | 25 ++++++++----------- app/ui_layer/adapters/browser_adapter.py | 14 ++++++++--- .../frontend/src/components/ui/ResetModal.tsx | 10 +++----- .../src/pages/Settings/GeneralSettings.tsx | 4 +-- app/ui_layer/commands/builtin/reset.py | 6 ++--- mkdocs/docs/core/commands/builtin.md | 2 +- 6 files changed, 30 insertions(+), 31 deletions(-) diff --git a/app/agent_base.py b/app/agent_base.py index 8e8068b45..d5e6366d9 100644 --- a/app/agent_base.py +++ b/app/agent_base.py @@ -2483,7 +2483,6 @@ def _build_db_interface(self, *, data_dir: str, chroma_path: str): # Components a selective reset can target. Order matters only for the # human-readable summary; each block is independent. RESET_COMPONENTS = ( - "conversation", "sessions", "memory", "workspace", @@ -2577,9 +2576,10 @@ async def _reset_selected_components(self, components: "Iterable[str]") -> str: rest. Unknown component names are ignored (logged). """ selected = {str(c).strip().lower() for c in components if str(c).strip()} - # Legacy name from the old task system maps onto sessions. - if "tasks" in selected: + # Legacy names map onto the single chats component. + if "tasks" in selected or "conversation" in selected: selected.discard("tasks") + selected.discard("conversation") selected.add("sessions") unknown = selected - set(self.RESET_COMPONENTS) if unknown: @@ -2592,8 +2592,9 @@ async def _reset_selected_components(self, components: "Iterable[str]") -> str: done: list[str] = [] - # Conversation: main session's conversation + chat/action/usage rows. - if "conversation" in selected: + # Chats: delete extra chat sessions, empty Main, and wipe Living UI + # conversation history only (apps stay unless "livingui" is selected). + if "sessions" in selected: try: from app.usage import ( get_chat_storage, @@ -2601,19 +2602,15 @@ async def _reset_selected_components(self, components: "Iterable[str]") -> str: get_usage_storage, ) + count = await self._delete_all_chat_sessions() get_chat_storage().clear_messages() get_action_storage().clear_items() get_usage_storage().clear_events() self.session_manager.clear_session(MAIN_SESSION_ID) - done.append("conversation") - except Exception as e: - logger.warning(f"[RESET] conversation reset failed: {e}") - - # Sessions: delete all chat sessions (main + living UI stay). - if "sessions" in selected: - try: - count = await self._delete_all_chat_sessions() - done.append(f"sessions ({count} deleted)") + for session in list(self.session_manager.sessions.values()): + if session.type == SessionType.LIVING_UI: + self.session_manager.clear_session(session.id) + done.append(f"sessions ({count} chats deleted)") except Exception as e: logger.warning(f"[RESET] sessions reset failed: {e}") diff --git a/app/ui_layer/adapters/browser_adapter.py b/app/ui_layer/adapters/browser_adapter.py index 094e55c2c..35220ac8a 100644 --- a/app/ui_layer/adapters/browser_adapter.py +++ b/app/ui_layer/adapters/browser_adapter.py @@ -4091,12 +4091,18 @@ async def _handle_reset(self, data: dict | None = None) -> None: result = await reset_agent_state(self._controller, components=components) if result.get("success"): - # Only clear the UI panels whose data was actually reset. A full - # reset (components is None) clears both. - if components is None or "conversation" in components: + # Chats (id "sessions", plus the legacy "conversation" alias): + # clear transcripts, the action panel, and push the session list + # so extra chats drop from the sidebar without a refresh. + chats_reset = ( + components is None + or "sessions" in components + or "conversation" in components + ) + if chats_reset: await self._chat.clear() - if components is None or "sessions" in components: await self._action_panel.clear() + await self._handle_session_list() # If LivingUI apps were deleted, push refreshed (now-empty) lists so # the frontend reflects the deletion. Both the main LivingUI page diff --git a/app/ui_layer/browser/frontend/src/components/ui/ResetModal.tsx b/app/ui_layer/browser/frontend/src/components/ui/ResetModal.tsx index afe5b814d..29e51606c 100644 --- a/app/ui_layer/browser/frontend/src/components/ui/ResetModal.tsx +++ b/app/ui_layer/browser/frontend/src/components/ui/ResetModal.tsx @@ -14,15 +14,11 @@ interface ResetItem { } export const RESET_ITEMS: ResetItem[] = [ - { - id: 'conversation', - label: 'Conversation history', - description: 'Chat messages and the action log.', - }, { id: 'sessions', - label: 'Chat sessions', - description: 'All chat sessions and their history.', + label: 'Chats', + description: + 'Delete extra chats, clear Main, and clear Living UI chat history. Apps are kept.', }, { id: 'memory', diff --git a/app/ui_layer/browser/frontend/src/pages/Settings/GeneralSettings.tsx b/app/ui_layer/browser/frontend/src/pages/Settings/GeneralSettings.tsx index ed8ff167e..62180e5aa 100644 --- a/app/ui_layer/browser/frontend/src/pages/Settings/GeneralSettings.tsx +++ b/app/ui_layer/browser/frontend/src/pages/Settings/GeneralSettings.tsx @@ -810,8 +810,8 @@ export function GeneralSettings() {

Reset Agent

- Reset the agent to its initial state. This will clear chat sessions, conversation history, - and restore the agent file system from templates. Saved settings and credentials are preserved. + Reset selected parts of the agent. Chats can be wiped without deleting + Living UI apps. Saved settings and credentials are preserved.