mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:57:40 +00:00
fix(browser): register AI snapshot refs (#1282)
thanks @John-Rood Co-authored-by: John Rood <62669593+John-Rood@users.noreply.github.com>
This commit is contained in:
@@ -9,8 +9,6 @@ import {
|
||||
DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS,
|
||||
DEFAULT_AI_SNAPSHOT_MAX_CHARS,
|
||||
} from "../constants.js";
|
||||
import { buildRoleSnapshotFromAiSnapshot } from "../pw-role-snapshot.js";
|
||||
import { rememberRoleRefsForTarget } from "../pw-session.js";
|
||||
import {
|
||||
DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES,
|
||||
DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE,
|
||||
@@ -216,20 +214,6 @@ export function registerBrowserAgentSnapshotRoutes(app: express.Express, ctx: Br
|
||||
targetId: tab.targetId,
|
||||
...(typeof resolvedMaxChars === "number" ? { maxChars: resolvedMaxChars } : {}),
|
||||
})
|
||||
.then((result) => {
|
||||
// Extract and register refs from AI snapshot so act commands can resolve them.
|
||||
// snapshotAiViaPlaywright returns raw text without ref registration.
|
||||
const parsed = buildRoleSnapshotFromAiSnapshot(result.snapshot);
|
||||
if (Object.keys(parsed.refs).length > 0) {
|
||||
rememberRoleRefsForTarget({
|
||||
cdpUrl: profileCtx.profile.cdpUrl,
|
||||
targetId: tab.targetId,
|
||||
refs: parsed.refs,
|
||||
mode: "aria",
|
||||
});
|
||||
}
|
||||
return { ...result, refs: parsed.refs };
|
||||
})
|
||||
.catch(async (err) => {
|
||||
// Public-API fallback when Playwright's private _snapshotForAI is missing.
|
||||
if (String(err).toLowerCase().includes("_snapshotforai")) {
|
||||
|
||||
Reference in New Issue
Block a user