fix(web-probe): prefer identity owner for loading nodes (#791)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -1363,6 +1363,7 @@ async function sampleOnePage(targetPage, { reason, groupSeq, pageRole, targetPag
|
|||||||
const elementDescriptor = (element) => {
|
const elementDescriptor = (element) => {
|
||||||
if (!element) return null;
|
if (!element) return null;
|
||||||
const className = String(element.className || "").replace(/\s+/g, " ").trim().split(" ").slice(0, 6).join(" ");
|
const className = String(element.className || "").replace(/\s+/g, " ").trim().split(" ").slice(0, 6).join(" ");
|
||||||
|
const identityDescendant = element.querySelector("[data-trace-id], [data-message-id], [data-session-id]");
|
||||||
return {
|
return {
|
||||||
tag: element.tagName.toLowerCase(),
|
tag: element.tagName.toLowerCase(),
|
||||||
testId: element.getAttribute("data-testid") || null,
|
testId: element.getAttribute("data-testid") || null,
|
||||||
@@ -1370,9 +1371,9 @@ async function sampleOnePage(targetPage, { reason, groupSeq, pageRole, targetPag
|
|||||||
id: element.getAttribute("id") || null,
|
id: element.getAttribute("id") || null,
|
||||||
className: className || null,
|
className: className || null,
|
||||||
status: element.getAttribute("data-status") || element.getAttribute("aria-busy") || null,
|
status: element.getAttribute("data-status") || element.getAttribute("aria-busy") || null,
|
||||||
sessionId: element.getAttribute("data-session-id") || null,
|
sessionId: element.getAttribute("data-session-id") || identityDescendant?.getAttribute("data-session-id") || null,
|
||||||
messageId: element.getAttribute("data-message-id") || null,
|
messageId: element.getAttribute("data-message-id") || identityDescendant?.getAttribute("data-message-id") || null,
|
||||||
traceId: element.getAttribute("data-trace-id") || null,
|
traceId: element.getAttribute("data-trace-id") || identityDescendant?.getAttribute("data-trace-id") || null,
|
||||||
ariaLabel: element.getAttribute("aria-label") || null
|
ariaLabel: element.getAttribute("aria-label") || null
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1419,7 +1420,9 @@ async function sampleOnePage(targetPage, { reason, groupSeq, pageRole, targetPag
|
|||||||
.slice(-80);
|
.slice(-80);
|
||||||
return candidates.map((element, index) => {
|
return candidates.map((element, index) => {
|
||||||
const rect = element.getBoundingClientRect();
|
const rect = element.getBoundingClientRect();
|
||||||
const owner = element.closest('[data-message-id], [data-trace-id], article.message-card, .message-card, [data-testid*="message" i], [data-testid*="turn" i], [data-testid*="composer" i], [data-testid*="session" i], [class*="composer" i], [class*="session" i], [class*="trace" i], [class*="diagnostic" i], article, section, aside, main, form, [role="status"], [role="alert"], [role="article"], [role="navigation"]') || element;
|
const identityOwner = element.closest('[data-message-id], [data-trace-id], [data-session-id]');
|
||||||
|
const structuralOwner = element.closest('article.message-card, .message-card, [data-testid*="message" i], [data-testid*="turn" i], [data-testid*="composer" i], [data-testid*="session" i], [class*="composer" i], [class*="session" i], [class*="trace" i], [class*="diagnostic" i], article, section, aside, main, form, [role="status"], [role="alert"], [role="article"], [role="navigation"]');
|
||||||
|
const owner = identityOwner || structuralOwner || element;
|
||||||
const ownerDescriptor = elementDescriptor(owner);
|
const ownerDescriptor = elementDescriptor(owner);
|
||||||
return {
|
return {
|
||||||
index,
|
index,
|
||||||
|
|||||||
Reference in New Issue
Block a user