Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix: /resume on Windows and cross-project session search

wdc6367e762f1670a
diff --git a/config/v2_sessions.py b/config/v2_sessions.py
index e8819b355..3890dacd8 100644
--- a/config/v2_sessions.py
+++ b/config/v2_sessions.py
@@ -94,6 +94,9 @@ class ActivePollInfo:
class SessionState:
# session_mappings: user_id -> agent_name -> thread_id -> session_id
session_mappings: Dict[str, Dict[str, Dict[str, str]]] = field(default_factory=dict)
+ # session_working_paths: user_id -> agent_name -> thread_id -> working_path
+ # Stores the original working_path for cross-project resumed sessions
+ session_working_paths: Dict[str, Dict[str, Dict[str, str]]] = field(default_factory=dict)
active_slack_threads: Dict[str, Dict[str, Dict[str, float]]] = field(default_factory=dict)
# active_polls: opencode_session_id -> ActivePollInfo
active_polls: Dict[str, Dict[str, Any]] = field(default_factory=dict)
@@ -118,6 +121,7 @@ class SessionsStore:
return
self.state = SessionState(
session_mappings=payload.get("session_mappings", {}),
+ session_working_paths=payload.get("session_working_paths", {}),
active_slack_threads=payload.get("active_slack_threads", {}),
active_polls=payload.get("active_polls", {}),
processed_message_ts=payload.get("processed_message_ts", {}),
@@ -353,6 +357,7 @@ class SessionsStore:
paths.ensure_data_dirs()
payload = {
"session_mappings": self.state.session_mappings,
+ "session_working_paths": self.state.session_working_paths,
"active_slack_threads": self.state.active_slack_threads,
"active_polls": self.state.active_polls,
"processed_message_ts": self.state.processed_message_ts,
diff --git a/core/handlers/command_handlers.py b/core/handlers/command_handlers.py
index ad5d4a4c7..a2f247599 100644
--- a/core/handlers/command_handlers.py
+++ b/core/handlers/command_handlers.py
@@ -119,9 +119,6 @@ class CommandHandlers(BaseHandler):
if time.time() - float(snapshot.get("stored_at", 0.0)) > self._resume_snapshot_ttl_seconds:
self._resume_snapshots.pop(self._get_resume_snapshot_key(context), None)
return None
- if snapshot.get("working_path") != self.controller.get_cwd(context):
- self._resume_snapshots.pop(self._get_resume_snapshot_key(context), None)
- return None
return snapshot
def _list_recent_native_sessions(
@@ -138,7 +135,7 @@ class CommandHandlers(BaseHandler):
native_session_service = getattr(self.controller, "native_session_service", None)
if native_session_service is None:
return working_path, []
- sessions = native_session_service.list_recent_sessions(working_path, limit=limit)
+ sessions = native_session_service.list_all_recent_sessions(limit=limit)
agent_service = getattr(self.controller, "agent_service", None)
registered_agents = getattr(agent_service, "agents", None)
if isinstance(registered_agents, dict) and registered_agents:
@@ -272,6 +269,7 @@ class CommandHandlers(BaseHandler):
host_message_ts=context.message_id,
is_dm=bool((context.platform_specific or {}).get("is_dm", False)),
platform=context.platform or (context.platform_specific or {}).get("platform") or self.config.platform,
+ session_working_path=item.working_path,
)
async def _handle_wechat_resume_latest(self, context: MessageContext, *, agent: Optional[str] = None) -> None:
@@ -298,6 +296,7 @@ class CommandHandlers(BaseHandler):
host_message_ts=context.message_id,
is_dm=bool((context.platform_specific or {}).get("is_dm", False)),
platform=context.platform or (context.platform_specific or {}).get("platform") or self.config.platform,
+ session_working_path=item.working_path,
)
async def _handle_wechat_resume(self, context: MessageContext, args: str) -> None:
@@ -457,7 +456,9 @@ class CommandHandlers(BaseHandler):
InlineButton(text=f"🤖 {self._t('button.agentSettings')}", callback_data="cmd_routing"),
],
# Row 4: Features
- [InlineButton(text=f"✨ {self._t('button.howItWorks')}", callback_data="info_how_it_works")],
+ [
+ InlineButton(text=f"✨ {self._t('button.howItWorks')}", callback_data="info_how_it_works"),
+ ],
]
keyboard = InlineKeyboard(buttons=buttons)
diff --git a/core/handlers/session_handler.py b/core/handlers/session_handler.py
index edd7bbf5c..f4d25c49f 100644
--- a/core/handlers/session_handler.py
+++ b/core/handlers/session_handler.py
@@ -404,6 +404,13 @@ class SessionHandler(BaseHandler):
session_key = self._get_session_key(context)
stored_claude_session_id = self.sessions.get_claude_session_id(session_key, base_session_id)
+ # For cross-project resumed sessions, use the stored working_path
+ # as cwd so Claude Code can find the session file.
+ stored_working_path = self.sessions.get_agent_session_working_path(session_key, base_session_id, agent_name="claude")
+ if stored_working_path and stored_claude_session_id:
+ logger.info(f"Using stored working_path for resumed session: {stored_working_path} (current: {working_path})")
+ working_path = stored_working_path
+
# Read routing overrides via get_channel_routing which correctly
# resolves DM users from the users store (not the stale channels store).
routing = self._get_settings_manager(context).get_channel_routing(settings_key)
@@ -666,6 +673,7 @@ class SessionHandler(BaseHandler):
host_message_ts: Optional[str] = None,
is_dm: bool = False,
platform: Optional[str] = None,
+ session_working_path: Optional[str] = None,
) -> None:
"""Bind a provided session_id to the current thread for the chosen agent."""
from modules.settings_manager import ChannelRouting
@@ -793,7 +801,7 @@ class SessionHandler(BaseHandler):
if agent == "opencode":
mapping_key = f"{base_session_id}:{working_path}"
- self.sessions.set_agent_session_mapping(session_key, agent, mapping_key, session_id)
+ self.sessions.set_agent_session_mapping(session_key, agent, mapping_key, session_id, session_working_path=session_working_path)
self.sessions.mark_thread_active(user_id, context.channel_id, mapped_thread)
except Exception as e:
logger.error(f"Error resuming session: {e}", exc_info=True)
diff --git a/modules/agents/native_sessions/claude.py b/modules/agents/native_sessions/claude.py
index bb265e7ba..615a4f980 100644
--- a/modules/agents/native_sessions/claude.py
+++ b/modules/agents/native_sessions/claude.py
@@ -2,6 +2,7 @@ from __future__ import annotations
import json
import logging
+import os
import re
from datetime import datetime
from pathlib import Path
@@ -18,8 +19,13 @@ from .types import NativeResumeSession
logger = logging.getLogger(__name__)
+def _norm_path(p: str) -> str:
+ """Normalize path for comparison: resolve case and separators."""
+ return os.path.normcase(os.path.normpath(p))
+
+
def encode_project_path(working_path: str) -> str:
- return working_path.replace("/", "-")
+ return re.sub(r"[^A-Za-z0-9]", "-", working_path)
class ClaudeNativeSessionProvider(NativeSessionProvider):
@@ -35,12 +41,20 @@ class ClaudeNativeSessionProvider(NativeSessionProvider):
@staticmethod
def _candidate_project_names(working_path: str) -> set[str]:
collapsed = re.sub(r"[^A-Za-z0-9]+", "-", working_path).strip("-")
- names = {
+ names: set[str] = {
encode_project_path(working_path),
encode_project_path(working_path).replace("_", "-"),
}
if collapsed:
names.add(f"-{collapsed}")
+ # On Windows, backslashes and colons are each replaced with a
+ # separate dash by Claude Code (e.g. "C:\Users" → "C--Users"),
+ # whereas the collapsed regex above merges consecutive non-alnum
+ # chars into one dash ("C:\Users" → "C-Users"). Add the
+ # per-character encoding so the actual directory name is found.
+ per_char = re.sub(r"[^A-Za-z0-9]", "-", working_path)
+ names.add(per_char)
+ names.add(per_char.replace("_", "-"))
return names
@staticmethod
@@ -104,7 +118,7 @@ class ClaudeNativeSessionProvider(NativeSessionProvider):
) -> str | None:
session_id = str(entry.get("sessionId") or "").strip()
project_path = str(entry.get("projectPath") or "").strip()
- if not session_id or project_path != working_path:
+ if not session_id or _norm_path(project_path) != _norm_path(working_path):
return None
created_at = self._parse_iso(entry.get("created"))
updated_at = self._parse_iso(entry.get("modified"))
@@ -191,7 +205,7 @@ class ClaudeNativeSessionProvider(NativeSessionProvider):
row_cwd = str(row.get("cwd") or row.get("projectPath") or "").strip()
if row_cwd:
inferred_working_path = row_cwd
- if row_cwd == working_path:
+ if _norm_path(row_cwd) == _norm_path(working_path):
matched_working_path = True
if row.get("type") == "user" and not first_prompt:
first_prompt = str((row.get("message") or {}).get("content") or "")
@@ -200,7 +214,7 @@ class ClaudeNativeSessionProvider(NativeSessionProvider):
created_at = timestamp
if timestamp:
updated_at = timestamp
- if not matched_working_path and inferred_working_path and inferred_working_path != working_path:
+ if not matched_working_path and inferred_working_path and _norm_path(inferred_working_path) != _norm_path(working_path):
return False
if not (created_at or updated_at):
stat = jsonl_path.stat()
@@ -274,15 +288,114 @@ class ClaudeNativeSessionProvider(NativeSessionProvider):
continue
self._merge_session_file(results, working_path=working_path, jsonl_path=jsonl_path)
- if not results:
- for project_dir in candidate_dirs:
- for jsonl_path in sorted(project_dir.glob("*.jsonl")):
+ # Always scan candidate dirs for .jsonl files not yet discovered
+ # via index or history (e.g. sessions created by SDK/agent that
+ # don't write to sessions-index.json or history.jsonl).
+ known_ids = set(results)
+ for project_dir in candidate_dirs:
+ for jsonl_path in sorted(project_dir.glob("*.jsonl")):
+ if jsonl_path.stem not in known_ids:
self._merge_session_file(results, working_path=working_path, jsonl_path=jsonl_path)
items = list(results.values())
items.sort(key=lambda item: (-item.sort_ts, item.native_session_id))
return items
+ def _merge_session_file_unfiltered(
+ self,
+ results: dict[str, NativeResumeSession],
+ *,
+ jsonl_path: Path,
+ ) -> bool:
+ """Merge a session file without filtering by working_path.
+ The session's working_path is inferred from the file's cwd/projectPath fields."""
+ rows = read_json_lines(jsonl_path)
+ if not rows:
+ return False
+ created_at = None
+ updated_at = None
+ first_prompt = ""
+ inferred_working_path = ""
+ for row in rows:
+ row_cwd = str(row.get("cwd") or row.get("projectPath") or "").strip()
+ if row_cwd:
+ inferred_working_path = row_cwd
+ if row.get("type") == "user" and not first_prompt:
+ first_prompt = str((row.get("message") or {}).get("content") or "")
+ timestamp = self._parse_iso(row.get("timestamp"))
+ if timestamp and created_at is None:
+ created_at = timestamp
+ if timestamp:
+ updated_at = timestamp
+ if not inferred_working_path:
+ return False
+ if not (created_at or updated_at):
+ stat = jsonl_path.stat()
+ created_at = datetime.fromtimestamp(stat.st_ctime)
+ updated_at = datetime.fromtimestamp(stat.st_mtime)
+ self._merge_session(
+ results,
+ NativeResumeSession(
+ agent="claude",
+ agent_prefix="cc",
+ native_session_id=jsonl_path.stem,
+ working_path=inferred_working_path,
+ created_at=created_at,
+ updated_at=updated_at,
+ sort_ts=(updated_at or created_at).timestamp() if (updated_at or created_at) else 0.0,
+ locator={"full_path": str(jsonl_path), "first_prompt": first_prompt},
+ ),
+ )
+ return True
+
+ def list_all_metadata(self) -> list[NativeResumeSession]:
+ """List sessions across all project directories."""
+ results: dict[str, NativeResumeSession] = {}
+
+ # Scan all project directories under ~/.claude/projects/
+ if not self.root.exists():
+ return []
+
+ for project_dir in sorted(self.root.iterdir()):
+ if not project_dir.is_dir():
+ continue
+ # Scan all .jsonl session files in each project dir
+ for jsonl_path in sorted(project_dir.glob("*.jsonl")):
+ self._merge_session_file_unfiltered(results, jsonl_path=jsonl_path)
+
+ # Also scan history.jsonl for sessions not found in files
+ if self.history_path.exists():
+ for row in read_json_lines(self.history_path):
+ session_id = str(row.get("sessionId") or "").strip()
+ project_path = str(row.get("project") or "").strip()
+ if not session_id or not project_path:
+ continue
+ if session_id in results:
+ # Already discovered from file; just enrich with display
+ display = str(row.get("display") or "").strip()
+ if display and not results[session_id].locator.get("history_display"):
+ results[session_id].locator["history_display"] = display
+ continue
+ updated_at = dt_from_ts(row.get("timestamp"), millis=True)
+ sort_ts = updated_at.timestamp() if updated_at else 0.0
+ self._merge_session(
+ results,
+ NativeResumeSession(
+ agent="claude",
+ agent_prefix="cc",
+ native_session_id=session_id,
+ working_path=project_path,
+ created_at=updated_at if isinstance(updated_at, datetime) else None,
+ updated_at=updated_at if isinstance(updated_at, datetime) else None,
+ sort_ts=sort_ts,
+ locator={"history_display": str(row.get("display") or "").strip()},
+ ),
+ )
+
+ items = list(results.values())
+ items.sort(key=lambda item: (-item.sort_ts, item.native_session_id))
+ return items
+
def hydrate_preview(self, item: NativeResumeSession) -> NativeResumeSession:
preview = ""
full_path_raw = str(item.locator.get("full_path") or "").strip()
diff --git a/modules/agents/native_sessions/codex.py b/modules/agents/native_sessions/codex.py
index 0758877b5..b26c36501 100644
--- a/modules/agents/native_sessions/codex.py
+++ b/modules/agents/native_sessions/codex.py
@@ -57,6 +57,47 @@ class CodexNativeSessionProvider(NativeSessionProvider):
logger.warning("Failed to list Codex sessions for %s: %s", working_path, exc)
return items
+ def list_all_metadata(self) -> list[NativeResumeSession]:
+ """List sessions across all project directories."""
+ if not self.db_path.exists():
+ return []
+ items: list[NativeResumeSession] = []
+ try:
+ with self._connect() as conn:
+ cursor = conn.execute(
+ """
+ SELECT id, cwd, created_at, updated_at, title, first_user_message, rollout_path
+ FROM threads
+ WHERE archived = 0
+ ORDER BY updated_at DESC, id DESC
+ """,
+ )
+ for session_id, cwd, created_ts, updated_ts, title, first_user_message, rollout_path in cursor.fetchall():
+ if not cwd:
+ continue
+ created_at = dt_from_ts(created_ts)
+ updated_at = dt_from_ts(updated_ts)
+ items.append(
+ NativeResumeSession(
+ agent="codex",
+ agent_prefix="cx",
+ native_session_id=session_id,
+ working_path=cwd,
+ created_at=created_at,
+ updated_at=updated_at,
+ sort_ts=(updated_at or created_at).timestamp() if (updated_at or created_at) else 0.0,
+ locator={
+ "title": title or "",
+ "first_user_message": first_user_message or "",
+ "rollout_path": rollout_path or "",
+ },
+ )
+ )
+ except Exception as exc:
+ logger.warning("Failed to list all Codex sessions: %s", exc)
+ items.sort(key=lambda item: (-item.sort_ts, item.native_session_id))
+ return items
+
def hydrate_preview(self, item: NativeResumeSession) -> NativeResumeSession:
preview = ""
rollout_path_raw = str(item.locator.get("rollout_path") or "").strip()
@@ -84,4 +125,4 @@ class CodexNativeSessionProvider(NativeSessionProvider):
preview = str(item.locator.get("title") or item.locator.get("first_user_message") or "")
item.last_agent_message = preview
item.last_agent_tail = build_tail_preview(preview or item.native_session_id)
- return item
+ return item
\ No newline at end of file
diff --git a/modules/agents/native_sessions/opencode.py b/modules/agents/native_sessions/opencode.py
index 73142958a..0fb584039 100644
--- a/modules/agents/native_sessions/opencode.py
+++ b/modules/agents/native_sessions/opencode.py
@@ -53,6 +53,42 @@ class OpenCodeNativeSessionProvider(NativeSessionProvider):
logger.warning("Failed to list OpenCode sessions for %s: %s", working_path, exc)
return rows
+ def list_all_metadata(self) -> list[NativeResumeSession]:
+ """List sessions across all project directories."""
+ if not self.db_path.exists():
+ return []
+ rows: list[NativeResumeSession] = []
+ try:
+ with self._connect() as conn:
+ cursor = conn.execute(
+ """
+ SELECT id, title, directory, time_created, time_updated
+ FROM session
+ ORDER BY time_updated DESC, id DESC
+ """,
+ )
+ for session_id, title, directory, created_ms, updated_ms in cursor.fetchall():
+ if not directory:
+ continue
+ created_at = dt_from_ts(created_ms, millis=True)
+ updated_at = dt_from_ts(updated_ms, millis=True)
+ rows.append(
+ NativeResumeSession(
+ agent="opencode",
+ agent_prefix="oc",
+ native_session_id=session_id,
+ working_path=directory,
+ created_at=created_at,
+ updated_at=updated_at,
+ sort_ts=(updated_at or created_at).timestamp() if (updated_at or created_at) else 0.0,
+ locator={"title": title or ""},
+ )
+ )
+ except Exception as exc:
+ logger.warning("Failed to list all OpenCode sessions: %s", exc)
+ rows.sort(key=lambda item: (-item.sort_ts, item.native_session_id))
+ return rows
+
def hydrate_preview(self, item: NativeResumeSession) -> NativeResumeSession:
preview = ""
if not self.db_path.exists():
@@ -85,4 +121,4 @@ class OpenCodeNativeSessionProvider(NativeSessionProvider):
item.last_agent_message = preview
fallback = str(item.locator.get("title") or item.native_session_id)
item.last_agent_tail = build_tail_preview(preview or fallback)
- return item
+ return item
\ No newline at end of file
diff --git a/modules/agents/native_sessions/service.py b/modules/agents/native_sessions/service.py
index 223c5beca..50af919f8 100644
--- a/modules/agents/native_sessions/service.py
+++ b/modules/agents/native_sessions/service.py
@@ -104,6 +104,32 @@ class AgentNativeSessionService:
selected.sort(key=lambda item: (-item.sort_ts, item.agent_prefix, item.native_session_id))
return selected
+ def list_all_recent_sessions(self, limit: int = 100) -> list[NativeResumeSession]:
+ """List recent sessions across all project directories."""
+ items: list[NativeResumeSession] = []
+ for provider in self.providers:
+ try:
+ items.extend(provider.list_all_metadata())
+ except Exception as exc:
+ logger.warning("Failed to list all %s sessions: %s", provider.agent_name, exc)
+
+ items.sort(key=lambda item: (-item.sort_ts, item.agent_prefix, item.native_session_id))
+ items = self._apply_limit(items, max(limit, 0))
+
+ provider_by_name = {provider.agent_name: provider for provider in self.providers}
+ hydrated: list[NativeResumeSession] = []
+ for item in items:
+ provider = provider_by_name.get(item.agent)
+ if not provider:
+ hydrated.append(item)
+ continue
+ try:
+ hydrated.append(provider.hydrate_preview(item))
+ except Exception as exc:
+ logger.warning("Failed to hydrate %s session %s: %s", item.agent, item.native_session_id, exc)
+ hydrated.append(item)
+ return hydrated
+
def get_session(
self,
working_path: str,
diff --git a/modules/im/telegram.py b/modules/im/telegram.py
index 6eeb09723..55c086573 100644
--- a/modules/im/telegram.py
+++ b/modules/im/telegram.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import asyncio
import json
import logging
+import os
import tempfile
import threading
from dataclasses import dataclass
@@ -31,7 +32,7 @@ class _TelegramCwdPrompt:
@dataclass
class _TelegramResumeSessionState:
message_id: str
- options: list[tuple[str, str]]
+ options: list[tuple[str, str, str]] # (agent, session_id, working_path)
is_dm: bool
@@ -1052,16 +1053,26 @@ class TelegramBot(BaseIMClient):
if context is None:
raise ValueError("Telegram resume flow requires a message context")
- options: list[tuple[str, str]] = []
+ options: list[tuple[str, str, str]] = [] # (agent, session_id, working_path)
rows: list[list[InlineButton]] = []
summary_lines = [
f"⏮️ {self._t('telegram.resumeTitle')}",
self._t("telegram.resumeBody"),
]
+ current_cwd = ""
+ if self._controller and hasattr(self._controller, "get_cwd"):
+ try:
+ current_cwd = self._controller.get_cwd(context)
+ except Exception:
+ pass
for item in list(sessions)[:12]:
idx = len(options)
- options.append((item.agent, item.native_session_id))
+ options.append((item.agent, item.native_session_id, item.working_path))
label = AgentNativeSessionService.format_display_summary(item)
+ # Show project name when session is from a different project
+ if current_cwd and item.working_path and os.path.normcase(os.path.normpath(item.working_path)) != os.path.normcase(os.path.normpath(current_cwd)):
+ project_name = os.path.basename(item.working_path)
+ label = f"{label} [{project_name}]"
rows.append([InlineButton(text=label[:40], callback_data=f"tg_resume:{idx}")])
summary_lines.append(
f"{idx + 1}. {label} ({AgentNativeSessionService.format_display_time(item)})"
@@ -1097,7 +1108,7 @@ class TelegramBot(BaseIMClient):
if option_index < 0 or option_index >= len(state.options):
return
- agent, session_id = state.options[option_index]
+ agent, session_id, working_path = state.options[option_index]
self._resume_states.pop(scope_key, None)
if self._controller is None or not hasattr(self._controller, "session_handler"):
await self.send_message(context, f"❌ {self._t('error.resumeFailed')}")
@@ -1111,6 +1122,7 @@ class TelegramBot(BaseIMClient):
session_id=session_id,
is_dm=state.is_dm,
platform="telegram",
+ session_working_path=working_path or None,
)
async def open_routing_modal(self, trigger_id: Any, channel_id: str, **kwargs):
diff --git a/modules/sessions_facade.py b/modules/sessions_facade.py
index d0707c1f6..161ab45e7 100644
--- a/modules/sessions_facade.py
+++ b/modules/sessions_facade.py
@@ -34,11 +34,35 @@ class SessionsFacade:
agent_name: str,
thread_id: str,
session_id: str,
+ session_working_path: Optional[str] = None,
) -> None:
agent_map = self._ensure_agent_namespace(user_id, agent_name)
agent_map[thread_id] = session_id
+ if session_working_path:
+ self._set_agent_session_working_path(user_id, agent_name, thread_id, session_working_path)
self.sessions_store.save()
- logger.info("Stored %s session mapping for %s: %s -> %s", agent_name, user_id, thread_id, session_id)
+ logger.info("Stored %s session mapping for %s: %s -> %s (working_path=%s)", agent_name, user_id, thread_id, session_id, session_working_path)
+
+ def _set_agent_session_working_path(
+ self,
+ user_id: Union[int, str],
+ agent_name: str,
+ thread_id: str,
+ working_path: str,
+ ) -> None:
+ user_key = self._normalize_user_id(user_id)
+ wp_map = self.sessions_store.state.session_working_paths.setdefault(user_key, {}).setdefault(agent_name, {})
+ wp_map[thread_id] = working_path
+
+ def get_agent_session_working_path(
+ self,
+ user_id: Union[int, str],
+ thread_id: str,
+ agent_name: str,
+ ) -> Optional[str]:
+ user_key = self._normalize_user_id(user_id)
+ wp_map = self.sessions_store.state.session_working_paths.get(user_key, {}).get(agent_name, {})
+ return wp_map.get(thread_id)
def get_agent_session_id(
self,
@@ -60,6 +84,8 @@ class SessionsFacade:
agent_map = self.sessions_store.get_agent_map(user_key, agent_name)
if thread_id in agent_map:
del agent_map[thread_id]
+ wp_map = self.sessions_store.state.session_working_paths.get(user_key, {}).get(agent_name, {})
+ wp_map.pop(thread_id, None)
self.sessions_store.save()
logger.info("Cleared %s session mapping for user %s: %s", agent_name, user_id, thread_id)
@@ -68,6 +94,9 @@ class SessionsFacade:
agent_map = self.sessions_store.get_agent_map(user_key, agent_name)
if agent_map:
self.sessions_store.state.session_mappings[user_key][agent_name] = {}
+ wp_map = self.sessions_store.state.session_working_paths.get(user_key, {}).get(agent_name, {})
+ if wp_map:
+ wp_map.clear()
self.sessions_store.save()
logger.info("Cleared all %s session namespaces for user %s", agent_name, user_id)
@@ -77,6 +106,7 @@ class SessionsFacade:
if agent_maps:
count = sum(len(agent_map) for agent_map in agent_maps.values())
self.sessions_store.state.session_mappings[user_key] = {}
+ self.sessions_store.state.session_working_paths.pop(user_key, None)
self.sessions_store.save()
logger.info("Cleared all session mappings (%s bases) for user %s", count, user_id)
@@ -200,6 +230,8 @@ class SessionsFacade:
continue
for mapping_key in keys_to_remove:
del agent_map[mapping_key]
+ wp_map = self.sessions_store.state.session_working_paths.get(user_key, {}).get(agent_name, {})
+ wp_map.pop(mapping_key, None)
cleared += 1
logger.info(
"Cleared %s session base for %s: %s (%s keys)",