Repository navigation
feat: cancel timed-out tasks; stable refs that late writes cannot overwrite - #64
Draft
cryptotavares wants to merge 2 commits into
Draft
cryptotavares wants to merge 2 commits into
cryptotavares wants to merge 2 commits into
Conversation
cryptotavares
added this pull request to stack #63
October 24, 2026 01:07
| ); | ||
| controller.abort(error); | ||
| reject(error); | ||
| }, effectiveTimeout); |
cryptotavares
force-pushed
the
cryptotavares/mmcli-p1-08-abort-refs
branch
from
October 24, 2026 01:20
de9777c to
5131d82
Compare
Collaborator
Author
cryptotavares
force-pushed
the
cryptotavares/mmcli-p1-08-abort-refs
branch
from
October 24, 2026 01:32
5131d82 to
69cf663
Compare
…rwrite
A request that timed out kept running: it could still click, snapshot and
then overwrite the refMap the next request relied on. Refs were renumbered
by every observation and discovery call, so refs an agent held could point
at other elements. On mobile, a click observation could show the old screen.
- RequestQueue passes an AbortSignal to each task and aborts it on timeout.
ToolContext gains optional `signal` and `setRefMap`. Interaction tools,
run_steps, discovery tools and the observation check the signal between
steps (MM_REQUEST_ABORTED, internal).
- New RefStore (server-owned, wraps sessionManager.setRefMap): each request
takes a generation; writes from an older or aborted request are dropped.
Tools that call context.sessionManager.setRefMap go through it too (proxy).
ISessionManager is unchanged.
- Stable refs: discovery tools and observations reuse the previous ref for
the same element (browser key: role + name + testId; mobile: testId, else
role + name; elements sharing a key are matched in screen order).
ToolContext.setRefMap returns the stabilized { refMap, nodes }, which
describe_screen / accessibility_snapshot return. New elements get refs
above a session high-water mark, so a removed ref is never reused until
launch/cleanup. When a tool set refs, the observation merges into them.
- list_testids no longer reads the a11y tree or sets refs (it returns none).
- Mobile observation and describe_screen: one device snapshot for both the
tree and test IDs (optional IPlatformDriver.captureScreen; ScreenCapture
type exported). After a mutating or batch call, re-snapshot every 300 ms
while the screen is busy (", busy" label, progress/activity indicator), at
most 3 times / 2 s; an unchanged screen gets one retry.
- The observation timeout now aborts the observation instead of leaving it
running.
CodeQL (js/resource-exhaustion) flagged the queue timer because its duration comes from the request body. Clamp it to MAX_QUEUE_TIMEOUT_MS.
cryptotavares
force-pushed
the
cryptotavares/mmcli-p1-08-abort-refs
branch
from
October 24, 2026 01:35
69cf663 to
7d0c565
Compare
Collaborator
Author
|
CodeQL js/resource-exhaustion on |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes three problems with refs and observations (tickets P1-08 and P1-09):
e1..eNin tree order). Refs an agent already held could then point at other elements, and diffs (which match by ref) reported unchanged nodes as removed and added.Changes:
RequestQueuegives each task anAbortSignaland aborts it on timeout.ToolContextgains optionalsignalandsetRefMap. Interaction tools,run_steps, discovery tools and the observation check the signal between steps. The observation timeout now aborts the observation instead of leaving it running.RefStore(owned by the server, wrapssessionManager.setRefMap): each request takes a generation, and writes from an older or aborted request are dropped. Tools that callcontext.sessionManager.setRefMapdirectly go through it too, via a proxy.ISessionManageris unchanged.stabilizeRefs): discovery tools and observations reuse the previous ref for the same element.launch/cleanup.list_testidsno longer reads the a11y tree or sets refs; it never returned refs.describe_screentake one device snapshot for both the tree and test IDs, via the optionalIPlatformDriver.captureScreen()(ScreenCapturetype exported). Before, it was two., busylabel or a progress/activity indicator), at most 3 times or 2 s. An unchanged screen gets one retry.Part of the mm CLI v2 effort: tickets
P1-08+P1-09(Phase 1), combined into one PR.Stacked on #62 (review that first).
Breaking changes
None.
ToolContext.signal,ToolContext.setRefMap,IPlatformDriver.captureScreenandScreenCaptureare optional additions.RequestQueue.enqueuenow passes the signal to its callback. Existing callbacks that take no argument keep working.Consumer impact
test/e2e/playwright/llm-workflow/RequestQueue, and itssetRefMap/getRefMapimplementation is unchanged.tests/llm-workflow/Proof
Tested with yalc builds in the Extension (e2e build, headless) and Mobile (dev client on iOS sim and Android emulator). The first full run used an earlier revision (e804b95). The final commit got a targeted mobile recheck plus a smoke run on all three platforms. Details are in the proof file in the mm-cli-v2 workspace.
click --testid does-not-exist --timeout 500, thendescribe-screen, then click by refdescribe-screenafter later clicksdescribe-screentwice: same refswait-for wallet-screen)click tab-bar-item-Wallet, p50 of 3)list_testidsno longer reads the tree)Known gap (Android): refs no longer churn, but unchanged-screen diffs are still larger than before. Status-bar nodes (clock, signal) and zero-height layout
ViewGroups change between snapshots. P1-13 (filtercom.android.systemui:*) and P1-14 (droppathand layout-only nodes) cover this; I added notes to both tickets.Unit tests
New:
RequestQueueabort tests;RefStore(generations, aborted writes dropped, merge with tool refs, high-water mark, baseline);stabilizeRefs(insert, remove, rename, duplicate keys in screen order, ranges, options);#privateclass, and mobile single snapshot and settle;