Skip to content

Commit 71666ea

Browse files
[Core] Clean Up Factory Pause Checkpoints
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent c0ea3c3 commit 71666ea

3 files changed

Lines changed: 10 additions & 19 deletions

File tree

‎nodejs/src/factory.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
} from "./generated/rpc.js";
1515
import type { ContextTier } from "./generated/session-events.js";
1616
import type { CopilotSession } from "./session.js";
17-
import type { FactoryLimits, FactoryMeta } from "./types.js";
17+
import type { FactoryMeta } from "./types.js";
1818

1919
export type { FactoryRunResult };
2020
export type {

‎nodejs/src/session.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ function runInFactoryHelperScope<TResult>(
128128
callback: () => Promise<TResult> | TResult
129129
): Promise<TResult> | TResult {
130130
const current = factoryExecutionStore.getStore();
131-
return factoryExecutionStore.run(
132-
{ active: current?.active ?? false, helperScope },
133-
callback
134-
);
131+
return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
135132
}
136133

137134
/**

‎nodejs/test/factory.test.ts‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,8 +1656,8 @@ describe("factories", () => {
16561656
session.registerFactories([factory]);
16571657

16581658
let settled = false;
1659-
const execution = session.clientSessionApis.factory!
1660-
.execute({
1659+
const execution = session.clientSessionApis
1660+
.factory!.execute({
16611661
sessionId: session.sessionId,
16621662
name: "checkpoint-pause",
16631663
runId: "run-checkpoint-pause",
@@ -2223,16 +2223,12 @@ describe("factories", () => {
22232223
it("ignores a late abort for an older execution token with the same run id", async () => {
22242224
const oldAgent = Promise.withResolvers<{ result: string }>();
22252225
const currentAgent = Promise.withResolvers<{ result: string }>();
2226-
const sendRequest = vi.fn(
2227-
async (method: string, params: { executionToken?: string }) => {
2228-
if (method !== "session.factory.agent") {
2229-
return {};
2230-
}
2231-
return params.executionToken === "old-token"
2232-
? oldAgent.promise
2233-
: currentAgent.promise;
2226+
const sendRequest = vi.fn(async (method: string, params: { executionToken?: string }) => {
2227+
if (method !== "session.factory.agent") {
2228+
return {};
22342229
}
2235-
);
2230+
return params.executionToken === "old-token" ? oldAgent.promise : currentAgent.promise;
2231+
});
22362232
const session = new CopilotSession("session-token-scoped-abort", {
22372233
sendRequest,
22382234
} as never);
@@ -2264,9 +2260,7 @@ describe("factories", () => {
22642260
executionToken: "current-token",
22652261
args: {},
22662262
});
2267-
await vi.waitFor(() =>
2268-
expect(sendRequest).toHaveBeenCalledTimes(2)
2269-
);
2263+
await vi.waitFor(() => expect(sendRequest).toHaveBeenCalledTimes(2));
22702264

22712265
await session.clientSessionApis.factory!.abort({
22722266
sessionId: session.sessionId,

0 commit comments

Comments
 (0)