Skip to content

Commit 96ea1e3

Browse files
authored
fix(nodes): deliver launch approvals to the requesting browser (#130573)
1 parent 9ccbbf8 commit 96ea1e3

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

‎src/gateway/node-invoke-plugin-policy.test.ts‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,11 @@ describe("applyPluginNodeInvokePolicy", () => {
263263

264264
const result = await invokeDemoPolicy(context);
265265

266-
if (result === null) {
267-
throw new Error("expected plugin policy failure");
268-
}
269-
expect(result.ok).toBe(false);
270-
if (result.ok) {
271-
throw new Error("expected plugin policy failure");
272-
}
273-
expect(result.code).toBe("PLUGIN_POLICY_MISSING");
274-
expect(result.details).toStrictEqual({ nodeCommandDispatched: false });
266+
expect(result).toMatchObject({
267+
ok: false,
268+
code: "PLUGIN_POLICY_MISSING",
269+
details: { nodeCommandDispatched: false },
270+
});
275271
expect(invoke).not.toHaveBeenCalled();
276272
});
277273

@@ -735,10 +731,13 @@ describe("applyPluginNodeInvokePolicy", () => {
735731
expect(invoke).toHaveBeenCalledOnce();
736732
});
737733

738-
it("binds plugin policy approval requests to the invoking client", async () => {
734+
it.each([false, true])("routes approvals for synthetic=%s", async (synthetic) => {
739735
const manager = new ExecApprovalManager<PluginApprovalRequestPayload>();
740-
const visibleConnIds = new Set(["conn-owner-approval"]);
736+
const visibleConnIds = new Set(
737+
synthetic ? ["conn-owner-approval", "conn-requester"] : ["conn-owner-approval"],
738+
);
741739
const getApprovalClientConnIds = createApprovalClientLookup([
740+
createOperatorClient(),
742741
createOperatorClient("conn-owner-approval"),
743742
createApprovalClient({
744743
connId: "conn-other-approval",
@@ -751,7 +750,9 @@ describe("applyPluginNodeInvokePolicy", () => {
751750
pluginApprovalManager: manager,
752751
getApprovalClientConnIds,
753752
});
754-
const resultPromise = invokeDemoPolicy(context, createOperatorClient());
753+
const requester = createOperatorClient();
754+
requester.internal = synthetic ? { syntheticClient: true } : undefined;
755+
const resultPromise = invokeDemoPolicy(context, requester);
755756

756757
const record = await expectSinglePendingApproval(manager);
757758
expect(record.requestedByConnId).toBe("conn-requester");

‎src/gateway/node-invoke-plugin-policy.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ function createApprovalRuntime(params: {
192192
decisionPromise,
193193
respond,
194194
context: params.context,
195-
clientConnId: params.client?.connId,
195+
// Internal calls retain the operator's connection as provenance; it is
196+
// still a reviewer, not the transport requester to exclude from delivery.
197+
clientConnId: params.client?.internal?.syntheticClient ? undefined : params.client?.connId,
196198
requestEventName: "plugin.approval.requested",
197199
requestEvent,
198200
twoPhase: false,

0 commit comments

Comments
 (0)