diff --git a/gateway/scripts/chat_bridge.py b/gateway/scripts/chat_bridge.py index 58c3d1a..b1f4e21 100644 --- a/gateway/scripts/chat_bridge.py +++ b/gateway/scripts/chat_bridge.py @@ -340,10 +340,13 @@ def _search_all_sessions(query: str, max_sessions: int = 5) -> str: return f"(搜索出错: {e})" -# ── Serve session DB path ── +# ── Serve session DB path (cross-platform) ── _SERVE_DB = os.path.join( - os.environ.get("USERPROFILE", "C:\\Users\\hmo"), - ".local", "share", "opencode", "opencode.db") + os.path.expanduser("~"), ".local", "share", "opencode", "opencode.db") +if sys.platform == "win32" and not os.path.exists(_SERVE_DB): + _SERVE_DB = os.path.join( + os.environ.get("USERPROFILE", "C:\\Users\\hmo"), + ".local", "share", "opencode", "opencode.db") class SessionBridge: