Skip to content

MCP-116: ui_tree root subtree scoping and clipped rows - #405

Open
marcoslor wants to merge 1 commit into
mainfrom
feat/mcp-116-uitree-root-clipped
Open

marcoslor wants to merge 1 commit into
mainfrom
feat/mcp-116-uitree-root-clipped

Conversation

@marcoslor

Copy link
Copy Markdown
Owner

Outcome

MCP-116 (issue #392): ui_tree takes root to keep one subtree, and a row the display or a scrollable clips says clipped: true.

  • Phone (:core): UiTree.row emits "clipped": true on a visible row whose screen box is strictly clipped by the display or a scrollable ancestor's visible viewport; a row wholly inside omits it, and an off row never carries it (UiTreeTest.testAPartiallyClippedNodeSaysSo_MCP116).
  • Mac: UITree.Node parses/preserves clipped and encodes it only when true; the text view prints it as a clipped state in the bracket ([e12 Button clipped]), a clipped plain label included; the row is declared (with a description) in the ui_tree / observed-tree output schema.
  • root: ui_tree {root: "e12"} resolves against the fresh read's keys and keeps that node and its descendants in document order (p against kept i values, so gapped indices after an off-screen read keep the right rows). It works for format: "tree", format: "text" and find; with find, the search, matched and total cover the subtree while in still names the scrollable above it that holds an off-screen match. A root the read does not name fails stale_ref naming the ref, window and snapshot; root is validated like tap's ref (^e[0-9]+$, ≤ 2147483647), so a non-key fails -32602 ("root must look like e12: use a ref from ui_tree"). The answered rows become that client's expects.
  • Docs: PROTOCOL.md "UI tree" (clipped row field, item 9), MCP-116 spec row with proofs, design ui_tree description/table (word-for-word with MCPCore.swift), arguments and answer shapes, WIN-79's row states, and the stale_ref error table row.
  • E2E: suite_read.py covers root in tree/text/find, a find outside the subtree, a stale root, a malformed root, and (through the fake phone's new clipped-tree mode) a clipped row in the tree and text view.

Fixes #392

Checks

scripts/check-rules.sh --base $(git merge-base HEAD main)

check-rules: PASS (base fd321e20828562dbd4ffefa6e48d398d8dc6cd06, 18 files checked)

scripts/check-ratchets.sh --base $(git merge-base HEAD main)

check-ratchets: PASS (base fd321e20828562dbd4ffefa6e48d398d8dc6cd06)

scripts/check-format.sh --base $(git merge-base HEAD main)

ktlint not installed; skipped (no third-party dependency added without maintainer approval)
check-format: PASS (base fd321e20828562dbd4ffefa6e48d398d8dc6cd06, 10 Swift files, 2 Kotlin files)

cd android && JAVA_HOME=/opt/homebrew/opt/openjdk@17 ./gradlew -q :core:test :app:assembleDebug :app:testDebugUnitTest

The app tasks pass; :core:test stops on the three documented environment-dependent cases:

1448 tests completed, 3 failed
PathTlsJoinTest > anInteractiveApprovalOnTheConscryptEngineSocketPairsAndWelcomes FAILED
    java.lang.UnsatisfiedLinkError (Conscrypt native library; android/AGENTS.md: needs its native library)
PathTlsJoinTest > anInteractiveApprovalOnTheConscryptFdSocketPairsAndWelcomes FAILED
    java.lang.UnsatisfiedLinkError (same)
SessionTest > theHeldReorderFramesAreBoundedByBytes FAILED
    java.net.SocketException: Connection reset (backpressure cases assume Linux socket behaviour, android/AGENTS.md)

The focused :core:test --tests app.contigua.server.UiTreeTest and the app tasks:

UiTreeTest: tests="47" skipped="0" failures="0" errors="0"
cd android && JAVA_HOME=/opt/homebrew/opt/openjdk@17 ./gradlew -q :app:assembleDebug :app:testDebugUnitTest
(exit 0, no output)

cd macos && swift build && swift test --filter "ContiguaCoreTests|MCPCoreTests|MCPToolHostTests"

Build complete! (125.50 secs)
Test Suite 'ContiguaCoreTests.xctest' passed
	 Executed 433 tests, with 0 failures (0 unexpected) in 30.484 (30.521) seconds

That filter only selects the ContiguaCoreTests target on this toolchain, so the four affected suites were run explicitly:

swift test --filter "MCPCoreTests|MCPToolHostTests|UITreeTests|UITreeTextTests"
Test Suite 'ContiguaTests.xctest' passed
	 Executed 148 tests, with 0 failures (0 unexpected) in 54.027 (54.038) seconds

python3 -m unittest discover -s tools/mcp-eval -p 'test_*.py'

Ran 34 tests in 1.054s

OK

E2E (tier 2, PD_E2E_PORT=47772 PD_E2E_PROFILE=e2e ./scripts/check-e2e.sh mcp)

PASS [MCP-116] MCP ui_tree {root} keeps the list and its rows only (['e11', 'e12', 'e13', 'e14'])
PASS [MCP-116] MCP ui_tree {root, format: text} reads the subtree only (...)
PASS [MCP-116] MCP ui_tree {root, find} searches only the subtree and counts it
PASS [MCP-116] MCP ui_tree {root, find} never reaches a row outside the subtree
PASS [MCP-116] MCP ui_tree {root} on a ref the read does not name fails stale_ref
PASS [MCP-116] MCP ui_tree {root} that is no key fails -32602
PASS [MCP-116] MCP ui_tree marks a partly clipped row clipped, and the text view says so

passed=163 failed=2

The two failures are the pre-existing suite-screen screenshot no_frame on this machine (the fake phone's frame timing), unrelated to this change.

`ui_tree` takes `root` (`e<k>`), keeping only that node and its
descendants in reading order for tree, text and find; a root the
fresh read does not name is stale_ref naming the ref, window and
snapshot, and an invalid root is -32602. Find searches and counts
only the subtree, while `in` still names the scrollable above it.

The phone marks a visible row the display or a scrollable clips
`clipped: true`; the Mac parses, declares and prints it (a
`clipped` state in the text view's bracket), and the fake phone
learns a `clipped-tree` mode for the e2e suite.

Docs: PROTOCOL.md "UI tree" row field, MCP-116 spec row, design
tools table and answer shapes, WIN-79's row states.

Fixes #392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: add ui_tree root subtree scoping and clipped flag (MCP-116)

1 participant