Skip to content

Commit f9fdc4b

Browse files
steipetequangtran88
andcommitted
style: satisfy event dispatch lint rules
Use non-mutating sorting for the fresh listener cohort, initialize the unsubscribe binding at its existing assignment, and distinguish unused mapper parameters without changing the proved behavior or assertions. Co-authored-by: Tran Quang <[email protected]>
1 parent 15e0530 commit f9fdc4b

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎src/auto-reply/reply/agent-event-bridge.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("agent event delivery bridge", () => {
2828
const bridges = Array.from({ length: runs }, (_, runIndex) => {
2929
const runId = `run-${runIndex}`;
3030
registerAgentRunContext(runId, { sessionKey: `session-${runIndex}` });
31-
return Array.from({ length: 8 }, (_, bridgeIndex) => {
31+
return Array.from({ length: 8 }, (_bridge, bridgeIndex) => {
3232
const delivered: string[] = [];
3333
const bridge = createAgentEventBridge<string>({
3434
get runId() {

‎src/infra/agent-events.run-listeners.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,14 @@ describe("run-indexed agent event listeners", () => {
8484
const subscribe = (listener: () => void) =>
8585
scope === "global" ? onAgentEvent(listener) : onAgentEventForRun("run-live", listener);
8686
const replaced = () => order.push("re-added");
87-
let stopReplaced: () => void;
8887
onAgentEventForRun("run-live", () => {
8988
order.push("first");
9089
stopReplaced();
9190
if (readd) {
9291
subscribe(replaced);
9392
}
9493
});
95-
stopReplaced = subscribe(replaced);
94+
const stopReplaced = subscribe(replaced);
9695
onAgentEvent(() => order.push("middle"));
9796
emitAgentEvent({ runId: "run-live", stream: "assistant", data: {} });
9897
expect(order).toEqual(readd ? ["first", "middle", "re-added"] : ["first", "middle"]);

‎src/infra/agent-events.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function* iterateAgentEventListeners(
356356
runId = currentRunId;
357357
pending = [...state.listeners, ...(state.runListeners.get(runId) ?? [])]
358358
.filter(([, id]) => id > lastId)
359-
.sort(([, left], [, right]) => left - right);
359+
.toSorted(([, left], [, right]) => left - right);
360360
index = 0;
361361
}
362362
const next = pending[index++];

0 commit comments

Comments
 (0)