_get_backend keys its cache on permission mode only, so a cua-driver cached before the Bot Desktop started (or restarted on another display number) keeps acting on the old seat, or on no display. desktop_identity() returns the DISPLAY a fresh spawn would get and backend_display_stale() compares it with the identity recorded at cache time; tool.py (owned by another lane) records the identity next to _backend_permission_modes[sid] and detaches+stops a stale backend the way the /yolo mode swap does. (cherry picked from commit 896304bcbb98b12f821c6e19f10b9f174fa08889)
14 lines
651 B
Python
14 lines
651 B
Python
"""A cached computer_use backend is bound to the display it spawned on; the identity helpers notice a change."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from tools.computer_use import cua_backend
|
|
|
|
|
|
def test_backend_display_identity_tracks_the_display_a_spawn_would_get():
|
|
before = cua_backend.desktop_identity({"HOME": "/x"}) # no screen yet
|
|
after = cua_backend.desktop_identity({"HOME": "/x", "DISPLAY": ":37"}) # Bot Desktop came up
|
|
assert before == "" and after == ":37"
|
|
assert cua_backend.backend_display_stale(before, after)
|
|
assert not cua_backend.backend_display_stale(after, cua_backend.desktop_identity({"DISPLAY": ":37"}))
|