fix(tui): persist resumed profile cwd updates to profile db

This commit is contained in:
Teknium 2026-06-13 21:25:25 -07:00
parent d842155da1
commit 9f33d673e9
3 changed files with 44 additions and 6 deletions

View File

@ -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",

View File

@ -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

View File

@ -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