← Back to Pull requests

feat: report what changed after each action (#450) #535

Open
unknown opened this pull request with 559 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 28, 2026 00:40 UTC
Author

Summary


Closes #450.

Every action tool used to return plain success, so an agent could not tell a tap that changed the screen from one that hit nothing, and spent most of its turns re-listing or screenshotting to find out. Action tools now wait for the UI to settle and append a compact report of what the action did.

Covered tools: mobile_click_on_screen_at_coordinates, mobile_double_tap_on_screen, mobile_long_press_on_screen_at_coordinates, mobile_swipe_on_screen, mobile_type_keys, mobile_press_button, mobile_open_url, mobile_launch_app.

How it works


  • New module src/action-feedback.ts, platform-agnostic: it only works on the ScreenElement[] lists from robot.getElementsOnScreen() (plus getForegroundApp() when the robot has it), so mobilecli and the legacy robots behave the same.

  • Before the action: one element read (and the foreground app). After: poll the element list every 250 ms until two consecutive snapshots are identical (refs ignored, since they are renumbered on every dump), or 2 s pass (MOBILEMCP_SETTLE_TIMEOUT_MS).

  • Elements are matched on type, id, label, name and text; an element whose text changed (a field being typed into) is matched in a second pass on type plus id or exact position.

  • Classification, in order: foreground app/activity changed → new screen; an Alert/Dialog/Sheet/Popover added or removed → dialog; most kept elements moved by the same offset → scrolled by N px; under 35% of elements kept → new screen, or a dialog/sheet when the new (or old) element set covers less than 60% of the screen (uiautomator only dumps the dialog window); otherwise content changed; no difference → nothing.

  • Touch: for coordinates, the topmost described element under the point; for a ref, reported only when another element covers the aimed one, or the aimed one is disabled.

  • Typing: the focused field (or, where focus isn't reported, the text field whose content changed) and its value, flagged MISMATCH when it doesn't contain the typed text. Secure/masked fields are not compared.

  • Diff: added (with refs from the new dump, valid for the next tap), changed (state and text first, plain moves last, moves omitted for a scroll), removed (without refs, they are gone). Capped at 8 lines with a pointer to mobile_list_elements_on_screen.

  • The action's own result line is unchanged and stays first. If the screen can't be read before the action (e.g. screen off), the action runs and returns as before; if it can't be read after, a one-line note is added. The feedback never fails the action.
  • Opting out / cost


  • feedback: false on any action tool skips it entirely (no extra reads).

  • MOBILEMCP_ACTION_FEEDBACK=0 turns it off by default; a call can still opt in with feedback: true.

  • mobile_batch_commands steps default to feedback: false (a batch runs known sequences); a step can pass feedback: true.

  • Cost when on: 1 element read before, and 2+ after (typically 2-3 on a static screen, ~0.5 s plus the dump time), plus 2 foreground-app reads on mobilecli.
  • Example


    Typed text: me@example.com
    Screen: content changed (settled in 500ms)
    Field: @e2 EditText "email" value="e@example.com" MISMATCH, typed "me@example.com": characters may have been dropped or auto-corrected
    Changes: 0 added, 0 removed, 1 changed
    ~ @e2 EditText "email": text "Email" -> "e@example.com", focused
    

    Clicked on screen at coordinates: 300, 560
    Screen: content changed (settled in 500ms)
    Touch: CheckBox text="I accept the terms" at=48,500 size=984x120
    Changes: 0 added, 0 removed, 2 changed
    ~ @e3 CheckBox "I accept the terms": checked
    ~ @e4 Button "Continue": enabled
    

    Clicked on element @e4
    Screen: no change, the action had no visible effect (settled in 500ms)
    Touch: Button text="Continue" at=48,2100 size=984x160 disabled
    

    Docs


    README (new "What changed after an action" section, two env vars), CHANGELOG (Unreleased), server instructions, and the bundled mobile-automation skill (step 4 now says to read the report before re-listing).

    Tests


    test/action-feedback.test.ts: 32 device-free unit tests (settle with a fake clock, matching, each classification, hit testing, typing checks, diff cap, error handling, env settings, and that every action tool exposes an optional feedback). npm run build, npm run lint and npx playwright test pass (180 tests). Not yet exercised on a real device or simulator; happy to iterate on the heuristics once someone tries it.

    Diff: 559 lines (+419 / -140) across 6 files Reviewer: bhargavmehta01 Review duration: 48528m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.55) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 559 lines diff across 6 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.379
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #535"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 55.2% (MEDIUM) · Higher = larger blast radius
    55.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.9% · Lower = rushed or shallow review
    40.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 32.6% · Safe to merge
    32.6%