




















@@ -163,6 +163,7 @@ function readTargetUrlParam(params: Record<string, unknown>) {
163163}
164164165165const LEGACY_BROWSER_ACT_REQUEST_KEYS = [
166+"kind",
166167"targetId",
167168"ref",
168169"doubleClick",
@@ -190,18 +191,39 @@ const LEGACY_BROWSER_ACT_REQUEST_KEYS = [
190191"timeoutMs",
191192] as const;
192193194+const LEGACY_BROWSER_ACT_SHARED_REQUEST_KEYS = new Set<
195+(typeof LEGACY_BROWSER_ACT_REQUEST_KEYS)[number]
196+>(["targetId"]);
197+193198function readActRequestParam(params: Record<string, unknown>) {
194199const requestParam = params.request;
195200if (requestParam && typeof requestParam === "object") {
196-return requestParam as Parameters<typeof browserAct>[1];
201+const request = { ...(requestParam as Record<string, unknown>) };
202+const hasMismatchedKind =
203+typeof request.kind === "string" &&
204+typeof params.kind === "string" &&
205+request.kind !== params.kind;
206+for (const key of LEGACY_BROWSER_ACT_REQUEST_KEYS) {
207+if (Object.hasOwn(request, key) || !Object.hasOwn(params, key)) {
208+continue;
209+}
210+// Flattened act fields are legacy shape repair. Only the tab scope is
211+// safe across kind mismatches; action-specific fields can corrupt the
212+// explicit nested request.
213+if (hasMismatchedKind && !LEGACY_BROWSER_ACT_SHARED_REQUEST_KEYS.has(key)) {
214+continue;
215+}
216+request[key] = params[key];
217+}
218+return request as Parameters<typeof browserAct>[1];
197219}
198220199221const kind = readStringParam(params, "kind");
200222if (!kind) {
201223return undefined;
202224}
203225204-const request: Record<string, unknown> = { kind };
226+const request: Record<string, unknown> = {};
205227for (const key of LEGACY_BROWSER_ACT_REQUEST_KEYS) {
206228if (!Object.hasOwn(params, key)) {
207229continue;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。