Skip to content

feat(automation): retain-tree locators via getFullTree - #147

Closed
espetro wants to merge 1 commit into
remorses:mainfrom
espetro:automation-full-tree-text
Closed

espetro wants to merge 1 commit into
remorses:mainfrom
espetro:automation-full-tree-text

Conversation

@espetro

@espetro espetro commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Closes #146.

What this adds

A paint-independent locator view over the retained tree, so automation can find and read elements regardless of how they painted:

  • getFullTree protocol method — same shape as getTree, but it does not force a render. The retained tree already holds every mounted element; paint state is only in the bounds map.
  • locator.allInTree() / elementInTree() — resolve selectors against that tree. An element below the fold in an overflow: scroll container, clipped by overflow: hidden, or outside a virtual list's window still carries its id, testId and text.
  • textContent() now resolves through elementInTree(). Text reads never needed paint; only the resolution did.
  • README "Locators" section documents painted-vs-retained explicitly, including when to reach for each.

Why

#146: on a live app getTree returns { tree: null }, getAllText() never reached the JS client, and a below-the-fold testId="sidecar-info" footer could be read by textContent() but not located by text or testId — exactly the M4 case in the Voce prototype evidence logs (https://github.com/espetro/voce-gpuix-prototype, evidence/m3-automation.log, evidence/m4-packaged-automation.log).

Companion to #144 (scrollIntoView), which makes such elements clickable once found; this one makes them findable and readable first.

Notes

  • TypeScript-only: protocol.ts gains one validated method, client.ts gains the in-process handler plus the three locator methods, README gains a paragraph. No Rust changes; the live napi renderer already accepts a forceRender flag on getAutomationTree and the test renderer's tree is retained.
  • Changeset for @gpuix/native and @gpuix/react (minor).

Testing

  • New test in packages/react/src/__tests__/automation.test.tsx: 100px overflow: scroll viewport, 600px content, footer at the bottom; asserts the footer resolves through allInTree()/textContent()/getByText while painted bounds stay clipped. Full automation suite: 8 passed; packages/react suite green except a pre-existing flaky events frame-loop timing test unrelated to this change.
  • packages/native: tsc --noEmit clean; bun run build:js regenerates dist/automation.

Harness: Maki CLI
Agent: none
Model: bifrost/zai-coding-plan/glm-4.5-air

User prompts
  1. You are the GPUIX prototype program, milestone M5 FINAL: upstream-contribution completion. Work in /Users/josocjoq/voce-gpuix-prototype. Hard deadline: 55 minutes.

MANDATORY GUI HYGIENE RULES — the following block is reproduced verbatim from /Users/josocjoq/voce-next-phase/E-m4-hygiene-rules.txt and overrides everything:

MANDATORY GUI HYGIENE RULES (user pain point: prior lanes opened dozens of instances and the constant focus capture made the computer unusable):

  1. At most ONE app instance at a time, ever. Before every launch, ps for prior instance PIDs of the prototype app/sidecar, verify cmdline paths are inside the prototype dir, and kill them.
  2. Minimize launches: batch all GUI verification into AT MOST 2-3 short sessions per milestone. Each GUI session must end within 90 seconds. Plan what you need to capture BEFORE launching, capture it, quit.
  3. Never open windows unless the specific evidence requires it. The tray-only path is the default. Voce is a menu-bar app: LSUIElement must be set so launches do not steal focus. If a window must open for a test, close it immediately after the capture.
  4. Automation scripts must kill everything they spawn in a finally/cleanup block, including sidecars. Disable restart-on-crash supervision during validation runs (or cap restarts at 1).
  5. Packaged .app verification: at most 2 launches per session total.
  6. Before ending your session, run ps and verify zero prototype processes remain. Leaving one stray is a lane failure.
  7. Prefer headless evidence: logs, automation-protocol assertions, file artifacts. screencapture only when a visual claim needs proof.

Upstream contribution strategy (mandatory): issue+PR pair in the espetro/gpuix fork, contribute upstream to remorses/gpuix; never approve deployments. Keep every diff minimal and reviewable. Use branches off espetro/gpuix, open PRs against remorses/gpuix, reference the M3/M4 evidence logs in issue bodies for reproduction context, and never merge upstream PRs yourself.

M5 objective from STATUS.md: turn the documented GPUIX blocker list into filed issue+PR pairs against remorses/gpuix, not new prototype features. Prioritize in this order:

  1. Automation text APIs: document/fix viewport-clipped getByType('text').all() versus unclipped locator.textContent(); add a getByText variant that searches the full tree regardless of paint state.
  2. CSS shorthand style strings: either parse padding/margin shorthand strings in the style serializer or return a precise actionable error naming the offending property and value instead of blanking the tree.
  3. Automation scroll-into-view helper: locator.scrollIntoViewIfNeeded() or equivalent, addressing below-the-fold click and text clipping together.
  4. Only if time remains and it reproduces on current bun, document Bun.isStandaloneExecutable undefined under bun build --compile; this is non-GPUIX and lower priority.

Constraints: do not redesign the prototype; do not start extra app instances; prefer headless evidence and automation-protocol assertions. GUI use is only for contribution validation evidence if truly required, under the hygiene rules above. Heavy compiles/tests must use flock /tmp/tsc.lock. Never use npm or pip. Commit atomically with conventional messages and no co-author trailers. Push contribution branches as needed for PR creation, but do not push unrelated prototype history. If a contribution is blocked by missing upstream access, missing tests, or an unclear API, document the blocker precisely and continue with the next contribution rather than stalling.

Completion requirements: update /Users/josocjoq/voce-gpuix-prototype/STATUS.md with an M5 section listing each issue/PR URL, branch, validation performed, and remaining blocker if any. End with a final ps verification showing zero prototype/sidecar/ffmpeg/app strays. Report in your last message: M5 status, issue/PR links, validation evidence, blockers and disposition, and confirmation that zero stray processes remain.

textContent() could read below-the-fold elements while all() and element()
could not even find them, and getTree returned null on the live renderer,
so the paint-independent text path had no way to resolve a locator.

Add getFullTree to the automation protocol (validated like every other
method, served by both backends) and build allInTree()/elementInTree() on
it; textContent() now resolves through it too.
@remorses

Copy link
Copy Markdown
Owner

Closing: getTree already returns the whole retained tree, and all() already finds elements below the fold (this PR's own test shows it). Bounds are the only extra data.

@remorses remorses closed this Nov 28, 2026
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.

automation: no paint-independent way to resolve a locator (getTree null in live mode; getAllText not on the client)

2 participants