mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:18:26 +00:00
fix: handle extension relay session reuse
This commit is contained in:
@@ -477,13 +477,23 @@ export async function ensureChromeExtensionRelayServer(opts: {
|
||||
const targetType = attached?.targetInfo?.type ?? "page";
|
||||
if (targetType !== "page") return;
|
||||
if (attached?.sessionId && attached?.targetInfo?.targetId) {
|
||||
const already = connectedTargets.has(attached.sessionId);
|
||||
const prev = connectedTargets.get(attached.sessionId);
|
||||
const nextTargetId = attached.targetInfo.targetId;
|
||||
const prevTargetId = prev?.targetId;
|
||||
const changedTarget = Boolean(prev && prevTargetId && prevTargetId !== nextTargetId);
|
||||
connectedTargets.set(attached.sessionId, {
|
||||
sessionId: attached.sessionId,
|
||||
targetId: attached.targetInfo.targetId,
|
||||
targetId: nextTargetId,
|
||||
targetInfo: attached.targetInfo,
|
||||
});
|
||||
if (!already) {
|
||||
if (changedTarget && prevTargetId) {
|
||||
broadcastToCdpClients({
|
||||
method: "Target.detachedFromTarget",
|
||||
params: { sessionId: attached.sessionId, targetId: prevTargetId },
|
||||
sessionId: attached.sessionId,
|
||||
});
|
||||
}
|
||||
if (!prev || changedTarget) {
|
||||
broadcastToCdpClients({ method, params, sessionId });
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user