The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(onboarding): a rerun ends the run it replaces
alt-glitch0be104b08c59
diff --git a/tests/tui_gateway/test_onboarding_session.py b/tests/tui_gateway/test_onboarding_session.pyindex 114e7cc31da..9e1ba5e4d12 100644--- a/tests/tui_gateway/test_onboarding_session.py+++ b/tests/tui_gateway/test_onboarding_session.py@@ -213,3 +213,15 @@ def test_an_old_ended_chat_never_closes_the_flag_of_a_newer_run(root):onboarding_record.advance(db, "old", SkipAll()) # the old chat's agent still carries setup_beatassert read_user_config_raw(root / "config.yaml")["onboarding"]["run"] is Trueassert onboarding_record.active_session_id(db) == "new"+++def test_a_rerun_ends_the_run_it_replaces_so_finishing_the_new_one_closes_the_flag(client, root):+ from hermes_cli.config import read_user_config_raw+ old = _call("onboarding.start")["result"]["stored_session_id"]+ new = _call("onboarding.start", {"rerun": True})["result"]["stored_session_id"]+ db = server._get_db()++ assert onboarding_record.load(db, old)["phase"] == "skipped"+ onboarding_record.advance(db, new, SkipAll())+ assert onboarding_record.active_session_id(db) is None+ assert read_user_config_raw(root / "config.yaml")["onboarding"]["run"] is Falsediff --git a/tui_gateway/methods_onboarding.py b/tui_gateway/methods_onboarding.pyindex 27ac63e9551..dd8062de442 100644--- a/tui_gateway/methods_onboarding.py+++ b/tui_gateway/methods_onboarding.py@@ -91,8 +91,8 @@ def _active_onboarding_session() -> str | None:@method("onboarding.start")def _(rid, params: dict) -> dict:from agent.onboarding_facts import read_facts- from agent.onboarding_flow import Facts- from agent.onboarding_record import active_session_id, load, start+ from agent.onboarding_flow import Facts, SkipAll+ from agent.onboarding_record import active_session_id, advance, load, startfrom agent.onboarding_text import CHAT_TITLE, opening_prompt# Held through the opening submit: two windows pressing start at once get one chat and one opening.with _onboarding_start_lock:@@ -100,7 +100,12 @@ def _(rid, params: dict) -> dict:with _profile_db(_ONBOARDING_PROFILE, writer=True) as db:if db is None:return _db_unavailable_error(rid, code=5000)- stored = None if params.get("rerun") else active_session_id(db)+ stored = active_session_id(db)+ if stored is not None and params.get("rerun"):+ # One open run at a time: a rerun ends the one it replaces, so finishing the new+ # run closes the install flag and the abandoned chat never reopens.+ advance(db, stored, SkipAll())+ stored = Nonecreated = stored is Noneif created:facts = read_facts(facts_source=params.get("facts_source") or "local", locale=params.get("locale"))