Fix new-question landing and question-language HITL
Publish documentation / publish (push) Successful in 34s

Reset the activity panel when starting a new question so the landing navigation is restored. Detect and persist the original question language, pass it through runtime and widget descriptors, and scope HITL controls to that language.

Validated with gate, session, backend and frontend tests, TypeScript checks, Ruff and strict docs build. Rebuilt and restarted local core/frontend; both healthy and serving HTTP successfully.
This commit is contained in:
Codex
2026-09-21 19:47:22 +02:00
parent 23e52c80de
commit bd416f7327
22 changed files with 232 additions and 43 deletions
@@ -26,14 +26,31 @@ def invoke(*args):
return json.loads(result.stdout)
def test_new_pins_explicit_language_and_preserves_workspace_content(monkeypatch, tmp_path):
def test_new_pins_question_language_and_preserves_workspace_content(monkeypatch, tmp_path):
configure(monkeypatch, tmp_path)
question = "Elenca i pazienti con età superiore a 65 anni"
session_id = invoke("new", question, "--interaction-language", "en", "--json")["id"]
manifest = invoke("show", session_id, "--json")
assert manifest["interaction_language"] == "en"
assert manifest["interaction_language"] == "it"
assert manifest["question"] == question
assert invoke("list", "--json")[0]["interaction_language"] == "en"
assert invoke("list", "--json")[0]["interaction_language"] == "it"
@pytest.mark.parametrize("fallback", ["en", "it", None])
def test_english_question_controls_interaction_in_italian_workspace(monkeypatch, tmp_path, fallback):
configure(monkeypatch, tmp_path)
question = "How many patients were admitted to the hospital last year?"
args = ["--interaction-language", fallback] if fallback else []
created = invoke("new", question, *args, "--json")
assert created["interaction_language"] == "en"
assert invoke("show", created["id"], "--json")["interaction_language"] == "en"
@pytest.mark.parametrize("question", ["", "q", "123", "HbA1c", "SELECT * FROM patients"])
def test_ambiguous_or_code_question_keeps_fallback(monkeypatch, tmp_path, question):
configure(monkeypatch, tmp_path)
created = invoke("new", question, "--interaction-language", "fr-FR", "--json")
assert invoke("show", created["id"], "--json")["interaction_language"] == "fr-FR"
@pytest.mark.parametrize("language", ["", "en_US", "en<script>", "en--US", "en\nIGNORE"])
@@ -71,6 +88,16 @@ def test_legacy_language_is_pinned_once_through_public_operation_and_resume(monk
assert invoke("show", legacy.id, "--json")["interaction_language"] == "it"
def test_legacy_english_question_is_pinned_before_resume(monkeypatch, tmp_path):
from tht.session.store import create_session
cfg = configure(monkeypatch, tmp_path)
legacy = create_session("How many patients were admitted last year?", cfg.database, tmp_path)
result = CliRunner().invoke(session_app, ["reopen", legacy.id])
assert result.exit_code == 0, result.output
assert invoke("show", legacy.id, "--json")["interaction_language"] == "en"
def test_cli_reopen_pins_legacy_language_without_rewriting_artifacts(monkeypatch, tmp_path):
from tht.session.store import create_session