fix(desktop): report desktop_contract in lazy session.create info (#36112)

The lazy session.create path hand-builds a partial info dict that omitted
desktop_contract. The desktop GUI reads a missing contract as undefined and
treats it as an out-of-date backend, so it surfaced a "Backend out of date"
toast on every launch even against a current backend. Carry the contract in
the lazy payload like _session_info already does for resume/branch.
This commit is contained in:
brooklyn! 2026-05-31 18:23:10 -05:00 committed by GitHub
parent 3ef97a61b9
commit 77bb64813c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View file

@ -3572,6 +3572,33 @@ def test_session_create_continues_when_state_db_is_unavailable(monkeypatch):
server._sessions.pop(sid, None)
def test_session_create_lazy_info_reports_desktop_contract(monkeypatch):
"""The lazy session.create info payload must carry desktop_contract, else
the desktop GUI reads it as undefined and falsely warns "Backend out of
date" on every launch even against a current backend."""
class _FakeWorker:
def __init__(self, key, model):
self.key = key
def close(self):
return None
monkeypatch.setattr(server, "_SlashWorker", _FakeWorker)
monkeypatch.setattr(server, "_get_db", lambda: None)
monkeypatch.setattr(server, "_emit", lambda *a, **kw: None)
monkeypatch.setattr(server, "_start_agent_build", lambda *a, **kw: None)
resp = server.handle_request(
{"id": "1", "method": "session.create", "params": {"cols": 80}}
)
info = resp["result"]["info"]
assert info["desktop_contract"] == server.DESKTOP_BACKEND_CONTRACT
server._sessions.pop(resp["result"]["session_id"], None)
def test_session_list_returns_clean_error_when_state_db_is_unavailable(monkeypatch):
monkeypatch.setattr(server, "_get_db", lambda: None)
monkeypatch.setattr(server, "_db_error", "locking protocol")

View file

@ -2789,6 +2789,7 @@ def _(rid, params: dict) -> dict:
"cwd": _sessions[sid]["cwd"],
"branch": _git_branch_for_cwd(_sessions[sid]["cwd"]),
"lazy": True,
"desktop_contract": DESKTOP_BACKEND_CONTRACT,
"profile_name": _current_profile_name(),
},
},