feat(v2): screenView sees someone's Discord screen share in its popped-out window

The share target checks that the person asked about shares their screen in
Jarvis's voice channel, finds Discord's popped-out window (title not ending in
Discord, the voice channel's name first) and, when there is none, asks for it in
the channel and looks again every second for 30 s. Screen actions now wait as
long as PC actions in the worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-19 13:43:31 +09:00
parent 3af881935c
commit 844958d311
13 changed files with 287 additions and 28 deletions

View File

@@ -68,6 +68,15 @@ def test_a_window_is_found_by_part_of_its_name(app):
assert app.calls[-1] == ("capture", {"target": "window", "window": "크롬", "detail": "normal"})
@pytest.mark.unit
def test_a_discord_screen_share_is_asked_for_with_the_person_named(app):
assert run(target="share", person=" 철수 ").success
assert run(target="share").success
assert app.calls == [("capture", {"target": "share", "person": "철수", "detail": "normal"}),
("capture", {"target": "share", "detail": "normal"})]
assert not run(target="share", person="x" * 201).success and len(app.calls) == 2
@pytest.mark.unit
@pytest.mark.parametrize("args", [{"target": "monitor"}, {"target": "monitor", "monitor": 0},
{"target": "monitor", "monitor": "two"}, {"target": "window"},

View File

@@ -1652,26 +1652,32 @@ def test_a_pc_action_goes_to_the_app_and_an_ask_answer_keeps_what_to_ask(store):
@pytest.mark.unit
def test_a_pc_action_waits_longer_than_the_other_app_actions(store):
def test_pc_and_screen_actions_wait_longer_than_the_other_app_actions(store):
"""Starting a program and reading its new window takes the app up to about 20 s (admin.spec.md,
"PC control"): a PC action is not given up after the chat actions' wait."""
"PC control"), and a screen share is waited for up to 30 s while it is popped out ("Screen
viewing"): those actions are not given up after the chat actions' wait."""
results = []
brain = FakeBrain(lambda u, t: results.append((brain.screen.act("list"), brain.pc.act("run", program="calc")))
or "ok")
brain = FakeBrain(lambda u, t: results.append((brain.notes_backend.act("list"),
brain.screen.act("capture", target="share"),
brain.pc.act("run", program="calc"))) or "ok")
async def body(url):
async with connect(url) as ws:
await hello(ws)
await send(ws, type="reply", id="r1", user="100", text="q", via="voice", speak=False)
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "screen_action")
seen = await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "pc_action")
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "note_action")
seen = await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "screen_action")
await asyncio.sleep(0.6) # longer than chat_timeout_s
await send(ws, type="screen_action_result", id=seen[-1]["id"], ok=True, item={"what": "화면공유"},
images=["x"])
seen = await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "pc_action")
await asyncio.sleep(0.6)
await send(ws, type="pc_action_result", id=seen[-1]["id"], ok=True, item={"window": {"id": "w1"}})
await recv_until(ws, lambda m: isinstance(m, dict) and m.get("type") == "reply_text")
asyncio.run(with_worker(body, store=store, brain=brain, chat_timeout_s=0.3))
(screen, pc), = results
assert not screen["ok"] and pc == {"ok": True, "item": {"window": {"id": "w1"}}}
(note, screen, pc), = results
assert not note["ok"] and screen["ok"] and pc == {"ok": True, "item": {"window": {"id": "w1"}}}
@pytest.mark.unit