From 9f33d673e9e631661f0f913d6967fbe27e142900 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 13 Jun 2026 21:25:25 -0700 Subject: [PATCH] fix(tui): persist resumed profile cwd updates to profile db --- scripts/release.py | 1 + tests/test_tui_gateway_server.py | 37 ++++++++++++++++++++++++++++++++ tui_gateway/server.py | 12 +++++------ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 313e71b75a..760653bd24 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -46,6 +46,7 @@ ACP_REGISTRY_MANIFEST = REPO_ROOT / "acp_registry" / "agent.json" # Auto-extracted from noreply emails + manual overrides AUTHOR_MAP = { "kenmege@yahoo.com": "Kenmege", + "sswdarius@gmail.com": "necoweb3", "peterhao@Peters-MacBook-Air.local": "pinguarmy", "adalsteinnhelgason@Aalsteinns-MacBook-Pro-3.local": "AIalliAI", "adalsteinnhelgason@users.noreply.github.com": "AIalliAI", diff --git a/tests/test_tui_gateway_server.py b/tests/test_tui_gateway_server.py index 30a9a9a341..4379d80aeb 100644 --- a/tests/test_tui_gateway_server.py +++ b/tests/test_tui_gateway_server.py @@ -1094,6 +1094,43 @@ def test_session_resume_profile_uses_profile_db_cwd(monkeypatch, tmp_path): server._sessions.clear() +def test_session_cwd_set_profile_session_updates_profile_db(monkeypatch, tmp_path): + target = "stored-profile-session" + profile_home = tmp_path / "profiles" / "worker" + profile_home.mkdir(parents=True) + new_cwd = tmp_path / "new-workspace" + new_cwd.mkdir() + captured = {} + + class ProfileDB: + def update_session_cwd(self, session_id, cwd): + captured["profile_update"] = (session_id, cwd) + + def close(self): + captured["profile_closed"] = True + + class LaunchDB: + def update_session_cwd(self, *_args): + captured["launch_update"] = True + + profile_db = ProfileDB() + + import tools.terminal_tool as terminal_tool + + monkeypatch.setattr("hermes_state.SessionDB", lambda db_path=None: profile_db) + monkeypatch.setattr(server, "_get_db", lambda: LaunchDB()) + monkeypatch.setattr(terminal_tool, "cleanup_vm", lambda _key: None) + monkeypatch.setattr(server, "_register_session_cwd", lambda _session: None) + + session = {"session_key": target, "profile_home": str(profile_home)} + assert server._set_session_cwd(session, str(new_cwd)) == str(new_cwd) + assert session["cwd"] == str(new_cwd) + assert session["explicit_cwd"] is True + assert captured["profile_update"] == (target, str(new_cwd)) + assert captured["profile_closed"] is True + assert "launch_update" not in captured + + def test_stored_session_runtime_overrides_skips_bare_billing_provider(): """A bare billing bucket ("custom"/"auto"/"openrouter") must not be restored as the provider identity on resume. A custom endpoint that never used `/model` persists only diff --git a/tui_gateway/server.py b/tui_gateway/server.py index e0517253db..d34f558f6c 100644 --- a/tui_gateway/server.py +++ b/tui_gateway/server.py @@ -1228,12 +1228,12 @@ def _set_session_cwd(session: dict, cwd: str) -> str: # lazy row creation persist it too, not the launch-dir fallback). session["explicit_cwd"] = True _register_session_cwd(session) - db = _get_db() - if db is not None: - try: - db.update_session_cwd(session.get("session_key", ""), resolved) - except Exception: - logger.debug("failed to persist session cwd", exc_info=True) + with _session_db(session) as db: + if db is not None: + try: + db.update_session_cwd(session.get("session_key", ""), resolved) + except Exception: + logger.debug("failed to persist session cwd", exc_info=True) try: from tools.terminal_tool import cleanup_vm