feat(m0): check a virtual monitor for the bot browser window

The user wants the bot window on no real screen at all. Add a vdisplay
stage that drives the Parsec Virtual Display Adapter already on the PC
(no install, the display dies with the script), moves the clock window
onto it as a normal and as a tool window, and asks about real monitors,
Alt+Tab, Discord's Screens tab and whether the cursor can wander there.

Record the M0 defaults the user confirmed in docs/v2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-10 13:29:58 +09:00
parent af0c773998
commit e0b172e796
9 changed files with 567 additions and 9 deletions

View File

@@ -178,3 +178,69 @@ def test_failed_strata_launch_keeps_the_engine_log_for_the_zip(tmp_path, monkeyp
text = kept[0].read_text(encoding="utf-8")
assert "out of memory" in text
assert home not in text
def test_recommended_launch_does_not_ask_for_the_dflash2_drafter(tmp_path, monkeypatch):
# Strata 0.1.59 picks DFlash2 alone (--draft-fallback none) for Q2_0, but the
# canonical Q2_0 pack is not a native pack, so the engine stops at start
# ("DFlash2 is off here: it needs a native pack ... the start ends here").
ran = []
monkeypatch.setattr(llm, "run_logged", lambda cmd, *a, **k: ran.append(cmd) or 1)
s = llm.Strata(tmp_path, tmp_path / "strata.log")
monkeypatch.setattr(s, "supported_flags", lambda: {"--family", "--model", "--drafting", "--parallel"})
for parallel in (1, 2):
s.launch(llm.PRESETS["recommended"], 32768, parallel=parallel)
for cmd in ran:
assert "--drafting" in cmd
assert cmd[cmd.index("--drafting") + 1] not in ("auto", "dflash2")
def test_virtual_display_structures_match_the_win32_layout():
# A wrong layout makes every display call fail on the PC, where we cannot debug it.
import ctypes
from m0lib import winvdd
assert ctypes.sizeof(winvdd.DEVMODEW) == 220
assert ctypes.sizeof(winvdd.DISPLAY_DEVICEW) == 840
if ctypes.sizeof(ctypes.c_void_p) == 8:
assert ctypes.sizeof(winvdd.SP_DEVICE_INTERFACE_DATA) == 32
assert ctypes.sizeof(winvdd.OVERLAPPED) == 32
def test_virtual_display_goes_where_it_only_touches_a_corner():
from m0lib import winvdd
# Two side-by-side 1440p monitors, the second one lower than the first.
physical = [{"rect": [0, 0, 2560, 1440]}, {"rect": [2560, 200, 5120, 1640]}]
x, y = winvdd.corner_position(physical)
assert (x, y) == (5120, 1640)
for d in physical:
left, top, right, bottom = d["rect"]
# Only a point is shared: no edge of length > 0 with any real monitor.
assert not (left <= x < right and top <= y < bottom)
def test_virtual_display_remove_sends_the_index_the_driver_expects():
from m0lib import winvdd
sent = []
vdd = object.__new__(winvdd.Vdd)
vdd.added = [1]
vdd.ioctl = lambda code, data=b"": sent.append((code, data)) or 0
vdd.remove(1)
assert sent[0] == (winvdd.IOCTL_REMOVE, b"\x00\x01")
assert vdd.added == []
def test_kit_runs_the_virtual_display_check_before_the_unattended_stages():
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts" / "m0"))
import m0
keys = [s[0] for s in m0.STAGES]
assert keys.index("vdisplay") < keys.index("tts_melo")
assert (Path(m0.KIT) / "m0lib" / m0.STAGES[keys.index("vdisplay")][3]).exists()
def test_virtual_display_names_are_read_from_utf16_buffers():
from m0lib import winvdd
dd = winvdd.DISPLAY_DEVICEW()
text = "Parsec Virtual Display Adapter".encode("utf-16-le")
winvdd.ctypes.memmove(winvdd.ctypes.addressof(dd) + winvdd.DISPLAY_DEVICEW.DeviceString.offset, text, len(text))
assert winvdd.wstr(dd.DeviceString) == "Parsec Virtual Display Adapter"