Skip to content

fix(page-controller): resolve *[N] isNew element indexes in getElementTextMap - #743

Open
wjl8636 wants to merge 2 commits into
alibaba:mainfrom
wjl8636:fix/getElementTextMap-isNew-prefix
Open

wjl8636 wants to merge 2 commits into
alibaba:mainfrom
wjl8636:fix/getElementTextMap-isNew-prefix

Conversation

@wjl8636

@wjl8636 wjl8636 commented Oct 7, 2026

Copy link
Copy Markdown

What

getElementTextMap() failed to parse lines with the *[N] prefix that flatTreeToString() emits for isNew (newly-appeared) interactive elements, so their index→text mapping was missing.

Why

PageController uses elementTextMap to report which element an action targeted. For isNew elements the look-up returned undefined, degrading action feedback to the bare index. Since most elements are isNew on first paint, this masked element labels in common cases.

How I verified

  • Added regression tests in src/dom/index.test.ts covering regular, isNew, and mixed pages (they fail before the fix).
  • npm run typecheck, npm run lint, prettier all pass.

…tTextMap

getElementTextMap() only matched lines starting with [N], but
flatTreeToString() emits newly-appeared (isNew) interactive elements with a
*[N] prefix. Those indexes were therefore missing from elementTextMap, so
PageController action feedback degraded to the bare index for isNew elements.

Add regression tests covering regular, isNew, and mixed pages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Oct 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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.

2 participants