惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
博客园 - Franky
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(browser): preserve tabs across target swaps · opencla...
steipete · 2026-04-26 · via Recent Commits to openclaw:main

@@ -34,9 +34,11 @@ import {

3434

readBody,

3535

requirePwAi,

3636

resolveTargetIdFromBody,

37+

resolveSafeRouteTabUrl,

3738

withRouteTabContext,

3839

SELECTOR_UNSUPPORTED_MESSAGE,

3940

} from "./agent.shared.js";

41+

import { resolveTargetIdAfterNavigate } from "./agent.snapshot-target.js";

4042

import { EXISTING_SESSION_LIMITS } from "./existing-session-limits.js";

4143

import type { BrowserRouteRegistrar } from "./types.js";

4244

import { asyncBrowserRoute, jsonError, toNumber, toStringOrEmpty } from "./utils.js";

@@ -388,11 +390,35 @@ export function registerBrowserAgentActRoutes(

388390

run: async ({ profileCtx, cdpUrl, tab, resolveTabUrl }) => {

389391

const evaluateEnabled = ctx.state().resolved.evaluateEnabled;

390392

const ssrfPolicy = ctx.state().resolved.ssrfPolicy;

391-

const jsonOk = async (extra?: Record<string, unknown>) => {

392-

const url = await resolveTabUrl(tab.url);

393+

const isExistingSession = getBrowserProfileCapabilities(profileCtx.profile).usesChromeMcp;

394+

const hasNavigationResultPolicy = Boolean(

395+

withBrowserNavigationPolicy(ssrfPolicy).ssrfPolicy,

396+

);

397+

const jsonOk = async (

398+

extra?: Record<string, unknown>,

399+

options?: { resolveCurrentTarget?: boolean },

400+

) => {

401+

const shouldResolveCurrentTarget =

402+

options?.resolveCurrentTarget && (!isExistingSession || hasNavigationResultPolicy);

403+

const responseTargetId = shouldResolveCurrentTarget

404+

? await resolveTargetIdAfterNavigate({

405+

oldTargetId: tab.targetId,

406+

navigatedUrl: tab.url,

407+

listTabs: () => profileCtx.listTabs(),

408+

})

409+

: tab.targetId;

410+

const url =

411+

responseTargetId === tab.targetId

412+

? await resolveTabUrl(tab.url)

413+

: await resolveSafeRouteTabUrl({

414+

ctx,

415+

profileCtx,

416+

targetId: responseTargetId,

417+

fallbackUrl: tab.url,

418+

});

393419

return res.json({

394420

ok: true,

395-

targetId: tab.targetId,

421+

targetId: responseTargetId,

396422

...(url ? { url } : {}),

397423

...extra,

398424

});

@@ -405,10 +431,9 @@ export function registerBrowserAgentActRoutes(

405431

"action targetId must match request targetId",

406432

);

407433

}

408-

const isExistingSession = getBrowserProfileCapabilities(profileCtx.profile).usesChromeMcp;

409434

const profileName = profileCtx.profile.name;

410435

if (isExistingSession) {

411-

const initialTabTargetIds = withBrowserNavigationPolicy(ssrfPolicy).ssrfPolicy

436+

const initialTabTargetIds = hasNavigationResultPolicy

412437

? new Set((await profileCtx.listTabs()).map((currentTab) => currentTab.targetId))

413438

: new Set<string>();

414439

const existingSessionNavigationGuard = {

@@ -443,7 +468,7 @@ export function registerBrowserAgentActRoutes(

443468

}),

444469

guard: existingSessionNavigationGuard,

445470

});

446-

return await jsonOk();

471+

return await jsonOk(undefined, { resolveCurrentTarget: true });

447472

case "clickCoords":

448473

await runExistingSessionActionWithNavigationGuard({

449474

execute: () =>

@@ -459,7 +484,7 @@ export function registerBrowserAgentActRoutes(

459484

}),

460485

guard: existingSessionNavigationGuard,

461486

});

462-

return await jsonOk();

487+

return await jsonOk(undefined, { resolveCurrentTarget: true });

463488

case "type":

464489

await runExistingSessionActionWithNavigationGuard({

465490

execute: async () => {

@@ -481,7 +506,7 @@ export function registerBrowserAgentActRoutes(

481506

},

482507

guard: existingSessionNavigationGuard,

483508

});

484-

return await jsonOk();

509+

return await jsonOk(undefined, { resolveCurrentTarget: true });

485510

case "press":

486511

await runExistingSessionActionWithNavigationGuard({

487512

execute: () =>

@@ -493,7 +518,7 @@ export function registerBrowserAgentActRoutes(

493518

}),

494519

guard: existingSessionNavigationGuard,

495520

});

496-

return await jsonOk();

521+

return await jsonOk(undefined, { resolveCurrentTarget: true });

497522

case "hover":

498523

await runExistingSessionActionWithNavigationGuard({

499524

execute: () =>

@@ -631,15 +656,19 @@ export function registerBrowserAgentActRoutes(

631656

});

632657

switch (action.kind) {

633658

case "batch":

634-

return await jsonOk({ results: result.results ?? [] });

659+

return await jsonOk(

660+

{ results: result.results ?? [] },

661+

{ resolveCurrentTarget: true },

662+

);

635663

case "evaluate":

636-

return await jsonOk({ result: result.result });

664+

return await jsonOk({ result: result.result }, { resolveCurrentTarget: true });

637665

case "click":

638666

case "clickCoords":

667+

return await jsonOk(undefined, { resolveCurrentTarget: true });

639668

case "resize":

640669

return await jsonOk();

641670

default:

642-

return await jsonOk();

671+

return await jsonOk(undefined, { resolveCurrentTarget: true });

643672

}

644673

},

645674

});