feat: settle mobile observations before summarizing steps
This commit is contained in:
1 parent
c818a09a49
commit
4465a2e199
12 files changed
+271
-9
No files matched your search
@@ -60,20 +60,21 @@ REFRESHED = [_el(1, "Back", 100, 100), _el(2, "Wi-Fi toggle", 900, 300)]
|
||||
|
||||
|
||||
class _FakeSession:
|
||||
"""An action session whose observations replay a scripted list sequence."""
|
||||
"""An action session whose screen advances after each device action."""
|
||||
|
||||
started = True
|
||||
|
||||
def __init__(self, observations: list[list[dict]]):
|
||||
self.calls: list[tuple[str, dict]] = []
|
||||
self._observations = list(observations)
|
||||
self._observations = observations
|
||||
|
||||
async def call(self, name, args):
|
||||
self.calls.append((name, dict(args)))
|
||||
return ActionResult.success(name, f"{name} dispatched")
|
||||
|
||||
async def observe(self, settle_ms=0):
|
||||
elements = self._observations.pop(0) if self._observations else []
|
||||
index = min(len(self.calls) - 1, len(self._observations) - 1)
|
||||
elements = self._observations[index] if self._observations else []
|
||||
return ObserveResult(
|
||||
ok=True,
|
||||
elements_text="\n".join(f"[{e['index']}] {e['text']}" for e in elements),
|
||||
|
||||
@@ -468,6 +468,8 @@ async def test_dual_frame_dispatch_keeps_transition_prompt(mock_context):
|
||||
pre_img_bytes=b"pre",
|
||||
post_img_bytes=b"post",
|
||||
exec_outcome="executed",
|
||||
post_ui_elements_text="[1] Text: '存储空间' | Bounds: [0,0][100,100]",
|
||||
observation_settled=False,
|
||||
)
|
||||
await summarizer.flush()
|
||||
|
||||
@@ -477,6 +479,10 @@ async def test_dual_frame_dispatch_keeps_transition_prompt(mock_context):
|
||||
assert "Before/After screenshots" in system_text
|
||||
assert "--- [1] BEFORE ACTION SCREEN (Action Marked Visually in Red) ---" in human_text
|
||||
assert "--- [2] AFTER ACTION SCREEN ---" in human_text
|
||||
assert "--- [3] AFTER ACTION UI ELEMENTS ---" in human_text
|
||||
assert "Text: '存储空间'" in human_text
|
||||
assert "screen still changing" in human_text
|
||||
assert "hierarchy names the new page" in system_text
|
||||
assert "DECISION FRAME" not in human_text
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user